コード例 #1
0
 function execute($requests)
 {
     $tail = $GLOBALS['KTAI_URL_TAIL'];
     $u = $GLOBALS['KTAI_C_MEMBER_ID'];
     // --- リクエスト変数
     $subject = $requests['subject'];
     $body = $requests['body'];
     $public_flag = util_cast_public_flag_diary($requests['public_flag']);
     $target_c_diary_id = $requests['target_c_diary_id'];
     $is_comment_input = $requests['is_comment_input'];
     // ----------
     if (is_null($subject) || $subject === '') {
         $_REQUEST['msg'] = 2;
         openpne_forward('ktai', 'page', 'h_diary_edit');
         exit;
     }
     if (is_null($body) || $body === '') {
         $_REQUEST['msg'] = 1;
         openpne_forward('ktai', 'page', 'h_diary_edit');
         exit;
     }
     if (!$target_c_diary_id) {
         // 新規作成
         $target_c_diary_id = db_diary_insert_c_diary($u, $subject, $body, $public_flag, $is_comment_input);
         if (OPENPNE_USE_POINT_RANK) {
             //日記を書いた人にポイント付与
             $point = db_action_get_point4c_action_id(4);
             db_point_add_point($u, $point);
         }
     } else {
         // 編集
         $c_diary = db_diary_get_c_diary4id($target_c_diary_id);
         if ($c_diary['c_member_id'] != $u) {
             handle_kengen_error();
         }
         db_diary_update_c_diary($target_c_diary_id, $subject, $body, $public_flag, $is_comment_input);
     }
     $p = array('target_c_member_id' => $u);
     openpne_redirect('ktai', 'page_fh_diary_list', $p);
 }
コード例 #2
0
ファイル: sns.php プロジェクト: KimuraYoichi/PukiWiki
 /**
  * 日記投稿
  */
 function add_diary()
 {
     $subject = $this->decoder->get_subject();
     $body = $this->decoder->get_text_body();
     if ($subject === '') {
         $subject = '無題';
     }
     if ($body === '') {
         $this->error_mail('本文が空のため投稿できませんでした');
         m_debug_log('mail_sns::add_diary() body is empty');
         return false;
     }
     $images = $this->decoder->get_images();
     if ($images === false) {
         $this->error_mail('画像は' . IMAGE_MAX_FILESIZE . 'KB以内のGIF・JPEG・PNGにしてください。');
         return false;
     }
     // 画像アップロード可能サイズチェック
     if ($images) {
         $filesize = 0;
         $image_num = 1;
         foreach ($images as $image) {
             $filesize += $image['filesize'];
             $image_num++;
             if ($image_num > 3) {
                 break;
             }
         }
         $result = util_image_check_add_image_upload($filesize, $this->c_member_id, 'diary');
         if ($result) {
             $msg = util_image_get_upload_err_msg($result);
             $this->error_mail($msg);
             m_debug_log('mail_sns::add_diary() size over');
             return false;
         }
     }
     $c_member = db_common_c_member4c_member_id($this->c_member_id);
     if (!($ins_id = db_diary_insert_c_diary($this->c_member_id, $subject, $body, $c_member['public_flag_diary']))) {
         return false;
     }
     // 写真登録
     $image_num = 1;
     foreach ($images as $image) {
         $image_ext = $image['ext'];
         $image_data = $image['data'];
         $filename = 'd_' . $ins_id . '_' . $image_num . '_' . time() . '.' . $image_ext;
         db_image_insert_c_image($filename, $image_data, $image['filesize'], $this->c_member_id);
         db_diary_update_c_diary_image_filename($ins_id, $filename, $image_num);
         $image_num++;
         if ($image_num > 3) {
             break;
         }
     }
     if (OPENPNE_USE_POINT_RANK) {
         //日記を書いた人にポイント付与
         $point = db_action_get_point4c_action_id(4);
         db_point_add_point($this->c_member_id, $point);
     }
     return true;
 }
コード例 #3
0
 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);
 }