1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | require_once("../require.php"); |
---|
8 | |
---|
9 | class LC_Page { |
---|
10 | |
---|
11 | var $arrForm; |
---|
12 | |
---|
13 | var $arrTempProduct; |
---|
14 | var $subProductNum; |
---|
15 | var $arrFileName; |
---|
16 | |
---|
17 | |
---|
18 | function LC_Page() { |
---|
19 | $this->tpl_mainpage = 'mail/htmlmail.tpl'; |
---|
20 | $this->tpl_mainno = 'mail'; |
---|
21 | $this->tpl_subnavi = 'mail/subnavi.tpl'; |
---|
22 | $this->tpl_subno = "template"; |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | |
---|
27 | class LC_Products{ |
---|
28 | |
---|
29 | var $conn; |
---|
30 | var $arrProduct; |
---|
31 | var $arrProductKey; |
---|
32 | |
---|
33 | function LC_Products ($conn=""){ |
---|
34 | |
---|
35 | $DB_class_name = "SC_DbConn"; |
---|
36 | if ( is_object($conn)){ |
---|
37 | if ( is_a($conn, $DB_class_name)){ |
---|
38 | // $conn¤¬$DB_class_name¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤Ç¤¢¤ë |
---|
39 | $this->conn = $conn; |
---|
40 | } |
---|
41 | } else { |
---|
42 | if (class_exists($DB_class_name)){ |
---|
43 | //$DB_class_name¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òºîÀ®¤¹¤ë |
---|
44 | $this->conn = new SC_DbConn(); |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | function setProduct($keyname, $id) { |
---|
50 | |
---|
51 | if ( sfCheckNumLength($id) ){ |
---|
52 | $result = $this->getProductData($id); |
---|
53 | } |
---|
54 | |
---|
55 | if ( $result && (in_array($keyname, $this->arrProductKey) ) ){ |
---|
56 | |
---|
57 | $this->arrProduct["${keyname}"] = $result; |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | function getProductData($id){ |
---|
62 | $conn = $this->conn; |
---|
63 | // ¾¦ÉʾðÊó¤ò¼èÆÀ¤¹¤ë |
---|
64 | $sql = "SELECT * FROM dtb_products WHERE product_id = ?"; |
---|
65 | $result = $conn->getAll($sql, array($id)); |
---|
66 | if ( is_array($result) ){ |
---|
67 | $return = $result[0]; |
---|
68 | } |
---|
69 | return $return; |
---|
70 | } |
---|
71 | |
---|
72 | function getProductImageData($id){ |
---|
73 | $conn = $this->conn; |
---|
74 | // ¾¦ÉʲèÁü¾ðÊó¤ò¼èÆÀ¤¹¤ë |
---|
75 | $sql = "SELECT main_image FROM dtb_products WHERE product_id = ?"; |
---|
76 | $result = $conn->getAll($sql, array($id)); |
---|
77 | if ( is_array($result) ){ |
---|
78 | $return = $result[0]["main_image"]; |
---|
79 | } |
---|
80 | return $return; |
---|
81 | } |
---|
82 | function setHiddenList($arrPOST) { |
---|
83 | foreach($this->arrProductKey as $val) { |
---|
84 | $key = "temp_" . $val; |
---|
85 | if($arrPOST[$key] != "") { |
---|
86 | $this->setProduct($val, $arrPOST[$key]); |
---|
87 | } |
---|
88 | } |
---|
89 | } |
---|
90 | } |
---|
91 | |
---|
92 | // ÅÐÏ¿¥«¥é¥à |
---|
93 | $arrRegist = array( |
---|
94 | "subject", "charge_image", "mail_method", "header", "main_title", "main_comment", "main_product_id", "sub_title", "sub_comment" |
---|
95 | , "sub_product_id01", "sub_product_id02", "sub_product_id03", "sub_product_id04", "sub_product_id05", "sub_product_id06", "sub_product_id07" |
---|
96 | , "sub_product_id08", "sub_product_id09", "sub_product_id10", "sub_product_id11", "sub_product_id12" |
---|
97 | ); |
---|
98 | |
---|
99 | // ´û¸¤ÎÅÐÏ¿ºÑ¤ß¾¦Éʤ«¤é²èÁüɽ¼¨¤òɬÍפȤ¹¤ë¹àÌܥꥹ¥È |
---|
100 | $arrFileList = array( |
---|
101 | "main_product_id", "sub_product_id01", "sub_product_id02", "sub_product_id03", "sub_product_id04", "sub_product_id05" |
---|
102 | , "sub_product_id06", "sub_product_id07", "sub_product_id08", "sub_product_id09", "sub_product_id10", "sub_product_id11", "sub_product_id12" |
---|
103 | ); |
---|
104 | |
---|
105 | $conn = new SC_DBConn(); |
---|
106 | $objPage = new LC_Page(); |
---|
107 | $objView = new SC_AdminView(); |
---|
108 | $objSess = new SC_Session(); |
---|
109 | $objQuery = new SC_Query(); |
---|
110 | |
---|
111 | // ǧ¾Ú²ÄÈݤÎȽÄê |
---|
112 | sfIsSuccess($objSess); |
---|
113 | |
---|
114 | |
---|
115 | // ²èÁü½èÍý¥¯¥é¥¹ÀßÄê |
---|
116 | $objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); |
---|
117 | $objUpFile->addFile("¥á¡¼¥ëôÅö¼Ì¿¿", 'charge_image', array('jpg'),IMAGE_SIZE, true, HTMLMAIL_IMAGE_WIDTH, HTMLMAIL_IMAGE_HEIGHT); |
---|
118 | |
---|
119 | // POSTÃͤΰú·Ñ¤®&ÆþÎÏÃͤÎÊÑ´¹ |
---|
120 | $objPage->arrForm = lfConvData($_POST); |
---|
121 | |
---|
122 | // Hidden¤«¤é¤Î¥Ç¡¼¥¿¤ò°ú¤·Ñ¤° |
---|
123 | $objUpFile->setHiddenFileList($_POST); |
---|
124 | |
---|
125 | switch ($_POST['mode']){ |
---|
126 | |
---|
127 | //²èÁü¥¢¥Ã¥×¥í¡¼¥É |
---|
128 | case 'upload_image': |
---|
129 | // ²èÁüÊݸ½èÍý |
---|
130 | $objPage->arrErr[$_POST['image_key']] = $objUpFile->makeTempFile($_POST['image_key']); |
---|
131 | break; |
---|
132 | |
---|
133 | //³Îǧ |
---|
134 | case 'confirm': |
---|
135 | |
---|
136 | // ¥¨¥é¡¼¥Á¥§¥Ã¥¯ |
---|
137 | $objPage->arrErr = lfErrorCheck($objPage->arrForm); |
---|
138 | //¥Õ¥¡¥¤¥ë¸ºß¥Á¥§¥Ã¥¯ |
---|
139 | $objPage->arrErr = array_merge((array)$objPage->arrErr, (array)$objUpFile->checkEXISTS()); |
---|
140 | |
---|
141 | //¥¨¥é¡¼¤Ê¤·¤Î¾ì¹ç¡¢³Îǧ¥Ú¡¼¥¸¤Ø |
---|
142 | if (!$objPage->arrErr){ |
---|
143 | // ¥¢¥Ã¥×¥í¡¼¥É¥Õ¥¡¥¤¥ë¾ðÊóÇÛÎó¤òÅϤ¹¡£ |
---|
144 | $objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
145 | //ºï½üÍ×µá¤Î¤¢¤Ã¤¿²èÁü¤òɽ¼¨¤·¤Ê¤¤ |
---|
146 | for($i = 1; $i <= HTML_TEMPLATE_SUB_MAX; $i++) { |
---|
147 | if($_POST['delete_sub'.$i] == "1") { |
---|
148 | $arrSub['delete'][$i] = "on"; |
---|
149 | }else{ |
---|
150 | $arrSub['delete'][$i] = ""; |
---|
151 | } |
---|
152 | } |
---|
153 | $objPage->arrSub = $arrSub; |
---|
154 | $objPage->tpl_mainpage = 'mail/htmlmail_confirm.tpl'; |
---|
155 | } |
---|
156 | break; |
---|
157 | |
---|
158 | // ³Îǧ¥Ú¡¼¥¸¤«¤é¤ÎÌá¤ê |
---|
159 | case 'return': |
---|
160 | break; |
---|
161 | |
---|
162 | //¡¡¥Æ¥ó¥×¥ì¡¼¥ÈÅÐÏ¿ |
---|
163 | case 'complete': |
---|
164 | // ÆþÎÏÃͤÎÊÑ´¹ |
---|
165 | $objPage->arrForm = lfConvData($_POST); |
---|
166 | $objPage->arrErr = lfErrorCheck($objPage->arrForm); // ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯ |
---|
167 | |
---|
168 | // ¥¢¥Ã¥×¥í¡¼¥É²èÁü¤ò¥»¡¼¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Ü¹Ô |
---|
169 | $objUpFile->moveTempFile(); |
---|
170 | |
---|
171 | // DBÅÐÏ¿ |
---|
172 | if (is_numeric($objPage->arrForm["template_id"])) { //¡¡ÊÔ½¸»þ |
---|
173 | lfUpdateData($arrRegist); |
---|
174 | } else { |
---|
175 | ifRegistData($arrRegist); |
---|
176 | } |
---|
177 | $objPage->tpl_mainpage = 'mail/htmlmail_complete.tpl'; |
---|
178 | break; |
---|
179 | } |
---|
180 | |
---|
181 | // ¸¡º÷·ë²Ì¤«¤é¤ÎÊÔ½¸»þ |
---|
182 | if ($_GET["mode"] == "edit" && is_numeric($_GET["template_id"])) { |
---|
183 | $objPage->edit_mode = "on"; |
---|
184 | //¥Æ¥ó¥×¥ì¡¼¥È¾ðÊóÆɤ߹þ¤ß |
---|
185 | lfSetRegistData($_GET["template_id"]); |
---|
186 | // DB¥Ç¡¼¥¿¤«¤é²èÁü¥Õ¥¡¥¤¥ë̾¤ÎÆɹþ |
---|
187 | $objUpFile->setDBFileList($objPage->arrForm); |
---|
188 | |
---|
189 | } |
---|
190 | |
---|
191 | if ($_GET['mode'] != 'edit'){ |
---|
192 | //ÅÐÏ¿¾ðÊó¤ÎÆɤ߹þ¤ß |
---|
193 | $objPage->arrFileName = lfGetProducts(); |
---|
194 | } |
---|
195 | |
---|
196 | // HIDDENÍѤËÇÛÎó¤òÅϤ¹¡£ |
---|
197 | $objPage->arrHidden = array_merge((array)$objPage->arrHidden, (array)$objUpFile->getHiddenFileList()); |
---|
198 | // ¥¢¥Ã¥×¥í¡¼¥É¥Õ¥¡¥¤¥ë¾ðÊóÇÛÎó¤òÅϤ¹¡£ |
---|
199 | $objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
200 | |
---|
201 | $objView->assignobj($objPage); |
---|
202 | $objView->display(MAIN_FRAME); |
---|
203 | |
---|
204 | //------------------------------------------------------------------------------------------------------------------------- |
---|
205 | |
---|
206 | /* ¾¦ÉʲèÁü¤ÎÆɤ߹þ¤ß */ |
---|
207 | function lfGetProducts() { |
---|
208 | global $objQuery; |
---|
209 | |
---|
210 | if ($_POST['main_product_id'] != ""){ |
---|
211 | $MainFile = $objQuery->select("main_image, name, product_id", "dtb_products", "product_id=?", array($_POST['main_product_id'])); |
---|
212 | $arrFileName[0] = $MainFile[0]; |
---|
213 | } |
---|
214 | for($i = 1; $i <= HTML_TEMPLATE_SUB_MAX; $i++) { |
---|
215 | $sub_keyname = "sub_product_id" . sprintf("%02d", $i); |
---|
216 | if($_POST[$sub_keyname] != "") { |
---|
217 | $arrSubFile = $objQuery->select("main_image, name, product_id", "dtb_products", "product_id = ?", array($_POST[$sub_keyname])); |
---|
218 | $arrFileName[$i] = $arrSubFile[0]; |
---|
219 | } |
---|
220 | } |
---|
221 | return $arrFileName; |
---|
222 | } |
---|
223 | |
---|
224 | /* ÅÐÏ¿ºÑ¤ß¥Ç¡¼¥¿Æɤ߹þ¤ß */ |
---|
225 | function lfSetRegistData($template_id) { |
---|
226 | global $objQuery; |
---|
227 | global $objPage; |
---|
228 | $arrRet = $objQuery->select("*", "dtb_mailmaga_template", "template_id=?", array($template_id)); |
---|
229 | $arrProductid = $arrRet[0]; |
---|
230 | //²èÁü°Ê³°¤Î¾ðÊó¼èÆÀ |
---|
231 | $objPage->arrForm = $arrRet[0]; |
---|
232 | if ($arrProductid['main_product_id'] != ""){ |
---|
233 | $MainFile = $objQuery->select("main_image, name, product_id", "dtb_products", "product_id=?", array($arrProductid['main_product_id'])); |
---|
234 | $arrFileName[0] = $MainFile[0]; |
---|
235 | } |
---|
236 | for ($i=1; $i<=HTML_TEMPLATE_SUB_MAX; $i++){ |
---|
237 | if ($arrProductid['sub_product_id'.sprintf("%02d", $i)] != ""){ |
---|
238 | $arrSubFile = $objQuery->select("main_image, name, product_id", "dtb_products", "product_id=?", array($arrProductid['sub_product_id'.sprintf("%02d", $i)])); |
---|
239 | $arrFileName[$i] = $arrSubFile[0]; |
---|
240 | } |
---|
241 | } |
---|
242 | //²èÁü¤Î¾ðÊó¼èÆÀ |
---|
243 | $objPage->arrFileName = $arrFileName; |
---|
244 | |
---|
245 | return $objPage; |
---|
246 | } |
---|
247 | |
---|
248 | // ÊÔ½¸¥Ç¡¼¥¿¼èÆÀ |
---|
249 | function lfGetEditData($id, $arrIdData) { |
---|
250 | global $conn; |
---|
251 | |
---|
252 | // DBÅÐÏ¿¾ðÊó |
---|
253 | $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ? AND del_flg = 0"; |
---|
254 | $result = $conn->getAll($sql, array($id)); |
---|
255 | |
---|
256 | //¡¡²èÁü¥Õ¥¡¥¤¥ë̾ |
---|
257 | for ($i = 0; $i < count($arrIdData); $i ++) { |
---|
258 | $data = ""; |
---|
259 | if (is_numeric($result[0][ $arrIdData[$i] ]) ) { |
---|
260 | $sql = "SELECT name,product_id,main_image FROM dtb_products WHERE product_id = ?"; |
---|
261 | $data = $conn->getAll($sql, array($result[0][ $arrIdData[$i] ])); |
---|
262 | } |
---|
263 | $arrFileName[] = $data[0]; |
---|
264 | } |
---|
265 | |
---|
266 | return array($result[0], $arrFileName); |
---|
267 | } |
---|
268 | |
---|
269 | // ³Îǧ¥Ç¡¼¥¿¼èÆÀ |
---|
270 | function lfGetConfirmData($arrPOST, $arrIdData) { |
---|
271 | global $conn; |
---|
272 | //¡¡²èÁü¥Õ¥¡¥¤¥ë̾ |
---|
273 | for ($i = 0; $i < count($arrIdData); $i ++) { |
---|
274 | $data = ""; |
---|
275 | if (is_numeric($arrPOST[ $arrIdData[$i] ]) ) { |
---|
276 | $sql = "SELECT name,product_id,main_image FROM dtb_products WHERE product_id = ?"; |
---|
277 | $data = $conn->getAll($sql, array($arrPOST[ $arrIdData[$i] ])); |
---|
278 | } |
---|
279 | $arrFileName[] = $data[0]; |
---|
280 | } |
---|
281 | return array($arrPOST, $arrFileName); |
---|
282 | } |
---|
283 | |
---|
284 | // ¥Ç¡¼¥¿¥Ù¡¼¥¹ÅÐÏ¿ |
---|
285 | function ifRegistData($arrRegist) { |
---|
286 | global $conn; |
---|
287 | global $objUpFile; |
---|
288 | |
---|
289 | foreach ($arrRegist as $data) { |
---|
290 | if (strlen($_POST[$data]) > 0) { |
---|
291 | $arrRegistValue[$data] = $_POST[$data]; |
---|
292 | } |
---|
293 | } |
---|
294 | $arrRegistValue["creator_id"] = $_SESSION["member_id"]; // ÅÐÏ¿¼ÔID¡Ê´ÉÍý²èÌÌ¡Ë |
---|
295 | $uploadfile = $objUpFile->getDBFileList(); |
---|
296 | //ºï½üÍ×µá¤Î¤¢¤Ã¤¿¾¦Éʤòºï½ü¤¹¤ë |
---|
297 | for ($i = 1; $i <= HTML_TEMPLATE_SUB_MAX; $i++){ |
---|
298 | if ($_POST['delete_sub'.$i] == '1'){ |
---|
299 | $arrRegistValue['sub_product_id'.sprintf("%02d", $i)] = NULL; |
---|
300 | } |
---|
301 | } |
---|
302 | $arrRegistValue = array_merge($arrRegistValue, $uploadfile); |
---|
303 | $conn->autoExecute("dtb_mailmaga_template", $arrRegistValue); |
---|
304 | } |
---|
305 | |
---|
306 | // ¥Ç¡¼¥¿¹¹¿· |
---|
307 | function lfUpdateData($arrRegist) { |
---|
308 | global $conn; |
---|
309 | global $objUpFile; |
---|
310 | |
---|
311 | foreach ($arrRegist as $data) { |
---|
312 | if (strlen($_POST[$data]) > 0) { |
---|
313 | $arrRegistValue[$data] = $_POST[$data]; |
---|
314 | } |
---|
315 | } |
---|
316 | $arrRegistValue["creator_id"] = $_SESSION["member_id"]; |
---|
317 | $arrRegistValue["update_date"] = "NOW()"; |
---|
318 | $uploadfile = $objUpFile->getDBFileList(); |
---|
319 | //ºï½üÍ×µá¤Î¤¢¤Ã¤¿¾¦Éʤòºï½ü¤¹¤ë |
---|
320 | for ($i = 1; $i <= HTML_TEMPLATE_SUB_MAX; $i++){ |
---|
321 | if ($_POST['delete_sub'.$i] == '1'){ |
---|
322 | $arrRegistValue['sub_product_id'.sprintf("%02d", $i)] = NULL; |
---|
323 | } |
---|
324 | } |
---|
325 | $arrRegistValue = array_merge($arrRegistValue, $uploadfile); |
---|
326 | |
---|
327 | $conn->autoExecute("dtb_mailmaga_template", $arrRegistValue, "template_id = ". addslashes($_POST["template_id"])); |
---|
328 | } |
---|
329 | |
---|
330 | // ÆþÎÏÃÍÊÑ´¹ |
---|
331 | function lfConvData( $data ){ |
---|
332 | |
---|
333 | // ʸ»úÎó¤ÎÊÑ´¹¡Êmb_convert_kana¤ÎÊÑ´¹¥ª¥×¥·¥ç¥ó¡Ë |
---|
334 | $arrFlag = array( |
---|
335 | "header" => "aKV" |
---|
336 | ,"subject" => "aKV" |
---|
337 | ,"main_title" => "aKV" |
---|
338 | ,"main_comment" => "aKV" |
---|
339 | ,"main_product_id" => "aKV" |
---|
340 | ,"sub_title" => "aKV" |
---|
341 | ,"sub_comment" => "aKV" |
---|
342 | ); |
---|
343 | |
---|
344 | if ( is_array($data) ){ |
---|
345 | foreach ($arrFlag as $key=>$line) { |
---|
346 | $data[$key] = mb_convert_kana($data[$key], $line); |
---|
347 | } |
---|
348 | } |
---|
349 | |
---|
350 | return $data; |
---|
351 | } |
---|
352 | |
---|
353 | // ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯ |
---|
354 | function lfErrorCheck($array) { |
---|
355 | $objErr = new SC_CheckError($array); |
---|
356 | |
---|
357 | $objErr->doFunc(array("¥á¡¼¥ë·Á¼°", "mail_method"), array("EXIST_CHECK", "ALNUM_CHECK")); |
---|
358 | $objErr->doFunc(array("Subject", "subject", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); |
---|
359 | $objErr->doFunc(array("¥Ø¥Ã¥À¡¼¥Æ¥¥¹¥È", 'header', LTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK") ); |
---|
360 | $objErr->doFunc(array("¥á¥¤¥ó¾¦ÉÊ¥¿¥¤¥È¥ë", 'main_title', STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK") ); |
---|
361 | $objErr->doFunc(array("¥á¥¤¥ó¾¦ÉÊ¥³¥á¥ó¥È", 'main_comment', LTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); |
---|
362 | $objErr->doFunc(array("¥á¥¤¥ó¾¦ÉʲèÁü", "main_product_id"), array("EXIST_CHECK")); |
---|
363 | $objErr->doFunc(array("¥µ¥Ö¾¦ÉÊ·²¥¿¥¤¥È¥ë", "sub_title", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); |
---|
364 | $objErr->doFunc(array("¥µ¥Ö¾¦ÉÊ·²¥³¥á¥ó¥È", "sub_comment", LTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); |
---|
365 | |
---|
366 | return $objErr->arrErr; |
---|
367 | } |
---|
368 | |
---|
369 | ?> |
---|