1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2008 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class mail_sns |
---|
8 | { |
---|
9 | var $decoder; |
---|
10 | var $from; |
---|
11 | var $to; |
---|
12 | |
---|
13 | var $c_member_id; |
---|
14 | |
---|
15 | function mail_sns(&$decoder) |
---|
16 | { |
---|
17 | $this->decoder =& $decoder; |
---|
18 | $this->from = $decoder->get_from(); |
---|
19 | $this->to = $decoder->get_to(); |
---|
20 | |
---|
21 | $this->c_member_id = db_member_c_member_id4ktai_address2($this->from); |
---|
22 | |
---|
23 | // メンバーIDが見つからない場合は、ローカルパートに二重引用符を付加してリトライ |
---|
24 | if (!$this->c_member_id) { |
---|
25 | list($local, $domain) = explode('@', $this->from, 2); |
---|
26 | $this->c_member_id = db_member_c_member_id4ktai_address2('"' . $local . '"' . '@' . $domain); |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | function main() |
---|
31 | { |
---|
32 | $matches = array(); |
---|
33 | list($from_user, $from_host) = explode('@', $this->from, 2); |
---|
34 | list($to_user, $to_host) = explode('@', $this->to, 2); |
---|
35 | |
---|
36 | // メンテナンスモード |
---|
37 | if (OPENPNE_UNDER_MAINTENANCE) { |
---|
38 | $this->error_mail('現在メンテナンス中のため、メール投稿はおこなえません。しばらく時間を空けて再度送信してください。'); |
---|
39 | m_debug_log('mail_sns::main() maintenance mode'); |
---|
40 | return false; |
---|
41 | } |
---|
42 | |
---|
43 | // from_host が携帯ドメイン以外はエラー |
---|
44 | if (!is_ktai_mail_address($this->from)) { |
---|
45 | m_debug_log('mail_sns::main() from wrong host'); |
---|
46 | return false; |
---|
47 | } |
---|
48 | |
---|
49 | if (MAIL_ADDRESS_PREFIX) { |
---|
50 | if (strpos($to_user, MAIL_ADDRESS_PREFIX) === 0) { |
---|
51 | $to_user = substr($to_user, strlen(MAIL_ADDRESS_PREFIX)); |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | if (!$this->c_member_id) { |
---|
56 | // 送信者がSNSメンバーでない場合 |
---|
57 | |
---|
58 | if (!IS_CLOSED_SNS) { |
---|
59 | // get 新規登録 |
---|
60 | if ($to_user == 'get') { |
---|
61 | // アフィリエイトIDが付いている場合 |
---|
62 | $body = $this->decoder->get_text_body(); |
---|
63 | |
---|
64 | m_debug_log('mail_sns::regist_get()', PEAR_LOG_INFO); |
---|
65 | return $this->regist_get($body); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | m_debug_log('mail_sns::main() action not found'); |
---|
70 | return false; |
---|
71 | } |
---|
72 | |
---|
73 | // 送信者がログイン停止登録されているメンバーの場合 |
---|
74 | if (db_member_is_login_rejected($this->c_member_id)) { |
---|
75 | m_debug_log('mail_sns::main() mail from rejected member'); |
---|
76 | return false; |
---|
77 | } |
---|
78 | |
---|
79 | // 送信者がブラックリスト登録済みメンバーの場合 |
---|
80 | if (db_member_is_blacklist($this->c_member_id)) { |
---|
81 | m_debug_log('mail_sns::main() mail from member on blacklist'); |
---|
82 | return false; |
---|
83 | } |
---|
84 | |
---|
85 | //--- |
---|
86 | |
---|
87 | // ログインURL通知 |
---|
88 | if ($to_user == 'get') { |
---|
89 | m_debug_log('mail_sns::login_get()', PEAR_LOG_INFO); |
---|
90 | return $this->login_get(); |
---|
91 | } |
---|
92 | |
---|
93 | //--- |
---|
94 | |
---|
95 | // コミュニティ掲示板投稿 |
---|
96 | elseif ( |
---|
97 | preg_match('/^t(\d+)$/', $to_user, $matches) || |
---|
98 | preg_match('/^t(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
99 | ) { |
---|
100 | |
---|
101 | // トピックIDのチェック |
---|
102 | if (!$c_commu_topic_id = $matches[1]) { |
---|
103 | return false; |
---|
104 | } |
---|
105 | |
---|
106 | if (MAIL_ADDRESS_HASHED) { |
---|
107 | if (empty($matches[2])) return false; |
---|
108 | |
---|
109 | // メンバーハッシュのチェック |
---|
110 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
111 | return false; |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | m_debug_log('mail_sns::add_commu_topic_comment()', PEAR_LOG_INFO); |
---|
116 | return $this->add_commu_topic_comment($c_commu_topic_id); |
---|
117 | } |
---|
118 | |
---|
119 | //--- |
---|
120 | |
---|
121 | // 日記投稿 |
---|
122 | elseif ( |
---|
123 | $to_user == 'blog' || |
---|
124 | preg_match('/^b(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
125 | ) { |
---|
126 | |
---|
127 | if (MAIL_ADDRESS_HASHED) { |
---|
128 | if (empty($matches[1]) || empty($matches[2])) return false; |
---|
129 | |
---|
130 | // メンバーIDのチェック |
---|
131 | if ($matches[1] != $this->c_member_id) { |
---|
132 | return false; |
---|
133 | } |
---|
134 | // メンバーハッシュのチェック |
---|
135 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
136 | return false; |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | m_debug_log('mail_sns::add_diary()', PEAR_LOG_INFO); |
---|
141 | return $this->add_diary(); |
---|
142 | } |
---|
143 | |
---|
144 | //--- |
---|
145 | |
---|
146 | // 日記コメント投稿 |
---|
147 | elseif ( |
---|
148 | preg_match('/^bc(\d+)$/', $to_user, $matches) || |
---|
149 | preg_match('/^bc(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
150 | ) { |
---|
151 | |
---|
152 | // 日記IDのチェック |
---|
153 | if (!$c_diary_id = $matches[1]) { |
---|
154 | return false; |
---|
155 | } |
---|
156 | |
---|
157 | if (MAIL_ADDRESS_HASHED) { |
---|
158 | if (empty($matches[2])) return false; |
---|
159 | |
---|
160 | // メンバーハッシュのチェック |
---|
161 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
162 | return false; |
---|
163 | } |
---|
164 | } |
---|
165 | |
---|
166 | m_debug_log('mail_sns::add_diary_comment()', PEAR_LOG_INFO); |
---|
167 | return $this->add_diary_comment($c_diary_id); |
---|
168 | } |
---|
169 | |
---|
170 | //--- |
---|
171 | |
---|
172 | // アルバム追加 |
---|
173 | elseif ( |
---|
174 | $to_user == 'album' || |
---|
175 | preg_match('/^a(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
176 | ) { |
---|
177 | |
---|
178 | if (MAIL_ADDRESS_HASHED) { |
---|
179 | if (empty($matches[1]) || empty($matches[2])) return false; |
---|
180 | |
---|
181 | // メンバーIDのチェック |
---|
182 | if ($matches[1] != $this->c_member_id) { |
---|
183 | return false; |
---|
184 | } |
---|
185 | // メンバーハッシュのチェック |
---|
186 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
187 | return false; |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | m_debug_log('mail_sns::add_album()', PEAR_LOG_INFO); |
---|
192 | return $this->add_album(); |
---|
193 | } |
---|
194 | |
---|
195 | //--- |
---|
196 | |
---|
197 | // アルバム写真登録 |
---|
198 | elseif ( |
---|
199 | preg_match('/^ai(\d+)$/', $to_user, $matches) || |
---|
200 | preg_match('/^ai(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
201 | ) { |
---|
202 | |
---|
203 | // アルバムIDのチェック |
---|
204 | if (!$c_album_id = $matches[1]) { |
---|
205 | return false; |
---|
206 | } |
---|
207 | |
---|
208 | if (MAIL_ADDRESS_HASHED) { |
---|
209 | if (empty($matches[2])) return false; |
---|
210 | |
---|
211 | // メンバーハッシュのチェック |
---|
212 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
213 | return false; |
---|
214 | } |
---|
215 | } |
---|
216 | |
---|
217 | m_debug_log('mail_sns::add_album_image()', PEAR_LOG_INFO); |
---|
218 | return $this->add_album_image($c_album_id); |
---|
219 | } |
---|
220 | |
---|
221 | //--- |
---|
222 | |
---|
223 | //プロフィール写真変更 |
---|
224 | elseif ( |
---|
225 | preg_match('/^p(\d+)$/', $to_user, $matches) || |
---|
226 | preg_match('/^p(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
227 | ) { |
---|
228 | |
---|
229 | // メンバーIDのチェック |
---|
230 | if ($matches[1] != $this->c_member_id) { |
---|
231 | return false; |
---|
232 | } |
---|
233 | |
---|
234 | if (MAIL_ADDRESS_HASHED) { |
---|
235 | if (empty($matches[2])) return false; |
---|
236 | |
---|
237 | // メンバーハッシュのチェック |
---|
238 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
239 | return false; |
---|
240 | } |
---|
241 | } |
---|
242 | |
---|
243 | m_debug_log('mail_sns::add_member_image()', PEAR_LOG_INFO); |
---|
244 | return $this->add_member_image(); |
---|
245 | } |
---|
246 | |
---|
247 | //--- |
---|
248 | |
---|
249 | // 日記写真変更 |
---|
250 | elseif ( |
---|
251 | preg_match('/^bi(\d+)$/', $to_user, $matches) || |
---|
252 | preg_match('/^bi(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
253 | ) { |
---|
254 | // 日記IDのチェック |
---|
255 | if (!$c_diary_id = $matches[1]) { |
---|
256 | return false; |
---|
257 | } |
---|
258 | |
---|
259 | if (MAIL_ADDRESS_HASHED) { |
---|
260 | if (empty($matches[2])) return false; |
---|
261 | |
---|
262 | // メンバーハッシュのチェック |
---|
263 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
264 | return false; |
---|
265 | } |
---|
266 | } |
---|
267 | |
---|
268 | m_debug_log('mail_sns::add_diary_image()', PEAR_LOG_INFO); |
---|
269 | return $this->add_diary_image($c_diary_id); |
---|
270 | } |
---|
271 | |
---|
272 | //--- |
---|
273 | |
---|
274 | // コミュニティ写真変更 |
---|
275 | elseif ( |
---|
276 | preg_match('/^ci(\d+)$/', $to_user, $matches) || |
---|
277 | preg_match('/^ci(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
278 | ) { |
---|
279 | // コミュニティIDのチェック |
---|
280 | if (!$c_commu_id = $matches[1]) { |
---|
281 | return false; |
---|
282 | } |
---|
283 | |
---|
284 | if (MAIL_ADDRESS_HASHED) { |
---|
285 | if (empty($matches[2])) return false; |
---|
286 | |
---|
287 | // メンバーハッシュのチェック |
---|
288 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
289 | return false; |
---|
290 | } |
---|
291 | } |
---|
292 | |
---|
293 | m_debug_log('mail_sns::add_commu_image()', PEAR_LOG_INFO); |
---|
294 | return $this->add_commu_image($c_commu_id); |
---|
295 | } |
---|
296 | |
---|
297 | //--- |
---|
298 | |
---|
299 | // トピック・イベント写真変更 |
---|
300 | elseif ( |
---|
301 | preg_match('/^ti(\d+)$/', $to_user, $matches) || |
---|
302 | preg_match('/^ti(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
303 | ) { |
---|
304 | // トピックIDのチェック |
---|
305 | if (!$c_commu_topic_id = $matches[1]) { |
---|
306 | return false; |
---|
307 | } |
---|
308 | |
---|
309 | if (MAIL_ADDRESS_HASHED) { |
---|
310 | if (empty($matches[2])) return false; |
---|
311 | |
---|
312 | // メンバーハッシュのチェック |
---|
313 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
314 | return false; |
---|
315 | } |
---|
316 | } |
---|
317 | |
---|
318 | m_debug_log('mail_sns::add_topic_image()', PEAR_LOG_INFO); |
---|
319 | return $this->add_topic_image($c_commu_topic_id); |
---|
320 | } |
---|
321 | |
---|
322 | //--- |
---|
323 | |
---|
324 | // アルバム表紙変更 |
---|
325 | elseif ( |
---|
326 | preg_match('/^ac(\d+)$/', $to_user, $matches) || |
---|
327 | preg_match('/^ac(\d+)-([0-9a-f]+)$/', $to_user, $matches) |
---|
328 | ) { |
---|
329 | |
---|
330 | // アルバムIDのチェック |
---|
331 | if (!$c_album_id = $matches[1]) { |
---|
332 | return false; |
---|
333 | } |
---|
334 | |
---|
335 | if (MAIL_ADDRESS_HASHED) { |
---|
336 | if (empty($matches[2])) return false; |
---|
337 | |
---|
338 | // メンバーハッシュのチェック |
---|
339 | if (!t_check_user_hash($this->c_member_id, $matches[2])) { |
---|
340 | return false; |
---|
341 | } |
---|
342 | } |
---|
343 | |
---|
344 | m_debug_log('mail_sns::add_album_cover_image()', PEAR_LOG_INFO); |
---|
345 | return $this->add_album_cover_image($c_album_id); |
---|
346 | } |
---|
347 | |
---|
348 | m_debug_log('mail_sns::main() action not found(member)'); |
---|
349 | return false; |
---|
350 | } |
---|
351 | |
---|
352 | /** |
---|
353 | * 新規登録のURL取得 |
---|
354 | */ |
---|
355 | function regist_get($aff_id) |
---|
356 | { |
---|
357 | // 招待者は c_member_id = 1 (固定) |
---|
358 | $c_member_id_invite = 1; |
---|
359 | |
---|
360 | // _pre に追加 |
---|
361 | $session = create_hash(); |
---|
362 | db_member_insert_c_member_ktai_pre($session, $this->from, $c_member_id_invite); |
---|
363 | |
---|
364 | do_common_send_mail_regist_get($session, $this->from, $aff_id); |
---|
365 | return true; |
---|
366 | } |
---|
367 | |
---|
368 | /** |
---|
369 | * ログインページのURL取得 |
---|
370 | */ |
---|
371 | function login_get() |
---|
372 | { |
---|
373 | do_mail_sns_login_get_mail_send($this->c_member_id, $this->from); |
---|
374 | return true; |
---|
375 | } |
---|
376 | |
---|
377 | /** |
---|
378 | * コミュニティ掲示板投稿 |
---|
379 | */ |
---|
380 | function add_commu_topic_comment($c_commu_topic_id) |
---|
381 | { |
---|
382 | if (!$topic = db_commu_c_commu_topic4c_commu_topic_id_3($c_commu_topic_id)) { |
---|
383 | return false; |
---|
384 | } |
---|
385 | |
---|
386 | $c_commu_id = $topic['c_commu_id']; |
---|
387 | if (!db_commu_is_c_commu_member($c_commu_id, $this->c_member_id)) { |
---|
388 | $this->error_mail(WORD_COMMUNITY . 'に参加していないため投稿できませんでした。'); |
---|
389 | m_debug_log('mail_sns::add_commu_topic_comment() not a member'); |
---|
390 | return false; |
---|
391 | } |
---|
392 | |
---|
393 | $images = $this->decoder->get_images(); |
---|
394 | if ($images === false) { |
---|
395 | $this->error_mail('画像は' . IMAGE_MAX_FILESIZE . 'KB以内のGIF・JPEG・PNGにしてください。'); |
---|
396 | return false; |
---|
397 | } |
---|
398 | |
---|
399 | // 画像アップロード可能サイズチェック |
---|
400 | if ($images) { |
---|
401 | $filesize = 0; |
---|
402 | $image_num = 1; |
---|
403 | foreach ($images as $image) { |
---|
404 | $filesize += $image['filesize']; |
---|
405 | $image_num++; |
---|
406 | if ($image_num > 3) { |
---|
407 | break; |
---|
408 | } |
---|
409 | } |
---|
410 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'commu'); |
---|
411 | if ($result) { |
---|
412 | $msg = util_image_get_upload_err_msg($result); |
---|
413 | $this->error_mail($msg); |
---|
414 | m_debug_log('mail_sns::add_commu_topic_comment() imagesize is full'); |
---|
415 | return false; |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | $body = $this->decoder->get_text_body(); |
---|
420 | if ($body === '') { |
---|
421 | $this->error_mail('本文が空のため投稿できませんでした。'); |
---|
422 | m_debug_log('mail_sns::add_commu_topic_comment() body is empty'); |
---|
423 | return false; |
---|
424 | } |
---|
425 | |
---|
426 | // 書き込みをDBに追加 |
---|
427 | $ins_id = db_commu_insert_c_commu_topic_comment($c_commu_id, $topic['c_commu_topic_id'], $this->c_member_id, $body); |
---|
428 | |
---|
429 | // 写真登録 |
---|
430 | $image_num = 1; |
---|
431 | foreach ($images as $image) { |
---|
432 | $image_ext = $image['ext']; |
---|
433 | $image_data = $image['data']; |
---|
434 | $filename = 'tc_' . $ins_id . '_' . $image_num . '_' . time() . '.' . $image_ext; |
---|
435 | |
---|
436 | db_image_insert_c_image($filename, $image_data, $image['filesize'], $this->c_member_id); |
---|
437 | db_commu_update_c_commu_topic_comment_image($ins_id, $filename, $image_num); |
---|
438 | $image_num++; |
---|
439 | if ($image_num > 3) { |
---|
440 | break; |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | //お知らせメール送信(携帯へ) |
---|
445 | send_bbs_info_mail($ins_id, $this->c_member_id); |
---|
446 | //お知らせメール送信(PCへ) |
---|
447 | send_bbs_info_mail_pc($ins_id, $this->c_member_id); |
---|
448 | |
---|
449 | if (OPENPNE_USE_POINT_RANK) { |
---|
450 | //トピック・イベントにコメントした人にポイント付与 |
---|
451 | $point = db_action_get_point4c_action_id(11); |
---|
452 | db_point_add_point($this->c_member_id, $point); |
---|
453 | } |
---|
454 | |
---|
455 | return true; |
---|
456 | } |
---|
457 | |
---|
458 | /** |
---|
459 | * 日記投稿 |
---|
460 | */ |
---|
461 | function add_diary() |
---|
462 | { |
---|
463 | $subject = $this->decoder->get_subject(); |
---|
464 | $body = $this->decoder->get_text_body(); |
---|
465 | |
---|
466 | if ($subject === '') { |
---|
467 | $subject = '無題'; |
---|
468 | } |
---|
469 | if ($body === '') { |
---|
470 | $this->error_mail('本文が空のため投稿できませんでした'); |
---|
471 | m_debug_log('mail_sns::add_diary() body is empty'); |
---|
472 | return false; |
---|
473 | } |
---|
474 | |
---|
475 | $images = $this->decoder->get_images(); |
---|
476 | if ($images === false) { |
---|
477 | $this->error_mail('画像は' . IMAGE_MAX_FILESIZE . 'KB以内のGIF・JPEG・PNGにしてください。'); |
---|
478 | return false; |
---|
479 | } |
---|
480 | |
---|
481 | // 画像アップロード可能サイズチェック |
---|
482 | if ($images) { |
---|
483 | $filesize = 0; |
---|
484 | $image_num = 1; |
---|
485 | foreach ($images as $image) { |
---|
486 | $filesize += $image['filesize']; |
---|
487 | $image_num++; |
---|
488 | if ($image_num > 3) { |
---|
489 | break; |
---|
490 | } |
---|
491 | } |
---|
492 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'diary'); |
---|
493 | if ($result) { |
---|
494 | $msg = util_image_get_upload_err_msg($result); |
---|
495 | $this->error_mail($msg); |
---|
496 | m_debug_log('mail_sns::add_diary() size over'); |
---|
497 | return false; |
---|
498 | } |
---|
499 | } |
---|
500 | |
---|
501 | $c_member = db_common_c_member4c_member_id($this->c_member_id); |
---|
502 | if (!$ins_id = db_diary_insert_c_diary($this->c_member_id, $subject, $body, $c_member['public_flag_diary'])) { |
---|
503 | return false; |
---|
504 | } |
---|
505 | |
---|
506 | // 写真登録 |
---|
507 | $image_num = 1; |
---|
508 | foreach ($images as $image) { |
---|
509 | $image_ext = $image['ext']; |
---|
510 | $image_data = $image['data']; |
---|
511 | $filename = 'd_' . $ins_id . '_' . $image_num . '_' . time() . '.' . $image_ext; |
---|
512 | |
---|
513 | db_image_insert_c_image($filename, $image_data, $image['filesize'], $this->c_member_id); |
---|
514 | db_diary_update_c_diary_image_filename($ins_id, $filename, $image_num); |
---|
515 | $image_num++; |
---|
516 | if ($image_num > 3) { |
---|
517 | break; |
---|
518 | } |
---|
519 | } |
---|
520 | |
---|
521 | if (OPENPNE_USE_POINT_RANK) { |
---|
522 | //日記を書いた人にポイント付与 |
---|
523 | $point = db_action_get_point4c_action_id(4); |
---|
524 | db_point_add_point($this->c_member_id, $point); |
---|
525 | } |
---|
526 | |
---|
527 | return true; |
---|
528 | } |
---|
529 | |
---|
530 | /** |
---|
531 | * 日記コメント投稿 |
---|
532 | */ |
---|
533 | function add_diary_comment($c_diary_id) |
---|
534 | { |
---|
535 | //--- 権限チェック |
---|
536 | |
---|
537 | $c_diary = db_diary_get_c_diary4id($c_diary_id); |
---|
538 | $target_c_member_id = $c_diary['c_member_id']; |
---|
539 | $target_c_member = db_member_c_member4c_member_id($target_c_member_id); |
---|
540 | |
---|
541 | if ($this->c_member_id != $target_c_member_id) { |
---|
542 | // check public_flag |
---|
543 | if (!pne_check_diary_public_flag($c_diary_id, $this->c_member_id)) { |
---|
544 | $this->error_mail(WORD_DIARY . 'にアクセスできないため投稿できませんでした。'); |
---|
545 | m_debug_log('mail_sns::add_diary_comment() not a member'); |
---|
546 | return false; |
---|
547 | } |
---|
548 | //アクセスブロック設定 |
---|
549 | if (db_member_is_access_block($this->c_member_id, $target_c_member_id)) { |
---|
550 | $this->error_mail(WORD_DIARY . 'にアクセスできないため投稿できませんでした。'); |
---|
551 | m_debug_log('mail_sns::add_diary_comment() access block'); |
---|
552 | return false; |
---|
553 | } |
---|
554 | } |
---|
555 | //--- |
---|
556 | |
---|
557 | // コメント許可設定取得 |
---|
558 | if (OPENPNE_USE_DIARY_COMMENT && !$c_diary['is_comment_input']) { |
---|
559 | $this->error_mail('現在この' . WORD_DIARY . 'にはコメントできません。'); |
---|
560 | m_debug_log('mail_sns::add_diary_comment() comment block'); |
---|
561 | return false; |
---|
562 | } |
---|
563 | |
---|
564 | $body = $this->decoder->get_text_body(); |
---|
565 | if ($body === '') { |
---|
566 | $this->error_mail('本文が空のため投稿できませんでした。'); |
---|
567 | m_debug_log('mail_sns::add_diary_comment() body is empty'); |
---|
568 | return false; |
---|
569 | } |
---|
570 | |
---|
571 | $images = $this->decoder->get_images(); |
---|
572 | if ($images === false) { |
---|
573 | $this->error_mail('画像は' . IMAGE_MAX_FILESIZE . 'KB以内のGIF・JPEG・PNGにしてください。'); |
---|
574 | return false; |
---|
575 | } |
---|
576 | |
---|
577 | // 画像アップロード可能サイズチェック |
---|
578 | if ($images) { |
---|
579 | $filesize = 0; |
---|
580 | $image_num = 1; |
---|
581 | foreach ($images as $image) { |
---|
582 | $filesize += $image['filesize']; |
---|
583 | $image_num++; |
---|
584 | if ($image_num > 3) { |
---|
585 | break; |
---|
586 | } |
---|
587 | } |
---|
588 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'diary'); |
---|
589 | if ($result) { |
---|
590 | $msg = util_image_get_upload_err_msg($result); |
---|
591 | $this->error_mail($msg); |
---|
592 | m_debug_log('mail_sns::add_diary_comment() size over'); |
---|
593 | return false; |
---|
594 | } |
---|
595 | } |
---|
596 | |
---|
597 | //日記コメント書き込み |
---|
598 | $ins_id = db_diary_insert_c_diary_comment($this->c_member_id, $c_diary_id, $body); |
---|
599 | |
---|
600 | //日記コメント記入履歴追加 |
---|
601 | if ($this->c_member_id != $target_c_member_id) { |
---|
602 | db_diary_insert_c_diary_comment_log($this->c_member_id, $c_diary_id); |
---|
603 | } |
---|
604 | //日記コメント記入履歴更新 |
---|
605 | db_diary_update_c_diary_comment_log($c_diary_id); |
---|
606 | |
---|
607 | // 写真登録 |
---|
608 | $image_num = 1; |
---|
609 | $filenames = array(1 => '', 2 => '', 3 => ''); |
---|
610 | foreach ($images as $image) { |
---|
611 | $image_ext = $image['ext']; |
---|
612 | $image_data = $image['data']; |
---|
613 | $filename = 'dc_' . $ins_id . '_' . $image_num . '_' . time() . '.' . $image_ext; |
---|
614 | |
---|
615 | db_image_insert_c_image($filename, $image_data, $image['filesize'], $this->c_member_id); |
---|
616 | $filenames[$image_num] = $filename; |
---|
617 | $image_num++; |
---|
618 | if ($image_num > 3) { |
---|
619 | break; |
---|
620 | } |
---|
621 | } |
---|
622 | db_diary_insert_c_diary_comment_images($ins_id, $filenames[1], $filenames[2], $filenames[3]); |
---|
623 | |
---|
624 | //お知らせメール送信(携帯へ) |
---|
625 | if ($this->c_member_id != $target_c_member_id) { |
---|
626 | send_diary_comment_info_mail($ins_id, $this->c_member_id); |
---|
627 | } |
---|
628 | |
---|
629 | //日記コメントが書き込まれたので日記自体を未読扱いにする |
---|
630 | if ($this->c_member_id != $target_c_member_id) { |
---|
631 | db_diary_update_c_diary_is_checked($c_diary_id, 0); |
---|
632 | } |
---|
633 | |
---|
634 | if (OPENPNE_USE_POINT_RANK) { |
---|
635 | // コメント者と被コメント者が違う場合にポイント加算 |
---|
636 | if ($this->c_member_id != $target_c_member_id) { |
---|
637 | //書いた人にポイント付与 |
---|
638 | $point = db_action_get_point4c_action_id(3); |
---|
639 | db_point_add_point($this->c_member_id, $point); |
---|
640 | |
---|
641 | //書かれた人にポイント付与 |
---|
642 | $point = db_action_get_point4c_action_id(2); |
---|
643 | db_point_add_point($target_c_member_id, $point); |
---|
644 | } |
---|
645 | } |
---|
646 | |
---|
647 | return true; |
---|
648 | } |
---|
649 | |
---|
650 | /** |
---|
651 | * アルバム追加 |
---|
652 | */ |
---|
653 | function add_album() |
---|
654 | { |
---|
655 | $subject = $this->decoder->get_subject(); |
---|
656 | $body = $this->decoder->get_text_body(); |
---|
657 | |
---|
658 | if ($subject === '') { |
---|
659 | $this->error_mail('メールの件名にアルバムのタイトルを入力してください。'); |
---|
660 | m_debug_log('mail_sns::add_album() subject is empty'); |
---|
661 | return false; |
---|
662 | } |
---|
663 | |
---|
664 | if ($body === '') { |
---|
665 | $this->error_mail('メールの本文にアルバムの説明文を入力してください。'); |
---|
666 | m_debug_log('mail_sns::add_album() body is empty'); |
---|
667 | return false; |
---|
668 | } |
---|
669 | |
---|
670 | if ($images = $this->decoder->get_images()) { |
---|
671 | // アルバムの作成 |
---|
672 | $c_member = db_common_c_member4c_member_id($this->c_member_id); |
---|
673 | if (!$ins_id = db_album_insert_c_album($this->c_member_id, $subject, $body, $c_member['public_flag_diary'])) { |
---|
674 | return false; |
---|
675 | } |
---|
676 | |
---|
677 | // 写真登録 |
---|
678 | $image = $images[0]; |
---|
679 | $image_ext = $image['ext']; |
---|
680 | $image_data = $image['data']; |
---|
681 | $filename = 'a_' . $ins_id . '_1_' . time() . '.' . $image_ext; |
---|
682 | |
---|
683 | // 画像アップロード可能サイズチェック |
---|
684 | $filesize = $image['filesize']; |
---|
685 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'other'); |
---|
686 | if ($result) { |
---|
687 | $msg = util_image_get_upload_err_msg($result); |
---|
688 | $this->error_mail($msg); |
---|
689 | m_debug_log('mail_sns::add_album() size over'); |
---|
690 | return false; |
---|
691 | } |
---|
692 | |
---|
693 | db_image_insert_c_image($filename, $image_data, $filesize, $this->c_member_id); |
---|
694 | //アルバムの表紙に写真ファイル名を登録 |
---|
695 | db_album_update_c_album_album_cover_image($ins_id, $filename); |
---|
696 | } else { |
---|
697 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、ファイル表紙を登録できませんでした。'); |
---|
698 | m_debug_log('mail_sns::add_album() no images'); |
---|
699 | return false; |
---|
700 | } |
---|
701 | |
---|
702 | return true; |
---|
703 | } |
---|
704 | |
---|
705 | /** |
---|
706 | * アルバム写真登録 |
---|
707 | */ |
---|
708 | function add_album_image($c_album_id) |
---|
709 | { |
---|
710 | if (!$c_album = db_album_get_c_album4c_album_id($c_album_id)) { |
---|
711 | return false; |
---|
712 | } |
---|
713 | |
---|
714 | if ($c_album['c_member_id'] != $this->c_member_id) { |
---|
715 | return false; |
---|
716 | } |
---|
717 | |
---|
718 | $subject = $this->decoder->get_subject(); |
---|
719 | $images = $this->decoder->get_images(); |
---|
720 | if (!$images) { |
---|
721 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
722 | m_debug_log('mail_sns::add_album_image() no images'); |
---|
723 | return false; |
---|
724 | } |
---|
725 | |
---|
726 | // 写真登録 |
---|
727 | $image = $images[0]; |
---|
728 | $image_ext = $image['ext']; |
---|
729 | $image_data = $image['data']; |
---|
730 | $image_size = $image['filesize']; |
---|
731 | |
---|
732 | // 容量制限 |
---|
733 | $result = util_image_check_add_image_upload($image_size, $this->c_member_id, 'album'); |
---|
734 | if ($result) { |
---|
735 | $msg = util_image_get_upload_err_msg($result); |
---|
736 | $this->error_mail($msg); |
---|
737 | m_debug_log('mail_sns::add_album_image() size over'); |
---|
738 | return false; |
---|
739 | } |
---|
740 | |
---|
741 | $filename = 'a_' . $c_album_id . '_1_' . time() . '.' . $image_ext; |
---|
742 | db_image_insert_c_image($filename, $image_data, $image_size, $this->c_member_id); |
---|
743 | if (!$subject) { |
---|
744 | // 説明文が空の場合はファイル名を挿入する |
---|
745 | $subject = $filename; |
---|
746 | } |
---|
747 | //アルバムデータの変更 |
---|
748 | db_insert_c_album_image($c_album_id, $this->c_member_id, $filename, $subject, $image_size); |
---|
749 | |
---|
750 | return true; |
---|
751 | } |
---|
752 | |
---|
753 | /** |
---|
754 | * プロフィール写真変更 |
---|
755 | */ |
---|
756 | function add_member_image() |
---|
757 | { |
---|
758 | $c_member = db_member_c_member4c_member_id($this->c_member_id); |
---|
759 | |
---|
760 | // 登録する写真番号(1-3)を決める |
---|
761 | $target_number = 0; |
---|
762 | if ($c_member['image_filename']) { |
---|
763 | if (!$c_member['image_filename_1']) { |
---|
764 | $target_number = 1; |
---|
765 | } elseif (!$c_member['image_filename_2']) { |
---|
766 | $target_number = 2; |
---|
767 | } elseif (!$c_member['image_filename_3']) { |
---|
768 | $target_number = 3; |
---|
769 | } else { |
---|
770 | $this->error_mail('プロフィール写真の登録は最大3枚までです。'); |
---|
771 | m_debug_log('mail_sns::add_diary() image is full'); |
---|
772 | return false; |
---|
773 | } |
---|
774 | } else { |
---|
775 | $target_number = 1; |
---|
776 | } |
---|
777 | |
---|
778 | // 写真登録 |
---|
779 | if ($images = $this->decoder->get_images()) { |
---|
780 | $image = $images[0]; |
---|
781 | $image_ext = $image['ext']; |
---|
782 | $image_data = $image['data']; |
---|
783 | $filename = 'm_' . $this->c_member_id . '_' . time() . '.' . $image_ext; |
---|
784 | |
---|
785 | // 画像アップロード可能サイズチェック |
---|
786 | $filesize = $image['filesize']; |
---|
787 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'other'); |
---|
788 | if ($result) { |
---|
789 | $msg = util_image_get_upload_err_msg($result); |
---|
790 | $this->error_mail($msg); |
---|
791 | m_debug_log('mail_sns::add_member_image() size over'); |
---|
792 | return false; |
---|
793 | } |
---|
794 | |
---|
795 | db_image_insert_c_image($filename, $image_data, $filesize, $this->c_member_id); |
---|
796 | db_member_update_c_member_image($this->c_member_id, $filename, $target_number); |
---|
797 | return true; |
---|
798 | } else { |
---|
799 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
800 | m_debug_log('mail_sns::add_member_image() no images'); |
---|
801 | return false; |
---|
802 | } |
---|
803 | } |
---|
804 | |
---|
805 | /** |
---|
806 | * 日記写真変更 |
---|
807 | */ |
---|
808 | function add_diary_image($c_diary_id) |
---|
809 | { |
---|
810 | if (!$c_diary = db_diary_get_c_diary4id($c_diary_id)) { |
---|
811 | return false; |
---|
812 | } |
---|
813 | |
---|
814 | if ($c_diary['c_member_id'] != $this->c_member_id) { |
---|
815 | return false; |
---|
816 | } |
---|
817 | |
---|
818 | // 登録する写真番号(1-3)を決める |
---|
819 | $target_number = 0; |
---|
820 | if ($c_diary['image_filename_1'] || $c_diary['image_filename_2'] || $c_diary['image_filename_3']) { |
---|
821 | if (!$c_diary['image_filename_1']) { |
---|
822 | $target_number = 1; |
---|
823 | } elseif (!$c_diary['image_filename_2']) { |
---|
824 | $target_number = 2; |
---|
825 | } elseif (!$c_diary['image_filename_3']) { |
---|
826 | $target_number = 3; |
---|
827 | } else { |
---|
828 | $this->error_mail(WORD_DIARY . '写真の登録は最大3枚までです。'); |
---|
829 | m_debug_log('mail_sns::add_diary_image() image is full'); |
---|
830 | return false; |
---|
831 | } |
---|
832 | } else { |
---|
833 | $target_number = 1; |
---|
834 | } |
---|
835 | |
---|
836 | // 写真登録 |
---|
837 | if ($images = $this->decoder->get_images()) { |
---|
838 | $image = $images[0]; |
---|
839 | $image_ext = $image['ext']; |
---|
840 | $image_data = $image['data']; |
---|
841 | $filename = 'd_' . $c_diary_id . '_' . $target_number . '_' . time() . '.' . $image_ext; |
---|
842 | |
---|
843 | // 画像アップロード可能サイズチェック |
---|
844 | $filesize = $image['filesize']; |
---|
845 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'diary'); |
---|
846 | if ($result) { |
---|
847 | $msg = util_image_get_upload_err_msg($result); |
---|
848 | $this->error_mail($msg); |
---|
849 | m_debug_log('mail_sns::add_diary_image() size over'); |
---|
850 | return false; |
---|
851 | } |
---|
852 | |
---|
853 | db_image_insert_c_image($filename, $image_data, $filesize, $this->c_member_id); |
---|
854 | db_diary_update_c_diary_image_filename($c_diary_id, $filename, $target_number); |
---|
855 | return true; |
---|
856 | } else { |
---|
857 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
858 | m_debug_log('mail_sns::add_diary_image() no images'); |
---|
859 | return false; |
---|
860 | } |
---|
861 | } |
---|
862 | |
---|
863 | /** |
---|
864 | * コミュニティ写真変更 |
---|
865 | */ |
---|
866 | function add_commu_image($c_commu_id) |
---|
867 | { |
---|
868 | if (!$c_commu = db_commu_c_commu4c_commu_id($c_commu_id)) { |
---|
869 | return false; |
---|
870 | } |
---|
871 | |
---|
872 | if ($c_commu['c_member_id_admin'] != $this->c_member_id && $c_commu['c_member_id_sub_admin'] != $this->c_member_id ) { |
---|
873 | return false; |
---|
874 | } |
---|
875 | |
---|
876 | if ($c_commu['image_filename']) { |
---|
877 | $this->error_mail(WORD_COMMUNITY . '写真の登録は最大1枚までです。'); |
---|
878 | m_debug_log('mail_sns::add_commu_image() image is full'); |
---|
879 | return false; |
---|
880 | } |
---|
881 | |
---|
882 | // 写真登録 |
---|
883 | if ($images = $this->decoder->get_images()) { |
---|
884 | $image = $images[0]; |
---|
885 | $image_ext = $image['ext']; |
---|
886 | $image_data = $image['data']; |
---|
887 | $filename = 'c_' . $c_commu_id . '_' . time() . '.' . $image_ext; |
---|
888 | |
---|
889 | // 画像アップロード可能サイズチェック |
---|
890 | $filesize = $image['filesize']; |
---|
891 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'other'); |
---|
892 | if ($result) { |
---|
893 | $msg = util_image_get_upload_err_msg($result); |
---|
894 | $this->error_mail($msg); |
---|
895 | m_debug_log('mail_sns::add_commu_image() size over'); |
---|
896 | return false; |
---|
897 | } |
---|
898 | |
---|
899 | db_image_insert_c_image($filename, $image_data, $filesize, $this->c_member_id); |
---|
900 | db_commu_update_c_commu_image_filename($c_commu_id, $filename); |
---|
901 | return true; |
---|
902 | } else { |
---|
903 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
904 | m_debug_log('mail_sns::add_commu_image() no images'); |
---|
905 | return false; |
---|
906 | } |
---|
907 | } |
---|
908 | |
---|
909 | /** |
---|
910 | * トピック・イベント写真変更 |
---|
911 | */ |
---|
912 | function add_topic_image($c_commu_topic_id) |
---|
913 | { |
---|
914 | if (!$c_topic = db_commu_c_topic4c_commu_topic_id($c_commu_topic_id)) { |
---|
915 | return false; |
---|
916 | } |
---|
917 | |
---|
918 | $c_commu_id = $c_topic['c_commu_id']; |
---|
919 | |
---|
920 | if (!db_commu_is_c_topic_admin($c_commu_topic_id, $this->c_member_id) && |
---|
921 | !db_commu_is_c_commu_admin($c_commu_id, $this->c_member_id)) { |
---|
922 | return false; |
---|
923 | } |
---|
924 | |
---|
925 | // 登録する写真番号(1-3)を決める |
---|
926 | $target_number = 0; |
---|
927 | if ($c_topic['image_filename1'] || $c_topic['image_filename2'] || $c_topic['image_filename3']) { |
---|
928 | if (!$c_topic['image_filename1']) { |
---|
929 | $target_number = 1; |
---|
930 | } elseif (!$c_topic['image_filename2']) { |
---|
931 | $target_number = 2; |
---|
932 | } elseif (!$c_topic['image_filename3']) { |
---|
933 | $target_number = 3; |
---|
934 | } else { |
---|
935 | $this->error_mail('トピック・イベント写真の登録は最大3枚までです。'); |
---|
936 | m_debug_log('mail_sns::add_topic_image() image is full'); |
---|
937 | return false; |
---|
938 | } |
---|
939 | } else { |
---|
940 | $target_number = 1; |
---|
941 | } |
---|
942 | |
---|
943 | // 写真登録 |
---|
944 | if ($images = $this->decoder->get_images()) { |
---|
945 | $image = $images[0]; |
---|
946 | $image_ext = $image['ext']; |
---|
947 | $image_data = $image['data']; |
---|
948 | $filename = 't_' . $c_commu_topic_id . '_' . $target_number . '_' . time() . '.' . $image_ext; |
---|
949 | |
---|
950 | // 画像アップロード可能サイズチェック |
---|
951 | $filesize = $image['filesize']; |
---|
952 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'commu'); |
---|
953 | if ($result) { |
---|
954 | $msg = util_image_get_upload_err_msg($result); |
---|
955 | $this->error_mail($msg); |
---|
956 | m_debug_log('mail_sns::add_topic_image() size over'); |
---|
957 | return false; |
---|
958 | } |
---|
959 | |
---|
960 | $c_topic['image_filename' . $target_number] = $filename; |
---|
961 | db_image_insert_c_image($filename, $image_data, $filesize, $this->c_member_id); |
---|
962 | db_commu_update_c_commu_topic_comment_images($c_topic['c_commu_topic_comment_id'], $c_topic['image_filename1'], $c_topic['image_filename2'], $c_topic['image_filename3']); |
---|
963 | return true; |
---|
964 | } else { |
---|
965 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
966 | m_debug_log('mail_sns::add_topic_image() no images'); |
---|
967 | return false; |
---|
968 | } |
---|
969 | |
---|
970 | } |
---|
971 | |
---|
972 | /** |
---|
973 | * アルバム表紙変更 |
---|
974 | */ |
---|
975 | function add_album_cover_image($c_album_id) |
---|
976 | { |
---|
977 | if (!$c_album = db_album_get_c_album4c_album_id($c_album_id)) { |
---|
978 | return false; |
---|
979 | } |
---|
980 | |
---|
981 | if ($c_album['c_member_id'] != $this->c_member_id) { |
---|
982 | return false; |
---|
983 | } |
---|
984 | |
---|
985 | // 写真登録 |
---|
986 | if ($images = $this->decoder->get_images()) { |
---|
987 | $image = $images[0]; |
---|
988 | $image_ext = $image['ext']; |
---|
989 | $image_data = $image['data']; |
---|
990 | $filename = 'a_' . $c_album_id . '_1_' . time() . '.' . $image_ext; |
---|
991 | |
---|
992 | // 画像アップロード可能サイズチェック |
---|
993 | $filesize = $image['filesize']; |
---|
994 | $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'other'); |
---|
995 | if ($result) { |
---|
996 | $msg = util_image_get_upload_err_msg($result); |
---|
997 | $this->error_mail($msg); |
---|
998 | m_debug_log('mail_sns::add_album_cover_image() size over'); |
---|
999 | return false; |
---|
1000 | } |
---|
1001 | |
---|
1002 | db_image_insert_c_image($filename, $image_data, $filesize, $this->c_member_id); |
---|
1003 | //アルバムデータの変更 |
---|
1004 | $c_album_cover = $c_album['album_cover_image']; |
---|
1005 | db_album_image_data_delete($c_album_cover, $c_album['c_member_id']); |
---|
1006 | db_album_update_c_album_album_cover_image($c_album_id,$filename); |
---|
1007 | } else { |
---|
1008 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、アルバム表紙を変更できませんでした。'); |
---|
1009 | m_debug_log('mail_sns::add_album_cover_image() no images'); |
---|
1010 | return false; |
---|
1011 | } |
---|
1012 | |
---|
1013 | return true; |
---|
1014 | } |
---|
1015 | |
---|
1016 | /** |
---|
1017 | * エラーメールをメール送信者へ返信 |
---|
1018 | */ |
---|
1019 | function error_mail($body) |
---|
1020 | { |
---|
1021 | $subject = '['.SNS_NAME.']メール投稿エラー'; |
---|
1022 | t_send_email($this->from, $subject, $body); |
---|
1023 | } |
---|
1024 | } |
---|
1025 | |
---|
1026 | ?> |
---|