source: branches/dev/data/lib/slib.php @ 11893

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