function execute($requests)
 {
     if (!OPENPNE_USE_ALBUM) {
         handle_kengen_error();
     }
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $subject = $requests['subject'];
     $description = $requests['description'];
     $public_flag = $requests['public_flag'];
     $tmpfile = $requests['tmpfile'];
     // ----------
     // 画像アップロード可能サイズチェック
     if ($tmpfile) {
         $filesize = util_image_get_c_tmp_filesize4filename("a_{$c_album_id}_1", $tmpfile);
         $result = util_image_check_add_image_upload($filesize, $u, 'other');
         if ($result) {
             $_REQUEST['err_msg'] = util_image_get_upload_err_msg($result);
             openpne_forward('pc', 'page', "h_album_add");
             exit;
         }
     }
     $c_member_id = $u;
     $c_album_id = db_album_insert_c_album($c_member_id, $subject, $description, $public_flag);
     if ($tmpfile) {
         $filename = image_insert_c_image4tmp("a_{$c_album_id}_1", $tmpfile, $u, 'other');
         $sessid = session_id();
         t_image_clear_tmp($sessid);
         //アルバムの表紙に写真ファイル名を登録
         db_album_update_c_album_album_cover_image($c_album_id, $filename);
     }
     $p = array('target_c_album_id' => $c_album_id);
     openpne_redirect('pc', 'page_h_album_image_add', $p);
 }
 function execute($requests)
 {
     if (!OPENPNE_USE_ALBUM) {
         handle_kengen_error();
     }
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $target_c_album_id = $requests['target_c_album_id'];
     $subject = $requests['subject'];
     $description = $requests['description'];
     $public_flag = $requests['public_flag'];
     $tmpfile_1 = $requests['tmpfile_1'];
     // ----------
     //--- 権限チェック
     $c_album = db_album_get_c_album4c_album_id($target_c_album_id);
     if ($c_album['c_member_id'] != $u) {
         handle_kengen_error();
     }
     //---
     //---画像アップロードサイズチェック
     if ($tmpfile_1) {
         $del_file = array();
         $filesize = util_image_get_c_tmp_filesize4filename("a_{$target_c_album_id}_1", $tmpfile_1);
         if ($c_album['album_cover_image']) {
             $del_file[] = $c_album['album_cover_image'];
         }
         $result = util_image_check_change_image_upload($filesize, $del_file, $u, 'other');
         if ($result) {
             $sessid = session_id();
             t_image_clear_tmp($sessid);
             $_REQUEST['msg'] = util_image_get_upload_err_msg($result);
             openpne_forward('pc', 'page', 'h_album_cover_edit');
             exit;
         }
     }
     $filename_1 = '';
     $c_album_cover = $c_album['album_cover_image'];
     if ($tmpfile_1) {
         db_album_image_data_delete($c_album_cover, $u);
         $filename_1 = image_insert_c_image4tmp("a_{$target_c_album_id}_1", $tmpfile_1, $u, 'other');
     }
     $sessid = session_id();
     t_image_clear_tmp($sessid);
     //アルバムデータの変更
     db_album_update_c_album_cover($target_c_album_id, $subject, $description, $filename_1, $public_flag);
     $p = array('target_c_album_id' => $target_c_album_id);
     openpne_redirect('pc', 'page_fh_album', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $name = $requests['name'];
     $c_commu_category_id = $requests['c_commu_category_id'];
     $info = $requests['info'];
     $is_admit = $requests['is_admit'];
     $is_open = $requests['is_open'];
     $tmpfile = $requests['tmpfile'];
     $err_msg = array();
     if (db_commu_is_commu4c_commu_name($name)) {
         $err_msg[] = 'その' . WORD_COMMUNITY . 'はすでに存在します';
     }
     if (!db_commu_c_commu_category_is_create_commu($c_commu_category_id)) {
         $err_msg[] = '指定されたカテゴリは選択できません';
     }
     // 画像アップロード可能サイズチェック
     if ($tmpfile) {
         $filesize = util_image_get_c_tmp_filesize4filename("c_{$c_commu_id}", $tmpfile);
         $result = util_image_check_add_image_upload($filesize, $u, 'other');
         if ($result) {
             $err_msg[] = util_image_get_upload_err_msg($result);
         }
     }
     if ($err_msg) {
         $_REQUEST['err_msg'] = $err_msg;
         openpne_forward('pc', 'page', "h_com_add");
         exit;
     }
     // ----------
     // コミュニティ作成
     $c_commu_id = db_commu_insert_c_commu($u, $name, $c_commu_category_id, $info, $is_admit, $is_open);
     if ($tmpfile) {
         $filename = image_insert_c_image4tmp("c_{$c_commu_id}", $tmpfile, $u);
         t_image_clear_tmp(session_id());
         // 画像更新
         if ($filename) {
             db_commu_update_c_commu_image_filename($c_commu_id, $filename);
         }
     }
     //作成者をコミュメンバーにする
     db_commu_join_c_commu($c_commu_id, $u);
     $p = array('target_c_commu_id' => $c_commu_id);
     openpne_redirect('pc', 'page_c_home', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $target_c_diary_id = $requests['target_c_diary_id'];
     $tmpfile_1 = $requests['tmpfile_1'];
     $tmpfile_2 = $requests['tmpfile_2'];
     $tmpfile_3 = $requests['tmpfile_3'];
     $body = $requests['body'];
     // ----------
     if (is_null($body) || $body === '') {
         $p = array('target_c_diary_id' => $target_c_diary_id, 'msg' => "コメントを入力してださい");
         openpne_redirect('pc', 'page_fh_diary', $p);
     }
     //--- 権限チェック
     $c_diary = db_diary_get_c_diary4id($target_c_diary_id);
     $target_c_member_id = $c_diary['c_member_id'];
     $target_c_member = db_member_c_member4c_member_id($target_c_member_id);
     if ($u != $target_c_member_id) {
         // check public_flag
         if (!pne_check_diary_public_flag($target_c_diary_id, $u)) {
             openpne_redirect('pc', 'page_h_err_diary_access');
         }
         //アクセスブロック設定
         if (db_member_is_access_block($u, $target_c_member_id)) {
             openpne_redirect('pc', 'page_h_access_block');
         }
     }
     //日記コメント停止設定
     if (OPENPNE_USE_DIARY_COMMENT && !$c_diary['is_comment_input']) {
         openpne_forward('pc', 'page', 'fh_diary');
         exit;
     }
     if (!db_diary_is_writable_comment4c_diary_id($target_c_diary_id)) {
         $_REQUEST['msg'] = 'コメントが1000番に達したので、この' . WORD_DIARY . 'にはコメントできません';
         openpne_forward('pc', 'page', 'fh_diary');
         exit;
     }
     //---
     //---画像アップロードサイズチェック
     $filesize = 0;
     if ($tmpfile_1) {
         $filesize += util_image_get_c_tmp_filesize4filename("dc_{$c_diary_comment_id}_1", $tmpfile_1);
     }
     if ($tmpfile_2) {
         $filesize += util_image_get_c_tmp_filesize4filename("dc_{$c_diary_comment_id}_2", $tmpfile_2);
     }
     if ($tmpfile_3) {
         $filesize += util_image_get_c_tmp_filesize4filename("dc_{$c_diary_comment_id}_3", $tmpfile_3);
     }
     if ($filesize) {
         $result = util_image_check_add_image_upload($filesize, $u, 'diary');
         if ($result) {
             if ($result == 2) {
                 $result = 3;
             }
             $_REQUEST['msg'] = util_image_get_upload_err_msg($result);
             openpne_forward('pc', 'page', 'fh_diary');
             exit;
         }
     }
     //日記コメント書き込み
     $c_diary_comment_id = db_diary_insert_c_diary_comment($u, $target_c_diary_id, $body);
     $sessid = session_id();
     $filename_1 = image_insert_c_image4tmp("dc_{$c_diary_comment_id}_1", $tmpfile_1, $u);
     $filename_2 = image_insert_c_image4tmp("dc_{$c_diary_comment_id}_2", $tmpfile_2, $u);
     $filename_3 = image_insert_c_image4tmp("dc_{$c_diary_comment_id}_3", $tmpfile_3, $u);
     t_image_clear_tmp($sessid);
     db_diary_insert_c_diary_comment_images($c_diary_comment_id, $filename_1, $filename_2, $filename_3);
     //日記コメント記入履歴更新
     if ($u != $target_c_member_id) {
         db_diary_insert_c_diary_comment_log($u, $target_c_diary_id);
     }
     db_diary_update_c_diary_comment_log($target_c_diary_id);
     //日記コメントが書き込まれたので日記自体を未読扱いにする
     db_diary_update_c_diary_is_checked($target_c_diary_id, 0);
     // お知らせメール送信(携帯へ)
     if ($u != $target_c_member_id) {
         send_diary_comment_info_mail($c_diary_comment_id, $u);
     }
     if (OPENPNE_USE_POINT_RANK) {
         // コメント者と被コメント者が違う場合にポイント加算
         if ($u != $target_c_member_id) {
             //書いた人にポイント付与
             $point = db_action_get_point4c_action_id(3);
             db_point_add_point($u, $point);
             //書かれた人にポイント付与
             $point = db_action_get_point4c_action_id(2);
             db_point_add_point($target_c_member_id, $point);
         }
     }
     $p = array('target_c_diary_id' => $target_c_diary_id, 'comment_count' => db_diary_count_c_diary_comment4c_diary_id($target_c_diary_id));
     openpne_redirect('pc', 'page_fh_diary', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     $c_commu_id = $requests['c_commu_id'];
     $title = $requests['title'];
     $image_filename1_tmpfile = $requests['image_filename1_tmpfile'];
     $image_filename2_tmpfile = $requests['image_filename2_tmpfile'];
     $image_filename3_tmpfile = $requests['image_filename3_tmpfile'];
     $body = $requests['body'];
     //---添付ファイル
     if (OPENPNE_USE_FILEUPLOAD) {
         $filename4_tmpfile = $requests['filename4_tmpfile'];
         $filename4_original_filename = $requests['filename4_original_filename'];
         if ($filename4_tmpfile) {
             // 拡張子制限
             if (!util_check_file_extention($filename4_original_filename)) {
                 $_REQUEST['target_c_commu_id'] = $c_commu_id;
                 $_REQUEST['err_msg'] = sprintf('アップロードできるファイルの種類は(%s)です', util_get_file_allowed_extensions('string'));
                 openpne_forward('pc', 'page', "c_topic_add");
                 exit;
             }
         }
     }
     //---権限チェック
     $c_commu = db_commu_c_commu4c_commu_id2($c_commu_id);
     switch ($c_commu['is_topic']) {
         case 'public':
             //誰でも作成可能
             break;
         case 'member':
             //コミュニティ参加者
             $status = db_common_commu_status($u, $c_commu_id);
             if (!$status['is_commu_member']) {
                 handle_kengen_error();
             }
             break;
         case 'admin_only':
             //トピック作成権限チェック
             if (!db_commu_is_c_commu_admin($c_commu_id, $u)) {
                 $_REQUEST['target_c_commu_id'] = $c_commu_id;
                 $_REQUEST['msg'] = "トピックは管理者だけが作成できます";
                 openpne_forward('pc', 'page', "c_home");
                 exit;
             }
             break;
     }
     //---画像アップロードサイズチェック
     $filesize = 0;
     if ($image_filename1_tmpfile) {
         $filesize += util_image_get_c_tmp_filesize4filename("t_{$c_commu_topic_id}_1", $image_filename1_tmpfile);
     }
     if ($image_filename2_tmpfile) {
         $filesize += util_image_get_c_tmp_filesize4filename("t_{$c_commu_topic_id}_2", $image_filename2_tmpfile);
     }
     if ($image_filename3_tmpfile) {
         $filesize += util_image_get_c_tmp_filesize4filename("t_{$c_commu_topic_id}_3", $image_filename3_tmpfile);
     }
     if ($filesize) {
         $result = util_image_check_add_image_upload($filesize, $u, 'commu');
         if ($result) {
             if ($result == 2) {
                 $result = 3;
             }
             $_REQUEST['target_c_commu_id'] = $c_commu_id;
             $_REQUEST['msg'] = util_image_get_upload_err_msg($result);
             openpne_forward('pc', 'page', "c_topic_add");
             exit;
         }
     }
     //---
     $insert_c_commu_topic = array("name" => $title, "c_commu_id" => $c_commu_id, "c_member_id" => $u, "event_flag" => 0);
     $c_commu_topic_id = db_commu_insert_c_commu_topic($insert_c_commu_topic);
     if ($image_filename1_tmpfile) {
         $filename1 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_1", $image_filename1_tmpfile, $u);
     }
     if ($image_filename2_tmpfile) {
         $filename2 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_2", $image_filename2_tmpfile, $u);
     }
     if ($image_filename3_tmpfile) {
         $filename3 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_3", $image_filename3_tmpfile, $u);
     }
     if (OPENPNE_USE_FILEUPLOAD) {
         // 添付ファイルをDBに入れる
         if ($filename4_tmpfile) {
             $filename4 = file_insert_c_file4tmp("t_{$c_commu_topic_id}_4", $filename4_tmpfile, $filename4_original_filename);
         }
     }
     //テンポラリファイルを削除(画像と同時)
     t_image_clear_tmp(session_id());
     t_file_clear_tmp(session_id());
     $insert_c_commu_topic_comment = array("c_commu_id" => $c_commu_id, "c_member_id" => $u, "body" => $body, "number" => 0, "c_commu_topic_id" => $c_commu_topic_id, "image_filename1" => !empty($filename1) ? $filename1 : '', "image_filename2" => !empty($filename2) ? $filename2 : '', "image_filename3" => !empty($filename3) ? $filename3 : '', "filename4" => !empty($filename4) ? $filename4 : '');
     $insert_id = db_commu_insert_c_commu_topic_comment_3($insert_c_commu_topic_comment);
     //お知らせメール送信(携帯へ)
     send_bbs_info_mail($insert_id, $u);
     //お知らせメール送信(PCへ)
     send_bbs_info_mail_pc($insert_id, $u);
     if (OPENPNE_USE_POINT_RANK) {
         //トピックを作成した人にポイント付与
         $point = db_action_get_point4c_action_id(9);
         db_point_add_point($u, $point);
     }
     $p = array('target_c_commu_topic_id' => $c_commu_topic_id);
     openpne_redirect('pc', 'page_c_topic_detail', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $tmpfile1 = $requests['image_filename1_tmpfile'];
     $tmpfile2 = $requests['image_filename2_tmpfile'];
     $tmpfile3 = $requests['image_filename3_tmpfile'];
     // ----------
     //---添付ファイル
     if (OPENPNE_USE_FILEUPLOAD) {
         $filename4_tmpfile = $requests['filename4_tmpfile'];
         $filename4_original_filename = $requests['filename4_original_filename'];
         if ($filename4_tmpfile) {
             // 拡張子制限
             if (!util_check_file_extention($filename4_original_filename)) {
                 $_REQUEST['target_c_commu_id'] = $requests['c_commu_id'];
                 $_REQUEST['err_msg'] = sprintf('アップロードできるファイルの種類は(%s)です', util_get_file_allowed_extensions('string'));
                 openpne_forward('pc', 'page', "c_event_add");
                 exit;
             }
         }
     }
     //--- 権限チェック
     //コミュニティ参加者
     list($event, $errors) = p_c_event_add_confirm_event4request(true);
     $c_commu = db_commu_c_commu4c_commu_id2($event['c_commu_id']);
     switch ($c_commu['is_topic']) {
         case 'public':
             //誰でも作成可能
             break;
         case 'member':
             $status = db_common_commu_status($u, $event['c_commu_id']);
             if (!$status['is_commu_member']) {
                 handle_kengen_error();
             }
             break;
         case 'admin_only':
             //トピック作成権限チェック
             if (!db_commu_is_c_commu_admin($event['c_commu_id'], $u)) {
                 $_REQUEST['target_c_commu_id'] = $event['c_commu_id'];
                 $_REQUEST['msg'] = "イベントは管理者だけが作成できます";
                 openpne_forward('pc', 'page', "c_home");
                 exit;
             }
             break;
     }
     //---
     // エラーチェック
     $err_msg = $errors;
     $filesize = 0;
     if (!$event['open_date_month'] || !$event['open_date_day'] || !$event['open_date_year']) {
         $err_msg[] = "開催日時を入力してください";
     } elseif (!t_checkdate($event['open_date_month'], $event['open_date_day'], $event['open_date_year'])) {
         $err_msg[] = "開催日時は存在しません";
     } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) < mktime(0, 0, 0)) {
         $err_msg[] = "開催日時は過去に指定できません";
     }
     if ($event['invite_period_month'] . $event['invite_period_day'] . $event['invite_period_year'] != "") {
         if (!$event['invite_period_month'] || !$event['invite_period_day'] || !$event['invite_period_year']) {
             $err_msg[] = "募集期限は存在しません";
         } elseif (!t_checkdate($event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) {
             $err_msg[] = "募集期限は存在しません";
         } elseif (mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year']) < mktime(0, 0, 0)) {
             $err_msg[] = "募集期限は過去に指定できません";
         } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) < mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) {
             $err_msg[] = "募集期限は開催日時より未来に指定できません";
         }
     }
     // 画像アップロード可能サイズチェック
     if ($tmpfile1) {
         $filesize += util_image_get_c_tmp_filesize4filename("t_{$c_commu_topic_id}_1", $tmpfile1);
     }
     if ($tmpfile2) {
         $filesize += util_image_get_c_tmp_filesize4filename("t_{$c_commu_topic_id}_2", $tmpfile2);
     }
     if ($tmpfile3) {
         $filesize += util_image_get_c_tmp_filesize4filename("t_{$c_commu_topic_id}_3", $tmpfile3);
     }
     if ($filesize) {
         $result = util_image_check_add_image_upload($filesize, $u, 'commu');
         if ($result) {
             if ($result == 2) {
                 $result = 3;
             }
             $err_msg[] = util_image_get_upload_err_msg($result);
         }
     }
     if ($err_msg) {
         $_REQUEST = $event;
         $_REQUEST['target_c_commu_id'] = $event['c_commu_id'];
         $_REQUEST['err_msg'] = $err_msg;
         openpne_forward('pc', 'page', "c_event_add");
         exit;
     }
     if ($event['invite_period_year'] . $event['invite_period_month'] . $event['invite_period_day'] != "") {
         $invite_period = $event['invite_period_year'] . "-" . $event['invite_period_month'] . "-" . $event['invite_period_day'];
     }
     $insert_c_commu_topic = array("name" => $event['title'], "c_commu_id" => $event['c_commu_id'], "c_member_id" => $u, "open_date" => $event['open_date_year'] . "-" . $event['open_date_month'] . "-" . $event['open_date_day'], "open_date_comment" => $event['open_date_comment'], "open_pref_id" => $event['open_pref_id'], "open_pref_comment" => $event['open_pref_comment'], "invite_period" => $invite_period, "event_flag" => 1, "capacity" => $event['capacity']);
     $c_commu_topic_id = db_commu_insert_c_commu_topic($insert_c_commu_topic);
     if ($tmpfile1) {
         $filename1 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_1", $tmpfile1, $u);
     }
     if ($tmpfile2) {
         $filename2 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_2", $tmpfile2, $u);
     }
     if ($tmpfile3) {
         $filename3 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_3", $tmpfile3, $u);
     }
     if (OPENPNE_USE_FILEUPLOAD) {
         // 添付ファイルをDBに入れる
         if ($filename4_tmpfile) {
             $filename4 = file_insert_c_file4tmp("t_{$c_commu_topic_id}_4", $filename4_tmpfile, $filename4_original_filename);
         }
     }
     //テンポラリファイルを削除(画像と同時)
     t_image_clear_tmp(session_id());
     t_file_clear_tmp(session_id());
     $insert_c_commu_topic_comment = array("c_commu_id" => $event['c_commu_id'], "c_member_id" => $u, "body" => $event['detail'], "number" => 0, "c_commu_topic_id" => $c_commu_topic_id, "image_filename1" => !empty($filename1) ? $filename1 : '', "image_filename2" => !empty($filename2) ? $filename2 : '', "image_filename3" => !empty($filename3) ? $filename3 : '', "filename4" => !empty($filename4) ? $filename4 : '');
     $insert_id = db_commu_insert_c_commu_topic_comment_3($insert_c_commu_topic_comment);
     //お知らせメール送信(携帯へ)
     send_bbs_info_mail($insert_id, $u);
     //お知らせメール送信(PCへ)
     send_bbs_info_mail_pc($insert_id, $u);
     db_commu_insert_c_event_member_as_admin($c_commu_topic_id, $u);
     if (OPENPNE_USE_POINT_RANK) {
         //イベントを作成した人にポイント付与
         $point = db_action_get_point4c_action_id(10);
         db_point_add_point($u, $point);
     }
     $p = array('target_c_commu_topic_id' => $c_commu_topic_id);
     openpne_redirect('pc', 'page_c_event_detail', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $c_commu_topic_id = $requests['target_c_commu_topic_id'];
     $body = $requests['body'];
     $tmpfile1 = $requests['image_filename1_tmpfile'];
     $tmpfile2 = $requests['image_filename2_tmpfile'];
     $tmpfile3 = $requests['image_filename3_tmpfile'];
     // ----------
     // 添付ファイル
     if (OPENPNE_USE_FILEUPLOAD) {
         $filename4_tmpfile = $requests['filename4_tmpfile'];
         $filename4_original_filename = $requests['filename4_original_filename'];
         if ($filename4_tmpfile) {
             // 拡張子制限
             if (!util_check_file_extention($filename4_original_filename)) {
                 $_REQUEST['target_c_commu_topic_id'] = $c_commu_topic_id;
                 $_REQUEST['err_msg'] = sprintf('アップロードできるファイルの種類は(%s)です', util_get_file_allowed_extensions('string'));
                 openpne_forward('pc', 'page', "c_topic_detail");
                 exit;
             }
         }
     }
     //--- 権限チェック
     //コミュニティ参加者
     $c_topic = db_commu_c_topic4c_commu_topic_id($c_commu_topic_id);
     $c_commu_id = $c_topic['c_commu_id'];
     $c_commu = db_commu_c_commu4c_commu_id($c_commu_id);
     switch ($c_commu['is_comment']) {
         case 'public':
             //誰でもコメント可能
             break;
         case 'member':
             $status = db_common_commu_status($u, $c_commu_id);
             if (!$status['is_commu_member']) {
                 handle_kengen_error();
             }
             break;
     }
     if (!db_commu_is_writable_c_commu_topic_comment4c_commu_topic_id($c_commu_topic_id)) {
         $err_msg[] = 'コメントが1000番に達したので、このトピックにはコメントできません';
         $_REQUEST['err_msg'] = $err_msg;
         openpne_forward('pc', 'page', "c_topic_detail");
         exit;
     }
     //---
     //---画像アップロードサイズチェック
     $filesize = 0;
     if ($tmpfile1) {
         $filesize += util_image_get_c_tmp_filesize4filename("tc_{$insert_id}_1", $tmpfile1);
     }
     if ($tmpfile2) {
         $filesize += util_image_get_c_tmp_filesize4filename("tc_{$insert_id}_2", $tmpfile2);
     }
     if ($tmpfile3) {
         $filesize += util_image_get_c_tmp_filesize4filename("tc_{$insert_id}_3", $tmpfile3);
     }
     if ($filesize) {
         $result = util_image_check_add_image_upload($filesize, $u, 'commu');
         if ($result) {
             if ($result == 2) {
                 $result = 3;
             }
             $_REQUEST['err_msg'] = util_image_get_upload_err_msg($result);
             openpne_forward('pc', 'page', "c_topic_detail");
             exit;
         }
     }
     $number = db_commu_c_commu_topic_comment_number4c_commu_topic_id($c_commu_topic_id);
     $insert_c_commu_topic_comment = array("c_commu_id" => $c_commu_id, "c_member_id" => $u, "body" => $body, "number" => $number, "c_commu_topic_id" => $c_commu_topic_id);
     $insert_id = db_commu_insert_c_commu_topic_comment_3($insert_c_commu_topic_comment);
     if ($tmpfile1) {
         $filename1 = image_insert_c_image4tmp("tc_{$insert_id}_1", $tmpfile1, $u);
     }
     if ($tmpfile2) {
         $filename2 = image_insert_c_image4tmp("tc_{$insert_id}_2", $tmpfile2, $u);
     }
     if ($tmpfile3) {
         $filename3 = image_insert_c_image4tmp("tc_{$insert_id}_3", $tmpfile3, $u);
     }
     if (OPENPNE_USE_FILEUPLOAD) {
         // 添付ファイルをDBに入れる
         if ($filename4_tmpfile) {
             $filename4 = file_insert_c_file4tmp("tc_{$insert_id}_4", $filename4_tmpfile, $filename4_original_filename);
         }
     }
     t_image_clear_tmp(session_id());
     t_file_clear_tmp(session_id());
     db_commu_update_c_commu_topic_comment_images($insert_id, $filename1, $filename2, $filename3);
     db_commu_update_c_commu_topic_comment_file($insert_id, $filename4);
     //お知らせメール送信(携帯へ)
     send_bbs_info_mail($insert_id, $u);
     //お知らせメール送信(PCへ)
     send_bbs_info_mail_pc($insert_id, $u);
     if (OPENPNE_USE_POINT_RANK) {
         //トピック・イベントにコメントした人にポイント付与
         $point = db_action_get_point4c_action_id(11);
         db_point_add_point($u, $point);
     }
     $p = array('target_c_commu_topic_id' => $c_commu_topic_id);
     openpne_redirect('pc', 'page_c_topic_detail', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $subject = $requests['subject'];
     $body = $requests['body'];
     $public_flag = util_cast_public_flag_diary($requests['public_flag']);
     $tmpfile_1 = $requests['tmpfile_1'];
     $tmpfile_2 = $requests['tmpfile_2'];
     $tmpfile_3 = $requests['tmpfile_3'];
     $category = array_unique(preg_split('/\\s+/', $requests['category']));
     $is_comment_input = $requests['is_comment_input'];
     // ----------
     $sessid = session_id();
     $c_member_id = $u;
     if (count($category) > 5) {
         $_REQUEST['msg'] = 'カテゴリは5つまでしか指定できません';
         openpne_forward('pc', 'page', 'h_diary_add');
         exit;
     }
     foreach ($category as $value) {
         if (mb_strwidth($value) > 20) {
             $_REQUEST['msg'] = 'カテゴリはひとつにつき全角10文字(半角20文字)以内で入力してください';
             openpne_forward('pc', 'page', 'h_diary_add');
             exit;
         }
     }
     // 画像アップロード可能サイズチェック
     $filesize = 0;
     if ($tmpfile_1) {
         $filesize += util_image_get_c_tmp_filesize4filename("d_{$c_diary_id}_1", $tmpfile_1);
     }
     if ($tmpfile_2) {
         $filesize += util_image_get_c_tmp_filesize4filename("d_{$c_diary_id}_2", $tmpfile_2);
     }
     if ($tmpfile_3) {
         $filesize += util_image_get_c_tmp_filesize4filename("d_{$c_diary_id}_3", $tmpfile_3);
     }
     if ($filesize) {
         $result = util_image_check_add_image_upload($filesize, $u, 'diary');
         if ($result) {
             if ($result == 2) {
                 $result = 3;
             }
             $_REQUEST['msg'] = util_image_get_upload_err_msg($result);
             openpne_forward('pc', 'page', 'h_diary_add');
             exit;
         }
     }
     if (!OPENPNE_USE_DIARY_COMMENT) {
         $is_comment_input = 1;
     }
     $c_diary_id = db_diary_insert_c_diary($c_member_id, $subject, $body, $public_flag, $is_comment_input);
     $c_diary_category_list = db_diary_category_list4c_member_id($c_member_id);
     foreach ($category as $value) {
         if (empty($value)) {
             break;
         }
         // 同一のカテゴリ名が登録済みかどうかを確認
         $c_category_id = 0;
         foreach ($c_diary_category_list as $c_diary_category) {
             if ($c_diary_category['category_name'] == $value) {
                 $c_category_id = $c_diary_category['c_diary_category_id'];
                 break;
             }
         }
         // 未登録の場合は新規に登録する
         if (!$c_category_id) {
             $c_category_id = db_diary_category_insert_category($c_member_id, $value);
         }
         db_diary_category_insert_c_diary_category_diary($c_diary_id, $c_category_id);
     }
     $filename_1 = image_insert_c_image4tmp("d_{$c_diary_id}_1", $tmpfile_1, $u);
     $filename_2 = image_insert_c_image4tmp("d_{$c_diary_id}_2", $tmpfile_2, $u);
     $filename_3 = image_insert_c_image4tmp("d_{$c_diary_id}_3", $tmpfile_3, $u);
     t_image_clear_tmp($sessid);
     db_diary_update_c_diary($c_diary_id, $subject, $body, $public_flag, $is_comment_input, $filename_1, $filename_2, $filename_3);
     if (OPENPNE_USE_POINT_RANK) {
         //日記を書いた人にポイント付与
         $point = db_action_get_point4c_action_id(4);
         db_point_add_point($u, $point);
     }
     $p = array('target_c_diary_id' => $c_diary_id);
     openpne_redirect('pc', 'page_fh_diary', $p);
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $c_member_id_to = $requests['c_member_id_to'];
     $subject = $requests['subject'];
     $body = $requests['body'];
     $tmpfile_1 = $requests['tmpfile_1'];
     $tmpfile_2 = $requests['tmpfile_2'];
     $tmpfile_3 = $requests['tmpfile_3'];
     // ----------
     // 添付ファイル
     $fileupload_error = '';
     if (OPENPNE_USE_FILEUPLOAD) {
         $tmpfile_4 = $requests['tmpfile_4'];
         $tmpfile_4_original_filename = $requests['tmpfile_4_original_filename'];
         if ($tmpfile_4) {
             // 拡張子制限
             if (!util_check_file_extention($tmpfile_4_original_filename)) {
                 $fileupload_error = sprintf('アップロードできるファイルの種類は(%s)です', util_get_file_allowed_extensions('string'));
             }
         }
     }
     $msg1 = "";
     $msg2 = "";
     if (null == $subject) {
         $msg1 = "件名を入力してください";
     }
     if (null == $body) {
         $msg2 = "メッセージを入力してください";
     }
     if (!$msg1 && !$msg2 && $fileupload_error) {
         $msg1 = $fileupload_error;
     } else {
         if (!$msg1 && !$msg2 && !$fileupload_error) {
             //---画像アップロードサイズチェック
             $filesize = 0;
             if ($tmpfile_1) {
                 $filesize += util_image_get_c_tmp_filesize4filename("ms_{$c_message_id}_1", $tmpfile_1);
             }
             if ($tmpfile_2) {
                 $filesize += util_image_get_c_tmp_filesize4filename("ms_{$c_message_id}_2", $tmpfile_2);
             }
             if ($tmpfile_3) {
                 $filesize += util_image_get_c_tmp_filesize4filename("ms_{$c_message_id}_3", $tmpfile_3);
             }
             if ($filesize) {
                 $result = util_image_check_add_image_upload($filesize, $u, 'other');
                 if ($result) {
                     if ($result == 2) {
                         $result = 3;
                     }
                     $msg1 = util_image_get_upload_err_msg($result);
                 }
             }
         }
     }
     if ($requests['target_c_message_id'] == $requests['jyusin_c_message_id']) {
         $is_savebox = false;
     } else {
         $is_savebox = true;
     }
     if ($msg1 || $msg2) {
         $p = array('target_c_member_id' => $c_member_id_to, 'target_c_message_id' => $requests['target_c_message_id'], 'jyusin_c_message_id' => $requests['jyusin_c_message_id'], 'body' => $requests['body'], 'subject' => $requests['subject'], 'msg1' => $msg1, 'msg2' => $msg2);
         if ($is_savebox) {
             $p['box'] = 'savebox';
         }
         openpne_redirect('pc', 'page_f_message_send', $p);
     }
     //修正
     if ($requests['no']) {
         $p = array('target_c_member_id' => $c_member_id_to, 'target_c_message_id' => $requests['target_c_message_id'], 'jyusin_c_message_id' => $requests['jyusin_c_message_id'], 'body' => $requests['body'], 'subject' => $requests['subject']);
         openpne_redirect('pc', 'page_f_message_send', $p);
     }
     //--- 権限チェック
     //送信先が自分以外
     if ($c_member_id_to == $u) {
         handle_kengen_error();
     }
     //存在しないメンバー
     $target_member = db_member_c_member4c_member_id($c_member_id_to);
     if (empty($target_member)) {
         handle_kengen_error();
     }
     //アクセスブロック設定
     if (db_member_is_access_block($u, $c_member_id_to)) {
         openpne_redirect('pc', 'page_h_access_block');
     }
     if ($requests['jyusin_c_message_id']) {
         $c_message = db_message_c_message4c_message_id($requests['jyusin_c_message_id']);
         if ($c_message['c_member_id_to'] != $u || !$c_message['is_send']) {
             handle_kengen_error();
         }
     }
     if ($requests['target_c_message_id'] != $requests['jyusin_c_message_id']) {
         $c_message = db_message_c_message4c_message_id($requests['target_c_message_id']);
         if ($c_message['c_member_id_from'] != $u || $c_message['is_send']) {
             handle_kengen_error();
         }
     }
     //---
     //返信済みにする
     if ($requests['jyusin_c_message_id']) {
         db_message_update_is_hensin($requests['jyusin_c_message_id']);
     }
     //下書き保存が存在しない
     if (!$is_savebox) {
         $c_message_id = db_message_send_message($u, $c_member_id_to, $subject, $body);
     } else {
         $c_message_id = $requests['target_c_message_id'];
         db_message_update_message_to_is_save($requests['target_c_message_id'], $subject, $body, 1);
         do_common_send_message_mail_send($c_member_id_to, $u, $subject, $body, $requests['target_c_message_id']);
         do_common_send_message_mail_send_ktai($c_member_id_to, $u, $subject, $body);
     }
     //画像・ファイル挿入
     $sessid = session_id();
     $filename_1 = image_insert_c_image4tmp("ms_{$c_message_id}_1", $tmpfile_1, $u);
     $filename_2 = image_insert_c_image4tmp("ms_{$c_message_id}_2", $tmpfile_2, $u);
     $filename_3 = image_insert_c_image4tmp("ms_{$c_message_id}_3", $tmpfile_3, $u);
     $filename_4 = '';
     if (OPENPNE_USE_FILEUPLOAD) {
         if ($tmpfile_4) {
             $filename_4 = file_insert_c_file4tmp("ms_{$c_message_id}_4", $tmpfile_4, $tmpfile_4_original_filename);
         }
     }
     t_image_clear_tmp($sessid);
     t_file_clear_tmp($sessid);
     db_message_update_c_message($c_message_id, $subject, $body, $filename_1, $filename_2, $filename_3, $filename_4);
     $p = array('msg' => 1);
     openpne_redirect('pc', 'page_h_reply_message', $p);
 }
Exemple #10
0
/**
 * アップロードされた画像をワンアクションでc_imageに登録する時に使用
 *
 * @params array $upfile_obj
 * @params string $prefix
 * @return string 画像ファイル名 | 失敗時false
 */
function image_insert_c_image_direct($upfile_obj, $prefix, $c_member_id = 0)
{
    if (!file_exists($upfile_obj['tmp_name'])) {
        return false;
    }
    $sessid = session_id();
    t_image_clear_tmp($sessid);
    $tmpfile = t_image_save2tmp($upfile_obj, $sessid, $prefix);
    if (!$tmpfile) {
        t_image_clear_tmp($sessid);
        return false;
    }
    $image_filename = image_insert_c_image4tmp($prefix, $tmpfile, $c_member_id);
    t_image_clear_tmp($sessid);
    return $image_filename;
}