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 = db_album_get_c_album4c_album_id($target_c_album_id); |
---|
35 | if ($c_album['c_member_id'] != $u) { |
---|
36 | handle_kengen_error(); |
---|
37 | } |
---|
38 | |
---|
39 | $sessid = session_id(); |
---|
40 | t_image_clear_tmp($sessid); |
---|
41 | |
---|
42 | $upfiles = array( |
---|
43 | 1 => $_FILES['upfile_1'], |
---|
44 | $_FILES['upfile_2'], |
---|
45 | $_FILES['upfile_3'], |
---|
46 | $_FILES['upfile_4'], |
---|
47 | $_FILES['upfile_5'], |
---|
48 | ); |
---|
49 | $tmpfiles = array( |
---|
50 | 1 => '', |
---|
51 | '', |
---|
52 | '', |
---|
53 | '', |
---|
54 | '', |
---|
55 | ); |
---|
56 | |
---|
57 | $is_set_file = false; |
---|
58 | foreach ($upfiles as $key => $upfile) { |
---|
59 | if($upfile['name']) { |
---|
60 | $is_set_file = true; |
---|
61 | break; |
---|
62 | } |
---|
63 | } |
---|
64 | if(!$is_set_file) { |
---|
65 | $_REQUEST['msg'] = '写真を指定してください'; |
---|
66 | openpne_forward('pc', 'page', 'h_album_image_add'); |
---|
67 | exit; |
---|
68 | } |
---|
69 | |
---|
70 | $filesize_all = 0; |
---|
71 | foreach ($upfiles as $key => $upfile) { |
---|
72 | if ($upfile['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
73 | if (!($image = t_check_image($upfile))) { |
---|
74 | $_REQUEST['msg'] = '写真は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
75 | openpne_forward('pc', 'page', 'h_album_image_add'); |
---|
76 | exit; |
---|
77 | } else { |
---|
78 | $tmpfiles[$key] = t_image_save2tmp($upfile, $sessid, "a_{$target_c_album_id}_{$key}", $image['format']); |
---|
79 | $filesize_all += $upfile['size']; |
---|
80 | } |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | if (!db_album_is_insertable4c_member_id($u, $filesize_all)) { |
---|
85 | t_image_clear_tmp($sessid); |
---|
86 | $msg = 'これ以上写真を投稿することができません。'; |
---|
87 | if (!db_album_is_insertable4c_member_id($u)) { |
---|
88 | $msg .= '登録済みの写真を削除してからやり直してください。'; |
---|
89 | } else { |
---|
90 | $msg .= '投稿する写真を減らすか、ファイルサイズを変更してやり直してください。'; |
---|
91 | } |
---|
92 | $p = array( |
---|
93 | 'msg' => $msg, |
---|
94 | 'target_c_album_id' => $target_c_album_id, |
---|
95 | ); |
---|
96 | openpne_redirect('pc', 'page_h_album_image_add', $p); |
---|
97 | } |
---|
98 | |
---|
99 | $this->set('inc_navi', fetch_inc_navi('h')); |
---|
100 | |
---|
101 | $form_val = array( |
---|
102 | "target_c_album_id" => $target_c_album_id, |
---|
103 | "subject" => $subject, |
---|
104 | "upfile_1" => $_FILES['upfile_1'], |
---|
105 | "upfile_2" => $_FILES['upfile_2'], |
---|
106 | "upfile_3" => $_FILES['upfile_3'], |
---|
107 | "upfile_4" => $_FILES['upfile_4'], |
---|
108 | "upfile_5" => $_FILES['upfile_5'], |
---|
109 | "tmpfile_1" => $tmpfiles[1], |
---|
110 | "tmpfile_2" => $tmpfiles[2], |
---|
111 | "tmpfile_3" => $tmpfiles[3], |
---|
112 | "tmpfile_4" => $tmpfiles[4], |
---|
113 | "tmpfile_5" => $tmpfiles[5], |
---|
114 | ); |
---|
115 | |
---|
116 | //ファイル写真を指定しているものだけ説明文を設定 |
---|
117 | foreach ($tmpfiles as $key => $tmpfile) { |
---|
118 | $name = "image_description{$key}"; |
---|
119 | if($tmpfile){ |
---|
120 | $form_val["$name"] = $$name; |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | $this->set("form_val", $form_val); |
---|
125 | |
---|
126 | return 'success'; |
---|
127 | } |
---|
128 | } |
---|
129 | |
---|
130 | ?> |
---|