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 | |
---|
75 | // ログインURL通知 |
---|
76 | if ($to_user == 'get') { |
---|
77 | m_debug_log('mail_sns::login_get()', PEAR_LOG_INFO); |
---|
78 | return $this->login_get(); |
---|
79 | } |
---|
80 | |
---|
81 | //--- |
---|
82 | |
---|
83 | // コミュニティ掲示板投稿 |
---|
84 | elseif ( |
---|
85 | preg_match('/^t(\d+)$/', $to_user, $matches) || |
---|
86 | preg_match('/^t(\d+)-([0-9a-f]{12})$/', $to_user, $matches) |
---|
87 | ) { |
---|
88 | |
---|
89 | // トピックIDのチェック |
---|
90 | if (!$c_commu_topic_id = $matches[1]) { |
---|
91 | return false; |
---|
92 | } |
---|
93 | |
---|
94 | if (MAIL_ADDRESS_HASHED) { |
---|
95 | if (empty($matches[2])) return false; |
---|
96 | |
---|
97 | // メンバーハッシュのチェック |
---|
98 | if ($matches[2] != t_get_user_hash($this->c_member_id)) { |
---|
99 | return false; |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | m_debug_log('mail_sns::add_commu_topic_comment()', PEAR_LOG_INFO); |
---|
104 | return $this->add_commu_topic_comment($c_commu_topic_id); |
---|
105 | } |
---|
106 | |
---|
107 | //--- |
---|
108 | |
---|
109 | // 日記投稿 |
---|
110 | elseif ( |
---|
111 | $to_user == 'blog' || |
---|
112 | preg_match('/^b(\d+)-([0-9a-f]{12})$/', $to_user, $matches) |
---|
113 | ) { |
---|
114 | |
---|
115 | if (MAIL_ADDRESS_HASHED) { |
---|
116 | if (empty($matches[1]) || empty($matches[2])) return false; |
---|
117 | |
---|
118 | // メンバーIDのチェック |
---|
119 | if ($matches[1] != $this->c_member_id) { |
---|
120 | return false; |
---|
121 | } |
---|
122 | // メンバーハッシュのチェック |
---|
123 | if ($matches[2] != t_get_user_hash($this->c_member_id)) { |
---|
124 | return false; |
---|
125 | } |
---|
126 | } |
---|
127 | |
---|
128 | m_debug_log('mail_sns::add_diary()', PEAR_LOG_INFO); |
---|
129 | return $this->add_diary(); |
---|
130 | } |
---|
131 | |
---|
132 | //--- |
---|
133 | |
---|
134 | // 日記コメント投稿 |
---|
135 | elseif ( |
---|
136 | preg_match('/^bc(\d+)$/', $to_user, $matches) || |
---|
137 | preg_match('/^bc(\d+)-([0-9a-f]{12})$/', $to_user, $matches) |
---|
138 | ) { |
---|
139 | |
---|
140 | // 日記IDのチェック |
---|
141 | if (!$c_diary_id = $matches[1]) { |
---|
142 | return false; |
---|
143 | } |
---|
144 | |
---|
145 | if (MAIL_ADDRESS_HASHED) { |
---|
146 | if (empty($matches[2])) return false; |
---|
147 | |
---|
148 | // メンバーハッシュのチェック |
---|
149 | if ($matches[2] != t_get_user_hash($this->c_member_id)) { |
---|
150 | return false; |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | m_debug_log('mail_sns::add_diary_comment()', PEAR_LOG_INFO); |
---|
155 | return $this->add_diary_comment($c_diary_id); |
---|
156 | } |
---|
157 | |
---|
158 | //--- |
---|
159 | |
---|
160 | //プロフィール写真変更 |
---|
161 | elseif ( |
---|
162 | preg_match('/^p(\d+)$/', $to_user, $matches) || |
---|
163 | preg_match('/^p(\d+)-([0-9a-f]{12})$/', $to_user, $matches) |
---|
164 | ) { |
---|
165 | |
---|
166 | // メンバーIDのチェック |
---|
167 | if ($matches[1] != $this->c_member_id) { |
---|
168 | return false; |
---|
169 | } |
---|
170 | |
---|
171 | if (MAIL_ADDRESS_HASHED) { |
---|
172 | if (empty($matches[2])) return false; |
---|
173 | |
---|
174 | // メンバーハッシュのチェック |
---|
175 | if ($matches[2] != t_get_user_hash($this->c_member_id)) { |
---|
176 | return false; |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | m_debug_log('mail_sns::add_member_image()', PEAR_LOG_INFO); |
---|
181 | return $this->add_member_image(); |
---|
182 | } |
---|
183 | |
---|
184 | //--- |
---|
185 | |
---|
186 | // 日記写真変更 |
---|
187 | elseif ( |
---|
188 | preg_match('/^bi(\d+)$/', $to_user, $matches) || |
---|
189 | preg_match('/^bi(\d+)-([0-9a-f]{12})$/', $to_user, $matches) |
---|
190 | ) { |
---|
191 | // 日記IDのチェック |
---|
192 | if (!$c_diary_id = $matches[1]) { |
---|
193 | return false; |
---|
194 | } |
---|
195 | |
---|
196 | if (MAIL_ADDRESS_HASHED) { |
---|
197 | if (empty($matches[2])) return false; |
---|
198 | |
---|
199 | // メンバーハッシュのチェック |
---|
200 | if ($matches[2] != t_get_user_hash($this->c_member_id)) { |
---|
201 | return false; |
---|
202 | } |
---|
203 | } |
---|
204 | |
---|
205 | m_debug_log('mail_sns::add_diary_image()', PEAR_LOG_INFO); |
---|
206 | return $this->add_diary_image($c_diary_id); |
---|
207 | } |
---|
208 | |
---|
209 | //--- |
---|
210 | |
---|
211 | // コミュニティ写真変更 |
---|
212 | elseif ( |
---|
213 | preg_match('/^ci(\d+)$/', $to_user, $matches) || |
---|
214 | preg_match('/^ci(\d+)-([0-9a-f]{12})$/', $to_user, $matches) |
---|
215 | ) { |
---|
216 | // コミュニティIDのチェック |
---|
217 | if (!$c_commu_id = $matches[1]) { |
---|
218 | return false; |
---|
219 | } |
---|
220 | |
---|
221 | if (MAIL_ADDRESS_HASHED) { |
---|
222 | if (empty($matches[2])) return false; |
---|
223 | |
---|
224 | // メンバーハッシュのチェック |
---|
225 | if ($matches[2] != t_get_user_hash($this->c_member_id)) { |
---|
226 | return false; |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | m_debug_log('mail_sns::add_commu_image()', PEAR_LOG_INFO); |
---|
231 | return $this->add_commu_image($c_commu_id); |
---|
232 | } |
---|
233 | |
---|
234 | //--- |
---|
235 | |
---|
236 | // トピック・イベント写真変更 |
---|
237 | elseif ( |
---|
238 | preg_match('/^ti(\d+)$/', $to_user, $matches) || |
---|
239 | preg_match('/^ti(\d+)-([0-9a-f]{12})$/', $to_user, $matches) |
---|
240 | ) { |
---|
241 | // トピックIDのチェック |
---|
242 | if (!$c_commu_topic_id = $matches[1]) { |
---|
243 | return false; |
---|
244 | } |
---|
245 | |
---|
246 | if (MAIL_ADDRESS_HASHED) { |
---|
247 | if (empty($matches[2])) return false; |
---|
248 | |
---|
249 | // メンバーハッシュのチェック |
---|
250 | if ($matches[2] != t_get_user_hash($this->c_member_id)) { |
---|
251 | return false; |
---|
252 | } |
---|
253 | } |
---|
254 | |
---|
255 | m_debug_log('mail_sns::add_topic_image()', PEAR_LOG_INFO); |
---|
256 | return $this->add_topic_image($c_commu_topic_id); |
---|
257 | } |
---|
258 | |
---|
259 | m_debug_log('mail_sns::main() action not found(member)'); |
---|
260 | return false; |
---|
261 | } |
---|
262 | |
---|
263 | /** |
---|
264 | * 新規登録のURL取得 |
---|
265 | */ |
---|
266 | function regist_get($aff_id) |
---|
267 | { |
---|
268 | // 招待者は c_member_id = 1 (固定) |
---|
269 | $c_member_id_invite = 1; |
---|
270 | |
---|
271 | // _pre に追加 |
---|
272 | $session = create_hash(); |
---|
273 | db_member_insert_c_member_ktai_pre($session, $this->from, $c_member_id_invite); |
---|
274 | |
---|
275 | do_common_send_mail_regist_get($session, $this->from, $aff_id); |
---|
276 | return true; |
---|
277 | } |
---|
278 | |
---|
279 | /** |
---|
280 | * ログインページのURL取得 |
---|
281 | */ |
---|
282 | function login_get() |
---|
283 | { |
---|
284 | do_mail_sns_login_get_mail_send($this->c_member_id, $this->from); |
---|
285 | return true; |
---|
286 | } |
---|
287 | |
---|
288 | /** |
---|
289 | * コミュニティ掲示板投稿 |
---|
290 | */ |
---|
291 | function add_commu_topic_comment($c_commu_topic_id) |
---|
292 | { |
---|
293 | if (!$topic = db_commu_c_commu_topic4c_commu_topic_id_3($c_commu_topic_id)) { |
---|
294 | return false; |
---|
295 | } |
---|
296 | |
---|
297 | $c_commu_id = $topic['c_commu_id']; |
---|
298 | if (!db_commu_is_c_commu_member($c_commu_id, $this->c_member_id)) { |
---|
299 | $this->error_mail(WORD_COMMUNITY . 'に参加していないため投稿できませんでした。'); |
---|
300 | m_debug_log('mail_sns::add_commu_topic_comment() not a member'); |
---|
301 | return false; |
---|
302 | } |
---|
303 | |
---|
304 | $body = $this->decoder->get_text_body(); |
---|
305 | if ($body === '') { |
---|
306 | $this->error_mail('本文が空のため投稿できませんでした。'); |
---|
307 | m_debug_log('mail_sns::add_commu_topic_comment() body is empty'); |
---|
308 | return false; |
---|
309 | } |
---|
310 | |
---|
311 | // 書き込みをDBに追加 |
---|
312 | $ins_id = db_commu_insert_c_commu_topic_comment($c_commu_id, $topic['c_commu_topic_id'], $this->c_member_id, $body); |
---|
313 | |
---|
314 | // 写真登録 |
---|
315 | $images = $this->decoder->get_images(); |
---|
316 | if ($images === false) { |
---|
317 | $this->error_mail('画像は' . IMAGE_MAX_FILESIZE . 'KB以内のGIF・JPEG・PNGにしてください。'); |
---|
318 | return false; |
---|
319 | } |
---|
320 | $image_num = 1; |
---|
321 | foreach ($images as $image) { |
---|
322 | $image_ext = $image['ext']; |
---|
323 | $image_data = $image['data']; |
---|
324 | $filename = 'tc_' . $ins_id . '_' . $image_num . '_' . time() . '.' . $image_ext; |
---|
325 | |
---|
326 | db_image_insert_c_image($filename, $image_data); |
---|
327 | db_commu_update_c_commu_topic_comment_image($ins_id, $filename, $image_num); |
---|
328 | $image_num++; |
---|
329 | if ($image_num > 3) { |
---|
330 | break; |
---|
331 | } |
---|
332 | } |
---|
333 | |
---|
334 | //お知らせメール送信(携帯へ) |
---|
335 | send_bbs_info_mail($ins_id, $this->c_member_id); |
---|
336 | //お知らせメール送信(PCへ) |
---|
337 | send_bbs_info_mail_pc($ins_id, $this->c_member_id); |
---|
338 | |
---|
339 | if (OPENPNE_USE_POINT_RANK) { |
---|
340 | //トピック・イベントにコメントした人にポイント付与 |
---|
341 | $point = db_action_get_point4c_action_id(11); |
---|
342 | db_point_add_point($this->c_member_id, $point); |
---|
343 | } |
---|
344 | |
---|
345 | return true; |
---|
346 | } |
---|
347 | |
---|
348 | /** |
---|
349 | * 日記投稿 |
---|
350 | */ |
---|
351 | function add_diary() |
---|
352 | { |
---|
353 | $subject = $this->decoder->get_subject(); |
---|
354 | $body = $this->decoder->get_text_body(); |
---|
355 | |
---|
356 | if ($subject === '') { |
---|
357 | $subject = '無題'; |
---|
358 | } |
---|
359 | if ($body === '') { |
---|
360 | $this->error_mail('本文が空のため投稿できませんでした'); |
---|
361 | m_debug_log('mail_sns::add_diary() body is empty'); |
---|
362 | return false; |
---|
363 | } |
---|
364 | |
---|
365 | $c_member = db_member_c_member4c_member_id($this->c_member_id); |
---|
366 | if (!$ins_id = db_diary_insert_c_diary($this->c_member_id, $subject, $body, $c_member['public_flag_diary'])) { |
---|
367 | return false; |
---|
368 | } |
---|
369 | |
---|
370 | // 写真登録 |
---|
371 | $images = $this->decoder->get_images(); |
---|
372 | if ($images === false) { |
---|
373 | $this->error_mail('画像は' . IMAGE_MAX_FILESIZE . 'KB以内のGIF・JPEG・PNGにしてください。'); |
---|
374 | return false; |
---|
375 | } |
---|
376 | $image_num = 1; |
---|
377 | foreach ($images as $image) { |
---|
378 | $image_ext = $image['ext']; |
---|
379 | $image_data = $image['data']; |
---|
380 | $filename = 'd_' . $ins_id . '_' . $image_num . '_' . time() . '.' . $image_ext; |
---|
381 | |
---|
382 | db_image_insert_c_image($filename, $image_data); |
---|
383 | db_diary_update_c_diary_image_filename($ins_id, $filename, $image_num); |
---|
384 | $image_num++; |
---|
385 | if ($image_num > 3) { |
---|
386 | break; |
---|
387 | } |
---|
388 | } |
---|
389 | |
---|
390 | if (OPENPNE_USE_POINT_RANK) { |
---|
391 | //日記を書いた人にポイント付与 |
---|
392 | $point = db_action_get_point4c_action_id(4); |
---|
393 | db_point_add_point($this->c_member_id, $point); |
---|
394 | } |
---|
395 | |
---|
396 | return true; |
---|
397 | } |
---|
398 | |
---|
399 | /** |
---|
400 | * 日記コメント投稿 |
---|
401 | */ |
---|
402 | function add_diary_comment($c_diary_id) |
---|
403 | { |
---|
404 | //--- 権限チェック |
---|
405 | |
---|
406 | $c_diary = db_diary_get_c_diary4id($c_diary_id); |
---|
407 | $target_c_member_id = $c_diary['c_member_id']; |
---|
408 | $target_c_member = db_member_c_member4c_member_id($target_c_member_id); |
---|
409 | |
---|
410 | if ($this->c_member_id != $target_c_member_id) { |
---|
411 | // check public_flag |
---|
412 | if (!pne_check_diary_public_flag($c_diary_id, $this->c_member_id)) { |
---|
413 | $this->error_mail(WORD_DIARY . 'にアクセスできないため投稿できませんでした。'); |
---|
414 | m_debug_log('mail_sns::add_diary_comment() not a member'); |
---|
415 | return false; |
---|
416 | } |
---|
417 | //アクセスブロック設定 |
---|
418 | if (db_member_is_access_block($this->c_member_id, $target_c_member_id)) { |
---|
419 | $this->error_mail(WORD_DIARY . 'にアクセスできないため投稿できませんでした。'); |
---|
420 | m_debug_log('mail_sns::add_diary_comment() access block'); |
---|
421 | return false; |
---|
422 | } |
---|
423 | } |
---|
424 | //--- |
---|
425 | |
---|
426 | $body = $this->decoder->get_text_body(); |
---|
427 | if ($body === '') { |
---|
428 | $this->error_mail('本文が空のため投稿できませんでした。'); |
---|
429 | m_debug_log('mail_sns::add_diary_comment() body is empty'); |
---|
430 | return false; |
---|
431 | } |
---|
432 | |
---|
433 | //日記コメント書き込み |
---|
434 | $ins_id = db_diary_insert_c_diary_comment($this->c_member_id, $c_diary_id, $body); |
---|
435 | |
---|
436 | //日記コメント記入履歴追加 |
---|
437 | if ($u != $target_c_member_id) { |
---|
438 | db_diary_insert_c_diary_comment_log($u, $target_c_diary_id); |
---|
439 | } |
---|
440 | //日記コメント記入履歴更新 |
---|
441 | db_diary_update_c_diary_comment_log($target_c_diary_id); |
---|
442 | |
---|
443 | // 写真登録 |
---|
444 | $images = $this->decoder->get_images(); |
---|
445 | $image_num = 1; |
---|
446 | $filenames = array(1 => '', 2 => '', 3 => ''); |
---|
447 | foreach ($images as $image) { |
---|
448 | $image_ext = $image['ext']; |
---|
449 | $image_data = $image['data']; |
---|
450 | $filename = 'dc_' . $ins_id . '_' . $image_num . '_' . time() . '.' . $image_ext; |
---|
451 | |
---|
452 | db_image_insert_c_image($filename, $image_data); |
---|
453 | $filenames[$image_num] = $filename; |
---|
454 | $image_num++; |
---|
455 | if ($image_num > 3) { |
---|
456 | break; |
---|
457 | } |
---|
458 | } |
---|
459 | db_diary_insert_c_diary_comment_images($ins_id, $filenames[1], $filenames[2], $filenames[3]); |
---|
460 | |
---|
461 | //お知らせメール送信(携帯へ) |
---|
462 | if ($this->c_member_id != $target_c_member_id) { |
---|
463 | send_diary_comment_info_mail($ins_id, $this->c_member_id); |
---|
464 | } |
---|
465 | |
---|
466 | //日記コメントが書き込まれたので日記自体を未読扱いにする |
---|
467 | if ($this->c_member_id != $target_c_member_id) { |
---|
468 | db_diary_update_c_diary_is_checked($c_diary_id, 0); |
---|
469 | } |
---|
470 | |
---|
471 | if (OPENPNE_USE_POINT_RANK) { |
---|
472 | // コメント者と被コメント者が違う場合にポイント加算 |
---|
473 | if ($this->c_member_id != $target_c_member_id) { |
---|
474 | //書いた人にポイント付与 |
---|
475 | $point = db_action_get_point4c_action_id(3); |
---|
476 | db_point_add_point($this->c_member_id, $point); |
---|
477 | |
---|
478 | //書かれた人にポイント付与 |
---|
479 | $point = db_action_get_point4c_action_id(2); |
---|
480 | db_point_add_point($target_c_member_id, $point); |
---|
481 | } |
---|
482 | } |
---|
483 | |
---|
484 | return true; |
---|
485 | } |
---|
486 | |
---|
487 | /** |
---|
488 | * プロフィール写真変更 |
---|
489 | */ |
---|
490 | function add_member_image() |
---|
491 | { |
---|
492 | $c_member = db_member_c_member4c_member_id($this->c_member_id); |
---|
493 | |
---|
494 | // 登録する写真番号(1-3)を決める |
---|
495 | $target_number = 0; |
---|
496 | if ($c_member['image_filename']) { |
---|
497 | if (!$c_member['image_filename_1']) { |
---|
498 | $target_number = 1; |
---|
499 | } elseif (!$c_member['image_filename_2']) { |
---|
500 | $target_number = 2; |
---|
501 | } elseif (!$c_member['image_filename_3']) { |
---|
502 | $target_number = 3; |
---|
503 | } else { |
---|
504 | $this->error_mail('プロフィール写真の登録は最大3枚までです。'); |
---|
505 | m_debug_log('mail_sns::add_diary() image is full'); |
---|
506 | return false; |
---|
507 | } |
---|
508 | } else { |
---|
509 | $target_number = 1; |
---|
510 | } |
---|
511 | |
---|
512 | // 写真登録 |
---|
513 | if ($images = $this->decoder->get_images()) { |
---|
514 | $image = $images[0]; |
---|
515 | $image_ext = $image['ext']; |
---|
516 | $image_data = $image['data']; |
---|
517 | $filename = 'm_' . $this->c_member_id . '_' . time() . '.' . $image_ext; |
---|
518 | |
---|
519 | db_image_insert_c_image($filename, $image_data); |
---|
520 | db_member_update_c_member_image($this->c_member_id, $filename, $target_number); |
---|
521 | return true; |
---|
522 | } else { |
---|
523 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
524 | m_debug_log('mail_sns::add_member_image() no images'); |
---|
525 | return false; |
---|
526 | } |
---|
527 | } |
---|
528 | |
---|
529 | /** |
---|
530 | * 日記写真変更 |
---|
531 | */ |
---|
532 | function add_diary_image($c_diary_id) |
---|
533 | { |
---|
534 | if (!$c_diary = db_diary_get_c_diary4id($c_diary_id)) { |
---|
535 | return false; |
---|
536 | } |
---|
537 | |
---|
538 | if ($c_diary['c_member_id'] != $this->c_member_id) { |
---|
539 | return false; |
---|
540 | } |
---|
541 | |
---|
542 | // 登録する写真番号(1-3)を決める |
---|
543 | $target_number = 0; |
---|
544 | if ($c_diary['image_filename_1'] || $c_diary['image_filename_2'] || $c_diary['image_filename_3']) { |
---|
545 | if (!$c_diary['image_filename_1']) { |
---|
546 | $target_number = 1; |
---|
547 | } elseif (!$c_diary['image_filename_2']) { |
---|
548 | $target_number = 2; |
---|
549 | } elseif (!$c_diary['image_filename_3']) { |
---|
550 | $target_number = 3; |
---|
551 | } else { |
---|
552 | $this->error_mail(WORD_DIARY . '写真の登録は最大3枚までです。'); |
---|
553 | m_debug_log('mail_sns::add_diary_image() image is full'); |
---|
554 | return false; |
---|
555 | } |
---|
556 | } else { |
---|
557 | $target_number = 1; |
---|
558 | } |
---|
559 | |
---|
560 | // 写真登録 |
---|
561 | if ($images = $this->decoder->get_images()) { |
---|
562 | $image = $images[0]; |
---|
563 | $image_ext = $image['ext']; |
---|
564 | $image_data = $image['data']; |
---|
565 | $filename = 'd_' . $c_diary_id . '_' . $target_number . '_' . time() . '.' . $image_ext; |
---|
566 | db_image_insert_c_image($filename, $image_data); |
---|
567 | db_diary_update_c_diary_image_filename($c_diary_id, $filename, $target_number); |
---|
568 | return true; |
---|
569 | } else { |
---|
570 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
571 | m_debug_log('mail_sns::add_diary_image() no images'); |
---|
572 | return false; |
---|
573 | } |
---|
574 | } |
---|
575 | |
---|
576 | /** |
---|
577 | * コミュニティ写真変更 |
---|
578 | */ |
---|
579 | function add_commu_image($c_commu_id) |
---|
580 | { |
---|
581 | if (!$c_commu = db_commu_c_commu4c_commu_id($c_commu_id)) { |
---|
582 | return false; |
---|
583 | } |
---|
584 | |
---|
585 | if ($c_commu['c_member_id_admin'] != $this->c_member_id && $c_commu['c_member_id_sub_admin'] != $this->c_member_id ) { |
---|
586 | return false; |
---|
587 | } |
---|
588 | |
---|
589 | if ($c_commu['image_filename']) { |
---|
590 | $this->error_mail(WORD_COMMUNITY . '写真の登録は最大1枚までです。'); |
---|
591 | m_debug_log('mail_sns::add_commu_image() image is full'); |
---|
592 | return false; |
---|
593 | } |
---|
594 | |
---|
595 | // 写真登録 |
---|
596 | if ($images = $this->decoder->get_images()) { |
---|
597 | $image = $images[0]; |
---|
598 | $image_ext = $image['ext']; |
---|
599 | $image_data = $image['data']; |
---|
600 | $filename = 'c_' . $c_commu_id . '_' . time() . '.' . $image_ext; |
---|
601 | db_image_insert_c_image($filename, $image_data); |
---|
602 | db_commu_update_c_commu_image_filename($c_commu_id, $filename); |
---|
603 | return true; |
---|
604 | } else { |
---|
605 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
606 | m_debug_log('mail_sns::add_commu_image() no images'); |
---|
607 | return false; |
---|
608 | } |
---|
609 | } |
---|
610 | |
---|
611 | /** |
---|
612 | * トピック・イベント写真変更 |
---|
613 | */ |
---|
614 | function add_topic_image($c_commu_topic_id) |
---|
615 | { |
---|
616 | if (!$c_topic = db_commu_c_topic4c_commu_topic_id($c_commu_topic_id)) { |
---|
617 | return false; |
---|
618 | } |
---|
619 | |
---|
620 | $c_commu_id = $c_topic['c_commu_id']; |
---|
621 | |
---|
622 | if (!db_commu_is_c_topic_admin($c_commu_topic_id, $this->c_member_id) && |
---|
623 | !db_commu_is_c_commu_admin($c_commu_id, $this->c_member_id)) { |
---|
624 | return false; |
---|
625 | } |
---|
626 | |
---|
627 | // 登録する写真番号(1-3)を決める |
---|
628 | $target_number = 0; |
---|
629 | if ($c_topic['image_filename1'] || $c_topic['image_filename2'] || $c_topic['image_filename3']) { |
---|
630 | if (!$c_topic['image_filename1']) { |
---|
631 | $target_number = 1; |
---|
632 | } elseif (!$c_topic['image_filename2']) { |
---|
633 | $target_number = 2; |
---|
634 | } elseif (!$c_topic['image_filename3']) { |
---|
635 | $target_number = 3; |
---|
636 | } else { |
---|
637 | $this->error_mail('トピック・イベント写真の登録は最大3枚までです。'); |
---|
638 | m_debug_log('mail_sns::add_topic_image() image is full'); |
---|
639 | return false; |
---|
640 | } |
---|
641 | } else { |
---|
642 | $target_number = 1; |
---|
643 | } |
---|
644 | |
---|
645 | // 写真登録 |
---|
646 | if ($images = $this->decoder->get_images()) { |
---|
647 | $image = $images[0]; |
---|
648 | $image_ext = $image['ext']; |
---|
649 | $image_data = $image['data']; |
---|
650 | $filename = 't_' . $c_commu_topic_id . '_' . $target_number . '_' . time() . '.' . $image_ext; |
---|
651 | |
---|
652 | $c_topic['image_filename' . $target_number] = $filename; |
---|
653 | db_image_insert_c_image($filename, $image_data); |
---|
654 | 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']); |
---|
655 | return true; |
---|
656 | } else { |
---|
657 | $this->error_mail('写真が添付されていないか、ファイルサイズが大きすぎるため、登録できませんでした。'); |
---|
658 | m_debug_log('mail_sns::add_topic_image() no images'); |
---|
659 | return false; |
---|
660 | } |
---|
661 | |
---|
662 | } |
---|
663 | |
---|
664 | /** |
---|
665 | * エラーメールをメール送信者へ返信 |
---|
666 | */ |
---|
667 | function error_mail($body) |
---|
668 | { |
---|
669 | $subject = '['.SNS_NAME.']メール投稿エラー'; |
---|
670 | t_send_email($this->from, $subject, $body); |
---|
671 | } |
---|
672 | } |
---|
673 | |
---|
674 | ?> |
---|