1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | |
---|
8 | //---¤³¤Î¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤ò»ØÄê |
---|
9 | $INC_PATH = realpath( dirname( __FILE__) ); |
---|
10 | require_once( $INC_PATH ."/../conf/conf.php" ); |
---|
11 | require_once( $INC_PATH ."/../class/SC_DbConn.php" ); |
---|
12 | require_once( $INC_PATH ."/../class/SC_Query.php" ); |
---|
13 | require_once( $INC_PATH ."/../class/SC_CampaignSession.php" ); |
---|
14 | require_once( $INC_PATH ."/../include/session.inc" ); |
---|
15 | |
---|
16 | // Á´¥Ú¡¼¥¸¶¦ÄÌ¥¨¥é¡¼ |
---|
17 | $GLOBAL_ERR = ""; |
---|
18 | |
---|
19 | // ¥¤¥ó¥¹¥È¡¼¥ë½é´ü½èÍý |
---|
20 | sfInitInstall(); |
---|
21 | |
---|
22 | /* ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥Ð¡¼¥¸¥ç¥ó½êÆÀ */ |
---|
23 | function sfGetDBVersion($dsn = "") { |
---|
24 | if($dsn == "") { |
---|
25 | if(defined('DEFAULT_DSN')) { |
---|
26 | $dsn = DEFAULT_DSN; |
---|
27 | } else { |
---|
28 | return; |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | $objQuery = new SC_Query($dsn, true, true); |
---|
33 | list($db_type) = split(":", $dsn); |
---|
34 | if($db_type == 'mysql') { |
---|
35 | $val = $objQuery->getOne("select version()"); |
---|
36 | $version = "MySQL " . $val; |
---|
37 | } |
---|
38 | if($db_type == 'pgsql') { |
---|
39 | $val = $objQuery->getOne("select version()"); |
---|
40 | $arrLine = split(" " , $val); |
---|
41 | $version = $arrLine[0] . " " . $arrLine[1]; |
---|
42 | } |
---|
43 | return $version; |
---|
44 | } |
---|
45 | |
---|
46 | /* ¥Æ¡¼¥Ö¥ë¤Î¸ºß¥Á¥§¥Ã¥¯ */ |
---|
47 | function sfTabaleExists($table_name, $dsn = "") { |
---|
48 | if($dsn == "") { |
---|
49 | if(defined('DEFAULT_DSN')) { |
---|
50 | $dsn = DEFAULT_DSN; |
---|
51 | } else { |
---|
52 | return; |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | $objQuery = new SC_Query($dsn, true, true); |
---|
57 | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
---|
58 | if(!$objQuery->isError()) { |
---|
59 | list($db_type) = split(":", $dsn); |
---|
60 | // postgresql¤Èmysql¤È¤Ç½èÍý¤òʬ¤±¤ë |
---|
61 | if ($db_type == "pgsql") { |
---|
62 | $sql = "SELECT |
---|
63 | relname |
---|
64 | FROM |
---|
65 | pg_class |
---|
66 | WHERE |
---|
67 | (relkind = 'r' OR relkind = 'v') AND |
---|
68 | relname = ? |
---|
69 | GROUP BY |
---|
70 | relname"; |
---|
71 | $arrRet = $objQuery->getAll($sql, array($table_name)); |
---|
72 | if(count($arrRet) > 0) { |
---|
73 | return true; |
---|
74 | } |
---|
75 | }else if ($db_type == "mysql") { |
---|
76 | $sql = "SHOW TABLE STATUS LIKE ?"; |
---|
77 | $arrRet = $objQuery->getAll($sql, array($table_name)); |
---|
78 | if(count($arrRet) > 0) { |
---|
79 | return true; |
---|
80 | } |
---|
81 | } |
---|
82 | } |
---|
83 | return false; |
---|
84 | } |
---|
85 | |
---|
86 | // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯¤ÈºîÀ® |
---|
87 | function sfColumnExists($table_name, $col_name, $col_type = "", $dsn = "", $add = false) { |
---|
88 | if($dsn == "") { |
---|
89 | if(defined('DEFAULT_DSN')) { |
---|
90 | $dsn = DEFAULT_DSN; |
---|
91 | } else { |
---|
92 | return; |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | // ¥Æ¡¼¥Ö¥ë¤¬Ìµ¤±¤ì¤Ð¥¨¥é¡¼ |
---|
97 | if(!sfTabaleExists($table_name, $dsn)) return false; |
---|
98 | |
---|
99 | $objQuery = new SC_Query($dsn, true, true); |
---|
100 | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
---|
101 | if(!$objQuery->isError()) { |
---|
102 | list($db_type) = split(":", $dsn); |
---|
103 | |
---|
104 | // ¥«¥é¥à¥ê¥¹¥È¤ò¼èÆÀ |
---|
105 | $arrRet = sfGetColumnList($table_name, $objQuery, $db_type); |
---|
106 | if(count($arrRet) > 0) { |
---|
107 | if(in_array($col_name, $arrRet)){ |
---|
108 | return true; |
---|
109 | } |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | // ¥«¥é¥à¤òÄɲ乤ë |
---|
114 | if($add){ |
---|
115 | $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); |
---|
116 | return true; |
---|
117 | } |
---|
118 | |
---|
119 | return false; |
---|
120 | } |
---|
121 | |
---|
122 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß¥Á¥§¥Ã¥¯¤ÈºîÀ® |
---|
123 | function sfIndexExists($table_name, $col_name, $index_name, $length = "", $dsn = "", $add = false) { |
---|
124 | if($dsn == "") { |
---|
125 | if(defined('DEFAULT_DSN')) { |
---|
126 | $dsn = DEFAULT_DSN; |
---|
127 | } else { |
---|
128 | return; |
---|
129 | } |
---|
130 | } |
---|
131 | |
---|
132 | // ¥Æ¡¼¥Ö¥ë¤¬Ìµ¤±¤ì¤Ð¥¨¥é¡¼ |
---|
133 | if(!sfTabaleExists($table_name, $dsn)) return false; |
---|
134 | |
---|
135 | $objQuery = new SC_Query($dsn, true, true); |
---|
136 | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
---|
137 | if(!$objQuery->isError()) { |
---|
138 | list($db_type) = split(":", $dsn); |
---|
139 | switch($db_type) { |
---|
140 | case 'pgsql': |
---|
141 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß³Îǧ |
---|
142 | $arrRet = $objQuery->getAll("SELECT relname FROM pg_class WHERE relname = ?", array($index_name)); |
---|
143 | break; |
---|
144 | case 'mysql': |
---|
145 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß³Îǧ |
---|
146 | $arrRet = $objQuery->getAll("SHOW INDEX FROM ? WHERE Key_name = ?", array($table_name, $index_name)); |
---|
147 | break; |
---|
148 | default: |
---|
149 | return false; |
---|
150 | } |
---|
151 | // ¤¹¤Ç¤Ë¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬Â¸ºß¤¹¤ë¾ì¹ç |
---|
152 | if(count($arrRet) > 0) { |
---|
153 | return true; |
---|
154 | } |
---|
155 | } |
---|
156 | |
---|
157 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤òºîÀ®¤¹¤ë |
---|
158 | if($add){ |
---|
159 | switch($db_type) { |
---|
160 | case 'pgsql': |
---|
161 | $objQuery->query("CREATE INDEX ? ON ? (?)", array($index_name, $table_name, $col_name)); |
---|
162 | break; |
---|
163 | case 'mysql': |
---|
164 | $objQuery->query("CREATE INDEX ? ON ? (?(?))", array($index_name, $table_name, $col_name, $length)); |
---|
165 | break; |
---|
166 | default: |
---|
167 | return false; |
---|
168 | } |
---|
169 | return true; |
---|
170 | } |
---|
171 | return false; |
---|
172 | } |
---|
173 | |
---|
174 | // ¥Ç¡¼¥¿¤Î¸ºß¥Á¥§¥Ã¥¯ |
---|
175 | function sfDataExists($table_name, $where, $arrval, $dsn = "", $sql = "", $add = false) { |
---|
176 | if($dsn == "") { |
---|
177 | if(defined('DEFAULT_DSN')) { |
---|
178 | $dsn = DEFAULT_DSN; |
---|
179 | } else { |
---|
180 | return; |
---|
181 | } |
---|
182 | } |
---|
183 | $objQuery = new SC_Query($dsn, true, true); |
---|
184 | $count = $objQuery->count($table_name, $where, $arrval); |
---|
185 | |
---|
186 | if($count > 0) { |
---|
187 | $ret = true; |
---|
188 | } else { |
---|
189 | $ret = false; |
---|
190 | } |
---|
191 | // ¥Ç¡¼¥¿¤òÄɲ乤ë |
---|
192 | if(!$ret && $add) { |
---|
193 | $objQuery->exec($sql); |
---|
194 | } |
---|
195 | |
---|
196 | return $ret; |
---|
197 | } |
---|
198 | |
---|
199 | /* |
---|
200 | * ¥µ¥¤¥È´ÉÍý¾ðÊ󤫤éÃͤò¼èÆÀ¤¹¤ë¡£ |
---|
201 | * ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¾ì¹ç¡¢É¬¤º1°Ê¾å¤Î¿ôÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¡£ |
---|
202 | * 0¤òÊÖ¤·¤¿¾ì¹ç¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤ÇÂбþ¤¹¤ë¤³¤È¡£ |
---|
203 | * |
---|
204 | * @param $control_id ´ÉÍýID |
---|
205 | * @param $dsn DataSource |
---|
206 | * @return $control_flg ¥Õ¥é¥° |
---|
207 | */ |
---|
208 | function sfGetSiteControlFlg($control_id, $dsn = "") { |
---|
209 | |
---|
210 | // ¥Ç¡¼¥¿¥½¡¼¥¹ |
---|
211 | if($dsn == "") { |
---|
212 | if(defined('DEFAULT_DSN')) { |
---|
213 | $dsn = DEFAULT_DSN; |
---|
214 | } else { |
---|
215 | return; |
---|
216 | } |
---|
217 | } |
---|
218 | |
---|
219 | // ¥¯¥¨¥êÀ¸À® |
---|
220 | $target_column = "control_flg"; |
---|
221 | $table_name = "dtb_site_control"; |
---|
222 | $where = "control_id = ?"; |
---|
223 | $arrval = array($control_id); |
---|
224 | $control_flg = 0; |
---|
225 | |
---|
226 | // ¥¯¥¨¥êȯ¹Ô |
---|
227 | $objQuery = new SC_Query($dsn, true, true); |
---|
228 | $arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval); |
---|
229 | |
---|
230 | // ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ì¤Ð¥Õ¥é¥°¤ò¼èÆÀ¤¹¤ë |
---|
231 | if (count($arrSiteControl) > 0) { |
---|
232 | $control_flg = $arrSiteControl[0]["control_flg"]; |
---|
233 | } |
---|
234 | |
---|
235 | return $control_flg; |
---|
236 | } |
---|
237 | |
---|
238 | // ¥Æ¡¼¥Ö¥ë¤Î¥«¥é¥à°ìÍ÷¤ò¼èÆÀ¤¹¤ë |
---|
239 | function sfGetColumnList($table_name, $objQuery = "", $db_type = DB_TYPE){ |
---|
240 | if($objQuery == "") $objQuery = new SC_Query(); |
---|
241 | $arrRet = array(); |
---|
242 | |
---|
243 | // postgresql¤Èmysql¤È¤Ç½èÍý¤òʬ¤±¤ë |
---|
244 | if ($db_type == "pgsql") { |
---|
245 | $sql = "SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname=? AND c.oid=a.attrelid AND a.attnum > 0 AND not a.attname like '........pg.dropped.%........' ORDER BY a.attnum"; |
---|
246 | $arrColList = $objQuery->getAll($sql, array($table_name)); |
---|
247 | $arrColList = sfswaparray($arrColList); |
---|
248 | $arrRet = $arrColList["attname"]; |
---|
249 | }else if ($db_type == "mysql") { |
---|
250 | $sql = "SHOW COLUMNS FROM $table_name"; |
---|
251 | $arrColList = $objQuery->getAll($sql); |
---|
252 | $arrColList = sfswaparray($arrColList); |
---|
253 | $arrRet = $arrColList["Field"]; |
---|
254 | } |
---|
255 | return $arrRet; |
---|
256 | } |
---|
257 | |
---|
258 | // ¥¤¥ó¥¹¥È¡¼¥ë½é´ü½èÍý |
---|
259 | function sfInitInstall() { |
---|
260 | // ¥¤¥ó¥¹¥È¡¼¥ëºÑ¤ß¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£ |
---|
261 | if(!defined('ECCUBE_INSTALL')) { |
---|
262 | if(!ereg("/install/", $_SERVER['PHP_SELF'])) { |
---|
263 | header("Location: ./install/"); |
---|
264 | } |
---|
265 | } else { |
---|
266 | $path = HTML_PATH . "install/index.php"; |
---|
267 | if(file_exists($path)) { |
---|
268 | sfErrorHeader(">> /install/index.php¤Ï¡¢¥¤¥ó¥¹¥È¡¼¥ë´°Î»¸å¤Ë¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£"); |
---|
269 | } |
---|
270 | |
---|
271 | // µì¥Ð¡¼¥¸¥ç¥ó¤Îinstall.php¤Î¥Á¥§¥Ã¥¯ |
---|
272 | $path = HTML_PATH . "install.php"; |
---|
273 | if(file_exists($path)) { |
---|
274 | sfErrorHeader(">> /install.php¤Ï¥»¥¥å¥ê¥Æ¥£¡¼¥Û¡¼¥ë¤È¤Ê¤ê¤Þ¤¹¡£ºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£"); |
---|
275 | } |
---|
276 | } |
---|
277 | } |
---|
278 | |
---|
279 | // ¥¢¥Ã¥×¥Ç¡¼¥È¤ÇÀ¸À®¤µ¤ì¤¿PHP¤òÆÉ¤ß½Ð¤· |
---|
280 | function sfLoadUpdateModule() { |
---|
281 | // URLÀßÄê¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü |
---|
282 | $main_php = ereg_replace(URL_DIR, "", $_SERVER['PHP_SELF']); |
---|
283 | $extern_php = UPDATE_PATH . $main_php; |
---|
284 | if(file_exists($extern_php)) { |
---|
285 | require_once($extern_php); |
---|
286 | } |
---|
287 | } |
---|
288 | |
---|
289 | function sf_getBasisData() { |
---|
290 | //DB¤«¤éÀßÄê¾ðÊó¤ò¼èÆÀ |
---|
291 | $objConn = new SC_DbConn(DEFAULT_DSN); |
---|
292 | $result = $objConn->getAll("SELECT * FROM dtb_baseinfo"); |
---|
293 | if(is_array($result[0])) { |
---|
294 | foreach ( $result[0] as $key=>$value ){ |
---|
295 | $CONF["$key"] = $value; |
---|
296 | } |
---|
297 | } |
---|
298 | return $CONF; |
---|
299 | } |
---|
300 | |
---|
301 | // Áõ¾þÉÕ¤¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Îɽ¼¨ |
---|
302 | function sfErrorHeader($mess, $print = false) { |
---|
303 | global $GLOBAL_ERR; |
---|
304 | if($GLOBAL_ERR == "") { |
---|
305 | $GLOBAL_ERR = "<meta http-equiv='Content-Type' content='text/html; charset=" . CHAR_CODE . "'>\n"; |
---|
306 | } |
---|
307 | $GLOBAL_ERR.= "<table width='100%' border='0' cellspacing='0' cellpadding='0' summary=' '>\n"; |
---|
308 | $GLOBAL_ERR.= "<tr>\n"; |
---|
309 | $GLOBAL_ERR.= "<td bgcolor='#ffeebb' height='25' colspan='2' align='center'>\n"; |
---|
310 | $GLOBAL_ERR.= "<SPAN style='color:red; font-size:12px'><strong>" . $mess . "</strong></span>\n"; |
---|
311 | $GLOBAL_ERR.= "</td>\n"; |
---|
312 | $GLOBAL_ERR.= " </tr>\n"; |
---|
313 | $GLOBAL_ERR.= "</table>\n"; |
---|
314 | |
---|
315 | if($print) { |
---|
316 | print($GLOBAL_ERR); |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | /* ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ */ |
---|
321 | function sfDispError($type) { |
---|
322 | |
---|
323 | class LC_ErrorPage { |
---|
324 | function LC_ErrorPage() { |
---|
325 | $this->tpl_mainpage = 'login_error.tpl'; |
---|
326 | $this->tpl_title = '¥¨¥é¡¼'; |
---|
327 | } |
---|
328 | } |
---|
329 | |
---|
330 | $objPage = new LC_ErrorPage(); |
---|
331 | $objView = new SC_AdminView(); |
---|
332 | |
---|
333 | switch ($type) { |
---|
334 | case LOGIN_ERROR: |
---|
335 | $objPage->tpl_error="£É£Ä¤Þ¤¿¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
336 | break; |
---|
337 | case ACCESS_ERROR: |
---|
338 | $objPage->tpl_error="¥í¥°¥¤¥óǧ¾Ú¤Î͸ú´ü¸ÂÀÚ¤ì¤Î²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
339 | break; |
---|
340 | case AUTH_ERROR: |
---|
341 | $objPage->tpl_error="¤³¤Î¥Õ¥¡¥¤¥ë¤Ë¤Ï¥¢¥¯¥»¥¹¸¢¸Â¤¬¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
342 | break; |
---|
343 | case INVALID_MOVE_ERRORR: |
---|
344 | $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
345 | break; |
---|
346 | default: |
---|
347 | $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
348 | break; |
---|
349 | } |
---|
350 | |
---|
351 | $objView->assignobj($objPage); |
---|
352 | $objView->display(LOGIN_FRAME); |
---|
353 | |
---|
354 | exit; |
---|
355 | } |
---|
356 | |
---|
357 | /* ¥µ¥¤¥È¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ */ |
---|
358 | function sfDispSiteError($type, $objSiteSess = "", $return_top = false, $err_msg = "", $is_mobile = false) { |
---|
359 | global $objCampaignSess; |
---|
360 | |
---|
361 | if ($objSiteSess != "") { |
---|
362 | $objSiteSess->setNowPage('error'); |
---|
363 | } |
---|
364 | |
---|
365 | class LC_ErrorPage { |
---|
366 | function LC_ErrorPage() { |
---|
367 | $this->tpl_mainpage = 'error.tpl'; |
---|
368 | $this->tpl_css = URL_DIR.'css/layout/error.css'; |
---|
369 | $this->tpl_title = '¥¨¥é¡¼'; |
---|
370 | } |
---|
371 | } |
---|
372 | |
---|
373 | $objPage = new LC_ErrorPage(); |
---|
374 | |
---|
375 | if($is_mobile === true) { |
---|
376 | $objView = new SC_MobileView(); |
---|
377 | } else { |
---|
378 | $objView = new SC_SiteView(); |
---|
379 | } |
---|
380 | |
---|
381 | switch ($type) { |
---|
382 | case PRODUCT_NOT_FOUND: |
---|
383 | $objPage->tpl_error="¤´»ØÄê¤Î¥Ú¡¼¥¸¤Ï¤´¤¶¤¤¤Þ¤»¤ó¡£"; |
---|
384 | break; |
---|
385 | case PAGE_ERROR: |
---|
386 | $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£"; |
---|
387 | break; |
---|
388 | case CART_EMPTY: |
---|
389 | $objPage->tpl_error="¥«¡¼¥È¤Ë¾¦Éʤ¬¤¬¤¢¤ê¤Þ¤»¤ó¡£"; |
---|
390 | break; |
---|
391 | case CART_ADD_ERROR: |
---|
392 | $objPage->tpl_error="¹ØÆþ½èÍýÃæ¤Ï¡¢¥«¡¼¥È¤Ë¾¦ÉʤòÄɲ乤뤳¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£"; |
---|
393 | break; |
---|
394 | case CANCEL_PURCHASE: |
---|
395 | $objPage->tpl_error="¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£°Ê²¼¤ÎÍ×°ø¤¬¹Í¤¨¤é¤ì¤Þ¤¹¡£<br />¡¦¥»¥Ã¥·¥ç¥ó¾ðÊó¤Î͸ú´ü¸Â¤¬ÀÚ¤ì¤Æ¤ë¾ì¹ç<br />¡¦¹ØÆþ¼ê³¤Ãæ¤Ë¿·¤·¤¤¹ØÆþ¼ê³¤¤ò¼Â¹Ô¤·¤¿¾ì¹ç<br />¡¦¤¹¤Ç¤Ë¹ØÆþ¼ê³¤¤ò´°Î»¤·¤Æ¤¤¤ë¾ì¹ç"; |
---|
396 | break; |
---|
397 | case CATEGORY_NOT_FOUND: |
---|
398 | $objPage->tpl_error="¤´»ØÄê¤Î¥«¥Æ¥´¥ê¤Ï¸ºß¤·¤Þ¤»¤ó¡£"; |
---|
399 | break; |
---|
400 | case SITE_LOGIN_ERROR: |
---|
401 | $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£"; |
---|
402 | break; |
---|
403 | case TEMP_LOGIN_ERROR: |
---|
404 | $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />ËÜÅÐÏ¿¤¬¤ªºÑ¤ß¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢²¾ÅÐÏ¿¥á¡¼¥ë¤ËµºÜ¤µ¤ì¤Æ¤¤¤ë<br />URL¤è¤êËÜÅÐÏ¿¤ò¹Ô¤Ã¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
405 | break; |
---|
406 | case CUSTOMER_ERROR: |
---|
407 | $objPage->tpl_error="ÉÔÀµ¤Ê¥¢¥¯¥»¥¹¤Ç¤¹¡£"; |
---|
408 | break; |
---|
409 | case SOLD_OUT: |
---|
410 | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤´¹ØÆþ¤ÎľÁ°¤ÇÇä¤êÀڤ줿¾¦Éʤ¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
---|
411 | break; |
---|
412 | case CART_NOT_FOUND: |
---|
413 | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥«¡¼¥ÈÆâ¤Î¾¦ÉʾðÊó¤Î¼èÆÀ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
---|
414 | break; |
---|
415 | case LACK_POINT: |
---|
416 | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥Ý¥¤¥ó¥È¤¬ÉÔ¤·¤Æ¤ª¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
---|
417 | break; |
---|
418 | case FAVORITE_ERROR: |
---|
419 | $objPage->tpl_error="´û¤Ë¤ªµ¤¤ËÆþ¤ê¤ËÄɲäµ¤ì¤Æ¤¤¤ë¾¦ÉʤǤ¹¡£"; |
---|
420 | break; |
---|
421 | case EXTRACT_ERROR: |
---|
422 | $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤Î²òÅà¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë½ñ¤¹þ¤ß¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
---|
423 | break; |
---|
424 | case FTP_DOWNLOAD_ERROR: |
---|
425 | $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤ÎFTP¥À¥¦¥ó¥í¡¼¥É¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
---|
426 | break; |
---|
427 | case FTP_LOGIN_ERROR: |
---|
428 | $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
---|
429 | break; |
---|
430 | case FTP_CONNECT_ERROR: |
---|
431 | $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
---|
432 | break; |
---|
433 | case CREATE_DB_ERROR: |
---|
434 | $objPage->tpl_error="DB¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥æ¡¼¥¶¡¼¤Ë¤Ï¡¢DBºîÀ®¤Î¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
---|
435 | break; |
---|
436 | case DB_IMPORT_ERROR: |
---|
437 | $objPage->tpl_error="¥Ç¡¼¥¿¥Ù¡¼¥¹¹½Â¤¤Î¥¤¥ó¥Ý¡¼¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\nsql¥Õ¥¡¥¤¥ë¤¬²õ¤ì¤Æ¤¤¤ë²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
---|
438 | break; |
---|
439 | case FILE_NOT_FOUND: |
---|
440 | $objPage->tpl_error="»ØÄê¤Î¥Ñ¥¹¤Ë¡¢ÀßÄê¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó¡£"; |
---|
441 | break; |
---|
442 | case WRITE_FILE_ERROR: |
---|
443 | $objPage->tpl_error="ÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤á¤Þ¤»¤ó¡£\nÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤ß¸¢¸Â¤òÍ¿¤¨¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
444 | break; |
---|
445 | case FREE_ERROR_MSG: |
---|
446 | $objPage->tpl_error=$err_msg; |
---|
447 | break; |
---|
448 | default: |
---|
449 | $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£"; |
---|
450 | break; |
---|
451 | } |
---|
452 | |
---|
453 | $objPage->return_top = $return_top; |
---|
454 | |
---|
455 | $objView->assignobj($objPage); |
---|
456 | |
---|
457 | if(is_object($objCampaignSess)) { |
---|
458 | // ¥Õ¥ì¡¼¥à¤òÁªÂò(¥¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹) |
---|
459 | $objCampaignSess->pageView($objView); |
---|
460 | } else { |
---|
461 | $objView->display(SITE_FRAME); |
---|
462 | } |
---|
463 | exit; |
---|
464 | } |
---|
465 | |
---|
466 | /* ǧ¾Ú¤Î²ÄÈÝȽÄê */ |
---|
467 | function sfIsSuccess($objSess, $disp_error = true) { |
---|
468 | $ret = $objSess->IsSuccess(); |
---|
469 | if($ret != SUCCESS) { |
---|
470 | if($disp_error) { |
---|
471 | // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ |
---|
472 | sfDispError($ret); |
---|
473 | } |
---|
474 | return false; |
---|
475 | } |
---|
476 | // ¥ê¥Õ¥¡¥é¡¼¥Á¥§¥Ã¥¯(CSRF¤Î»ÃÄêŪ¤ÊÂкö) |
---|
477 | // ¡Ö¥ê¥Õ¥¡¥é̵¡× ¤Î¾ì¹ç¤Ï¥¹¥ë¡¼ |
---|
478 | // ¡Ö¥ê¥Õ¥¡¥éÍ¡× ¤«¤Ä ¡Ö´ÉÍý²èÌ̤«¤é¤ÎÁ«°Ü¤Ç¤Ê¤¤¡× ¾ì¹ç¤Ë¥¨¥é¡¼²èÌ̤òɽ¼¨¤¹¤ë |
---|
479 | if ( empty($_SERVER['HTTP_REFERER']) ) { |
---|
480 | // ·Ù¹ðɽ¼¨¤µ¤»¤ë¡© |
---|
481 | // sfErrorHeader('>> referrer¤¬Ìµ¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£'); |
---|
482 | } else { |
---|
483 | $siteurl = preg_quote(SITE_URL, "/"); |
---|
484 | $sslurl = preg_quote(SSL_URL, "/"); |
---|
485 | |
---|
486 | $pattern = "/^($siteurl|$sslurl)/"; |
---|
487 | $referer = $_SERVER['HTTP_REFERER']; |
---|
488 | |
---|
489 | // ´ÉÍý²èÌ̤«¤é°Ê³°¤ÎÁ«°Ü¤Î¾ì¹ç¤Ï¥¨¥é¡¼²èÌ̤òɽ¼¨ |
---|
490 | if ( !preg_match($pattern, $referer) ) { |
---|
491 | if ($disp_error) sfDispError(INVALID_MOVE_ERRORR); |
---|
492 | return false; |
---|
493 | } |
---|
494 | } |
---|
495 | return true; |
---|
496 | } |
---|
497 | |
---|
498 | /** |
---|
499 | * HTTPS¤«¤É¤¦¤«¤òȽÄê |
---|
500 | * |
---|
501 | * @return bool |
---|
502 | */ |
---|
503 | function sfIsHTTPS () { |
---|
504 | // HTTPS»þ¤Ë¤Ï$_SERVER['HTTPS']¤Ë¤Ï¶õ¤Ç¤Ê¤¤Ãͤ¬Æþ¤ë |
---|
505 | // $_SERVER['HTTPS'] != 'off' ¤ÏIISÍÑ |
---|
506 | if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { |
---|
507 | return true; |
---|
508 | } else { |
---|
509 | return false; |
---|
510 | } |
---|
511 | } |
---|
512 | |
---|
513 | /** |
---|
514 | * Àµµ¬¤ÎÁ«°Ü¤¬¤µ¤ì¤Æ¤¤¤ë¤«¤òȽÄê |
---|
515 | * Á°²èÌ̤Çuniqid¤òËä¤á¹þ¤ó¤Ç¤ª¤¯É¬Íפ¬¤¢¤ë |
---|
516 | * @param obj SC_Session, SC_SiteSession |
---|
517 | * @return bool |
---|
518 | */ |
---|
519 | function sfIsValidTransition($objSess) { |
---|
520 | // Á°²èÌ̤«¤éPOST¤µ¤ì¤ëuniqid¤¬Àµ¤·¤¤¤â¤Î¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯ |
---|
521 | $uniqid = $objSess->getUniqId(); |
---|
522 | if ( !empty($_POST['uniqid']) && ($_POST['uniqid'] === $uniqid) ) { |
---|
523 | return true; |
---|
524 | } else { |
---|
525 | return false; |
---|
526 | } |
---|
527 | } |
---|
528 | |
---|
529 | /* Á°¤Î¥Ú¡¼¥¸¤ÇÀµ¤·¤¯ÅÐÏ¿¤¬¹Ô¤ï¤ì¤¿¤«È½Äê */ |
---|
530 | function sfIsPrePage($objSiteSess, $is_mobile = false) { |
---|
531 | $ret = $objSiteSess->isPrePage(); |
---|
532 | if($ret != true) { |
---|
533 | // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ |
---|
534 | sfDispSiteError(PAGE_ERROR, $objSiteSess, false, "", $is_mobile); |
---|
535 | } |
---|
536 | } |
---|
537 | |
---|
538 | function sfCheckNormalAccess($objSiteSess, $objCartSess) { |
---|
539 | // ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ |
---|
540 | $uniqid = $objSiteSess->getUniqId(); |
---|
541 | // ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤¿»þ¤Î¥«¡¼¥ÈÆâÍÆ¤¬¥³¥Ô¡¼¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Î¤ß¥³¥Ô¡¼¤¹¤ë¡£ |
---|
542 | $objCartSess->saveCurrentCart($uniqid); |
---|
543 | // POST¤Î¥æ¥Ë¡¼¥¯ID¤È¥»¥Ã¥·¥ç¥ó¤Î¥æ¥Ë¡¼¥¯ID¤òÈæ³Ó(¥æ¥Ë¡¼¥¯ID¤¬POST¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¥¹¥ë¡¼) |
---|
544 | $ret = $objSiteSess->checkUniqId(); |
---|
545 | if($ret != true) { |
---|
546 | // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ |
---|
547 | sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); |
---|
548 | } |
---|
549 | |
---|
550 | // ¥«¡¼¥ÈÆâ¤¬¶õ¤Ç¤Ê¤¤¤« || ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤«¤éÊѲ½¤¬¤Ê¤¤¤« |
---|
551 | $quantity = $objCartSess->getTotalQuantity(); |
---|
552 | $ret = $objCartSess->checkChangeCart(); |
---|
553 | if($ret == true || !($quantity > 0)) { |
---|
554 | // ¥«¡¼¥È¾ðÊóɽ¼¨¤Ë¶¯À©°Üư¤¹¤ë |
---|
555 | header("Location: ".URL_CART_TOP); |
---|
556 | exit; |
---|
557 | } |
---|
558 | return $uniqid; |
---|
559 | } |
---|
560 | |
---|
561 | /* DBÍÑÆüÉÕʸ»úÎó¼èÆÀ */ |
---|
562 | function sfGetTimestamp($year, $month, $day, $last = false) { |
---|
563 | if($year != "" && $month != "" && $day != "") { |
---|
564 | if($last) { |
---|
565 | $time = "23:59:59"; |
---|
566 | } else { |
---|
567 | $time = "00:00:00"; |
---|
568 | } |
---|
569 | $date = $year."-".$month."-".$day." ".$time; |
---|
570 | } else { |
---|
571 | $date = ""; |
---|
572 | } |
---|
573 | return $date; |
---|
574 | } |
---|
575 | |
---|
576 | // INT·¿¤Î¿ôÃÍ¥Á¥§¥Ã¥¯ |
---|
577 | function sfIsInt($value) { |
---|
578 | if($value != "" && strlen($value) <= INT_LEN && is_numeric($value)) { |
---|
579 | return true; |
---|
580 | } |
---|
581 | return false; |
---|
582 | } |
---|
583 | |
---|
584 | function sfCSVDownload($data, $prefix = ""){ |
---|
585 | |
---|
586 | if($prefix == "") { |
---|
587 | $dir_name = sfUpDirName(); |
---|
588 | $file_name = $dir_name . date("ymdHis") .".csv"; |
---|
589 | } else { |
---|
590 | $file_name = $prefix . date("ymdHis") .".csv"; |
---|
591 | } |
---|
592 | |
---|
593 | /* HTTP¥Ø¥Ã¥À¤Î½ÐÎÏ */ |
---|
594 | Header("Content-disposition: attachment; filename=${file_name}"); |
---|
595 | Header("Content-type: application/octet-stream; name=${file_name}"); |
---|
596 | Header("Cache-Control: "); |
---|
597 | Header("Pragma: "); |
---|
598 | |
---|
599 | if (mb_internal_encoding() == CHAR_CODE){ |
---|
600 | $data = mb_convert_encoding($data,'SJIS',CHAR_CODE); |
---|
601 | } |
---|
602 | |
---|
603 | /* ¥Ç¡¼¥¿¤ò½ÐÎÏ */ |
---|
604 | echo $data; |
---|
605 | } |
---|
606 | |
---|
607 | /* 1³¬Áؾå¤Î¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ¤¹¤ë */ |
---|
608 | function sfUpDirName() { |
---|
609 | $path = $_SERVER['PHP_SELF']; |
---|
610 | $arrVal = split("/", $path); |
---|
611 | $cnt = count($arrVal); |
---|
612 | return $arrVal[($cnt - 2)]; |
---|
613 | } |
---|
614 | |
---|
615 | // ¸½ºß¤Î¥µ¥¤¥È¤ò¹¹¿·¡Ê¤¿¤À¤·¥Ý¥¹¥È¤Ï¹Ô¤ï¤Ê¤¤¡Ë |
---|
616 | function sfReload($get = "") { |
---|
617 | if ($_SERVER["SERVER_PORT"] == "443" ){ |
---|
618 | $url = ereg_replace(URL_DIR . "$", "", SSL_URL); |
---|
619 | } else { |
---|
620 | $url = ereg_replace(URL_DIR . "$", "", SITE_URL); |
---|
621 | } |
---|
622 | |
---|
623 | if($get != "") { |
---|
624 | header("Location: ". $url . $_SERVER['PHP_SELF'] . "?" . $get); |
---|
625 | } else { |
---|
626 | header("Location: ". $url . $_SERVER['PHP_SELF']); |
---|
627 | } |
---|
628 | exit; |
---|
629 | } |
---|
630 | |
---|
631 | // ¥é¥ó¥¥ó¥°¤ò¾å¤²¤ë¡£ |
---|
632 | function sfRankUp($table, $colname, $id, $andwhere = "") { |
---|
633 | $objQuery = new SC_Query(); |
---|
634 | $objQuery->begin(); |
---|
635 | $where = "$colname = ?"; |
---|
636 | if($andwhere != "") { |
---|
637 | $where.= " AND $andwhere"; |
---|
638 | } |
---|
639 | // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ |
---|
640 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
641 | // ¥é¥ó¥¯¤ÎºÇÂçÃͤò¼èÆÀ |
---|
642 | $maxrank = $objQuery->max($table, "rank", $andwhere); |
---|
643 | // ¥é¥ó¥¯¤¬ºÇÂçÃͤè¤ê¤â¾®¤µ¤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£ |
---|
644 | if($rank < $maxrank) { |
---|
645 | // ¥é¥ó¥¯¤¬°ì¤Ä¾å¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ |
---|
646 | $where = "rank = ?"; |
---|
647 | if($andwhere != "") { |
---|
648 | $where.= " AND $andwhere"; |
---|
649 | } |
---|
650 | $uprank = $rank + 1; |
---|
651 | $up_id = $objQuery->get($table, $colname, $where, array($uprank)); |
---|
652 | // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô |
---|
653 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
---|
654 | $objQuery->exec($sqlup, array($rank + 1, $id)); |
---|
655 | $objQuery->exec($sqlup, array($rank, $up_id)); |
---|
656 | } |
---|
657 | $objQuery->commit(); |
---|
658 | } |
---|
659 | |
---|
660 | // ¥é¥ó¥¥ó¥°¤ò²¼¤²¤ë¡£ |
---|
661 | function sfRankDown($table, $colname, $id, $andwhere = "") { |
---|
662 | $objQuery = new SC_Query(); |
---|
663 | $objQuery->begin(); |
---|
664 | $where = "$colname = ?"; |
---|
665 | if($andwhere != "") { |
---|
666 | $where.= " AND $andwhere"; |
---|
667 | } |
---|
668 | // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ |
---|
669 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
670 | |
---|
671 | // ¥é¥ó¥¯¤¬1(ºÇ¾®ÃÍ)¤è¤ê¤âÂ礤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£ |
---|
672 | if($rank > 1) { |
---|
673 | // ¥é¥ó¥¯¤¬°ì¤Ä²¼¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ |
---|
674 | $where = "rank = ?"; |
---|
675 | if($andwhere != "") { |
---|
676 | $where.= " AND $andwhere"; |
---|
677 | } |
---|
678 | $downrank = $rank - 1; |
---|
679 | $down_id = $objQuery->get($table, $colname, $where, array($downrank)); |
---|
680 | // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô |
---|
681 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
---|
682 | $objQuery->exec($sqlup, array($rank - 1, $id)); |
---|
683 | $objQuery->exec($sqlup, array($rank, $down_id)); |
---|
684 | } |
---|
685 | $objQuery->commit(); |
---|
686 | } |
---|
687 | |
---|
688 | //----¡¡»ØÄê½ç°Ì¤Ø°Üư |
---|
689 | function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = "") { |
---|
690 | $objQuery = new SC_Query(); |
---|
691 | $objQuery->begin(); |
---|
692 | |
---|
693 | // ¼«¿È¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë |
---|
694 | $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId)); |
---|
695 | $max = $objQuery->max($tableName, "rank", $where); |
---|
696 | |
---|
697 | // ÃͤÎÄ´À°¡ÊµÕ½ç¡Ë |
---|
698 | if($pos > $max) { |
---|
699 | $position = 1; |
---|
700 | } else if($pos < 1) { |
---|
701 | $position = $max; |
---|
702 | } else { |
---|
703 | $position = $max - $pos + 1; |
---|
704 | } |
---|
705 | |
---|
706 | if( $position > $rank ) $term = "rank - 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤êÂ礤¤¾ì¹ç |
---|
707 | if( $position < $rank ) $term = "rank + 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤ê¾®¤µ¤¤¾ì¹ç |
---|
708 | |
---|
709 | //--¡¡»ØÄꤷ¤¿½ç°Ì¤Î¾¦Éʤ«¤é°Üư¤µ¤»¤ë¾¦ÉʤޤǤÎrank¤ò£±¤Ä¤º¤é¤¹ |
---|
710 | $sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0"; |
---|
711 | if($where != "") { |
---|
712 | $sql.= " AND $where"; |
---|
713 | } |
---|
714 | |
---|
715 | if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position )); |
---|
716 | if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 )); |
---|
717 | |
---|
718 | //-- »ØÄꤷ¤¿½ç°Ì¤Ørank¤ò½ñ¤´¹¤¨¤ë¡£ |
---|
719 | $sql = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 "; |
---|
720 | if($where != "") { |
---|
721 | $sql.= " AND $where"; |
---|
722 | } |
---|
723 | |
---|
724 | $objQuery->exec( $sql, array( $position, $keyId ) ); |
---|
725 | $objQuery->commit(); |
---|
726 | } |
---|
727 | |
---|
728 | // ¥é¥ó¥¯¤ò´Þ¤à¥ì¥³¡¼¥É¤Îºï½ü |
---|
729 | // ¥ì¥³¡¼¥É¤´¤Èºï½ü¤¹¤ë¾ì¹ç¤Ï¡¢$delete¤òtrue¤Ë¤¹¤ë¡£ |
---|
730 | function sfDeleteRankRecord($table, $colname, $id, $andwhere = "", $delete = false) { |
---|
731 | $objQuery = new SC_Query(); |
---|
732 | $objQuery->begin(); |
---|
733 | // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
---|
734 | $where = "$colname = ?"; |
---|
735 | if($andwhere != "") { |
---|
736 | $where.= " AND $andwhere"; |
---|
737 | } |
---|
738 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
739 | |
---|
740 | if(!$delete) { |
---|
741 | // ¥é¥ó¥¯¤òºÇ²¼°Ì¤Ë¤¹¤ë¡¢DEL¥Õ¥é¥°ON |
---|
742 | $sqlup = "UPDATE $table SET rank = 0, del_flg = 1, update_date = Now() "; |
---|
743 | $sqlup.= "WHERE $colname = ?"; |
---|
744 | // UPDATE¤Î¼Â¹Ô |
---|
745 | $objQuery->exec($sqlup, array($id)); |
---|
746 | } else { |
---|
747 | $objQuery->delete($table, "$colname = ?", array($id)); |
---|
748 | } |
---|
749 | |
---|
750 | // Äɲå쥳¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä¤º¤é¤¹¡£ |
---|
751 | $where = "rank > ?"; |
---|
752 | if($andwhere != "") { |
---|
753 | $where.= " AND $andwhere"; |
---|
754 | } |
---|
755 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
---|
756 | $objQuery->exec($sqlup, array($rank)); |
---|
757 | $objQuery->commit(); |
---|
758 | } |
---|
759 | |
---|
760 | // ¥ì¥³¡¼¥É¤Î¸ºß¥Á¥§¥Ã¥¯ |
---|
761 | function sfIsRecord($table, $col, $arrval, $addwhere = "") { |
---|
762 | $objQuery = new SC_Query(); |
---|
763 | $arrCol = split("[, ]", $col); |
---|
764 | |
---|
765 | $where = "del_flg = 0"; |
---|
766 | |
---|
767 | if($addwhere != "") { |
---|
768 | $where.= " AND $addwhere"; |
---|
769 | } |
---|
770 | |
---|
771 | foreach($arrCol as $val) { |
---|
772 | if($val != "") { |
---|
773 | if($where == "") { |
---|
774 | $where = "$val = ?"; |
---|
775 | } else { |
---|
776 | $where.= " AND $val = ?"; |
---|
777 | } |
---|
778 | } |
---|
779 | } |
---|
780 | $ret = $objQuery->get($table, $col, $where, $arrval); |
---|
781 | |
---|
782 | if($ret != "") { |
---|
783 | return true; |
---|
784 | } |
---|
785 | return false; |
---|
786 | } |
---|
787 | |
---|
788 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤò¥Þ¡¼¥¸ |
---|
789 | function sfMergeCBValue($keyname, $max) { |
---|
790 | $conv = ""; |
---|
791 | $cnt = 1; |
---|
792 | for($cnt = 1; $cnt <= $max; $cnt++) { |
---|
793 | if ($_POST[$keyname . $cnt] == "1") { |
---|
794 | $conv.= "1"; |
---|
795 | } else { |
---|
796 | $conv.= "0"; |
---|
797 | } |
---|
798 | } |
---|
799 | return $conv; |
---|
800 | } |
---|
801 | |
---|
802 | // html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤Æ2¿Ê¿ô·Á¼°¤ËÊѹ¹¤¹¤ë¡£ |
---|
803 | function sfMergeCheckBoxes($array, $max) { |
---|
804 | $ret = ""; |
---|
805 | if(is_array($array)) { |
---|
806 | foreach($array as $val) { |
---|
807 | $arrTmp[$val] = "1"; |
---|
808 | } |
---|
809 | } |
---|
810 | for($i = 1; $i <= $max; $i++) { |
---|
811 | if($arrTmp[$i] == "1") { |
---|
812 | $ret.= "1"; |
---|
813 | } else { |
---|
814 | $ret.= "0"; |
---|
815 | } |
---|
816 | } |
---|
817 | return $ret; |
---|
818 | } |
---|
819 | |
---|
820 | |
---|
821 | // html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤Æ¡Ö-¡×¤Ç¤Ä¤Ê¤²¤ë¡£ |
---|
822 | function sfMergeParamCheckBoxes($array) { |
---|
823 | $ret = ''; |
---|
824 | if(is_array($array)) { |
---|
825 | foreach($array as $val) { |
---|
826 | if($ret != "") { |
---|
827 | $ret.= "-$val"; |
---|
828 | } else { |
---|
829 | $ret = $val; |
---|
830 | } |
---|
831 | } |
---|
832 | } else { |
---|
833 | $ret = $array; |
---|
834 | } |
---|
835 | return $ret; |
---|
836 | } |
---|
837 | |
---|
838 | // html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤ÆSQL¸¡º÷ÍѤËÊѹ¹¤¹¤ë¡£ |
---|
839 | function sfSearchCheckBoxes($array) { |
---|
840 | $max = 0; |
---|
841 | $ret = ""; |
---|
842 | foreach($array as $val) { |
---|
843 | $arrTmp[$val] = "1"; |
---|
844 | if($val > $max) { |
---|
845 | $max = $val; |
---|
846 | } |
---|
847 | } |
---|
848 | for($i = 1; $i <= $max; $i++) { |
---|
849 | if($arrTmp[$i] == "1") { |
---|
850 | $ret.= "1"; |
---|
851 | } else { |
---|
852 | $ret.= "_"; |
---|
853 | } |
---|
854 | } |
---|
855 | |
---|
856 | if($ret != "") { |
---|
857 | $ret.= "%"; |
---|
858 | } |
---|
859 | return $ret; |
---|
860 | } |
---|
861 | |
---|
862 | // 2¿Ê¿ô·Á¼°¤ÎÃͤòhtml_checkboxesÂбþ¤ÎÃͤËÀÚ¤êÂØ¤¨¤ë |
---|
863 | function sfSplitCheckBoxes($val) { |
---|
864 | $len = strlen($val); |
---|
865 | for($i = 0; $i < $len; $i++) { |
---|
866 | if(substr($val, $i, 1) == "1") { |
---|
867 | $arrRet[] = ($i + 1); |
---|
868 | } |
---|
869 | } |
---|
870 | return $arrRet; |
---|
871 | } |
---|
872 | |
---|
873 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤò¥Þ¡¼¥¸ |
---|
874 | function sfMergeCBSearchValue($keyname, $max) { |
---|
875 | $conv = ""; |
---|
876 | $cnt = 1; |
---|
877 | for($cnt = 1; $cnt <= $max; $cnt++) { |
---|
878 | if ($_POST[$keyname . $cnt] == "1") { |
---|
879 | $conv.= "1"; |
---|
880 | } else { |
---|
881 | $conv.= "_"; |
---|
882 | } |
---|
883 | } |
---|
884 | return $conv; |
---|
885 | } |
---|
886 | |
---|
887 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤòʬ²ò |
---|
888 | function sfSplitCBValue($val, $keyname = "") { |
---|
889 | $len = strlen($val); |
---|
890 | $no = 1; |
---|
891 | for ($cnt = 0; $cnt < $len; $cnt++) { |
---|
892 | if($keyname != "") { |
---|
893 | $arr[$keyname . $no] = substr($val, $cnt, 1); |
---|
894 | } else { |
---|
895 | $arr[] = substr($val, $cnt, 1); |
---|
896 | } |
---|
897 | $no++; |
---|
898 | } |
---|
899 | return $arr; |
---|
900 | } |
---|
901 | |
---|
902 | // ¥¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ |
---|
903 | function sfArrKeyValue($arrList, $keyname, $valname, $len_max = "", $keysize = "") { |
---|
904 | |
---|
905 | $max = count($arrList); |
---|
906 | |
---|
907 | if($len_max != "" && $max > $len_max) { |
---|
908 | $max = $len_max; |
---|
909 | } |
---|
910 | |
---|
911 | for($cnt = 0; $cnt < $max; $cnt++) { |
---|
912 | if($keysize != "") { |
---|
913 | $key = sfCutString($arrList[$cnt][$keyname], $keysize); |
---|
914 | } else { |
---|
915 | $key = $arrList[$cnt][$keyname]; |
---|
916 | } |
---|
917 | $val = $arrList[$cnt][$valname]; |
---|
918 | |
---|
919 | if(!isset($arrRet[$key])) { |
---|
920 | $arrRet[$key] = $val; |
---|
921 | } |
---|
922 | |
---|
923 | } |
---|
924 | return $arrRet; |
---|
925 | } |
---|
926 | |
---|
927 | // ¥¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ(Ãͤ¬Ê£¿ô¤Î¾ì¹ç) |
---|
928 | function sfArrKeyValues($arrList, $keyname, $valname, $len_max = "", $keysize = "", $connect = "") { |
---|
929 | |
---|
930 | $max = count($arrList); |
---|
931 | |
---|
932 | if($len_max != "" && $max > $len_max) { |
---|
933 | $max = $len_max; |
---|
934 | } |
---|
935 | |
---|
936 | for($cnt = 0; $cnt < $max; $cnt++) { |
---|
937 | if($keysize != "") { |
---|
938 | $key = sfCutString($arrList[$cnt][$keyname], $keysize); |
---|
939 | } else { |
---|
940 | $key = $arrList[$cnt][$keyname]; |
---|
941 | } |
---|
942 | $val = $arrList[$cnt][$valname]; |
---|
943 | |
---|
944 | if($connect != "") { |
---|
945 | $arrRet[$key].= "$val".$connect; |
---|
946 | } else { |
---|
947 | $arrRet[$key][] = $val; |
---|
948 | } |
---|
949 | } |
---|
950 | return $arrRet; |
---|
951 | } |
---|
952 | |
---|
953 | // ÇÛÎó¤ÎÃͤò¥«¥ó¥Þ¶èÀÚ¤ê¤ÇÊÖ¤¹¡£ |
---|
954 | function sfGetCommaList($array, $space=true) { |
---|
955 | if (count($array) > 0) { |
---|
956 | $line = ""; |
---|
957 | foreach($array as $val) { |
---|
958 | if ($space) { |
---|
959 | $line .= $val . ", "; |
---|
960 | }else{ |
---|
961 | $line .= $val . ","; |
---|
962 | } |
---|
963 | } |
---|
964 | if ($space) { |
---|
965 | $line = ereg_replace(", $", "", $line); |
---|
966 | }else{ |
---|
967 | $line = ereg_replace(",$", "", $line); |
---|
968 | } |
---|
969 | return $line; |
---|
970 | }else{ |
---|
971 | return false; |
---|
972 | } |
---|
973 | |
---|
974 | } |
---|
975 | |
---|
976 | /* ÇÛÎó¤ÎÍ×ÁǤòCSV¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç½ÐÎϤ¹¤ë¡£*/ |
---|
977 | function sfGetCSVList($array) { |
---|
978 | if (count($array) > 0) { |
---|
979 | foreach($array as $key => $val) { |
---|
980 | $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE); |
---|
981 | $line .= "\"".$val."\","; |
---|
982 | } |
---|
983 | $line = ereg_replace(",$", "\n", $line); |
---|
984 | }else{ |
---|
985 | return false; |
---|
986 | } |
---|
987 | return $line; |
---|
988 | } |
---|
989 | |
---|
990 | /* ÇÛÎó¤ÎÍ×ÁǤòPDF¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç½ÐÎϤ¹¤ë¡£*/ |
---|
991 | function sfGetPDFList($array) { |
---|
992 | foreach($array as $key => $val) { |
---|
993 | $line .= "\t".$val; |
---|
994 | } |
---|
995 | $line.="\n"; |
---|
996 | return $line; |
---|
997 | } |
---|
998 | |
---|
999 | |
---|
1000 | |
---|
1001 | /*-----------------------------------------------------------------*/ |
---|
1002 | /* check_set_term |
---|
1003 | /* ǯ·îÆü¤ËÊ̤줿2¤Ä¤Î´ü´Ö¤ÎÂÅÅöÀ¤ò¥Á¥§¥Ã¥¯¤·¡¢À°¹çÀ¤È´ü´Ö¤òÊÖ¤¹ |
---|
1004 | /*¡¡°ú¿ô (³«»Ïǯ,³«»Ï·î,³«»ÏÆü,½ªÎ»Ç¯,½ªÎ»·î,½ªÎ»Æü) |
---|
1005 | /*¡¡ÌáÃÍ array(£±¡¤£²¡¤£³¡Ë |
---|
1006 | /* £±¡¥³«»Ïǯ·îÆü (YYYY/MM/DD 000000) |
---|
1007 | /* £²¡¥½ªÎ»Ç¯·îÆü (YYYY/MM/DD 235959) |
---|
1008 | /* £³¡¥¥¨¥é¡¼ ( 0 = OK, 1 = NG ) |
---|
1009 | /*-----------------------------------------------------------------*/ |
---|
1010 | function sfCheckSetTerm ( $start_year, $start_month, $start_day, $end_year, $end_month, $end_day ) { |
---|
1011 | |
---|
1012 | // ´ü´Ö»ØÄê |
---|
1013 | $error = 0; |
---|
1014 | if ( $start_month || $start_day || $start_year){ |
---|
1015 | if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1; |
---|
1016 | } else { |
---|
1017 | $error = 1; |
---|
1018 | } |
---|
1019 | if ( $end_month || $end_day || $end_year){ |
---|
1020 | if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2; |
---|
1021 | } |
---|
1022 | if ( ! $error ){ |
---|
1023 | $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000"; |
---|
1024 | $date2 = $end_year ."/".sprintf("%02d",$end_month) ."/".sprintf("%02d",$end_day) ." 235959"; |
---|
1025 | if ($date1 > $date2) $error = 3; |
---|
1026 | } else { |
---|
1027 | $error = 1; |
---|
1028 | } |
---|
1029 | return array($date1, $date2, $error); |
---|
1030 | } |
---|
1031 | |
---|
1032 | // ¥¨¥é¡¼²Õ½ê¤ÎÇØ·Ê¿§¤òÊѹ¹¤¹¤ë¤¿¤á¤Îfunction SC_View¤ÇÆÉ¤ß¹þ¤à |
---|
1033 | function sfSetErrorStyle(){ |
---|
1034 | return 'style="background-color:'.ERR_COLOR.'"'; |
---|
1035 | } |
---|
1036 | |
---|
1037 | /* DB¤ËÅϤ¹¿ôÃͤΥÁ¥§¥Ã¥¯ |
---|
1038 | * 10·å°Ê¾å¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¥¨¥é¡¼¤òµ¯¤³¤¹¤Î¤Ç¡£ |
---|
1039 | */ |
---|
1040 | function sfCheckNumLength( $value ){ |
---|
1041 | if ( ! is_numeric($value) ){ |
---|
1042 | return false; |
---|
1043 | } |
---|
1044 | |
---|
1045 | if ( strlen($value) > 9 ) { |
---|
1046 | return false; |
---|
1047 | } |
---|
1048 | |
---|
1049 | return true; |
---|
1050 | } |
---|
1051 | |
---|
1052 | // °ìÃפ·¤¿ÃͤΥ¡¼Ì¾¤ò¼èÆÀ |
---|
1053 | function sfSearchKey($array, $word, $default) { |
---|
1054 | foreach($array as $key => $val) { |
---|
1055 | if($val == $word) { |
---|
1056 | return $key; |
---|
1057 | } |
---|
1058 | } |
---|
1059 | return $default; |
---|
1060 | } |
---|
1061 | |
---|
1062 | // ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ($products_check:true¾¦ÉÊÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤À¤±¼èÆÀ) |
---|
1063 | function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) { |
---|
1064 | $objQuery = new SC_Query(); |
---|
1065 | $where = "del_flg = 0"; |
---|
1066 | |
---|
1067 | if($addwhere != "") { |
---|
1068 | $where.= " AND $addwhere"; |
---|
1069 | } |
---|
1070 | |
---|
1071 | $objQuery->setoption("ORDER BY rank DESC"); |
---|
1072 | |
---|
1073 | if($products_check) { |
---|
1074 | $col = "T1.category_id, category_name, level"; |
---|
1075 | $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; |
---|
1076 | $where .= " AND product_count > 0"; |
---|
1077 | } else { |
---|
1078 | $col = "category_id, category_name, level"; |
---|
1079 | $from = "dtb_category"; |
---|
1080 | } |
---|
1081 | |
---|
1082 | $arrRet = $objQuery->select($col, $from, $where); |
---|
1083 | |
---|
1084 | $max = count($arrRet); |
---|
1085 | for($cnt = 0; $cnt < $max; $cnt++) { |
---|
1086 | $id = $arrRet[$cnt]['category_id']; |
---|
1087 | $name = $arrRet[$cnt]['category_name']; |
---|
1088 | $arrList[$id] = ""; |
---|
1089 | /* |
---|
1090 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
---|
1091 | $arrList[$id].= "¡¡"; |
---|
1092 | } |
---|
1093 | */ |
---|
1094 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
---|
1095 | $arrList[$id].= $head; |
---|
1096 | } |
---|
1097 | $arrList[$id].= $name; |
---|
1098 | } |
---|
1099 | return $arrList; |
---|
1100 | } |
---|
1101 | |
---|
1102 | // ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ¡Ê¿Æ¥«¥Æ¥´¥ê¤ÎValue:0) |
---|
1103 | function sfGetLevelCatList($parent_zero = true) { |
---|
1104 | $objQuery = new SC_Query(); |
---|
1105 | $col = "category_id, category_name, level"; |
---|
1106 | $where = "del_flg = 0"; |
---|
1107 | $objQuery->setoption("ORDER BY rank DESC"); |
---|
1108 | $arrRet = $objQuery->select($col, "dtb_category", $where); |
---|
1109 | $max = count($arrRet); |
---|
1110 | |
---|
1111 | for($cnt = 0; $cnt < $max; $cnt++) { |
---|
1112 | if($parent_zero) { |
---|
1113 | if($arrRet[$cnt]['level'] == LEVEL_MAX) { |
---|
1114 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
---|
1115 | } else { |
---|
1116 | $arrValue[$cnt] = ""; |
---|
1117 | } |
---|
1118 | } else { |
---|
1119 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
---|
1120 | } |
---|
1121 | |
---|
1122 | $arrOutput[$cnt] = ""; |
---|
1123 | /* |
---|
1124 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
---|
1125 | $arrOutput[$cnt].= "¡¡"; |
---|
1126 | } |
---|
1127 | */ |
---|
1128 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
---|
1129 | $arrOutput[$cnt].= CATEGORY_HEAD; |
---|
1130 | } |
---|
1131 | $arrOutput[$cnt].= $arrRet[$cnt]['category_name']; |
---|
1132 | } |
---|
1133 | return array($arrValue, $arrOutput); |
---|
1134 | } |
---|
1135 | |
---|
1136 | function sfGetErrorColor($val) { |
---|
1137 | if($val != "") { |
---|
1138 | return "background-color:" . ERR_COLOR; |
---|
1139 | } |
---|
1140 | return ""; |
---|
1141 | } |
---|
1142 | |
---|
1143 | |
---|
1144 | function sfGetEnabled($val) { |
---|
1145 | if( ! $val ) { |
---|
1146 | return " disabled=\"disabled\""; |
---|
1147 | } |
---|
1148 | return ""; |
---|
1149 | } |
---|
1150 | |
---|
1151 | function sfGetChecked($param, $value) { |
---|
1152 | if($param == $value) { |
---|
1153 | return "checked=\"checked\""; |
---|
1154 | } |
---|
1155 | return ""; |
---|
1156 | } |
---|
1157 | |
---|
1158 | // SELECT¥Ü¥Ã¥¯¥¹Íѥꥹ¥È¤ÎºîÀ® |
---|
1159 | function sfGetIDValueList($table, $keyname, $valname) { |
---|
1160 | $objQuery = new SC_Query(); |
---|
1161 | $col = "$keyname, $valname"; |
---|
1162 | $objQuery->setwhere("del_flg = 0"); |
---|
1163 | $objQuery->setorder("rank DESC"); |
---|
1164 | $arrList = $objQuery->select($col, $table); |
---|
1165 | $count = count($arrList); |
---|
1166 | for($cnt = 0; $cnt < $count; $cnt++) { |
---|
1167 | $key = $arrList[$cnt][$keyname]; |
---|
1168 | $val = $arrList[$cnt][$valname]; |
---|
1169 | $arrRet[$key] = $val; |
---|
1170 | } |
---|
1171 | return $arrRet; |
---|
1172 | } |
---|
1173 | |
---|
1174 | function sfTrim($str) { |
---|
1175 | $ret = ereg_replace("^[¡¡ \n\r]*", "", $str); |
---|
1176 | $ret = ereg_replace("[¡¡ \n\r]*$", "", $ret); |
---|
1177 | return $ret; |
---|
1178 | } |
---|
1179 | |
---|
1180 | /* ½ê°¤¹¤ë¤¹¤Ù¤Æ¤Î³¬ÁؤοÆID¤òÇÛÎó¤ÇÊÖ¤¹ */ |
---|
1181 | function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) { |
---|
1182 | $arrRet = sfGetParentsArray($table, $pid_name, $id_name, $id); |
---|
1183 | // ÇÛÎó¤ÎÀèÆ¬1¤Ä¤òºï½ü¤¹¤ë¡£ |
---|
1184 | array_shift($arrRet); |
---|
1185 | return $arrRet; |
---|
1186 | } |
---|
1187 | |
---|
1188 | |
---|
1189 | /* ¿ÆID¤ÎÇÛÎó¤ò¸µ¤ËÆÃÄê¤Î¥«¥é¥à¤ò¼èÆÀ¤¹¤ë¡£*/ |
---|
1190 | function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) { |
---|
1191 | $col = $col_name; |
---|
1192 | $len = count($arrId); |
---|
1193 | $where = ""; |
---|
1194 | |
---|
1195 | for($cnt = 0; $cnt < $len; $cnt++) { |
---|
1196 | if($where == "") { |
---|
1197 | $where = "$id_name = ?"; |
---|
1198 | } else { |
---|
1199 | $where.= " OR $id_name = ?"; |
---|
1200 | } |
---|
1201 | } |
---|
1202 | |
---|
1203 | $objQuery->setorder("level"); |
---|
1204 | $arrRet = $objQuery->select($col, $table, $where, $arrId); |
---|
1205 | return $arrRet; |
---|
1206 | } |
---|
1207 | |
---|
1208 | /* »ÒID¤ÎÇÛÎó¤òÊÖ¤¹ */ |
---|
1209 | function sfGetChildsID($table, $pid_name, $id_name, $id) { |
---|
1210 | $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id); |
---|
1211 | return $arrRet; |
---|
1212 | } |
---|
1213 | |
---|
1214 | /* ¥«¥Æ¥´¥êÊѹ¹»þ¤Î°Üư½èÍý */ |
---|
1215 | function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) { |
---|
1216 | if ($old_catid == $new_catid) { |
---|
1217 | return; |
---|
1218 | } |
---|
1219 | // µì¥«¥Æ¥´¥ê¤Ç¤Î¥é¥ó¥¯ºï½ü½èÍý |
---|
1220 | // °Üư¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
---|
1221 | $where = "$id_name = ?"; |
---|
1222 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
1223 | // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä²¼¤Ë¤º¤é¤¹¡£ |
---|
1224 | $where = "rank > ? AND $cat_name = ?"; |
---|
1225 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
---|
1226 | $objQuery->exec($sqlup, array($rank, $old_catid)); |
---|
1227 | // ¿·¥«¥Æ¥´¥ê¤Ç¤ÎÅÐÏ¿½èÍý |
---|
1228 | // ¿·¥«¥Æ¥´¥ê¤ÎºÇÂç¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
---|
1229 | $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1; |
---|
1230 | $where = "$id_name = ?"; |
---|
1231 | $sqlup = "UPDATE $table SET rank = ? WHERE $where"; |
---|
1232 | $objQuery->exec($sqlup, array($max_rank, $id)); |
---|
1233 | } |
---|
1234 | |
---|
1235 | /* ÀǶâ·×»» */ |
---|
1236 | function sfTax($price, $tax, $tax_rule) { |
---|
1237 | $real_tax = $tax / 100; |
---|
1238 | $ret = $price * $real_tax; |
---|
1239 | switch($tax_rule) { |
---|
1240 | // »Í¼Î¸ÞÆþ |
---|
1241 | case 1: |
---|
1242 | $ret = round($ret); |
---|
1243 | break; |
---|
1244 | // ÀÚ¤ê¼Î¤Æ |
---|
1245 | case 2: |
---|
1246 | $ret = floor($ret); |
---|
1247 | break; |
---|
1248 | // ÀÚ¤ê¾å¤² |
---|
1249 | case 3: |
---|
1250 | $ret = ceil($ret); |
---|
1251 | break; |
---|
1252 | // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤² |
---|
1253 | default: |
---|
1254 | $ret = ceil($ret); |
---|
1255 | break; |
---|
1256 | } |
---|
1257 | return $ret; |
---|
1258 | } |
---|
1259 | |
---|
1260 | /* ÀǶâÉÕÍ¿ */ |
---|
1261 | function sfPreTax($price, $tax, $tax_rule) { |
---|
1262 | $real_tax = $tax / 100; |
---|
1263 | $ret = $price * (1 + $real_tax); |
---|
1264 | |
---|
1265 | switch($tax_rule) { |
---|
1266 | // »Í¼Î¸ÞÆþ |
---|
1267 | case 1: |
---|
1268 | $ret = round($ret); |
---|
1269 | break; |
---|
1270 | // ÀÚ¤ê¼Î¤Æ |
---|
1271 | case 2: |
---|
1272 | $ret = floor($ret); |
---|
1273 | break; |
---|
1274 | // ÀÚ¤ê¾å¤² |
---|
1275 | case 3: |
---|
1276 | $ret = ceil($ret); |
---|
1277 | break; |
---|
1278 | // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤² |
---|
1279 | default: |
---|
1280 | $ret = ceil($ret); |
---|
1281 | break; |
---|
1282 | } |
---|
1283 | return $ret; |
---|
1284 | } |
---|
1285 | |
---|
1286 | // ·å¿ô¤ò»ØÄꤷ¤Æ»Í¼Î¸ÞÆþ |
---|
1287 | function sfRound($value, $pow = 0){ |
---|
1288 | $adjust = pow(10 ,$pow-1); |
---|
1289 | |
---|
1290 | // À°¿ô³î¤Ä0½Ð¤Ê¤±¤ì¤Ð·å¿ô»ØÄê¤ò¹Ô¤¦ |
---|
1291 | if(sfIsInt($adjust) and $pow > 1){ |
---|
1292 | $ret = (round($value * $adjust)/$adjust); |
---|
1293 | } |
---|
1294 | |
---|
1295 | $ret = round($ret); |
---|
1296 | |
---|
1297 | return $ret; |
---|
1298 | } |
---|
1299 | |
---|
1300 | /* ¥Ý¥¤¥ó¥ÈÉÕÍ¿ */ |
---|
1301 | function sfPrePoint($price, $point_rate, $rule = POINT_RULE, $product_id = "") { |
---|
1302 | if(sfIsInt($product_id)) { |
---|
1303 | $objQuery = new SC_Query(); |
---|
1304 | $where = "now() >= cast(start_date as date) AND "; |
---|
1305 | $where .= "now() < cast(end_date as date) AND "; |
---|
1306 | |
---|
1307 | $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )"; |
---|
1308 | //ÅÐÏ¿(¹¹¿·)ÆüÉÕ½ç |
---|
1309 | $objQuery->setorder('update_date DESC'); |
---|
1310 | //¥¥ã¥ó¥Ú¡¼¥ó¥Ý¥¤¥ó¥È¤Î¼èÆÀ |
---|
1311 | $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id)); |
---|
1312 | } |
---|
1313 | //Ê£¿ô¤Î¥¥ã¥ó¥Ú¡¼¥ó¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾¦Éʤϡ¢ºÇ¿·¤Î¥¥ã¥ó¥Ú¡¼¥ó¤«¤é¥Ý¥¤¥ó¥È¤ò¼èÆÀ |
---|
1314 | if($arrRet[0]['campaign_point_rate'] != "") { |
---|
1315 | $campaign_point_rate = $arrRet[0]['campaign_point_rate']; |
---|
1316 | $real_point = $campaign_point_rate / 100; |
---|
1317 | } else { |
---|
1318 | $real_point = $point_rate / 100; |
---|
1319 | } |
---|
1320 | $ret = $price * $real_point; |
---|
1321 | switch($rule) { |
---|
1322 | // »Í¼Î¸ÞÆþ |
---|
1323 | case 1: |
---|
1324 | $ret = round($ret); |
---|
1325 | break; |
---|
1326 | // ÀÚ¤ê¼Î¤Æ |
---|
1327 | case 2: |
---|
1328 | $ret = floor($ret); |
---|
1329 | break; |
---|
1330 | // ÀÚ¤ê¾å¤² |
---|
1331 | case 3: |
---|
1332 | $ret = ceil($ret); |
---|
1333 | break; |
---|
1334 | // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤² |
---|
1335 | default: |
---|
1336 | $ret = ceil($ret); |
---|
1337 | break; |
---|
1338 | } |
---|
1339 | //¥¥ã¥ó¥Ú¡¼¥ó¾¦Éʤξì¹ç |
---|
1340 | if($campaign_point_rate != "") { |
---|
1341 | $ret = "(".$arrRet[0]['campaign_name']."¥Ý¥¤¥ó¥ÈΨ".$campaign_point_rate."%)".$ret; |
---|
1342 | } |
---|
1343 | return $ret; |
---|
1344 | } |
---|
1345 | |
---|
1346 | /* µ¬³ÊʬÎà¤Î·ï¿ô¼èÆÀ */ |
---|
1347 | function sfGetClassCatCount() { |
---|
1348 | $sql = "select count(dtb_class.class_id) as count, dtb_class.class_id "; |
---|
1349 | $sql.= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id "; |
---|
1350 | $sql.= "where dtb_class.del_flg = 0 AND dtb_classcategory.del_flg = 0 "; |
---|
1351 | $sql.= "group by dtb_class.class_id, dtb_class.name"; |
---|
1352 | $objQuery = new SC_Query(); |
---|
1353 | $arrList = $objQuery->getall($sql); |
---|
1354 | // ¥¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ |
---|
1355 | $arrRet = sfArrKeyValue($arrList, 'class_id', 'count'); |
---|
1356 | |
---|
1357 | return $arrRet; |
---|
1358 | } |
---|
1359 | |
---|
1360 | /* µ¬³Ê¤ÎÅÐÏ¿ */ |
---|
1361 | function sfInsertProductClass($objQuery, $arrList, $product_id) { |
---|
1362 | // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£ |
---|
1363 | $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0"; |
---|
1364 | $count = $objQuery->count("dtb_products_class", $where, array($product_id)); |
---|
1365 | |
---|
1366 | // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤Ê¤¤¾ì¹ç |
---|
1367 | if($count == 0) { |
---|
1368 | // ´û¸µ¬³Ê¤Îºï½ü |
---|
1369 | $where = "product_id = ?"; |
---|
1370 | $objQuery->delete("dtb_products_class", $where, array($product_id)); |
---|
1371 | $sqlval['product_id'] = $product_id; |
---|
1372 | $sqlval['classcategory_id1'] = '0'; |
---|
1373 | $sqlval['classcategory_id2'] = '0'; |
---|
1374 | $sqlval['product_code'] = $arrList["product_code"]; |
---|
1375 | $sqlval['stock'] = $arrList["stock"]; |
---|
1376 | $sqlval['stock_unlimited'] = $arrList["stock_unlimited"]; |
---|
1377 | $sqlval['price01'] = $arrList['price01']; |
---|
1378 | $sqlval['price02'] = $arrList['price02']; |
---|
1379 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
1380 | $sqlval['create_date'] = "now()"; |
---|
1381 | |
---|
1382 | if($_SESSION['member_id'] == "") { |
---|
1383 | $sqlval['creator_id'] = '0'; |
---|
1384 | } |
---|
1385 | |
---|
1386 | // INSERT¤Î¼Â¹Ô |
---|
1387 | $objQuery->insert("dtb_products_class", $sqlval); |
---|
1388 | } |
---|
1389 | } |
---|
1390 | |
---|
1391 | function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) { |
---|
1392 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
---|
1393 | $objQuery = new SC_Query(); |
---|
1394 | $ret = $objQuery->get("dtb_products_class", "product_class_id", $where, Array($product_id, $classcategory_id1, $classcategory_id2)); |
---|
1395 | return $ret; |
---|
1396 | } |
---|
1397 | |
---|
1398 | /* ʸËö¤Î¡Ö/¡×¤ò¤Ê¤¯¤¹ */ |
---|
1399 | function sfTrimURL($url) { |
---|
1400 | $ret = ereg_replace("[/]+$", "", $url); |
---|
1401 | return $ret; |
---|
1402 | } |
---|
1403 | |
---|
1404 | /* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */ |
---|
1405 | function sfGetProductsClass($arrID) { |
---|
1406 | list($product_id, $classcategory_id1, $classcategory_id2) = $arrID; |
---|
1407 | |
---|
1408 | if($classcategory_id1 == "") { |
---|
1409 | $classcategory_id1 = '0'; |
---|
1410 | } |
---|
1411 | if($classcategory_id2 == "") { |
---|
1412 | $classcategory_id2 = '0'; |
---|
1413 | } |
---|
1414 | |
---|
1415 | // ¾¦Éʵ¬³Ê¼èÆÀ |
---|
1416 | $objQuery = new SC_Query(); |
---|
1417 | $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited"; |
---|
1418 | $table = "vw_product_class AS prdcls"; |
---|
1419 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
---|
1420 | $objQuery->setorder("rank1 DESC, rank2 DESC"); |
---|
1421 | $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2)); |
---|
1422 | return $arrRet[0]; |
---|
1423 | } |
---|
1424 | |
---|
1425 | /* ½¸·×¾ðÊó¤ò¸µ¤ËºÇ½ª·×»» */ |
---|
1426 | function sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo, $objCustomer = "") { |
---|
1427 | // ¾¦Éʤιç·×¸Ä¿ô |
---|
1428 | $total_quantity = $objCartSess->getTotalQuantity(true); |
---|
1429 | |
---|
1430 | // ÀǶâ¤Î¼èÆÀ |
---|
1431 | $arrData['tax'] = $objPage->tpl_total_tax; |
---|
1432 | // ¾®·×¤Î¼èÆÀ |
---|
1433 | $arrData['subtotal'] = $objPage->tpl_total_pretax; |
---|
1434 | |
---|
1435 | // ¹ç·×Á÷ÎÁ¤Î¼èÆÀ |
---|
1436 | $arrData['deliv_fee'] = 0; |
---|
1437 | |
---|
1438 | // ¾¦Éʤ´¤È¤ÎÁ÷ÎÁ¤¬Í¸ú¤Î¾ì¹ç |
---|
1439 | if (OPTION_PRODUCT_DELIV_FEE == 1) { |
---|
1440 | $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee(); |
---|
1441 | } |
---|
1442 | |
---|
1443 | // ÇÛÁ÷¶È¼Ô¤ÎÁ÷ÎÁ¤¬Í¸ú¤Î¾ì¹ç |
---|
1444 | if (OPTION_DELIV_FEE == 1) { |
---|
1445 | // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë |
---|
1446 | $arrData['deliv_fee']+= sfGetDelivFee($arrData['deliv_pref'], $arrData['payment_id']); |
---|
1447 | } |
---|
1448 | |
---|
1449 | // Á÷ÎÁ̵ÎÁ¤Î¹ØÆþ¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç |
---|
1450 | if(DELIV_FREE_AMOUNT > 0) { |
---|
1451 | if($total_quantity >= DELIV_FREE_AMOUNT) { |
---|
1452 | $arrData['deliv_fee'] = 0; |
---|
1453 | } |
---|
1454 | } |
---|
1455 | |
---|
1456 | // Á÷ÎÁ̵ÎÁ¾ò·ï¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç |
---|
1457 | if($arrInfo['free_rule'] > 0) { |
---|
1458 | // ¾®·×¤¬ÌµÎÁ¾ò·ï¤òͤ¨¤Æ¤¤¤ë¾ì¹ç |
---|
1459 | if($arrData['subtotal'] >= $arrInfo['free_rule']) { |
---|
1460 | $arrData['deliv_fee'] = 0; |
---|
1461 | } |
---|
1462 | } |
---|
1463 | |
---|
1464 | // ¹ç·×¤Î·×»» |
---|
1465 | $arrData['total'] = $objPage->tpl_total_pretax; // ¾¦Éʹç·× |
---|
1466 | $arrData['total']+= $arrData['deliv_fee']; // Á÷ÎÁ |
---|
1467 | $arrData['total']+= $arrData['charge']; // ¼ê¿ôÎÁ |
---|
1468 | // ¤ª»Ùʧ¤¤¹ç·× |
---|
1469 | $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE); |
---|
1470 | // ²Ã»»¥Ý¥¤¥ó¥È¤Î·×»» |
---|
1471 | $arrData['add_point'] = sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo); |
---|
1472 | |
---|
1473 | if($objCustomer != "") { |
---|
1474 | // ÃÂÀ¸Æü·î¤Ç¤¢¤Ã¤¿¾ì¹ç |
---|
1475 | if($objCustomer->isBirthMonth()) { |
---|
1476 | $arrData['birth_point'] = BIRTH_MONTH_POINT; |
---|
1477 | $arrData['add_point'] += $arrData['birth_point']; |
---|
1478 | } |
---|
1479 | } |
---|
1480 | |
---|
1481 | if($arrData['add_point'] < 0) { |
---|
1482 | $arrData['add_point'] = 0; |
---|
1483 | } |
---|
1484 | |
---|
1485 | return $arrData; |
---|
1486 | } |
---|
1487 | |
---|
1488 | /* ¥«¡¼¥ÈÆâ¾¦Éʤν¸·×½èÍý */ |
---|
1489 | function sfTotalCart($objPage, $objCartSess, $arrInfo) { |
---|
1490 | // µ¬³Ê̾°ìÍ÷ |
---|
1491 | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); |
---|
1492 | // µ¬³ÊʬÎà̾°ìÍ÷ |
---|
1493 | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
---|
1494 | |
---|
1495 | $objPage->tpl_total_pretax = 0; // ÈñÍѹç·×(Àǹþ¤ß) |
---|
1496 | $objPage->tpl_total_tax = 0; // ¾ÃÈñÀǹç·× |
---|
1497 | $objPage->tpl_total_point = 0; // ¥Ý¥¤¥ó¥È¹ç·× |
---|
1498 | |
---|
1499 | // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ |
---|
1500 | $arrCart = $objCartSess->getCartList(); |
---|
1501 | $max = count($arrCart); |
---|
1502 | $cnt = 0; |
---|
1503 | |
---|
1504 | for ($i = 0; $i < $max; $i++) { |
---|
1505 | // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ |
---|
1506 | $arrData = sfGetProductsClass($arrCart[$i]['id']); |
---|
1507 | $limit = ""; |
---|
1508 | // DB¤Ë¸ºß¤¹¤ë¾¦ÉÊ |
---|
1509 | if (count($arrData) > 0) { |
---|
1510 | |
---|
1511 | // ¹ØÆþÀ©¸Â¿ô¤òµá¤á¤ë¡£ |
---|
1512 | if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') { |
---|
1513 | if($arrData['sale_limit'] < $arrData['stock']) { |
---|
1514 | $limit = $arrData['sale_limit']; |
---|
1515 | } else { |
---|
1516 | $limit = $arrData['stock']; |
---|
1517 | } |
---|
1518 | } else { |
---|
1519 | if ($arrData['sale_unlimited'] != '1') { |
---|
1520 | $limit = $arrData['sale_limit']; |
---|
1521 | } |
---|
1522 | if ($arrData['stock_unlimited'] != '1') { |
---|
1523 | $limit = $arrData['stock']; |
---|
1524 | } |
---|
1525 | } |
---|
1526 | |
---|
1527 | if($limit != "" && $limit < $arrCart[$i]['quantity']) { |
---|
1528 | // ¥«¡¼¥ÈÆâ¾¦ÉÊ¿ô¤òÀ©¸Â¤Ë¹ç¤ï¤»¤ë |
---|
1529 | $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit); |
---|
1530 | $quantity = $limit; |
---|
1531 | $objPage->tpl_message = "¢¨¡Ö" . $arrData['name'] . "¡×¤ÏÈÎÇäÀ©¸Â¤·¤Æ¤ª¤ê¤Þ¤¹¡¢°ìÅ٤ˤ³¤ì°Ê¾å¤Î¹ØÆþ¤Ï¤Ç¤¤Þ¤»¤ó¡£"; |
---|
1532 | } else { |
---|
1533 | $quantity = $arrCart[$i]['quantity']; |
---|
1534 | } |
---|
1535 | |
---|
1536 | $objPage->arrProductsClass[$cnt] = $arrData; |
---|
1537 | $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; |
---|
1538 | $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no']; |
---|
1539 | $objPage->arrProductsClass[$cnt]['class_name1'] = $arrClassName[$arrData['class_id1']]; |
---|
1540 | $objPage->arrProductsClass[$cnt]['class_name2'] = $arrClassName[$arrData['class_id2']]; |
---|
1541 | $objPage->arrProductsClass[$cnt]['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']]; |
---|
1542 | $objPage->arrProductsClass[$cnt]['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']]; |
---|
1543 | |
---|
1544 | // ²èÁü¥µ¥¤¥º |
---|
1545 | list($image_width, $image_height) = getimagesize(IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"])); |
---|
1546 | $objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60; |
---|
1547 | $objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80; |
---|
1548 | |
---|
1549 | // ²Á³Ê¤ÎÅÐÏ¿ |
---|
1550 | if ($arrData['price02'] != "") { |
---|
1551 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']); |
---|
1552 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02']; |
---|
1553 | } else { |
---|
1554 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']); |
---|
1555 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01']; |
---|
1556 | } |
---|
1557 | // ¥Ý¥¤¥ó¥ÈÉÕͿΨ¤ÎÅÐÏ¿ |
---|
1558 | $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']); |
---|
1559 | // ¾¦Éʤ´¤È¤Î¹ç·×¶â³Û |
---|
1560 | $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']); |
---|
1561 | // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë |
---|
1562 | $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']); |
---|
1563 | $cnt++; |
---|
1564 | } else { |
---|
1565 | // DB¤Ë¾¦Éʤ¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï¥«¡¼¥È¾¦Éʤκï½ü |
---|
1566 | $objCartSess->delProductKey('id', $arrCart[$i]['id']); |
---|
1567 | } |
---|
1568 | } |
---|
1569 | |
---|
1570 | // Á´¾¦Éʹç·×¶â³Û(Àǹþ¤ß) |
---|
1571 | $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo); |
---|
1572 | // Á´¾¦Éʹç·×¾ÃÈñÀÇ |
---|
1573 | $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo); |
---|
1574 | // Á´¾¦Éʹç·×¥Ý¥¤¥ó¥È |
---|
1575 | $objPage->tpl_total_point = $objCartSess->getAllProductsPoint(); |
---|
1576 | |
---|
1577 | return $objPage; |
---|
1578 | } |
---|
1579 | |
---|
1580 | /* DB¤«¤é¼è¤ê½Ð¤·¤¿ÆüÉÕ¤Îʸ»úÎó¤òÄ´À°¤¹¤ë¡£*/ |
---|
1581 | function sfDispDBDate($dbdate, $time = true) { |
---|
1582 | list($y, $m, $d, $H, $M) = split("[- :]", $dbdate); |
---|
1583 | |
---|
1584 | if(strlen($y) > 0 && strlen($m) > 0 && strlen($d) > 0) { |
---|
1585 | if ($time) { |
---|
1586 | $str = sprintf("%04d/%02d/%02d %02d:%02d", $y, $m, $d, $H, $M); |
---|
1587 | } else { |
---|
1588 | $str = sprintf("%04d/%02d/%02d", $y, $m, $d, $H, $M); |
---|
1589 | } |
---|
1590 | } else { |
---|
1591 | $str = ""; |
---|
1592 | } |
---|
1593 | return $str; |
---|
1594 | } |
---|
1595 | |
---|
1596 | function sfGetDelivTime($payment_id = "") { |
---|
1597 | $objQuery = new SC_Query(); |
---|
1598 | |
---|
1599 | $deliv_id = ""; |
---|
1600 | |
---|
1601 | if($payment_id != "") { |
---|
1602 | $where = "del_flg = 0 AND payment_id = ?"; |
---|
1603 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
---|
1604 | $deliv_id = $arrRet[0]['deliv_id']; |
---|
1605 | } |
---|
1606 | |
---|
1607 | if($deliv_id != "") { |
---|
1608 | $objQuery->setorder("time_id"); |
---|
1609 | $where = "deliv_id = ?"; |
---|
1610 | $arrRet= $objQuery->select("time_id, deliv_time", "dtb_delivtime", $where, array($deliv_id)); |
---|
1611 | } |
---|
1612 | |
---|
1613 | return $arrRet; |
---|
1614 | } |
---|
1615 | |
---|
1616 | |
---|
1617 | // ÅÔÆ»Éܸ©¡¢»Ùʧ¤¤ÊýË¡¤«¤éÇÛÁ÷ÎÁ¶â¤ò¼èÆÀ¤¹¤ë |
---|
1618 | function sfGetDelivFee($pref, $payment_id = "") { |
---|
1619 | $objQuery = new SC_Query(); |
---|
1620 | |
---|
1621 | $deliv_id = ""; |
---|
1622 | |
---|
1623 | // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢Âбþ¤·¤¿ÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë |
---|
1624 | if($payment_id != "") { |
---|
1625 | $where = "del_flg = 0 AND payment_id = ?"; |
---|
1626 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
---|
1627 | $deliv_id = $arrRet[0]['deliv_id']; |
---|
1628 | // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÀèÆ¬¤ÎÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë |
---|
1629 | } else { |
---|
1630 | $where = "del_flg = 0"; |
---|
1631 | $objQuery->setOrder("rank DESC"); |
---|
1632 | $objQuery->setLimitOffset(1); |
---|
1633 | $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where); |
---|
1634 | $deliv_id = $arrRet[0]['deliv_id']; |
---|
1635 | } |
---|
1636 | |
---|
1637 | // ÇÛÁ÷¶È¼Ô¤«¤éÇÛÁ÷ÎÁ¤ò¼èÆÀ |
---|
1638 | if($deliv_id != "") { |
---|
1639 | |
---|
1640 | // ÅÔÆ»Éܸ©¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÅìµþÅÔ¤ÎÈÖ¹æ¤ò»ØÄꤷ¤Æ¤ª¤¯ |
---|
1641 | if($pref == "") { |
---|
1642 | $pref = 13; |
---|
1643 | } |
---|
1644 | |
---|
1645 | $objQuery = new SC_Query(); |
---|
1646 | $where = "deliv_id = ? AND pref = ?"; |
---|
1647 | $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref)); |
---|
1648 | } |
---|
1649 | return $arrRet[0]['fee']; |
---|
1650 | } |
---|
1651 | |
---|
1652 | /* »Ùʧ¤¤ÊýË¡¤Î¼èÆÀ */ |
---|
1653 | function sfGetPayment() { |
---|
1654 | $objQuery = new SC_Query(); |
---|
1655 | // ¹ØÆþ¶â³Û¤¬¾ò·ï³Û°Ê²¼¤Î¹àÌܤò¼èÆÀ |
---|
1656 | $where = "del_flg = 0"; |
---|
1657 | $objQuery->setorder("fix, rank DESC"); |
---|
1658 | $arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where); |
---|
1659 | return $arrRet; |
---|
1660 | } |
---|
1661 | |
---|
1662 | /* ÇÛÎó¤ò¥¡¼Ì¾¤´¤È¤ÎÇÛÎó¤ËÊѹ¹¤¹¤ë */ |
---|
1663 | function sfSwapArray($array) { |
---|
1664 | $max = count($array); |
---|
1665 | for($i = 0; $i < $max; $i++) { |
---|
1666 | foreach($array[$i] as $key => $val) { |
---|
1667 | $arrRet[$key][] = $val; |
---|
1668 | } |
---|
1669 | } |
---|
1670 | return $arrRet; |
---|
1671 | } |
---|
1672 | |
---|
1673 | /* ¤«¤±»»¤ò¤¹¤ë¡ÊSmartyÍÑ) */ |
---|
1674 | function sfMultiply($num1, $num2) { |
---|
1675 | return ($num1 * $num2); |
---|
1676 | } |
---|
1677 | |
---|
1678 | /* DB¤ËÅÐÏ¿¤µ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È¥á¡¼¥ë¤ÎÁ÷¿® */ |
---|
1679 | function sfSendTemplateMail($to, $to_name, $template_id, $objPage) { |
---|
1680 | global $arrMAILTPLPATH; |
---|
1681 | $objQuery = new SC_Query(); |
---|
1682 | // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ |
---|
1683 | $where = "template_id = ?"; |
---|
1684 | $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id)); |
---|
1685 | $objPage->tpl_header = $arrRet[0]['header']; |
---|
1686 | $objPage->tpl_footer = $arrRet[0]['footer']; |
---|
1687 | $tmp_subject = $arrRet[0]['subject']; |
---|
1688 | |
---|
1689 | $objSiteInfo = new SC_SiteInfo(); |
---|
1690 | $arrInfo = $objSiteInfo->data; |
---|
1691 | |
---|
1692 | $objMailView = new SC_SiteView(); |
---|
1693 | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
---|
1694 | $objMailView->assignobj($objPage); |
---|
1695 | $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]); |
---|
1696 | |
---|
1697 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
---|
1698 | $objSendMail = new GC_SendMail(); |
---|
1699 | $from = $arrInfo['email03']; |
---|
1700 | $error = $arrInfo['email04']; |
---|
1701 | $tosubject = $tmp_subject; |
---|
1702 | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error); |
---|
1703 | $objSendMail->setTo($to, $to_name); |
---|
1704 | $objSendMail->sendMail(); // ¥á¡¼¥ëÁ÷¿® |
---|
1705 | } |
---|
1706 | |
---|
1707 | /* ¼õÃí´°Î»¥á¡¼¥ëÁ÷¿® */ |
---|
1708 | function sfSendOrderMail($order_id, $template_id, $subject = "", $header = "", $footer = "", $send = true) { |
---|
1709 | global $arrMAILTPLPATH; |
---|
1710 | |
---|
1711 | $objPage = new LC_Page(); |
---|
1712 | $objSiteInfo = new SC_SiteInfo(); |
---|
1713 | $arrInfo = $objSiteInfo->data; |
---|
1714 | $objPage->arrInfo = $arrInfo; |
---|
1715 | |
---|
1716 | $objQuery = new SC_Query(); |
---|
1717 | |
---|
1718 | if($subject == "" && $header == "" && $footer == "") { |
---|
1719 | // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ |
---|
1720 | $where = "template_id = ?"; |
---|
1721 | $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array('1')); |
---|
1722 | $objPage->tpl_header = $arrRet[0]['header']; |
---|
1723 | $objPage->tpl_footer = $arrRet[0]['footer']; |
---|
1724 | $tmp_subject = $arrRet[0]['subject']; |
---|
1725 | } else { |
---|
1726 | $objPage->tpl_header = $header; |
---|
1727 | $objPage->tpl_footer = $footer; |
---|
1728 | $tmp_subject = $subject; |
---|
1729 | } |
---|
1730 | |
---|
1731 | // ¼õÃí¾ðÊó¤Î¼èÆÀ |
---|
1732 | $where = "order_id = ?"; |
---|
1733 | $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id)); |
---|
1734 | $arrOrder = $arrRet[0]; |
---|
1735 | $arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id)); |
---|
1736 | |
---|
1737 | $objPage->Message_tmp = $arrOrder['message']; |
---|
1738 | |
---|
1739 | // ¸ÜµÒ¾ðÊó¤Î¼èÆÀ |
---|
1740 | $customer_id = $arrOrder['customer_id']; |
---|
1741 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
---|
1742 | $arrCustomer = $arrRet[0]; |
---|
1743 | |
---|
1744 | $objPage->arrCustomer = $arrCustomer; |
---|
1745 | $objPage->arrOrder = $arrOrder; |
---|
1746 | |
---|
1747 | //¤½¤Î¾·èºÑ¾ðÊó |
---|
1748 | if($arrOrder['memo02'] != "") { |
---|
1749 | $arrOther = unserialize($arrOrder['memo02']); |
---|
1750 | |
---|
1751 | foreach($arrOther as $other_key => $other_val){ |
---|
1752 | if(sfTrim($other_val["value"]) == ""){ |
---|
1753 | $arrOther[$other_key]["value"] = ""; |
---|
1754 | } |
---|
1755 | } |
---|
1756 | |
---|
1757 | $objPage->arrOther = $arrOther; |
---|
1758 | } |
---|
1759 | |
---|
1760 | // ÅÔÆ»Éܸ©ÊÑ´¹ |
---|
1761 | global $arrPref; |
---|
1762 | $objPage->arrOrder['deliv_pref'] = $arrPref[$objPage->arrOrder['deliv_pref']]; |
---|
1763 | |
---|
1764 | $objPage->arrOrderDetail = $arrOrderDetail; |
---|
1765 | |
---|
1766 | $objCustomer = new SC_Customer(); |
---|
1767 | $objPage->tpl_user_point = $objCustomer->getValue('point'); |
---|
1768 | |
---|
1769 | $objMailView = new SC_SiteView(); |
---|
1770 | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
---|
1771 | $objMailView->assignobj($objPage); |
---|
1772 | $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]); |
---|
1773 | |
---|
1774 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
---|
1775 | $objSendMail = new GC_SendMail(); |
---|
1776 | $bcc = $arrInfo['email01']; |
---|
1777 | $from = $arrInfo['email03']; |
---|
1778 | $error = $arrInfo['email04']; |
---|
1779 | |
---|
1780 | $tosubject = sfMakeSubject($tmp_subject); |
---|
1781 | |
---|
1782 | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
---|
1783 | $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." ÍÍ"); |
---|
1784 | |
---|
1785 | |
---|
1786 | // Á÷¿®¥Õ¥é¥°:true¤Î¾ì¹ç¤Ï¡¢Á÷¿®¤¹¤ë¡£ |
---|
1787 | if($send) { |
---|
1788 | if ($objSendMail->sendMail()) { |
---|
1789 | sfSaveMailHistory($order_id, $template_id, $tosubject, $body); |
---|
1790 | } |
---|
1791 | } |
---|
1792 | |
---|
1793 | return $objSendMail; |
---|
1794 | } |
---|
1795 | |
---|
1796 | // ¥Æ¥ó¥×¥ì¡¼¥È¤ò»ÈÍѤ·¤¿¥á¡¼¥ë¤ÎÁ÷¿® |
---|
1797 | function sfSendTplMail($to, $subject, $tplpath, $objPage) { |
---|
1798 | $objMailView = new SC_SiteView(); |
---|
1799 | $objSiteInfo = new SC_SiteInfo(); |
---|
1800 | $arrInfo = $objSiteInfo->data; |
---|
1801 | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
---|
1802 | $objPage->tpl_shopname=$arrInfo['shop_name']; |
---|
1803 | $objPage->tpl_infoemail = $arrInfo['email02']; |
---|
1804 | $objMailView->assignobj($objPage); |
---|
1805 | $body = $objMailView->fetch($tplpath); |
---|
1806 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
---|
1807 | $objSendMail = new GC_SendMail(); |
---|
1808 | $to = mb_encode_mimeheader($to); |
---|
1809 | $bcc = $arrInfo['email01']; |
---|
1810 | $from = $arrInfo['email03']; |
---|
1811 | $error = $arrInfo['email04']; |
---|
1812 | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
---|
1813 | $objSendMail->sendMail(); |
---|
1814 | } |
---|
1815 | |
---|
1816 | // Ä̾ï¤Î¥á¡¼¥ëÁ÷¿® |
---|
1817 | function sfSendMail($to, $subject, $body) { |
---|
1818 | $objSiteInfo = new SC_SiteInfo(); |
---|
1819 | $arrInfo = $objSiteInfo->data; |
---|
1820 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
---|
1821 | $objSendMail = new GC_SendMail(); |
---|
1822 | $bcc = $arrInfo['email01']; |
---|
1823 | $from = $arrInfo['email03']; |
---|
1824 | $error = $arrInfo['email04']; |
---|
1825 | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
---|
1826 | $objSendMail->sendMail(); |
---|
1827 | } |
---|
1828 | |
---|
1829 | //·ï̾¤Ë¥Æ¥ó¥×¥ì¡¼¥È¤òÍѤ¤¤ë |
---|
1830 | function sfMakeSubject($subject){ |
---|
1831 | |
---|
1832 | $objQuery = new SC_Query(); |
---|
1833 | $objMailView = new SC_SiteView(); |
---|
1834 | $objPage = new LC_Page(); |
---|
1835 | |
---|
1836 | $arrInfo = $objQuery->select("*","dtb_baseinfo"); |
---|
1837 | $arrInfo = $arrInfo[0]; |
---|
1838 | $objPage->tpl_shopname=$arrInfo['shop_name']; |
---|
1839 | $objPage->tpl_infoemail=$subject; |
---|
1840 | $objMailView->assignobj($objPage); |
---|
1841 | $mailtitle = $objMailView->fetch('mail_templates/mail_title.tpl'); |
---|
1842 | $ret = $mailtitle.$subject; |
---|
1843 | return $ret; |
---|
1844 | } |
---|
1845 | |
---|
1846 | // ¥á¡¼¥ëÇÛ¿®ÍúÎò¤Ø¤ÎÅÐÏ¿ |
---|
1847 | function sfSaveMailHistory($order_id, $template_id, $subject, $body) { |
---|
1848 | $sqlval['subject'] = $subject; |
---|
1849 | $sqlval['order_id'] = $order_id; |
---|
1850 | $sqlval['template_id'] = $template_id; |
---|
1851 | $sqlval['send_date'] = "Now()"; |
---|
1852 | if($_SESSION['member_id'] != "") { |
---|
1853 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
1854 | } else { |
---|
1855 | $sqlval['creator_id'] = '0'; |
---|
1856 | } |
---|
1857 | $sqlval['mail_body'] = $body; |
---|
1858 | |
---|
1859 | $objQuery = new SC_Query(); |
---|
1860 | $objQuery->insert("dtb_mail_history", $sqlval); |
---|
1861 | } |
---|
1862 | |
---|
1863 | /* ²ñ°÷¾ðÊó¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */ |
---|
1864 | function sfGetCustomerSqlVal($uniqid, $sqlval) { |
---|
1865 | $objCustomer = new SC_Customer(); |
---|
1866 | // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý |
---|
1867 | if ($objCustomer->isLoginSuccess()) { |
---|
1868 | // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ® |
---|
1869 | $sqlval['order_temp_id'] = $uniqid; |
---|
1870 | $sqlval['update_date'] = 'Now()'; |
---|
1871 | $sqlval['customer_id'] = $objCustomer->getValue('customer_id'); |
---|
1872 | $sqlval['order_name01'] = $objCustomer->getValue('name01'); |
---|
1873 | $sqlval['order_name02'] = $objCustomer->getValue('name02'); |
---|
1874 | $sqlval['order_kana01'] = $objCustomer->getValue('kana01'); |
---|
1875 | $sqlval['order_kana02'] = $objCustomer->getValue('kana02'); |
---|
1876 | $sqlval['order_sex'] = $objCustomer->getValue('sex'); |
---|
1877 | $sqlval['order_zip01'] = $objCustomer->getValue('zip01'); |
---|
1878 | $sqlval['order_zip02'] = $objCustomer->getValue('zip02'); |
---|
1879 | $sqlval['order_pref'] = $objCustomer->getValue('pref'); |
---|
1880 | $sqlval['order_addr01'] = $objCustomer->getValue('addr01'); |
---|
1881 | $sqlval['order_addr02'] = $objCustomer->getValue('addr02'); |
---|
1882 | $sqlval['order_tel01'] = $objCustomer->getValue('tel01'); |
---|
1883 | $sqlval['order_tel02'] = $objCustomer->getValue('tel02'); |
---|
1884 | $sqlval['order_tel03'] = $objCustomer->getValue('tel03'); |
---|
1885 | if (defined('MOBILE_SITE')) { |
---|
1886 | $sqlval['order_email'] = $objCustomer->getValue('email_mobile'); |
---|
1887 | } else { |
---|
1888 | $sqlval['order_email'] = $objCustomer->getValue('email'); |
---|
1889 | } |
---|
1890 | $sqlval['order_job'] = $objCustomer->getValue('job'); |
---|
1891 | $sqlval['order_birth'] = $objCustomer->getValue('birth'); |
---|
1892 | } |
---|
1893 | return $sqlval; |
---|
1894 | } |
---|
1895 | |
---|
1896 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ø¤Î½ñ¤¹þ¤ß½èÍý |
---|
1897 | function sfRegistTempOrder($uniqid, $sqlval) { |
---|
1898 | if($uniqid != "") { |
---|
1899 | // ´û¸¥Ç¡¼¥¿¤Î¥Á¥§¥Ã¥¯ |
---|
1900 | $objQuery = new SC_Query(); |
---|
1901 | $where = "order_temp_id = ?"; |
---|
1902 | $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid)); |
---|
1903 | // ´û¸¥Ç¡¼¥¿¤¬¤Ê¤¤¾ì¹ç |
---|
1904 | if ($cnt == 0) { |
---|
1905 | // ½é²ó½ñ¤¹þ¤ß»þ¤Ë²ñ°÷¤ÎÅÐÏ¿ºÑ¤ß¾ðÊó¤ò¼è¤ê¹þ¤à |
---|
1906 | $sqlval = sfGetCustomerSqlVal($uniqid, $sqlval); |
---|
1907 | $sqlval['create_date'] = "now()"; |
---|
1908 | $objQuery->insert("dtb_order_temp", $sqlval); |
---|
1909 | } else { |
---|
1910 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); |
---|
1911 | } |
---|
1912 | } |
---|
1913 | } |
---|
1914 | |
---|
1915 | /* ²ñ°÷ÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤Î¥Á¥§¥Ã¥¯(²¾²ñ°÷¤ò´Þ¤Þ¤Ê¤¤) */ |
---|
1916 | function sfCheckCustomerMailMaga($email) { |
---|
1917 | $col = "email, mailmaga_flg, customer_id"; |
---|
1918 | $from = "dtb_customer"; |
---|
1919 | $where = "email = ? AND status = 2 AND del_flg = 0"; |
---|
1920 | $objQuery = new SC_Query(); |
---|
1921 | $arrRet = $objQuery->select($col, $from, $where, array($email)); |
---|
1922 | // ²ñ°÷¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë |
---|
1923 | if($arrRet[0]['customer_id'] != "") { |
---|
1924 | return true; |
---|
1925 | } |
---|
1926 | return false; |
---|
1927 | } |
---|
1928 | |
---|
1929 | // ¥«¡¼¥É¤Î½èÍý·ë²Ì¤òÊÖ¤¹ |
---|
1930 | function sfGetAuthonlyResult($dir, $file_name, $name01, $name02, $card_no, $card_exp, $amount, $order_id, $jpo_info = "10"){ |
---|
1931 | |
---|
1932 | $path = $dir .$file_name; // cgi¥Õ¥¡¥¤¥ë¤Î¥Õ¥ë¥Ñ¥¹À¸À® |
---|
1933 | $now_dir = getcwd(); // require¤¬¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¤Î¤Ç¡¢cgi¼Â¹Ô¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Üư¤¹¤ë |
---|
1934 | chdir($dir); |
---|
1935 | |
---|
1936 | // ¥Ñ¥¤¥×ÅϤ·¤Ç¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤écgiµ¯Æ° |
---|
1937 | $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info"; |
---|
1938 | |
---|
1939 | $tmpResult = popen($cmd, "r"); |
---|
1940 | |
---|
1941 | // ·ë²Ì¼èÆÀ |
---|
1942 | while( ! FEOF ( $tmpResult ) ) { |
---|
1943 | $result .= FGETS($tmpResult); |
---|
1944 | } |
---|
1945 | pclose($tmpResult); // ¥Ñ¥¤¥×¤òÊĤ¸¤ë |
---|
1946 | chdir($now_dir); //¡¡¸µ¤Ë¤¤¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ëµ¢¤ë |
---|
1947 | |
---|
1948 | // ·ë²Ì¤òÏ¢ÁÛÇÛÎ󤨳ÊǼ |
---|
1949 | $result = ereg_replace("&$", "", $result); |
---|
1950 | foreach (explode("&",$result) as $data) { |
---|
1951 | list($key, $val) = explode("=", $data, 2); |
---|
1952 | $return[$key] = $val; |
---|
1953 | } |
---|
1954 | |
---|
1955 | return $return; |
---|
1956 | } |
---|
1957 | |
---|
1958 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤«¤é¾ðÊó¤ò¼èÆÀ¤¹¤ë |
---|
1959 | function sfGetOrderTemp($order_temp_id) { |
---|
1960 | $objQuery = new SC_Query(); |
---|
1961 | $where = "order_temp_id = ?"; |
---|
1962 | $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id)); |
---|
1963 | return $arrRet[0]; |
---|
1964 | } |
---|
1965 | |
---|
1966 | // ¥«¥Æ¥´¥êID¼èÆÀȽÄêÍѤΥ°¥í¡¼¥Ð¥ëÊÑ¿ô(°ìÅÙ¼èÆÀ¤µ¤ì¤Æ¤¤¤¿¤éºÆ¼èÆÀ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë) |
---|
1967 | $g_category_on = false; |
---|
1968 | $g_category_id = ""; |
---|
1969 | |
---|
1970 | /* ÁªÂòÃæ¤Î¥«¥Æ¥´¥ê¤ò¼èÆÀ¤¹¤ë */ |
---|
1971 | function sfGetCategoryId($product_id, $category_id) { |
---|
1972 | global $g_category_on; |
---|
1973 | global $g_category_id; |
---|
1974 | if(!$g_category_on) { |
---|
1975 | $g_category_on = true; |
---|
1976 | $category_id = (int) $category_id; |
---|
1977 | $product_id = (int) $product_id; |
---|
1978 | if(sfIsInt($category_id) && sfIsRecord("dtb_category","category_id", $category_id)) { |
---|
1979 | $g_category_id = $category_id; |
---|
1980 | } else if (sfIsInt($product_id) && sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { |
---|
1981 | $objQuery = new SC_Query(); |
---|
1982 | $where = "product_id = ?"; |
---|
1983 | $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id)); |
---|
1984 | $g_category_id = $category_id; |
---|
1985 | } else { |
---|
1986 | // ÉÔÀµ¤Ê¾ì¹ç¤Ï¡¢0¤òÊÖ¤¹¡£ |
---|
1987 | $g_category_id = 0; |
---|
1988 | } |
---|
1989 | } |
---|
1990 | return $g_category_id; |
---|
1991 | } |
---|
1992 | |
---|
1993 | // ROOTID¼èÆÀȽÄêÍѤΥ°¥í¡¼¥Ð¥ëÊÑ¿ô(°ìÅÙ¼èÆÀ¤µ¤ì¤Æ¤¤¤¿¤éºÆ¼èÆÀ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë) |
---|
1994 | $g_root_on = false; |
---|
1995 | $g_root_id = ""; |
---|
1996 | |
---|
1997 | /* ÁªÂòÃæ¤Î¥¢¥¤¥Æ¥à¤Î¥ë¡¼¥È¥«¥Æ¥´¥êID¤ò¼èÆÀ¤¹¤ë */ |
---|
1998 | function sfGetRootId() { |
---|
1999 | global $g_root_on; |
---|
2000 | global $g_root_id; |
---|
2001 | if(!$g_root_on) { |
---|
2002 | $g_root_on = true; |
---|
2003 | $objQuery = new SC_Query(); |
---|
2004 | if($_GET['product_id'] != "" || $_GET['category_id'] != "") { |
---|
2005 | // ÁªÂòÃæ¤Î¥«¥Æ¥´¥êID¤òȽÄꤹ¤ë |
---|
2006 | $category_id = sfGetCategoryId($_GET['product_id'], $_GET['category_id']); |
---|
2007 | // ROOT¥«¥Æ¥´¥êID¤Î¼èÆÀ |
---|
2008 | $arrRet = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); |
---|
2009 | $root_id = $arrRet[0]; |
---|
2010 | } else { |
---|
2011 | // ROOT¥«¥Æ¥´¥êID¤ò¤Ê¤·¤ËÀßÄꤹ¤ë |
---|
2012 | $root_id = ""; |
---|
2013 | } |
---|
2014 | $g_root_id = $root_id; |
---|
2015 | } |
---|
2016 | return $g_root_id; |
---|
2017 | } |
---|
2018 | |
---|
2019 | /* ¥«¥Æ¥´¥ê¤«¤é¾¦Éʤò¸¡º÷¤¹¤ë¾ì¹ç¤ÎWHEREʸ¤ÈÃͤòÊÖ¤¹ */ |
---|
2020 | function sfGetCatWhere($category_id) { |
---|
2021 | // »Ò¥«¥Æ¥´¥êID¤Î¼èÆÀ |
---|
2022 | $arrRet = sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id); |
---|
2023 | $tmp_where = ""; |
---|
2024 | foreach ($arrRet as $val) { |
---|
2025 | if($tmp_where == "") { |
---|
2026 | $tmp_where.= " category_id IN ( ?"; |
---|
2027 | } else { |
---|
2028 | $tmp_where.= ",? "; |
---|
2029 | } |
---|
2030 | $arrval[] = $val; |
---|
2031 | } |
---|
2032 | $tmp_where.= " ) "; |
---|
2033 | return array($tmp_where, $arrval); |
---|
2034 | } |
---|
2035 | |
---|
2036 | /* ²Ã»»¥Ý¥¤¥ó¥È¤Î·×»»¼° */ |
---|
2037 | function sfGetAddPoint($totalpoint, $use_point, $arrInfo) { |
---|
2038 | // ¹ØÆþ¾¦Éʤιç·×¥Ý¥¤¥ó¥È¤«¤éÍøÍѤ·¤¿¥Ý¥¤¥ó¥È¤Î¥Ý¥¤¥ó¥È´¹»»²ÁÃͤò°ú¤¯Êý¼° |
---|
2039 | $add_point = $totalpoint - intval($use_point * ($arrInfo['point_rate'] / 100)); |
---|
2040 | |
---|
2041 | if($add_point < 0) { |
---|
2042 | $add_point = '0'; |
---|
2043 | } |
---|
2044 | return $add_point; |
---|
2045 | } |
---|
2046 | |
---|
2047 | /* °ì°Õ¤«¤Äͽ¬¤µ¤ì¤Ë¤¯¤¤ID */ |
---|
2048 | function sfGetUniqRandomId($head = "") { |
---|
2049 | // ͽ¬¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¥é¥ó¥À¥àʸ»úÎó¤òÉÕÍ¿¤¹¤ë¡£ |
---|
2050 | $random = gfMakePassword(8); |
---|
2051 | // Ʊ°ì¥Û¥¹¥ÈÆâ¤Ç°ì°Õ¤ÊID¤òÀ¸À® |
---|
2052 | $id = uniqid($head); |
---|
2053 | return ($id . $random); |
---|
2054 | } |
---|
2055 | |
---|
2056 | // ¥«¥Æ¥´¥êÊÌ¥ª¥¹¥¹¥áÉʤμèÆÀ |
---|
2057 | function sfGetBestProducts( $conn, $category_id = 0){ |
---|
2058 | // ´û¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÆâÍÆ¤ò¼èÆÀ¤¹¤ë |
---|
2059 | $sql = "SELECT name, main_image, main_list_image, price01_min, price01_max, price02_min, price02_max, point_rate, |
---|
2060 | A.product_id, A.comment FROM dtb_best_products as A LEFT JOIN vw_products_allclass AS allcls |
---|
2061 | USING (product_id) WHERE A.category_id = ? AND A.del_flg = 0 AND status = 1 ORDER BY A.rank"; |
---|
2062 | $arrItems = $conn->getAll($sql, array($category_id)); |
---|
2063 | |
---|
2064 | return $arrItems; |
---|
2065 | } |
---|
2066 | |
---|
2067 | // ÆÃ¼ìÀ©¸æÊ¸»ú¤Î¼êư¥¨¥¹¥±¡¼¥× |
---|
2068 | function sfManualEscape($data) { |
---|
2069 | // ÇÛÎó¤Ç¤Ê¤¤¾ì¹ç |
---|
2070 | if(!is_array($data)) { |
---|
2071 | if (DB_TYPE == "pgsql") { |
---|
2072 | $ret = pg_escape_string($data); |
---|
2073 | }else if(DB_TYPE == "mysql"){ |
---|
2074 | $ret = mysql_real_escape_string($data); |
---|
2075 | } |
---|
2076 | $ret = ereg_replace("%", "\\%", $ret); |
---|
2077 | $ret = ereg_replace("_", "\\_", $ret); |
---|
2078 | return $ret; |
---|
2079 | } |
---|
2080 | |
---|
2081 | // ÇÛÎó¤Î¾ì¹ç |
---|
2082 | foreach($data as $val) { |
---|
2083 | if (DB_TYPE == "pgsql") { |
---|
2084 | $ret = pg_escape_string($val); |
---|
2085 | }else if(DB_TYPE == "mysql"){ |
---|
2086 | $ret = mysql_real_escape_string($val); |
---|
2087 | } |
---|
2088 | |
---|
2089 | $ret = ereg_replace("%", "\\%", $ret); |
---|
2090 | $ret = ereg_replace("_", "\\_", $ret); |
---|
2091 | $arrRet[] = $ret; |
---|
2092 | } |
---|
2093 | |
---|
2094 | return $arrRet; |
---|
2095 | } |
---|
2096 | |
---|
2097 | // ¼õÃíÈÖ¹æ¡¢ÍøÍѥݥ¤¥ó¥È¡¢²Ã»»¥Ý¥¤¥ó¥È¤«¤éºÇ½ª¥Ý¥¤¥ó¥È¤ò¼èÆÀ |
---|
2098 | function sfGetCustomerPoint($order_id, $use_point, $add_point) { |
---|
2099 | $objQuery = new SC_Query(); |
---|
2100 | $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); |
---|
2101 | $customer_id = $arrRet[0]['customer_id']; |
---|
2102 | if($customer_id != "" && $customer_id >= 1) { |
---|
2103 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
---|
2104 | $point = $arrRet[0]['point']; |
---|
2105 | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
---|
2106 | } else { |
---|
2107 | $total_point = ""; |
---|
2108 | $point = ""; |
---|
2109 | } |
---|
2110 | return array($point, $total_point); |
---|
2111 | } |
---|
2112 | |
---|
2113 | /* ¥É¥á¥¤¥ó´Ö¤Ç͸ú¤Ê¥»¥Ã¥·¥ç¥ó¤Î¥¹¥¿¡¼¥È */ |
---|
2114 | function sfDomainSessionStart() { |
---|
2115 | $ret = session_id(); |
---|
2116 | /* |
---|
2117 | ¥Ø¥Ã¥À¡¼¤òÁ÷¿®¤·¤Æ¤¤¤Æ¤âsession_start()¤¬É¬Íפʥڡ¼¥¸¤¬¤¢¤ë¤Î¤Ç |
---|
2118 | ¥³¥á¥ó¥È¥¢¥¦¥È¤·¤Æ¤ª¤¯ |
---|
2119 | if($ret == "" && !headers_sent()) { |
---|
2120 | */ |
---|
2121 | if($ret == "") { |
---|
2122 | /* ¥»¥Ã¥·¥ç¥ó¥Ñ¥é¥á¡¼¥¿¤Î»ØÄê |
---|
2123 | ¡¦¥Ö¥é¥¦¥¶¤òÊĤ¸¤ë¤Þ¤Ç͸ú |
---|
2124 | ¡¦¤¹¤Ù¤Æ¤Î¥Ñ¥¹¤Ç͸ú |
---|
2125 | ¡¦Æ±¤¸¥É¥á¥¤¥ó´Ö¤Ç¶¦Í */ |
---|
2126 | session_set_cookie_params (0, "/", DOMAIN_NAME); |
---|
2127 | |
---|
2128 | if(!ini_get("session.auto_start")){ |
---|
2129 | // ¥»¥Ã¥·¥ç¥ó³«»Ï |
---|
2130 | session_start(); |
---|
2131 | } |
---|
2132 | } |
---|
2133 | } |
---|
2134 | |
---|
2135 | /* ʸ»úÎó¤Ë¶¯À©Åª¤Ë²þ¹Ô¤òÆþ¤ì¤ë */ |
---|
2136 | function sfPutBR($str, $size) { |
---|
2137 | $i = 0; |
---|
2138 | $cnt = 0; |
---|
2139 | $line = array(); |
---|
2140 | $ret = ""; |
---|
2141 | |
---|
2142 | while($str[$i] != "") { |
---|
2143 | $line[$cnt].=$str[$i]; |
---|
2144 | $i++; |
---|
2145 | if(strlen($line[$cnt]) > $size) { |
---|
2146 | $line[$cnt].="<br />"; |
---|
2147 | $cnt++; |
---|
2148 | } |
---|
2149 | } |
---|
2150 | |
---|
2151 | foreach($line as $val) { |
---|
2152 | $ret.=$val; |
---|
2153 | } |
---|
2154 | return $ret; |
---|
2155 | } |
---|
2156 | |
---|
2157 | // Æó²ó°Ê¾å·«¤êÊÖ¤µ¤ì¤Æ¤¤¤ë¥¹¥é¥Ã¥·¥å[/]¤ò°ì¤Ä¤ËÊÑ´¹¤¹¤ë¡£ |
---|
2158 | function sfRmDupSlash($istr){ |
---|
2159 | if(ereg("^http://", $istr)) { |
---|
2160 | $str = substr($istr, 7); |
---|
2161 | $head = "http://"; |
---|
2162 | } else if(ereg("^https://", $istr)) { |
---|
2163 | $str = substr($istr, 8); |
---|
2164 | $head = "https://"; |
---|
2165 | } else { |
---|
2166 | $str = $istr; |
---|
2167 | } |
---|
2168 | $str = ereg_replace("[/]+", "/", $str); |
---|
2169 | $ret = $head . $str; |
---|
2170 | return $ret; |
---|
2171 | } |
---|
2172 | |
---|
2173 | function sfEncodeFile($filepath, $enc_type, $out_dir) { |
---|
2174 | $ifp = fopen($filepath, "r"); |
---|
2175 | |
---|
2176 | $basename = basename($filepath); |
---|
2177 | $outpath = $out_dir . "enc_" . $basename; |
---|
2178 | |
---|
2179 | $ofp = fopen($outpath, "w+"); |
---|
2180 | |
---|
2181 | while(!feof($ifp)) { |
---|
2182 | $line = fgets($ifp); |
---|
2183 | $line = mb_convert_encoding($line, $enc_type, "auto"); |
---|
2184 | fwrite($ofp, $line); |
---|
2185 | } |
---|
2186 | |
---|
2187 | fclose($ofp); |
---|
2188 | fclose($ifp); |
---|
2189 | |
---|
2190 | return $outpath; |
---|
2191 | } |
---|
2192 | |
---|
2193 | function sfCutString($str, $len, $byte = true, $commadisp = true) { |
---|
2194 | if($byte) { |
---|
2195 | if(strlen($str) > ($len + 2)) { |
---|
2196 | $ret =substr($str, 0, $len); |
---|
2197 | $cut = substr($str, $len); |
---|
2198 | } else { |
---|
2199 | $ret = $str; |
---|
2200 | $commadisp = false; |
---|
2201 | } |
---|
2202 | } else { |
---|
2203 | if(mb_strlen($str) > ($len + 1)) { |
---|
2204 | $ret = mb_substr($str, 0, $len); |
---|
2205 | $cut = mb_substr($str, $len); |
---|
2206 | } else { |
---|
2207 | $ret = $str; |
---|
2208 | $commadisp = false; |
---|
2209 | } |
---|
2210 | } |
---|
2211 | |
---|
2212 | // ³¨Ê¸»ú¥¿¥°¤ÎÅÓÃæ¤ÇʬÃǤµ¤ì¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£ |
---|
2213 | if (isset($cut)) { |
---|
2214 | // ʬ³ä°ÌÃÖ¤è¤êÁ°¤ÎºÇ¸å¤Î [ °Ê¹ß¤ò¼èÆÀ¤¹¤ë¡£ |
---|
2215 | $head = strrchr($ret, '['); |
---|
2216 | |
---|
2217 | // ʬ³ä°ÌÃÖ¤è¤ê¸å¤ÎºÇ½é¤Î ] °ÊÁ°¤ò¼èÆÀ¤¹¤ë¡£ |
---|
2218 | $tail_pos = strpos($cut, ']'); |
---|
2219 | if ($tail_pos !== false) { |
---|
2220 | $tail = substr($cut, 0, $tail_pos + 1); |
---|
2221 | } |
---|
2222 | |
---|
2223 | // ʬ³ä°ÌÃÖ¤è¤êÁ°¤Ë [¡¢¸å¤Ë ] ¤¬¸«¤Ä¤«¤Ã¤¿¾ì¹ç¤Ï¡¢[ ¤«¤é ] ¤Þ¤Ç¤ò |
---|
2224 | // Àܳ¤·¤Æ³¨Ê¸»ú¥¿¥°1¸Äʬ¤Ë¤Ê¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£ |
---|
2225 | if ($head !== false && $tail_pos !== false) { |
---|
2226 | $subject = $head . $tail; |
---|
2227 | if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) { |
---|
2228 | // ³¨Ê¸»ú¥¿¥°¤¬¸«¤Ä¤«¤Ã¤¿¤Î¤Çºï½ü¤¹¤ë¡£ |
---|
2229 | $ret = substr($ret, 0, -strlen($head)); |
---|
2230 | } |
---|
2231 | } |
---|
2232 | } |
---|
2233 | |
---|
2234 | if($commadisp){ |
---|
2235 | $ret = $ret . "..."; |
---|
2236 | } |
---|
2237 | return $ret; |
---|
2238 | } |
---|
2239 | |
---|
2240 | // ǯ¡¢·î¡¢Äù¤áÆü¤«¤é¡¢Àè·î¤ÎÄù¤áÆü+1¡¢º£·î¤ÎÄù¤áÆü¤òµá¤á¤ë¡£ |
---|
2241 | function sfTermMonth($year, $month, $close_day) { |
---|
2242 | $end_year = $year; |
---|
2243 | $end_month = $month; |
---|
2244 | |
---|
2245 | // ³«»Ï·î¤¬½ªÎ»·î¤ÈƱ¤¸¤«Èݤ« |
---|
2246 | $same_month = false; |
---|
2247 | |
---|
2248 | // ³ºÅö·î¤ÎËöÆü¤òµá¤á¤ë¡£ |
---|
2249 | $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year)); |
---|
2250 | |
---|
2251 | // ·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç |
---|
2252 | if($end_last_day < $close_day) { |
---|
2253 | // Äù¤áÆü¤ò·îËöÆü¤Ë¹ç¤ï¤»¤ë |
---|
2254 | $end_day = $end_last_day; |
---|
2255 | } else { |
---|
2256 | $end_day = $close_day; |
---|
2257 | } |
---|
2258 | |
---|
2259 | // Á°·î¤Î¼èÆÀ |
---|
2260 | $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year)); |
---|
2261 | $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year)); |
---|
2262 | // Á°·î¤ÎËöÆü¤òµá¤á¤ë¡£ |
---|
2263 | $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year)); |
---|
2264 | |
---|
2265 | // Á°·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç |
---|
2266 | if ($start_last_day < $close_day) { |
---|
2267 | // ·îËöÆü¤Ë¹ç¤ï¤»¤ë |
---|
2268 | $tmp_day = $start_last_day; |
---|
2269 | } else { |
---|
2270 | $tmp_day = $close_day; |
---|
2271 | } |
---|
2272 | |
---|
2273 | // Àè·î¤ÎËöÆü¤ÎÍâÆü¤ò¼èÆÀ¤¹¤ë |
---|
2274 | $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
---|
2275 | $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
---|
2276 | $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
---|
2277 | |
---|
2278 | // ÆüÉդκîÀ® |
---|
2279 | $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day); |
---|
2280 | $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day); |
---|
2281 | |
---|
2282 | return array($start_date, $end_date); |
---|
2283 | } |
---|
2284 | |
---|
2285 | // PDFÍѤÎRGB¥«¥é¡¼¤òÊÖ¤¹ |
---|
2286 | function sfGetPdfRgb($hexrgb) { |
---|
2287 | $hex = substr($hexrgb, 0, 2); |
---|
2288 | $r = hexdec($hex) / 255; |
---|
2289 | |
---|
2290 | $hex = substr($hexrgb, 2, 2); |
---|
2291 | $g = hexdec($hex) / 255; |
---|
2292 | |
---|
2293 | $hex = substr($hexrgb, 4, 2); |
---|
2294 | $b = hexdec($hex) / 255; |
---|
2295 | |
---|
2296 | return array($r, $g, $b); |
---|
2297 | } |
---|
2298 | |
---|
2299 | //¥á¥ë¥Þ¥¬²¾ÅÐÏ¿¤È¥á¡¼¥ëÇÛ¿® |
---|
2300 | function sfRegistTmpMailData($mail_flag, $email){ |
---|
2301 | $objQuery = new SC_Query(); |
---|
2302 | $objConn = new SC_DBConn(); |
---|
2303 | $objPage = new LC_Page(); |
---|
2304 | |
---|
2305 | $random_id = sfGetUniqRandomId(); |
---|
2306 | $arrRegistMailMagazine["mail_flag"] = $mail_flag; |
---|
2307 | $arrRegistMailMagazine["email"] = $email; |
---|
2308 | $arrRegistMailMagazine["temp_id"] =$random_id; |
---|
2309 | $arrRegistMailMagazine["end_flag"]='0'; |
---|
2310 | $arrRegistMailMagazine["update_date"] = 'now()'; |
---|
2311 | |
---|
2312 | //¥á¥ë¥Þ¥¬²¾ÅÐÏ¿Íѥե饰 |
---|
2313 | $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email)); |
---|
2314 | $objConn->query("BEGIN"); |
---|
2315 | switch ($flag){ |
---|
2316 | case '0': |
---|
2317 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine); |
---|
2318 | break; |
---|
2319 | |
---|
2320 | case '1': |
---|
2321 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = '" .addslashes($email). "'"); |
---|
2322 | break; |
---|
2323 | } |
---|
2324 | $objConn->query("COMMIT"); |
---|
2325 | $subject = sfMakeSubject('¥á¥ë¥Þ¥¬²¾ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£'); |
---|
2326 | $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id']; |
---|
2327 | switch ($mail_flag){ |
---|
2328 | case '1': |
---|
2329 | $objPage->tpl_name = "ÅÐÏ¿"; |
---|
2330 | $objPage->tpl_kindname = "HTML"; |
---|
2331 | break; |
---|
2332 | |
---|
2333 | case '2': |
---|
2334 | $objPage->tpl_name = "ÅÐÏ¿"; |
---|
2335 | $objPage->tpl_kindname = "¥Æ¥¥¹¥È"; |
---|
2336 | break; |
---|
2337 | |
---|
2338 | case '3': |
---|
2339 | $objPage->tpl_name = "²ò½ü"; |
---|
2340 | break; |
---|
2341 | } |
---|
2342 | $objPage->tpl_email = $email; |
---|
2343 | sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage); |
---|
2344 | } |
---|
2345 | |
---|
2346 | // ºÆµ¢Åª¤Ë¿ÃÊÇÛÎó¤ò¸¡º÷¤·¤Æ°ì¼¡¸µÇÛÎó(Hidden°úÅϤ·ÍÑÇÛÎó)¤ËÊÑ´¹¤¹¤ë¡£ |
---|
2347 | function sfMakeHiddenArray($arrSrc, $arrDst = array(), $parent_key = "") { |
---|
2348 | if(is_array($arrSrc)) { |
---|
2349 | foreach($arrSrc as $key => $val) { |
---|
2350 | if($parent_key != "") { |
---|
2351 | $keyname = $parent_key . "[". $key . "]"; |
---|
2352 | } else { |
---|
2353 | $keyname = $key; |
---|
2354 | } |
---|
2355 | if(is_array($val)) { |
---|
2356 | $arrDst = sfMakeHiddenArray($val, $arrDst, $keyname); |
---|
2357 | } else { |
---|
2358 | $arrDst[$keyname] = $val; |
---|
2359 | } |
---|
2360 | } |
---|
2361 | } |
---|
2362 | return $arrDst; |
---|
2363 | } |
---|
2364 | |
---|
2365 | // DB¼èÆÀÆü»þ¤ò¥¿¥¤¥à¤ËÊÑ´¹ |
---|
2366 | function sfDBDatetoTime($db_date) { |
---|
2367 | $date = ereg_replace("\..*$","",$db_date); |
---|
2368 | $time = strtotime($date); |
---|
2369 | return $time; |
---|
2370 | } |
---|
2371 | |
---|
2372 | // ½ÐÎϤκݤ˥ƥó¥×¥ì¡¼¥È¤òÀÚ¤êÂØ¤¨¤é¤ì¤ë |
---|
2373 | /* |
---|
2374 | index.php?tpl=test.tpl |
---|
2375 | */ |
---|
2376 | function sfCustomDisplay($objPage, $is_mobile = false) { |
---|
2377 | $basename = basename($_SERVER["REQUEST_URI"]); |
---|
2378 | |
---|
2379 | if($basename == "") { |
---|
2380 | $path = $_SERVER["REQUEST_URI"] . "index.php"; |
---|
2381 | } else { |
---|
2382 | $path = $_SERVER["REQUEST_URI"]; |
---|
2383 | } |
---|
2384 | |
---|
2385 | if($_GET['tpl'] != "") { |
---|
2386 | $tpl_name = $_GET['tpl']; |
---|
2387 | } else { |
---|
2388 | $tpl_name = ereg_replace("^/", "", $path); |
---|
2389 | $tpl_name = ereg_replace("/", "_", $tpl_name); |
---|
2390 | $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name); |
---|
2391 | } |
---|
2392 | |
---|
2393 | $template_path = TEMPLATE_FTP_DIR . $tpl_name; |
---|
2394 | |
---|
2395 | if($is_mobile === true) { |
---|
2396 | $objView = new SC_MobileView(); |
---|
2397 | $objView->assignobj($objPage); |
---|
2398 | $objView->display(SITE_FRAME); |
---|
2399 | } else if(file_exists($template_path)) { |
---|
2400 | $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR); |
---|
2401 | $objView->assignobj($objPage); |
---|
2402 | $objView->display($tpl_name); |
---|
2403 | } else { |
---|
2404 | $objView = new SC_SiteView(); |
---|
2405 | $objView->assignobj($objPage); |
---|
2406 | $objView->display(SITE_FRAME); |
---|
2407 | } |
---|
2408 | } |
---|
2409 | |
---|
2410 | //²ñ°÷ÊÔ½¸ÅÐÏ¿½èÍý |
---|
2411 | function sfEditCustomerData($array, $arrRegistColumn) { |
---|
2412 | $objQuery = new SC_Query(); |
---|
2413 | |
---|
2414 | foreach ($arrRegistColumn as $data) { |
---|
2415 | if ($data["column"] != "password") { |
---|
2416 | if($array[ $data['column'] ] != "") { |
---|
2417 | $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; |
---|
2418 | } else { |
---|
2419 | $arrRegist[ $data['column'] ] = NULL; |
---|
2420 | } |
---|
2421 | } |
---|
2422 | } |
---|
2423 | if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) { |
---|
2424 | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
---|
2425 | } else { |
---|
2426 | $arrRegist["birth"] = NULL; |
---|
2427 | } |
---|
2428 | |
---|
2429 | //-- ¥Ñ¥¹¥ï¡¼¥É¤Î¹¹¿·¤¬¤¢¤ë¾ì¹ç¤Ï°Å¹æ²½¡£¡Ê¹¹¿·¤¬¤Ê¤¤¾ì¹ç¤ÏUPDATEʸ¤ò¹½À®¤·¤Ê¤¤¡Ë |
---|
2430 | if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
---|
2431 | $arrRegist["update_date"] = "NOW()"; |
---|
2432 | |
---|
2433 | //-- ÊÔ½¸ÅÐÏ¿¼Â¹Ô |
---|
2434 | if (defined('MOBILE_SITE')) { |
---|
2435 | $arrRegist['email_mobile'] = $arrRegist['email']; |
---|
2436 | unset($arrRegist['email']); |
---|
2437 | } |
---|
2438 | $objQuery->begin(); |
---|
2439 | $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id'])); |
---|
2440 | $objQuery->commit(); |
---|
2441 | } |
---|
2442 | |
---|
2443 | // PHP¤Îmb_convert_encoding´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë |
---|
2444 | function sf_mb_convert_encoding($str, $encode = 'CHAR_CODE') { |
---|
2445 | return mb_convert_encoding($str, $encode); |
---|
2446 | } |
---|
2447 | |
---|
2448 | // PHP¤Îmktime´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë |
---|
2449 | function sf_mktime($format, $hour=0, $minute=0, $second=0, $month=1, $day=1, $year=1999) { |
---|
2450 | return date($format,mktime($hour, $minute, $second, $month, $day, $year)); |
---|
2451 | } |
---|
2452 | |
---|
2453 | // PHP¤Îdate´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë |
---|
2454 | function sf_date($format, $timestamp = '') { |
---|
2455 | return date( $format, $timestamp); |
---|
2456 | } |
---|
2457 | |
---|
2458 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤Î·¿¤òÊÑ´¹¤¹¤ë |
---|
2459 | function sfChangeCheckBox($data , $tpl = false){ |
---|
2460 | if ($tpl) { |
---|
2461 | if ($data == 1){ |
---|
2462 | return 'checked'; |
---|
2463 | }else{ |
---|
2464 | return ""; |
---|
2465 | } |
---|
2466 | }else{ |
---|
2467 | if ($data == "on"){ |
---|
2468 | return 1; |
---|
2469 | }else{ |
---|
2470 | return 2; |
---|
2471 | } |
---|
2472 | } |
---|
2473 | } |
---|
2474 | |
---|
2475 | function sfCategory_Count($objQuery){ |
---|
2476 | $sql = ""; |
---|
2477 | |
---|
2478 | //¥Æ¡¼¥Ö¥ëÆâÍÆ¤Îºï½ü |
---|
2479 | $objQuery->query("DELETE FROM dtb_category_count"); |
---|
2480 | $objQuery->query("DELETE FROM dtb_category_total_count"); |
---|
2481 | |
---|
2482 | //³Æ¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò¿ô¤¨¤Æ³ÊǼ |
---|
2483 | $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) "; |
---|
2484 | $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 "; |
---|
2485 | $sql .= " ON T1.category_id = T2.category_id "; |
---|
2486 | $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; |
---|
2487 | $sql .= " GROUP BY T1.category_id, T2.category_id "; |
---|
2488 | $objQuery->query($sql); |
---|
2489 | |
---|
2490 | //»Ò¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò½¸·×¤¹¤ë |
---|
2491 | $arrCat = $objQuery->getAll("SELECT * FROM dtb_category"); |
---|
2492 | |
---|
2493 | $sql = ""; |
---|
2494 | foreach($arrCat as $key => $val){ |
---|
2495 | |
---|
2496 | // »ÒID°ìÍ÷¤ò¼èÆÀ |
---|
2497 | $arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']); |
---|
2498 | $line = sfGetCommaList($arrRet); |
---|
2499 | |
---|
2500 | $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) "; |
---|
2501 | $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count "; |
---|
2502 | $sql .= " WHERE category_id IN (" . $line . ")"; |
---|
2503 | |
---|
2504 | $objQuery->query($sql, array($val['category_id'])); |
---|
2505 | } |
---|
2506 | } |
---|
2507 | |
---|
2508 | // 2¤Ä¤ÎÇÛÎó¤òÍѤ¤¤ÆÏ¢ÁÛÇÛÎó¤òºîÀ®¤¹¤ë |
---|
2509 | function sfarrCombine($arrKeys, $arrValues) { |
---|
2510 | |
---|
2511 | if(count($arrKeys) <= 0 and count($arrValues) <= 0) return array(); |
---|
2512 | |
---|
2513 | $keys = array_values($arrKeys); |
---|
2514 | $vals = array_values($arrValues); |
---|
2515 | |
---|
2516 | $max = max( count( $keys ), count( $vals ) ); |
---|
2517 | $combine_ary = array(); |
---|
2518 | for($i=0; $i<$max; $i++) { |
---|
2519 | $combine_ary[$keys[$i]] = $vals[$i]; |
---|
2520 | } |
---|
2521 | if(is_array($combine_ary)) return $combine_ary; |
---|
2522 | |
---|
2523 | return false; |
---|
2524 | } |
---|
2525 | |
---|
2526 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤é»ÒIDÇÛÎó¤ò¼èÆÀ¤¹¤ë */ |
---|
2527 | function sfGetChildrenArray($table, $pid_name, $id_name, $id) { |
---|
2528 | $objQuery = new SC_Query(); |
---|
2529 | $col = $pid_name . "," . $id_name; |
---|
2530 | $arrData = $objQuery->select($col, $table); |
---|
2531 | |
---|
2532 | $arrPID = array(); |
---|
2533 | $arrPID[] = $id; |
---|
2534 | $arrChildren = array(); |
---|
2535 | $arrChildren[] = $id; |
---|
2536 | |
---|
2537 | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); |
---|
2538 | |
---|
2539 | while(count($arrRet) > 0) { |
---|
2540 | $arrChildren = array_merge($arrChildren, $arrRet); |
---|
2541 | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); |
---|
2542 | } |
---|
2543 | |
---|
2544 | return $arrChildren; |
---|
2545 | } |
---|
2546 | |
---|
2547 | /* ¿ÆIDľ²¼¤Î»ÒID¤ò¤¹¤Ù¤Æ¼èÆÀ¤¹¤ë */ |
---|
2548 | function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) { |
---|
2549 | $arrChildren = array(); |
---|
2550 | $max = count($arrData); |
---|
2551 | |
---|
2552 | for($i = 0; $i < $max; $i++) { |
---|
2553 | foreach($arrPID as $val) { |
---|
2554 | if($arrData[$i][$pid_name] == $val) { |
---|
2555 | $arrChildren[] = $arrData[$i][$id_name]; |
---|
2556 | } |
---|
2557 | } |
---|
2558 | } |
---|
2559 | return $arrChildren; |
---|
2560 | } |
---|
2561 | |
---|
2562 | |
---|
2563 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤é¿ÆIDÇÛÎó¤ò¼èÆÀ¤¹¤ë */ |
---|
2564 | function sfGetParentsArray($table, $pid_name, $id_name, $id) { |
---|
2565 | $objQuery = new SC_Query(); |
---|
2566 | $col = $pid_name . "," . $id_name; |
---|
2567 | $arrData = $objQuery->select($col, $table); |
---|
2568 | |
---|
2569 | $arrParents = array(); |
---|
2570 | $arrParents[] = $id; |
---|
2571 | $child = $id; |
---|
2572 | |
---|
2573 | $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $child); |
---|
2574 | |
---|
2575 | while($ret != "") { |
---|
2576 | $arrParents[] = $ret; |
---|
2577 | $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret); |
---|
2578 | } |
---|
2579 | |
---|
2580 | $arrParents = array_reverse($arrParents); |
---|
2581 | |
---|
2582 | return $arrParents; |
---|
2583 | } |
---|
2584 | |
---|
2585 | /* »ÒID½ê°¤¹¤ë¿ÆID¤ò¼èÆÀ¤¹¤ë */ |
---|
2586 | function sfGetParentsArraySub($arrData, $pid_name, $id_name, $child) { |
---|
2587 | $max = count($arrData); |
---|
2588 | $parent = ""; |
---|
2589 | for($i = 0; $i < $max; $i++) { |
---|
2590 | if($arrData[$i][$id_name] == $child) { |
---|
2591 | $parent = $arrData[$i][$pid_name]; |
---|
2592 | break; |
---|
2593 | } |
---|
2594 | } |
---|
2595 | return $parent; |
---|
2596 | } |
---|
2597 | |
---|
2598 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤éÍ¿¤¨¤é¤ì¤¿ID¤Î·»Äï¤ò¼èÆÀ¤¹¤ë */ |
---|
2599 | function sfGetBrothersArray($arrData, $pid_name, $id_name, $arrPID) { |
---|
2600 | $max = count($arrData); |
---|
2601 | |
---|
2602 | $arrBrothers = array(); |
---|
2603 | foreach($arrPID as $id) { |
---|
2604 | // ¿ÆID¤ò¸¡º÷¤¹¤ë |
---|
2605 | for($i = 0; $i < $max; $i++) { |
---|
2606 | if($arrData[$i][$id_name] == $id) { |
---|
2607 | $parent = $arrData[$i][$pid_name]; |
---|
2608 | break; |
---|
2609 | } |
---|
2610 | } |
---|
2611 | // ·»ÄïID¤ò¸¡º÷¤¹¤ë |
---|
2612 | for($i = 0; $i < $max; $i++) { |
---|
2613 | if($arrData[$i][$pid_name] == $parent) { |
---|
2614 | $arrBrothers[] = $arrData[$i][$id_name]; |
---|
2615 | } |
---|
2616 | } |
---|
2617 | } |
---|
2618 | return $arrBrothers; |
---|
2619 | } |
---|
2620 | |
---|
2621 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤éÍ¿¤¨¤é¤ì¤¿ID¤Îľ°¤Î»Ò¤ò¼èÆÀ¤¹¤ë */ |
---|
2622 | function sfGetUnderChildrenArray($arrData, $pid_name, $id_name, $parent) { |
---|
2623 | $max = count($arrData); |
---|
2624 | |
---|
2625 | $arrChildren = array(); |
---|
2626 | // »ÒID¤ò¸¡º÷¤¹¤ë |
---|
2627 | for($i = 0; $i < $max; $i++) { |
---|
2628 | if($arrData[$i][$pid_name] == $parent) { |
---|
2629 | $arrChildren[] = $arrData[$i][$id_name]; |
---|
2630 | } |
---|
2631 | } |
---|
2632 | return $arrChildren; |
---|
2633 | } |
---|
2634 | |
---|
2635 | |
---|
2636 | // ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ |
---|
2637 | function sfGetCatTree($parent_category_id, $count_check = false) { |
---|
2638 | $objQuery = new SC_Query(); |
---|
2639 | $col = ""; |
---|
2640 | $col .= " cat.category_id,"; |
---|
2641 | $col .= " cat.category_name,"; |
---|
2642 | $col .= " cat.parent_category_id,"; |
---|
2643 | $col .= " cat.level,"; |
---|
2644 | $col .= " cat.rank,"; |
---|
2645 | $col .= " cat.creator_id,"; |
---|
2646 | $col .= " cat.create_date,"; |
---|
2647 | $col .= " cat.update_date,"; |
---|
2648 | $col .= " cat.del_flg, "; |
---|
2649 | $col .= " ttl.product_count"; |
---|
2650 | $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; |
---|
2651 | // ÅÐÏ¿¾¦ÉÊ¿ô¤Î¥Á¥§¥Ã¥¯ |
---|
2652 | if($count_check) { |
---|
2653 | $where = "del_flg = 0 AND product_count > 0"; |
---|
2654 | } else { |
---|
2655 | $where = "del_flg = 0"; |
---|
2656 | } |
---|
2657 | $objQuery->setoption("ORDER BY rank DESC"); |
---|
2658 | $arrRet = $objQuery->select($col, $from, $where); |
---|
2659 | |
---|
2660 | $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); |
---|
2661 | |
---|
2662 | foreach($arrRet as $key => $array) { |
---|
2663 | foreach($arrParentID as $val) { |
---|
2664 | if($array['category_id'] == $val) { |
---|
2665 | $arrRet[$key]['display'] = 1; |
---|
2666 | break; |
---|
2667 | } |
---|
2668 | } |
---|
2669 | } |
---|
2670 | |
---|
2671 | return $arrRet; |
---|
2672 | } |
---|
2673 | |
---|
2674 | // ¿Æ¥«¥Æ¥´¥ê¡¼¤òÏ¢·ë¤·¤¿Ê¸»úÎó¤ò¼èÆÀ¤¹¤ë |
---|
2675 | function sfGetCatCombName($category_id){ |
---|
2676 | // ¾¦Éʤ¬Â°¤¹¤ë¥«¥Æ¥´¥êID¤ò½Ä¤Ë¼èÆÀ |
---|
2677 | $objQuery = new SC_Query(); |
---|
2678 | $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
---|
2679 | $ConbName = ""; |
---|
2680 | |
---|
2681 | // ¥«¥Æ¥´¥ê¡¼Ì¾¾Î¤ò¼èÆÀ¤¹¤ë |
---|
2682 | foreach($arrCatID as $key => $val){ |
---|
2683 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
---|
2684 | $arrVal = array($val); |
---|
2685 | $CatName = $objQuery->getOne($sql,$arrVal); |
---|
2686 | $ConbName .= $CatName . ' | '; |
---|
2687 | } |
---|
2688 | // ºÇ¸å¤Î ¡Ã ¤ò¥«¥Ã¥È¤¹¤ë |
---|
2689 | $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); |
---|
2690 | |
---|
2691 | return $ConbName; |
---|
2692 | } |
---|
2693 | |
---|
2694 | // »ØÄꤷ¤¿¥«¥Æ¥´¥ê¡¼ID¤ÎÂ祫¥Æ¥´¥ê¡¼¤ò¼èÆÀ¤¹¤ë |
---|
2695 | function sfGetFirstCat($category_id){ |
---|
2696 | // ¾¦Éʤ¬Â°¤¹¤ë¥«¥Æ¥´¥êID¤ò½Ä¤Ë¼èÆÀ |
---|
2697 | $objQuery = new SC_Query(); |
---|
2698 | $arrRet = array(); |
---|
2699 | $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
---|
2700 | $arrRet['id'] = $arrCatID[0]; |
---|
2701 | |
---|
2702 | // ¥«¥Æ¥´¥ê¡¼Ì¾¾Î¤ò¼èÆÀ¤¹¤ë |
---|
2703 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
---|
2704 | $arrVal = array($arrRet['id']); |
---|
2705 | $arrRet['name'] = $objQuery->getOne($sql,$arrVal); |
---|
2706 | |
---|
2707 | return $arrRet; |
---|
2708 | } |
---|
2709 | |
---|
2710 | //MySQLÍѤÎSQLʸ¤ËÊѹ¹¤¹¤ë |
---|
2711 | function sfChangeMySQL($sql){ |
---|
2712 | // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹ |
---|
2713 | $sql = preg_replace("/[\r\n\t]/"," ",$sql); |
---|
2714 | |
---|
2715 | $sql = sfChangeView($sql); // viewɽ¤ò¥¤¥ó¥é¥¤¥ó¥Ó¥å¡¼¤ËÊÑ´¹¤¹¤ë |
---|
2716 | $sql = sfChangeILIKE($sql); // ILIKE¸¡º÷¤òLIKE¸¡º÷¤ËÊÑ´¹¤¹¤ë |
---|
2717 | $sql = sfChangeRANDOM($sql); // RANDOM()¤òRAND()¤ËÊÑ´¹¤¹¤ë |
---|
2718 | |
---|
2719 | return $sql; |
---|
2720 | } |
---|
2721 | |
---|
2722 | // SQL¤ÎÃæ¤Ëview¤¬Â¸ºß¤·¤Æ¤¤¤ë¤«¥Á¥§¥Ã¥¯¤ò¹Ô¤¦¡£ |
---|
2723 | function sfInArray($sql){ |
---|
2724 | global $arrView; |
---|
2725 | |
---|
2726 | foreach($arrView as $key => $val){ |
---|
2727 | if (strcasecmp($sql, $val) == 0){ |
---|
2728 | $changesql = eregi_replace("($key)", "$val", $sql); |
---|
2729 | sfInArray($changesql); |
---|
2730 | } |
---|
2731 | } |
---|
2732 | return false; |
---|
2733 | } |
---|
2734 | |
---|
2735 | // SQL¥·¥ó¥°¥ë¥¯¥©¡¼¥ÈÂбþ |
---|
2736 | function sfQuoteSmart($in){ |
---|
2737 | |
---|
2738 | if (is_int($in) || is_double($in)) { |
---|
2739 | return $in; |
---|
2740 | } elseif (is_bool($in)) { |
---|
2741 | return $in ? 1 : 0; |
---|
2742 | } elseif (is_null($in)) { |
---|
2743 | return 'NULL'; |
---|
2744 | } else { |
---|
2745 | return "'" . str_replace("'", "''", $in) . "'"; |
---|
2746 | } |
---|
2747 | } |
---|
2748 | |
---|
2749 | // viewɽ¤ò¥¤¥ó¥é¥¤¥ó¥Ó¥å¡¼¤ËÊÑ´¹¤¹¤ë |
---|
2750 | function sfChangeView($sql){ |
---|
2751 | global $arrView; |
---|
2752 | global $arrViewWhere; |
---|
2753 | |
---|
2754 | $arrViewTmp = $arrView; |
---|
2755 | |
---|
2756 | // view¤Îwhere¤òÊÑ´¹ |
---|
2757 | foreach($arrViewTmp as $key => $val){ |
---|
2758 | $arrViewTmp[$key] = strtr($arrViewTmp[$key], $arrViewWhere); |
---|
2759 | } |
---|
2760 | |
---|
2761 | // view¤òÊÑ´¹ |
---|
2762 | $changesql = strtr($sql, $arrViewTmp); |
---|
2763 | |
---|
2764 | return $changesql; |
---|
2765 | } |
---|
2766 | |
---|
2767 | // ILIKE¸¡º÷¤òLIKE¸¡º÷¤ËÊÑ´¹¤¹¤ë |
---|
2768 | function sfChangeILIKE($sql){ |
---|
2769 | $changesql = eregi_replace("(ILIKE )", "LIKE BINARY ", $sql); |
---|
2770 | return $changesql; |
---|
2771 | } |
---|
2772 | |
---|
2773 | // RANDOM()¤òRAND()¤ËÊÑ´¹¤¹¤ë |
---|
2774 | function sfChangeRANDOM($sql){ |
---|
2775 | $changesql = eregi_replace("( RANDOM)", " RAND", $sql); |
---|
2776 | return $changesql; |
---|
2777 | } |
---|
2778 | |
---|
2779 | // view¤Îwhere¤òÃÖ´¹¤¹¤ë |
---|
2780 | function sfViewWhere($target, $where = "", $arrval = array(), $option = ""){ |
---|
2781 | global $arrViewWhere; |
---|
2782 | $arrWhere = split("[?]", $where); |
---|
2783 | $where_tmp = " WHERE " . $arrWhere[0]; |
---|
2784 | for($i = 1; $i < count($arrWhere); $i++){ |
---|
2785 | $where_tmp .= sfQuoteSmart($arrval[$i - 1]) . $arrWhere[$i]; |
---|
2786 | } |
---|
2787 | $arrViewWhere[$target] = $where_tmp . " " . $option; |
---|
2788 | } |
---|
2789 | |
---|
2790 | // ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤òºÆµ¢Åª¤Ë¥³¥Ô¡¼ |
---|
2791 | function sfCopyDir($src, $des, $mess, $override = false){ |
---|
2792 | if(!is_dir($src)){ |
---|
2793 | return false; |
---|
2794 | } |
---|
2795 | |
---|
2796 | $oldmask = umask(0); |
---|
2797 | $mod= stat($src); |
---|
2798 | |
---|
2799 | // ¥Ç¥£¥ì¥¯¥È¥ê¤¬¤Ê¤±¤ì¤ÐºîÀ®¤¹¤ë |
---|
2800 | if(!file_exists($des)) { |
---|
2801 | if(!mkdir($des, $mod[2])) { |
---|
2802 | print("path:" . $des); |
---|
2803 | } |
---|
2804 | } |
---|
2805 | |
---|
2806 | $fileArray=glob( $src."*" ); |
---|
2807 | foreach( $fileArray as $key => $data_ ){ |
---|
2808 | // CVS´ÉÍý¥Õ¥¡¥¤¥ë¤Ï¥³¥Ô¡¼¤·¤Ê¤¤ |
---|
2809 | if(ereg("/CVS/Entries", $data_)) { |
---|
2810 | break; |
---|
2811 | } |
---|
2812 | if(ereg("/CVS/Repository", $data_)) { |
---|
2813 | break; |
---|
2814 | } |
---|
2815 | if(ereg("/CVS/Root", $data_)) { |
---|
2816 | break; |
---|
2817 | } |
---|
2818 | |
---|
2819 | mb_ereg("^(.*[\/])(.*)",$data_, $matches); |
---|
2820 | $data=$matches[2]; |
---|
2821 | if( is_dir( $data_ ) ){ |
---|
2822 | $mess = sfCopyDir( $data_.'/', $des.$data.'/', $mess); |
---|
2823 | }else{ |
---|
2824 | if(!$override && file_exists($des.$data)) { |
---|
2825 | $mess.= $des.$data . "¡§¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤¹\n"; |
---|
2826 | } else { |
---|
2827 | if(@copy( $data_, $des.$data)) { |
---|
2828 | $mess.= $des.$data . "¡§¥³¥Ô¡¼À®¸ù\n"; |
---|
2829 | } else { |
---|
2830 | $mess.= $des.$data . "¡§¥³¥Ô¡¼¼ºÇÔ\n"; |
---|
2831 | } |
---|
2832 | } |
---|
2833 | $mod=stat($data_ ); |
---|
2834 | } |
---|
2835 | } |
---|
2836 | umask($oldmask); |
---|
2837 | return $mess; |
---|
2838 | } |
---|
2839 | |
---|
2840 | // »ØÄꤷ¤¿¥Õ¥©¥ë¥ÀÆâ¤Î¥Õ¥¡¥¤¥ë¤òÁ´¤Æºï½ü¤¹¤ë |
---|
2841 | function sfDelFile($dir){ |
---|
2842 | $dh = opendir($dir); |
---|
2843 | // ¥Õ¥©¥ë¥ÀÆâ¤Î¥Õ¥¡¥¤¥ë¤òºï½ü |
---|
2844 | while($file = readdir($dh)){ |
---|
2845 | if ($file == "." or $file == "..") continue; |
---|
2846 | $del_file = $dir . "/" . $file; |
---|
2847 | if(is_file($del_file)){ |
---|
2848 | $ret = unlink($dir . "/" . $file); |
---|
2849 | }else if (is_dir($del_file)){ |
---|
2850 | $ret = sfDelFile($del_file); |
---|
2851 | } |
---|
2852 | |
---|
2853 | if(!$ret){ |
---|
2854 | return $ret; |
---|
2855 | } |
---|
2856 | } |
---|
2857 | |
---|
2858 | // ÊĤ¸¤ë |
---|
2859 | closedir($dh); |
---|
2860 | |
---|
2861 | // ¥Õ¥©¥ë¥À¤òºï½ü |
---|
2862 | return rmdir($dir); |
---|
2863 | } |
---|
2864 | |
---|
2865 | /* |
---|
2866 | * ´Ø¿ô̾¡§sfWriteFile |
---|
2867 | * °ú¿ô1 ¡§½ñ¤¹þ¤à¥Ç¡¼¥¿ |
---|
2868 | * °ú¿ô2 ¡§¥Õ¥¡¥¤¥ë¥Ñ¥¹ |
---|
2869 | * °ú¿ô3 ¡§½ñ¤¹þ¤ß¥¿¥¤¥× |
---|
2870 | * °ú¿ô4 ¡§¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó |
---|
2871 | * Ìá¤êÃÍ¡§·ë²Ì¥Õ¥é¥° À®¸ù¤Ê¤é true ¼ºÇԤʤé false |
---|
2872 | * ÀâÌÀ¡¡¡§¥Õ¥¡¥¤¥ë½ñ¤½Ð¤· |
---|
2873 | */ |
---|
2874 | function sfWriteFile($str, $path, $type, $permission = "") { |
---|
2875 | //¥Õ¥¡¥¤¥ë¤ò³«¤¯ |
---|
2876 | if (!($file = fopen ($path, $type))) { |
---|
2877 | return false; |
---|
2878 | } |
---|
2879 | |
---|
2880 | //¥Õ¥¡¥¤¥ë¥í¥Ã¥¯ |
---|
2881 | flock ($file, LOCK_EX); |
---|
2882 | //¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß |
---|
2883 | fputs ($file, $str); |
---|
2884 | //¥Õ¥¡¥¤¥ë¥í¥Ã¥¯¤Î²ò½ü |
---|
2885 | flock ($file, LOCK_UN); |
---|
2886 | //¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë |
---|
2887 | fclose ($file); |
---|
2888 | // ¸¢¸Â¤ò»ØÄê |
---|
2889 | if($permission != "") { |
---|
2890 | chmod($path, $permission); |
---|
2891 | } |
---|
2892 | |
---|
2893 | return true; |
---|
2894 | } |
---|
2895 | |
---|
2896 | function sfFlush($output = " ", $sleep = 0){ |
---|
2897 | // ¼Â¹Ô»þ´Ö¤òÀ©¸Â¤·¤Ê¤¤ |
---|
2898 | set_time_limit(0); |
---|
2899 | // ½ÐÎϤò¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤·¤Ê¤¤(==ÆüËܸ켫ưÊÑ´¹¤â¤·¤Ê¤¤) |
---|
2900 | ob_end_clean(); |
---|
2901 | |
---|
2902 | // IE¤Î¤¿¤á¤Ë256¥Ð¥¤¥È¶õʸ»ú½ÐÎÏ |
---|
2903 | echo str_pad('',256); |
---|
2904 | |
---|
2905 | // ½ÐÎϤϥ֥é¥ó¥¯¤À¤±¤Ç¤â¤¤¤¤¤È»×¤¦ |
---|
2906 | echo $output; |
---|
2907 | // ½ÐÎϤò¥Õ¥é¥Ã¥·¥å¤¹¤ë |
---|
2908 | flush(); |
---|
2909 | |
---|
2910 | ob_end_flush(); |
---|
2911 | ob_start(); |
---|
2912 | |
---|
2913 | // »þ´Ö¤Î¤«¤«¤ë½èÍý |
---|
2914 | sleep($sleep); |
---|
2915 | } |
---|
2916 | |
---|
2917 | // @version¤ÎµºÜ¤¬¤¢¤ë¥Õ¥¡¥¤¥ë¤«¤é¥Ð¡¼¥¸¥ç¥ó¤ò¼èÆÀ¤¹¤ë¡£ |
---|
2918 | function sfGetFileVersion($path) { |
---|
2919 | if(file_exists($path)) { |
---|
2920 | $src_fp = fopen($path, "rb"); |
---|
2921 | if($src_fp) { |
---|
2922 | while (!feof($src_fp)) { |
---|
2923 | $line = fgets($src_fp); |
---|
2924 | if(ereg("@version", $line)) { |
---|
2925 | $arrLine = split(" ", $line); |
---|
2926 | $version = $arrLine[5]; |
---|
2927 | } |
---|
2928 | } |
---|
2929 | fclose($src_fp); |
---|
2930 | } |
---|
2931 | } |
---|
2932 | return $version; |
---|
2933 | } |
---|
2934 | |
---|
2935 | // »ØÄꤷ¤¿URL¤ËÂФ·¤ÆPOST¤Ç¥Ç¡¼¥¿¤òÁ÷¿®¤¹¤ë |
---|
2936 | function sfSendPostData($url, $arrData, $arrOkCode = array()){ |
---|
2937 | require_once(DATA_PATH . "module/Request.php"); |
---|
2938 | |
---|
2939 | // Á÷¿®¥¤¥ó¥¹¥¿¥ó¥¹À¸À® |
---|
2940 | $req = new HTTP_Request($url); |
---|
2941 | |
---|
2942 | $req->addHeader('User-Agent', 'DoCoMo/2.0¡¡P2101V(c100)'); |
---|
2943 | $req->setMethod(HTTP_REQUEST_METHOD_POST); |
---|
2944 | |
---|
2945 | // POST¥Ç¡¼¥¿Á÷¿® |
---|
2946 | $req->addPostDataArray($arrData); |
---|
2947 | |
---|
2948 | // ¥¨¥é¡¼¤¬Ìµ¤±¤ì¤Ð¡¢±þÅú¾ðÊó¤ò¼èÆÀ¤¹¤ë |
---|
2949 | if (!PEAR::isError($req->sendRequest())) { |
---|
2950 | |
---|
2951 | // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É¤¬¥¨¥é¡¼È½Äê¤Ê¤é¡¢¶õ¤òÊÖ¤¹ |
---|
2952 | $res_code = $req->getResponseCode(); |
---|
2953 | |
---|
2954 | if(!in_array($res_code, $arrOkCode)){ |
---|
2955 | $response = ""; |
---|
2956 | }else{ |
---|
2957 | $response = $req->getResponseBody(); |
---|
2958 | } |
---|
2959 | |
---|
2960 | } else { |
---|
2961 | $response = ""; |
---|
2962 | } |
---|
2963 | |
---|
2964 | // POST¥Ç¡¼¥¿¥¯¥ê¥¢ |
---|
2965 | $req->clearPostData(); |
---|
2966 | |
---|
2967 | return $response; |
---|
2968 | } |
---|
2969 | |
---|
2970 | /* ¥Ç¥Ð¥Ã¥°ÍÑ ------------------------------------------------------------------------------------------------*/ |
---|
2971 | function sfPrintR($obj) { |
---|
2972 | print("<div style='font-size: 12px;color: #00FF00;'>\n"); |
---|
2973 | print("<strong>**¥Ç¥Ð¥Ã¥°Ãæ**</strong><br />\n"); |
---|
2974 | print("<pre>\n"); |
---|
2975 | print_r($obj); |
---|
2976 | print("</pre>\n"); |
---|
2977 | print("<strong>**¥Ç¥Ð¥Ã¥°Ãæ**</strong></div>\n"); |
---|
2978 | } |
---|
2979 | |
---|
2980 | ?> |
---|