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 pc_page_h_album_image_add_confirm extends OpenPNE_Action |
---|
8 | { |
---|
9 | function handleError($errors) |
---|
10 | { |
---|
11 | $_REQUEST['err_msg'] = $errors; |
---|
12 | openpne_forward('pc', 'page', 'h_album_image_add', $errors); |
---|
13 | exit; |
---|
14 | } |
---|
15 | |
---|
16 | function execute($requests) |
---|
17 | { |
---|
18 | if (!OPENPNE_USE_ALBUM) { |
---|
19 | handle_kengen_error(); |
---|
20 | } |
---|
21 | |
---|
22 | $u = $GLOBALS['AUTH']->uid(); |
---|
23 | |
---|
24 | // --- リクエスト変数 |
---|
25 | $target_c_album_id = $requests['target_c_album_id']; |
---|
26 | $subject = $requests['subject']; |
---|
27 | $image_description1 = $requests['image_description1']; |
---|
28 | $image_description2 = $requests['image_description2']; |
---|
29 | $image_description3 = $requests['image_description3']; |
---|
30 | $image_description4 = $requests['image_description4']; |
---|
31 | $image_description5 = $requests['image_description5']; |
---|
32 | // ---------- |
---|
33 | |
---|
34 | $c_album = array(); |
---|
35 | $c_album = db_album_get_c_album4c_album_id($target_c_album_id); |
---|
36 | if ($c_album['c_member_id'] != $u) { |
---|
37 | handle_kengen_error(); |
---|
38 | } |
---|
39 | |
---|
40 | $sessid = session_id(); |
---|
41 | t_image_clear_tmp($sessid); |
---|
42 | |
---|
43 | $upfiles = array( |
---|
44 | 1 => $_FILES['upfile_1'], |
---|
45 | $_FILES['upfile_2'], |
---|
46 | $_FILES['upfile_3'], |
---|
47 | $_FILES['upfile_4'], |
---|
48 | $_FILES['upfile_5'], |
---|
49 | ); |
---|
50 | $tmpfiles = array( |
---|
51 | 1 => '', |
---|
52 | '', |
---|
53 | '', |
---|
54 | '', |
---|
55 | '', |
---|
56 | ); |
---|
57 | |
---|
58 | $is_set_file = false; |
---|
59 | foreach ($upfiles as $key => $upfile) { |
---|
60 | if($upfile['name']) { |
---|
61 | $is_set_file = true; |
---|
62 | break; |
---|
63 | } |
---|
64 | } |
---|
65 | if(!$is_set_file) { |
---|
66 | $_REQUEST['msg'] = '写真を指定してください'; |
---|
67 | openpne_forward('pc', 'page', 'h_album_image_add'); |
---|
68 | exit; |
---|
69 | } |
---|
70 | |
---|
71 | $filesize_all = 0; |
---|
72 | foreach ($upfiles as $key => $upfile) { |
---|
73 | if ($upfile['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
74 | if (!($image = t_check_image($upfile))) { |
---|
75 | $_REQUEST['msg'] = '写真は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
76 | openpne_forward('pc', 'page', 'h_album_image_add'); |
---|
77 | exit; |
---|
78 | } else { |
---|
79 | $filesize_all += $image['size']; |
---|
80 | $tmpfiles[$key] = t_image_save2tmp($upfile, $sessid, "a_{$target_c_album_id}_{$key}", $image['format']); |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | // 画像アップロード可能サイズチェック |
---|
86 | $result = util_image_check_add_image_upload($filesize_all, $u, 'album'); |
---|
87 | if ($result) { |
---|
88 | if ($result == 2) { |
---|
89 | $result = 3; |
---|
90 | } |
---|
91 | t_image_clear_tmp($sessid); |
---|
92 | |
---|
93 | $msg = util_image_get_upload_err_msg($result); |
---|
94 | $p = array( |
---|
95 | 'msg' => $msg, |
---|
96 | 'target_c_album_id' => $target_c_album_id, |
---|
97 | ); |
---|
98 | openpne_redirect('pc', 'page_h_album_image_add', $p); |
---|
99 | } |
---|
100 | |
---|
101 | if (!db_album_is_insertable4c_member_id($u, $filesize_all)) { |
---|
102 | t_image_clear_tmp($sessid); |
---|
103 | $msg = 'これ以上写真を投稿することができません。'; |
---|
104 | if (!db_album_is_insertable4c_member_id($u)) { |
---|
105 | $msg .= '登録済みの写真を削除してからやり直してください。'; |
---|
106 | } else { |
---|
107 | $msg .= '投稿する写真を減らすか、ファイルサイズを変更してやり直してください。'; |
---|
108 | } |
---|
109 | $p = array( |
---|
110 | 'msg' => $msg, |
---|
111 | 'target_c_album_id' => $target_c_album_id, |
---|
112 | ); |
---|
113 | openpne_redirect('pc', 'page_h_album_image_add', $p); |
---|
114 | } |
---|
115 | |
---|
116 | $this->set('inc_navi', fetch_inc_navi('h')); |
---|
117 | |
---|
118 | $form_val = array( |
---|
119 | "target_c_album_id" => $target_c_album_id, |
---|
120 | "subject" => $subject, |
---|
121 | "upfile_1" => $_FILES['upfile_1'], |
---|
122 | "upfile_2" => $_FILES['upfile_2'], |
---|
123 | "upfile_3" => $_FILES['upfile_3'], |
---|
124 | "upfile_4" => $_FILES['upfile_4'], |
---|
125 | "upfile_5" => $_FILES['upfile_5'], |
---|
126 | "tmpfile_1" => $tmpfiles[1], |
---|
127 | "tmpfile_2" => $tmpfiles[2], |
---|
128 | "tmpfile_3" => $tmpfiles[3], |
---|
129 | "tmpfile_4" => $tmpfiles[4], |
---|
130 | "tmpfile_5" => $tmpfiles[5], |
---|
131 | ); |
---|
132 | |
---|
133 | //ファイル写真を指定しているものだけ説明文を設定 |
---|
134 | foreach ($tmpfiles as $key => $tmpfile) { |
---|
135 | $name = "image_description{$key}"; |
---|
136 | if($tmpfile){ |
---|
137 | $form_val["$name"] = $$name; |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | $this->set("form_val", $form_val); |
---|
142 | |
---|
143 | return 'success'; |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | ?> |
---|