source: temp/trunk/data/lib/slib.php @ 3444

Revision 3444, 64.0 KB checked in by naka, 20 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3//---¤³¤Î¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤ò»ØÄê
4$INC_PATH = realpath( dirname( __FILE__) );
5require_once( $INC_PATH ."/../conf/conf.php" );
6require_once( $INC_PATH ."/../class/SC_DbConn.php" );
7
8// Á´¥Ú¡¼¥¸¶¦ÄÌ¥¨¥é¡¼
9$GLOBAL_ERR = "";
10
11// ¥¤¥ó¥¹¥È¡¼¥ë½é´ü½èÍý
12sfInitInstall();
13// ¥¢¥Ã¥×¥Ç¡¼¥È¤ÇÀ¸À®¤µ¤ì¤¿PHP¤òÆÉ¤ß½Ð¤¹
14sfLoadUpdateModule();
15
16// ¥¤¥ó¥¹¥È¡¼¥ë½é´ü½èÍý
17function sfInitInstall() {
18    // ¥¤¥ó¥¹¥È¡¼¥ëºÑ¤ß¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
19    if(!defined('ECCUBE_INSTALL')) {
20        if(!ereg("^/install/", $_SERVER['PHP_SELF'])) {
21            header("Location: /install/");
22        }   
23    } else {
24        $path = ROOT_DIR . "html/install/index.php";
25        if(file_exists($path)) {
26            sfErrorHeader(">> /install/index.php¤Ï¥»¥­¥å¥ê¥Æ¥£¥Û¡¼¥ë¤Ë¤Ê¤ê¤Þ¤¹¡£¥¤¥ó¥¹¥È¡¼¥ë´°Î»¸å¤Ï¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£");
27        }       
28        $objConn = new SC_DbConn(DEFAULT_DSN);
29        $result = $objConn->getAll("SELECT * FROM dtb_baseinfo");
30        if(count($result) == 0) {
31            sfErrorHeader(">> ´ÉÍý²èÌÌ-´ðËܾðÊó´ÉÍý¤«¤éSHOP¥Þ¥¹¥¿¤òÅÐÏ¿¤·¤Æ¤¯¤À¤µ¤¤¡£");
32        }       
33    }
34}
35
36// ¥¢¥Ã¥×¥Ç¡¼¥È¤ÇÀ¸À®¤µ¤ì¤¿PHP¤òÆÉ¤ß½Ð¤·
37function sfLoadUpdateModule() {
38    if(ereg("^/install/", $_SERVER['PHP_SELF'])) {
39        return;
40    }       
41    //DB¤«¤éÀßÄê¾ðÊó¤ò¼èÆÀ
42    if(defined('DB_USER') && defined('DB_PASSWORD') && defined('DB_SERVER') && defined('DB_NAME')) {
43        $objConn = new SC_DbConn(DEFAULT_DSN);
44        // ºÇ½é¤Ë¼Â¹Ô¤¹¤ëPHP¥½¡¼¥¹¤ò¸¡º÷¤¹¤ë
45        $arrRet = $objConn->getAll("SELECT extern_php FROM dtb_update WHERE main_php = ? OR main_php = '*'",array($_SERVER['PHP_SELF']));
46        foreach($arrRet as $array) {
47            if($array['extern_php'] != "") {
48                $path = ROOT_DIR . $array['extern_php'];
49                if(file_exists($path)) {
50                    require_once($path);
51                }
52            }
53        }
54    }
55}
56
57function sf_getBasisData() {
58    //DB¤«¤éÀßÄê¾ðÊó¤ò¼èÆÀ
59    $objConn = new SC_DbConn(DEFAULT_DSN);
60    $result = $objConn->getAll("SELECT * FROM dtb_baseinfo");
61    if(is_array($result[0])) {
62        foreach ( $result[0] as $key=>$value ){
63            $CONF["$key"] = $value;
64        }
65    }
66    return $CONF;
67}
68
69// Áõ¾þÉÕ¤­¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Îɽ¼¨
70function sfErrorHeader($mess) {
71    global $GLOBAL_ERR;
72    if($GLOBAL_ERR == "") {
73        $GLOBAL_ERR = "<meta http-equiv='Content-Type' content='text/html; charset=EUC-JP'>\n";
74    }
75    $GLOBAL_ERR.= "<table width='100%' border='0' cellspacing='0' cellpadding='0' summary=' '>\n";
76    $GLOBAL_ERR.= "<tr>\n";
77    $GLOBAL_ERR.= "<td bgcolor='#ffeebb' height='25' colspan='2' align='center'>\n";
78    $GLOBAL_ERR.= "<SPAN style='color:red; font-size:12px'><strong>" . $mess . "</strong></span>\n";
79    $GLOBAL_ERR.= "</td>\n";
80    $GLOBAL_ERR.= " </tr>\n";
81    $GLOBAL_ERR.= "</table>\n";
82}
83
84/* ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ */
85function sfDispError($type) {
86   
87    class LC_ErrorPage {
88        function LC_ErrorPage() {
89            $this->tpl_mainpage = 'login_error.tpl';
90            $this->tpl_title = '¥¨¥é¡¼';
91        }
92    }
93
94    $objPage = new LC_ErrorPage();
95    $objView = new SC_AdminView();
96   
97    switch ($type) {
98        case LOGIN_ERROR:
99            $objPage->tpl_error="£É£Ä¤Þ¤¿¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£";
100            break;
101        case ACCESS_ERROR:
102            $objPage->tpl_error="¥í¥°¥¤¥óǧ¾Ú¤ÎÍ­¸ú´ü¸ÂÀÚ¤ì¤Î²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£";
103            break;
104        case AUTH_ERROR:
105            $objPage->tpl_error="¤³¤Î¥Õ¥¡¥¤¥ë¤Ë¤Ï¥¢¥¯¥»¥¹¸¢¸Â¤¬¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£";
106            break;
107        case PAGE_ERROR:
108            $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£";
109            break;
110        default:
111            $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£";
112            break;
113    }
114   
115    $objView->assignobj($objPage);
116    $objView->display(LOGIN_FRAME);
117   
118    exit;
119}
120
121/* ¥µ¥¤¥È¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ */
122function sfDispSiteError($type, $objSiteSess = "") {
123   
124    if ($objSiteSess != "") {
125        $objSiteSess->setNowPage('error');
126    }
127   
128    class LC_ErrorPage {
129        function LC_ErrorPage() {
130            $this->tpl_mainpage = 'error.tpl';
131            $this->tpl_css = '/css/layout/error.css';
132            $this->tpl_title = '¥¨¥é¡¼';
133        }
134    }
135   
136    $objPage = new LC_ErrorPage();
137    $objView = new SC_SiteView();
138   
139    switch ($type) {
140        case PRODUCT_NOT_FOUND:
141            $objPage->tpl_error="¤´»ØÄê¤Î¥Ú¡¼¥¸¤Ï¤´¤¶¤¤¤Þ¤»¤ó¡£";
142            break;
143        case PAGE_ERROR:
144            $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£";
145            break;
146        case CART_EMPTY:
147            $objPage->tpl_error="¥«¡¼¥È¤Ë¾¦Éʤ¬¤¬¤¢¤ê¤Þ¤»¤ó¡£";
148            break;
149        case CART_ADD_ERROR:
150            $objPage->tpl_error="¹ØÆþ½èÍýÃæ¤Ï¡¢¥«¡¼¥È¤Ë¾¦ÉʤòÄɲ乤뤳¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
151            break;
152        case CANCEL_PURCHASE:
153            $objPage->tpl_error="¤³¤Î¼ê³¤­¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£°Ê²¼¤ÎÍ×°ø¤¬¹Í¤¨¤é¤ì¤Þ¤¹¡£<br />¡¦¥»¥Ã¥·¥ç¥ó¾ðÊó¤ÎÍ­¸ú´ü¸Â¤¬ÀÚ¤ì¤Æ¤ë¾ì¹ç<br />¡¦¹ØÆþ¼ê³¤­Ãæ¤Ë¿·¤·¤¤¹ØÆþ¼ê³¤­¤ò¼Â¹Ô¤·¤¿¾ì¹ç<br />¡¦¤¹¤Ç¤Ë¹ØÆþ¼ê³¤­¤ò´°Î»¤·¤Æ¤¤¤ë¾ì¹ç";
154            break;
155        case CATEGORY_NOT_FOUND:
156            $objPage->tpl_error="¤´»ØÄê¤Î¥«¥Æ¥´¥ê¤Ï¸ºß¤·¤Þ¤»¤ó¡£";
157            break;
158        case SITE_LOGIN_ERROR:
159            $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£";
160            break;
161        case TEMP_LOGIN_ERROR:
162            $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />ËÜÅÐÏ¿¤¬¤ªºÑ¤ß¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢²¾ÅÐÏ¿¥á¡¼¥ë¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤ë<br />URL¤è¤êËÜÅÐÏ¿¤ò¹Ô¤Ã¤Æ¤¯¤À¤µ¤¤¡£";
163            break;
164        case CUSTOMER_ERROR:
165            $objPage->tpl_error="ÉÔÀµ¤Ê¥¢¥¯¥»¥¹¤Ç¤¹¡£";
166            break;
167        case SOLD_OUT:
168            $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤´¹ØÆþ¤ÎľÁ°¤ÇÇä¤êÀڤ줿¾¦Éʤ¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤­¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£";
169            break;
170        case CART_NOT_FOUND:
171            $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥«¡¼¥ÈÆâ¤Î¾¦ÉʾðÊó¤Î¼èÆÀ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¤³¤Î¼ê³¤­¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£";
172            break;
173        case LACK_POINT:
174            $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥Ý¥¤¥ó¥È¤¬ÉÔ­¤·¤Æ¤ª¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤­¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£";
175            break;
176        case FAVORITE_ERROR:
177            $objPage->tpl_error="´û¤Ë¤ªµ¤¤ËÆþ¤ê¤ËÄɲäµ¤ì¤Æ¤¤¤ë¾¦ÉʤǤ¹¡£";
178            break;
179        case EXTRACT_ERROR:
180            $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤Î²òÅà¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë½ñ¤­¹þ¤ß¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£";
181            break;
182        case FTP_DOWNLOAD_ERROR:
183            $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤ÎFTP¥À¥¦¥ó¥í¡¼¥É¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£";
184            break;
185        case FTP_LOGIN_ERROR:
186            $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£";
187            break;
188        case FTP_CONNECT_ERROR:
189            $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£";
190            break;
191        case CREATE_DB_ERROR:
192            $objPage->tpl_error="DB¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥æ¡¼¥¶¡¼¤Ë¤Ï¡¢DBºîÀ®¤Î¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£";
193            break;
194        case DB_IMPORT_ERROR:
195            $objPage->tpl_error="¥Ç¡¼¥¿¥Ù¡¼¥¹¹½Â¤¤Î¥¤¥ó¥Ý¡¼¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\nsql¥Õ¥¡¥¤¥ë¤¬²õ¤ì¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£";
196            break;
197        case FILE_NOT_FOUND:
198            $objPage->tpl_error="»ØÄê¤Î¥Ñ¥¹¤Ë¡¢ÀßÄê¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó¡£";
199            break;
200        case WRITE_FILE_ERROR:
201            $objPage->tpl_error="ÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤á¤Þ¤»¤ó¡£\nÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤ß¸¢¸Â¤òÍ¿¤¨¤Æ¤¯¤À¤µ¤¤¡£";
202            break;
203        default:
204            $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£";
205            break;
206    }
207   
208    $objView->assignobj($objPage);
209    $objView->display(SITE_FRAME);
210    exit;
211}
212
213/* ǧ¾Ú¤Î²ÄÈÝȽÄê */
214function sfIsSuccess($objSess, $disp_error = true) {
215    $ret = $objSess->IsSuccess();
216    if($ret != SUCCESS) {
217        if($disp_error) {
218            // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨
219            sfDispError($ret);
220        }
221        return false;
222    }
223    return true;       
224}
225
226/* Á°¤Î¥Ú¡¼¥¸¤ÇÀµ¤·¤¯ÅÐÏ¿¤¬¹Ô¤ï¤ì¤¿¤«È½Äê */
227function sfIsPrePage($objSiteSess) {
228    $ret = $objSiteSess->isPrePage();
229    if($ret != true) {
230        // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨
231        sfDispSiteError(PAGE_ERROR, $objSiteSess);
232    }
233}
234
235function sfCheckNormalAccess($objSiteSess, $objCartSess) {
236    // ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ
237    $uniqid = $objSiteSess->getUniqId();
238    // ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤¿»þ¤Î¥«¡¼¥ÈÆâÍÆ¤¬¥³¥Ô¡¼¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Î¤ß¥³¥Ô¡¼¤¹¤ë¡£
239    $objCartSess->saveCurrentCart($uniqid);
240    // POST¤Î¥æ¥Ë¡¼¥¯ID¤È¥»¥Ã¥·¥ç¥ó¤Î¥æ¥Ë¡¼¥¯ID¤òÈæ³Ó(¥æ¥Ë¡¼¥¯ID¤¬POST¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¥¹¥ë¡¼)
241    $ret = $objSiteSess->checkUniqId();
242    if($ret != true) {
243        // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨
244        sfDispSiteError(CANCEL_PURCHASE, $objSiteSess);
245    }
246   
247    // ¥«¡¼¥ÈÆâ¤¬¶õ¤Ç¤Ê¤¤¤« || ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤«¤éÊѲ½¤¬¤Ê¤¤¤«
248    $quantity = $objCartSess->getTotalQuantity();
249    $ret = $objCartSess->checkChangeCart();
250    if($ret == true || !($quantity > 0)) {
251        // ¥«¡¼¥È¾ðÊóɽ¼¨¤Ë¶¯À©°Üư¤¹¤ë
252        header("Location: ".URL_CART_TOP);
253        exit;
254    }
255    return $uniqid;
256}
257
258/* DBÍÑÆüÉÕʸ»úÎó¼èÆÀ */
259function sfGetTimestamp($year, $month, $day, $last = false) {
260    if($year != "" && $month != "" && $day != "") {
261        if($last) {
262            $time = "23:59:59";
263        } else {
264            $time = "00:00:00";
265        }
266        $date = $year."-".$month."-".$day." ".$time;
267    } else {
268        $date = "";
269    }
270    return  $date;
271}
272
273// INT·¿¤Î¿ôÃÍ¥Á¥§¥Ã¥¯
274function sfIsInt($value) {
275    if($value != "" && strlen($value) <= INT_LEN && is_numeric($value)) {
276        return true;
277    }
278    return false;
279}
280
281function sfCSVDownload($data, $prefix = ""){
282   
283    if($prefix == "") {
284        $dir_name = sfUpDirName();
285        $file_name = $dir_name . date("ymdHis") .".csv";
286    } else {
287        $file_name = $prefix . date("ymdHis") .".csv";
288    }
289   
290    /* HTTP¥Ø¥Ã¥À¤Î½ÐÎÏ */
291    Header("Content-disposition: attachment; filename=${file_name}");
292    Header("Content-type: application/octet-stream; name=${file_name}");
293    Header("Cache-Control: ");
294    Header("Pragma: ");
295   
296   
297    /* i18n¢· ¤À¤ÈÀµ¾ï¤Ëưºî¤·¤Ê¤¤¤¿¤á¡¢mb¢· ¤ËÊѹ¹
298    if (i18n_discover_encoding($data) == 'EUC-JP'){
299        $data = i18n_convert($data,'SJIS','EUC-JP');
300    }
301    */
302    if (mb_internal_encoding() == 'EUC-JP'){
303        $data = mb_convert_encoding($data,'SJIS','EUC-JP');
304    }
305   
306    /* ¥Ç¡¼¥¿¤ò½ÐÎÏ */
307    echo $data;
308}
309
310/* 1³¬Áؾå¤Î¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ¤¹¤ë */
311function sfUpDirName() {
312    $path = $_SERVER['PHP_SELF'];
313    $arrVal = split("/", $path);
314    $cnt = count($arrVal);
315    return $arrVal[($cnt - 2)];
316}
317
318// ¸½ºß¤Î¥µ¥¤¥È¤ò¹¹¿·¡Ê¤¿¤À¤·¥Ý¥¹¥È¤Ï¹Ô¤ï¤Ê¤¤¡Ë
319function sfReload($get = "") {
320    if ($_SERVER["SERVER_PORT"] == "443" ){
321        $protocol = "https";
322    } else {
323        $protocol = "http";
324    }
325       
326    if($get != "") {
327        header("Location: ".$protocol."://" .$_SERVER["SERVER_NAME"] . $_SERVER['PHP_SELF'] . "?" . $get);
328    } else {
329        header("Location: ".$protocol."://" .$_SERVER["SERVER_NAME"] . $_SERVER['PHP_SELF']);
330    }
331    exit;
332}
333
334// ¥é¥ó¥­¥ó¥°¤ò¾å¤²¤ë¡£
335function sfRankUp($table, $colname, $id, $andwhere = "") {
336    $objQuery = new SC_Query();
337    $objQuery->begin();
338    $where = "$colname = ?";
339    if($andwhere != "") {
340        $where.= " AND $andwhere";
341    }
342    // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ
343    $rank = $objQuery->get($table, "rank", $where, array($id));
344    // ¥é¥ó¥¯¤ÎºÇÂçÃͤò¼èÆÀ
345    $maxrank = $objQuery->max($table, "rank", $andwhere);
346    // ¥é¥ó¥¯¤¬ºÇÂçÃͤè¤ê¤â¾®¤µ¤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£
347    if($rank < $maxrank) {
348        // ¥é¥ó¥¯¤¬°ì¤Ä¾å¤ÎID¤ò¼èÆÀ¤¹¤ë¡£
349        $where = "rank = ?";
350        if($andwhere != "") {
351            $where.= " AND $andwhere";
352        }
353        $uprank = $rank + 1;
354        $up_id = $objQuery->get($table, $colname, $where, array($uprank));
355        // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô
356        $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?";
357        $objQuery->exec($sqlup, array($rank + 1, $id));
358        $objQuery->exec($sqlup, array($rank, $up_id));
359    }
360    $objQuery->commit();
361}
362
363// ¥é¥ó¥­¥ó¥°¤ò²¼¤²¤ë¡£
364function sfRankDown($table, $colname, $id, $andwhere = "") {
365    $objQuery = new SC_Query();
366    $objQuery->begin();
367    $where = "$colname = ?";
368    if($andwhere != "") {
369        $where.= " AND $andwhere";
370    }
371    // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ
372    $rank = $objQuery->get($table, "rank", $where, array($id));
373       
374    // ¥é¥ó¥¯¤¬1(ºÇ¾®ÃÍ)¤è¤ê¤âÂ礭¤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£
375    if($rank > 1) {
376        // ¥é¥ó¥¯¤¬°ì¤Ä²¼¤ÎID¤ò¼èÆÀ¤¹¤ë¡£
377        $where = "rank = ?";
378        if($andwhere != "") {
379            $where.= " AND $andwhere";
380        }
381        $downrank = $rank - 1;
382        $down_id = $objQuery->get($table, $colname, $where, array($downrank));
383        // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô
384        $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?";
385        $objQuery->exec($sqlup, array($rank - 1, $id));
386        $objQuery->exec($sqlup, array($rank, $down_id));
387    }
388    $objQuery->commit();
389}
390
391//----¡¡»ØÄê½ç°Ì¤Ø°Üư
392function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = "") {
393    $objQuery = new SC_Query();
394    $objQuery->begin();
395       
396    // ¼«¿È¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë
397    $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId)); 
398    $max = $objQuery->max($tableName, "rank", $where);
399       
400    // ÃͤÎÄ´À°¡ÊµÕ½ç¡Ë
401    if($pos > $max) {
402        $position = 1;
403    } else if($pos < 1) {
404        $position = $max;
405    } else {
406        $position = $max - $pos + 1;
407    }
408   
409    if( $position > $rank ) $term = "rank - 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤êÂ礭¤¤¾ì¹ç
410    if( $position < $rank ) $term = "rank + 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤ê¾®¤µ¤¤¾ì¹ç
411
412    //--¡¡»ØÄꤷ¤¿½ç°Ì¤Î¾¦Éʤ«¤é°Üư¤µ¤»¤ë¾¦ÉʤޤǤÎrank¤ò£±¤Ä¤º¤é¤¹
413    $sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND delete = 0";
414    if($where != "") {
415        $sql.= " AND $where";
416    }
417   
418    if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position ));
419    if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 ));
420
421    //-- »ØÄꤷ¤¿½ç°Ì¤Ørank¤ò½ñ¤­´¹¤¨¤ë¡£
422    $sql  = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND delete = 0 ";
423    if($where != "") {
424        $sql.= " AND $where";
425    }
426   
427    $objQuery->exec( $sql, array( $position, $keyId ) );
428    $objQuery->commit();
429}
430
431// ¥é¥ó¥¯¤ò´Þ¤à¥ì¥³¡¼¥É¤Îºï½ü
432// ¥ì¥³¡¼¥É¤´¤Èºï½ü¤¹¤ë¾ì¹ç¤Ï¡¢$delete¤òtrue¤Ë¤¹¤ë¡£
433function sfDeleteRankRecord($table, $colname, $id, $andwhere = "", $delete = false) {
434    $objQuery = new SC_Query();
435    $objQuery->begin();
436    // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£     
437    $where = "$colname = ?";
438    if($andwhere != "") {
439        $where.= " AND $andwhere";
440    }
441    $rank = $objQuery->get($table, "rank", $where, array($id));
442
443    if(!$delete) {
444        // ¥é¥ó¥¯¤òºÇ²¼°Ì¤Ë¤¹¤ë¡¢DEL¥Õ¥é¥°ON
445        $sqlup = "UPDATE $table SET rank = 0, delete = 1, update_date = Now() ";
446        $sqlup.= "WHERE $colname = ?";
447        // UPDATE¤Î¼Â¹Ô
448        $objQuery->exec($sqlup, array($id));
449    } else {
450        $objQuery->delete($table, "$colname = ?", array($id));
451    }
452   
453    // Äɲå쥳¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä¤º¤é¤¹¡£
454    $where = "rank > ?";
455    if($andwhere != "") {
456        $where.= " AND $andwhere";
457    }
458    $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
459    $objQuery->exec($sqlup, array($rank));
460    $objQuery->commit();
461}
462
463// ¥ì¥³¡¼¥É¤Î¸ºß¥Á¥§¥Ã¥¯
464function sfIsRecord($table, $col, $arrval, $addwhere = "") {
465    $objQuery = new SC_Query();
466    $arrCol = split("[, ]", $col);
467       
468    $where = "delete = 0";
469   
470    if($addwhere != "") {
471        $where.= " AND $addwhere";
472    }
473       
474    foreach($arrCol as $val) {
475        if($val != "") {
476            if($where == "") {
477                $where = "$val = ?";
478            } else {
479                $where.= " AND $val = ?";
480            }
481        }
482    }
483    $ret = $objQuery->get($table, $col, $where, $arrval);
484   
485    if($ret != "") {
486        return true;
487    }
488    return false;
489}
490
491// ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤò¥Þ¡¼¥¸
492function sfMergeCBValue($keyname, $max) {
493    $conv = "";
494    $cnt = 1;
495    for($cnt = 1; $cnt <= $max; $cnt++) {
496        if ($_POST[$keyname . $cnt] == "1") {
497            $conv.= "1";
498        } else {
499            $conv.= "0";
500        }
501    }
502    return $conv;
503}
504
505// html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤Æ2¿Ê¿ô·Á¼°¤ËÊѹ¹¤¹¤ë¡£
506function sfMergeCheckBoxes($array, $max) {
507    $ret = "";
508    if(is_array($array)) { 
509        foreach($array as $val) {
510            $arrTmp[$val] = "1";
511        }
512    }
513    for($i = 1; $i <= $max; $i++) {
514        if($arrTmp[$i] == "1") {
515            $ret.= "1";
516        } else {
517            $ret.= "0";
518        }
519    }
520    return $ret;
521}
522
523
524// html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤Æ¡Ö-¡×¤Ç¤Ä¤Ê¤²¤ë¡£
525function sfMergeParamCheckBoxes($array) {
526    if(is_array($array)) {
527        foreach($array as $val) {
528            if($ret != "") {
529                $ret.= "-$val";
530            } else {
531                $ret = $val;           
532            }
533        }
534    } else {
535        $ret = $array;
536    }
537    return $ret;
538}
539
540// html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤ÆSQL¸¡º÷ÍѤËÊѹ¹¤¹¤ë¡£
541function sfSearchCheckBoxes($array) {
542    $max = 0;
543    $ret = "";
544    foreach($array as $val) {
545        $arrTmp[$val] = "1";
546        if($val > $max) {
547            $max = $val;
548        }
549    }
550    for($i = 1; $i <= $max; $i++) {
551        if($arrTmp[$i] == "1") {
552            $ret.= "1";
553        } else {
554            $ret.= "_";
555        }
556    }
557   
558    if($ret != "") {   
559        $ret.= "%";
560    }
561    return $ret;
562}
563
564// 2¿Ê¿ô·Á¼°¤ÎÃͤòhtml_checkboxesÂбþ¤ÎÃͤËÀÚ¤êÂØ¤¨¤ë
565function sfSplitCheckBoxes($val) {
566    $len = strlen($val);
567    for($i = 0; $i < $len; $i++) {
568        if(substr($val, $i, 1) == "1") {
569            $arrRet[] = ($i + 1);
570        }
571    }
572    return $arrRet;
573}
574
575// ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤò¥Þ¡¼¥¸
576function sfMergeCBSearchValue($keyname, $max) {
577    $conv = "";
578    $cnt = 1;
579    for($cnt = 1; $cnt <= $max; $cnt++) {
580        if ($_POST[$keyname . $cnt] == "1") {
581            $conv.= "1";
582        } else {
583            $conv.= "_";
584        }
585    }
586    return $conv;
587}
588
589// ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤòʬ²ò
590function sfSplitCBValue($val, $keyname = "") {
591    $len = strlen($val);
592    $no = 1;
593    for ($cnt = 0; $cnt < $len; $cnt++) {
594        if($keyname != "") {
595            $arr[$keyname . $no] = substr($val, $cnt, 1);
596        } else {
597            $arr[] = substr($val, $cnt, 1);
598        }
599        $no++;
600    }
601    return $arr;
602}
603
604// ¥­¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ
605function sfArrKeyValue($arrList, $keyname, $valname, $len_max = "", $keysize = "") {
606   
607    $max = count($arrList);
608   
609    if($len_max != "" && $max > $len_max) {
610        $max = $len_max;
611    }
612   
613    for($cnt = 0; $cnt < $max; $cnt++) {
614        if($keysize != "") {
615            $key = sfCutString($arrList[$cnt][$keyname], $keysize);
616        } else {
617            $key = $arrList[$cnt][$keyname];
618        }
619        $val = $arrList[$cnt][$valname];
620       
621        if(!isset($arrRet[$key])) {
622            $arrRet[$key] = $val;
623        }
624       
625    }
626    return $arrRet;
627}
628
629// ¥­¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ(Ãͤ¬Ê£¿ô¤Î¾ì¹ç)
630function sfArrKeyValues($arrList, $keyname, $valname, $len_max = "", $keysize = "", $connect = "") {
631   
632    $max = count($arrList);
633   
634    if($len_max != "" && $max > $len_max) {
635        $max = $len_max;
636    }
637   
638    for($cnt = 0; $cnt < $max; $cnt++) {
639        if($keysize != "") {
640            $key = sfCutString($arrList[$cnt][$keyname], $keysize);
641        } else {
642            $key = $arrList[$cnt][$keyname];
643        }
644        $val = $arrList[$cnt][$valname];
645       
646        if($connect != "") {
647            $arrRet[$key].= "$val".$connect;
648        } else {
649            $arrRet[$key][] = $val;     
650        }
651    }
652    return $arrRet;
653}
654
655// ÇÛÎó¤ÎÃͤò¥«¥ó¥Þ¶èÀÚ¤ê¤ÇÊÖ¤¹¡£
656function sfGetCommaList($array) {
657    if (count($array) > 0) {
658        foreach($array as $val) {
659            $line .= $val . ", ";
660        }
661        $line = ereg_replace(", $", "", $line);
662        return $line;
663    }else{
664        return false;
665    }
666   
667}
668
669/* ÇÛÎó¤ÎÍ×ÁǤòCSV¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç½ÐÎϤ¹¤ë¡£*/
670function sfGetCSVList($array) {
671    if (count($array) > 0) {
672        foreach($array as $key => $val) {
673            $line .= "\"".$val."\",";
674        }
675        $line = ereg_replace(",$", "\n", $line);
676        return $line;
677    }else{
678        return false;
679    }
680}
681
682/* ÇÛÎó¤ÎÍ×ÁǤòPDF¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç½ÐÎϤ¹¤ë¡£*/
683function sfGetPDFList($array) {
684    foreach($array as $key => $val) {
685        $line .= "\t".$val;
686    }
687    $line.="\n";
688    return $line;
689}
690
691
692
693/*-----------------------------------------------------------------*/
694/*  check_set_term
695/*  ǯ·îÆü¤ËÊ̤줿2¤Ä¤Î´ü´Ö¤ÎÂÅÅöÀ­¤ò¥Á¥§¥Ã¥¯¤·¡¢À°¹çÀ­¤È´ü´Ö¤òÊÖ¤¹
696/*¡¡°ú¿ô (³«»Ïǯ,³«»Ï·î,³«»ÏÆü,½ªÎ»Ç¯,½ªÎ»·î,½ªÎ»Æü)
697/*¡¡ÌáÃÍ array(£±¡¤£²¡¤£³¡Ë
698/*          £±¡¥³«»Ïǯ·îÆü (YYYY/MM/DD 000000)
699/*          £²¡¥½ªÎ»Ç¯·îÆü (YYYY/MM/DD 235959)
700/*          £³¡¥¥¨¥é¡¼ ( 0 = OK, 1 = NG )
701/*-----------------------------------------------------------------*/
702function sfCheckSetTerm ( $start_year, $start_month, $start_day, $end_year, $end_month, $end_day ) {
703
704    // ´ü´Ö»ØÄê
705    $error = 0;
706    if ( $start_month || $start_day || $start_year){
707        if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1;
708    } else {
709        $error = 1;
710    }
711    if ( $end_month || $end_day || $end_year){
712        if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2;
713    }
714    if ( ! $error ){
715        $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000";
716        $date2 = $end_year   ."/".sprintf("%02d",$end_month)   ."/".sprintf("%02d",$end_day)   ." 235959";
717        if ($date1 > $date2) $error = 3;
718    } else {
719        $error = 1;
720    }
721    return array($date1, $date2, $error);
722}
723
724// ¥¨¥é¡¼²Õ½ê¤ÎÇØ·Ê¿§¤òÊѹ¹¤¹¤ë¤¿¤á¤Îfunction SC_View¤ÇÆÉ¤ß¹þ¤à
725function sfSetErrorStyle(){
726    return 'style="background-color:'.ERR_COLOR.'"';
727}
728
729/* DB¤ËÅϤ¹¿ôÃͤΥÁ¥§¥Ã¥¯
730 * 10·å°Ê¾å¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¥¨¥é¡¼¤òµ¯¤³¤¹¤Î¤Ç¡£
731 */
732function sfCheckNumLength( $value ){
733    if ( ! is_numeric($value)  ){
734        return false;
735    }
736   
737    if ( strlen($value) > 9 ) {
738        return false;
739    }
740   
741    return true;
742}
743
744// °ìÃפ·¤¿ÃͤΥ­¡¼Ì¾¤ò¼èÆÀ
745function sfSearchKey($array, $word, $default) {
746    foreach($array as $key => $val) {
747        if($val == $word) {
748            return $key;
749        }
750    }
751    return $default;
752}
753
754// ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ($products_check:true¾¦ÉÊÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤À¤±¼èÆÀ)
755function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) {
756    $objQuery = new SC_Query();
757    $where = "delete = 0";
758   
759    if($addwhere != "") {
760        $where.= " AND $addwhere";
761    }
762       
763    $objQuery->setoption("ORDER BY rank DESC");
764   
765    if($products_check) {
766        $col = "T1.category_id, category_name, level";
767        $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id";
768        $where .= " AND product_count > 0";
769    } else {
770        $col = "category_id, category_name, level";
771        $from = "dtb_category";
772    }
773   
774    $arrRet = $objQuery->select($col, $from, $where);
775           
776    $max = count($arrRet);
777    for($cnt = 0; $cnt < $max; $cnt++) {
778        $id = $arrRet[$cnt]['category_id'];
779        $name = $arrRet[$cnt]['category_name'];
780        $arrList[$id] = "";
781        /*
782        for($n = 1; $n < $arrRet[$cnt]['level']; $n++) {
783            $arrList[$id].= "¡¡";
784        }
785        */
786        for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) {
787            $arrList[$id].= $head;
788        }
789        $arrList[$id].= $name;
790    }
791    return $arrList;
792}
793
794// ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ¡Ê¿Æ¥«¥Æ¥´¥ê¤ÎValue:0)
795function sfGetLevelCatList($parent_zero = true) {
796    $objQuery = new SC_Query();
797    $col = "category_id, category_name, level";
798    $where = "delete = 0";
799    $objQuery->setoption("ORDER BY rank DESC");
800    $arrRet = $objQuery->select($col, "dtb_category", $where);
801    $max = count($arrRet);
802   
803    for($cnt = 0; $cnt < $max; $cnt++) {
804        if($parent_zero) {
805            if($arrRet[$cnt]['level'] == LEVEL_MAX) {
806                $arrValue[$cnt] = $arrRet[$cnt]['category_id'];
807            } else {
808                $arrValue[$cnt] = "";
809            }
810        } else {
811            $arrValue[$cnt] = $arrRet[$cnt]['category_id'];
812        }
813       
814        $arrOutput[$cnt] = "";
815        /*         
816        for($n = 1; $n < $arrRet[$cnt]['level']; $n++) {
817            $arrOutput[$cnt].= "¡¡";
818        }
819        */
820        for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) {
821            $arrOutput[$cnt].= CATEGORY_HEAD;
822        }
823        $arrOutput[$cnt].= $arrRet[$cnt]['category_name'];
824    }
825    return array($arrValue, $arrOutput);
826}
827
828function sfGetErrorColor($val) {
829    if($val != "") {
830        return "background-color:" . ERR_COLOR;
831    }
832    return "";
833}
834
835
836function sfGetEnabled($val) {
837    if( ! $val ) {
838        return " disabled=\"disabled\"";
839    }
840    return "";
841}
842
843function sfGetChecked($param, $value) {
844    if($param == $value) {
845        return "checked=\"checked\"";
846    }
847    return "";
848}
849
850// SELECT¥Ü¥Ã¥¯¥¹Íѥꥹ¥È¤ÎºîÀ®
851function sfGetIDValueList($table, $keyname, $valname) {
852    $objQuery = new SC_Query();
853    $col = "$keyname, $valname";
854    $objQuery->setwhere("delete = 0");
855    $objQuery->setorder("rank DESC");
856    $arrList = $objQuery->select($col, $table);
857    $count = count($arrList);
858    for($cnt = 0; $cnt < $count; $cnt++) {
859        $key = $arrList[$cnt][$keyname];
860        $val = $arrList[$cnt][$valname];
861        $arrRet[$key] = $val;
862    }
863    return $arrRet;
864}
865
866function sfTrim($str) {
867    $ret = ereg_replace("^[¡¡ \n\r]*", "", $str);
868    $ret = ereg_replace("[¡¡ \n\r]*$", "", $ret);
869    return $ret;
870}
871
872/* ½ê°¤¹¤ë¤¹¤Ù¤Æ¤Î³¬ÁؤοÆID¤òÇÛÎó¤ÇÊÖ¤¹ */
873function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) {
874    $arrRet = sfGetParentsArray($table, $pid_name, $id_name, $id);
875    // ÇÛÎó¤ÎÀèÆ¬1¤Ä¤òºï½ü¤¹¤ë¡£
876    array_shift($arrRet);
877    return $arrRet;
878}
879
880
881/* ¿ÆID¤ÎÇÛÎó¤ò¸µ¤ËÆÃÄê¤Î¥«¥é¥à¤ò¼èÆÀ¤¹¤ë¡£*/
882function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) {
883    $col = $col_name;
884    $len = count($arrId);
885    $where = "";
886   
887    for($cnt = 0; $cnt < $len; $cnt++) {
888        if($where == "") {
889            $where = "$id_name = ?";
890        } else {
891            $where.= " OR $id_name = ?";
892        }
893    }
894   
895    $objQuery->setorder("level");
896    $arrRet = $objQuery->select($col, $table, $where, $arrId);
897    return $arrRet;
898}
899
900/* »ÒID¤ÎÇÛÎó¤òÊÖ¤¹ */
901function sfGetChildsID($table, $pid_name, $id_name, $id) {
902    $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);
903    return $arrRet;
904}
905
906/* ¥«¥Æ¥´¥êÊѹ¹»þ¤Î°Üư½èÍý */
907function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) {
908    if ($old_catid == $new_catid) {
909        return;
910    }
911    // µì¥«¥Æ¥´¥ê¤Ç¤Î¥é¥ó¥¯ºï½ü½èÍý
912    // °Üư¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£     
913    $where = "$id_name = ?";
914    $rank = $objQuery->get($table, "rank", $where, array($id));
915    // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä²¼¤Ë¤º¤é¤¹¡£
916    $where = "rank > ? AND $cat_name = ?";
917    $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where";
918    $objQuery->exec($sqlup, array($rank, $old_catid));
919    // ¿·¥«¥Æ¥´¥ê¤Ç¤ÎÅÐÏ¿½èÍý
920    // ¿·¥«¥Æ¥´¥ê¤ÎºÇÂç¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£
921    $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1;
922    $where = "$id_name = ?";
923    $sqlup = "UPDATE $table SET rank = ? WHERE $where";
924    $objQuery->exec($sqlup, array($max_rank, $id));
925}
926
927/* ÀǶâ·×»» */
928function sfTax($price, $tax, $tax_rule) {
929    $real_tax = $tax / 100;
930    $ret = $price * $real_tax;
931    switch($tax_rule) {
932    // »Í¼Î¸ÞÆþ
933    case 1:
934        $ret = round($ret);
935        break;
936    // ÀÚ¤ê¼Î¤Æ
937    case 2:
938        $ret = floor($ret);
939        break;
940    // ÀÚ¤ê¾å¤²
941    case 3:
942        $ret = ceil($ret);
943        break;
944    // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤²
945    default:
946        $ret = ceil($ret);
947        break;
948    }
949    return $ret;
950}
951
952/* ÀǶâÉÕÍ¿ */
953function sfPreTax($price, $tax, $tax_rule) {
954    $real_tax = $tax / 100;
955    $ret = $price * (1 + $real_tax);
956    switch($tax_rule) {
957    // »Í¼Î¸ÞÆþ
958    case 1:
959        $ret = round($ret);
960        break;
961    // ÀÚ¤ê¼Î¤Æ
962    case 2:
963        $ret = floor($ret);
964        break;
965    // ÀÚ¤ê¾å¤²
966    case 3:
967        $ret = ceil($ret);
968        break;
969    // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤²
970    default:
971        $ret = ceil($ret);
972        break;
973    }
974    return $ret;
975}
976
977/* ¥Ý¥¤¥ó¥ÈÉÕÍ¿ */
978function sfPrePoint($price, $point_rate, $rule = POINT_RULE, $product_id = "") {
979    if(sfIsInt($product_id)) {
980        $objQuery = new SC_Query();
981        $where = "to_char(now(),'YYYY/MM/DD/HH24') >= to_char(start_date,'YYYY/MM/DD/HH24') AND ";
982        $where .= "to_char(now(),'YYYY/MM/DD/HH24') < to_char(end_date,'YYYY/MM/DD/HH24') AND ";
983        $where .= "delete = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )";
984        //ÅÐÏ¿(¹¹¿·)ÆüÉÕ½ç
985        $objQuery->setorder('update_date DESC');
986        //¥­¥ã¥ó¥Ú¡¼¥ó¥Ý¥¤¥ó¥È¤Î¼èÆÀ
987        $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id));
988    }
989    //Ê£¿ô¤Î¥­¥ã¥ó¥Ú¡¼¥ó¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾¦Éʤϡ¢ºÇ¿·¤Î¥­¥ã¥ó¥Ú¡¼¥ó¤«¤é¥Ý¥¤¥ó¥È¤ò¼èÆÀ
990    if($arrRet[0]['campaign_point_rate'] != "") {
991        $campaign_point_rate = $arrRet[0]['campaign_point_rate'];
992        $real_point = $campaign_point_rate / 100;
993    } else {
994        $real_point = $point_rate / 100;
995    }
996    $ret = $price * $real_point;
997    switch($rule) {
998    // »Í¼Î¸ÞÆþ
999    case 1:
1000        $ret = round($ret);
1001        break;
1002    // ÀÚ¤ê¼Î¤Æ
1003    case 2:
1004        $ret = floor($ret);
1005        break;
1006    // ÀÚ¤ê¾å¤²
1007    case 3:
1008        $ret = ceil($ret);
1009        break;
1010    // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤²
1011    default:
1012        $ret = ceil($ret);
1013        break;
1014    }
1015    //¥­¥ã¥ó¥Ú¡¼¥ó¾¦Éʤξì¹ç
1016    if($campaign_point_rate != "") {
1017        $ret = "(".$arrRet[0]['campaign_name']."¥Ý¥¤¥ó¥ÈΨ".$campaign_point_rate."%)".$ret;
1018    }
1019    return $ret;
1020}
1021
1022/* µ¬³ÊʬÎà¤Î·ï¿ô¼èÆÀ */
1023function sfGetClassCatCount() {
1024    $sql = "select count(dtb_class.class_id), dtb_class.class_id ";
1025    $sql.= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id ";
1026    $sql.= "where dtb_class.delete = 0 AND dtb_classcategory.delete = 0 ";
1027    $sql.= "group by dtb_class.class_id, dtb_class.name;";
1028    $objQuery = new SC_Query();
1029    $arrList = $objQuery->getall($sql);
1030    // ¥­¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ
1031    $arrRet = sfArrKeyValue($arrList, 'class_id', 'count');
1032    return $arrRet;
1033}
1034
1035/* µ¬³Ê¤ÎÅÐÏ¿ */
1036function sfInsertProductClass($objQuery, $arrList, $product_id) {
1037    // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£
1038    $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
1039    $count = $objQuery->count("dtb_products_class", $where,  array($product_id));
1040   
1041    // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤Ê¤¤¾ì¹ç
1042    if($count == 0) {
1043        // ´û¸µ¬³Ê¤Îºï½ü
1044        $where = "product_id = ?";
1045        $objQuery->delete("dtb_products_class", $where, array($product_id));
1046        $sqlval['product_id'] = $product_id;
1047        $sqlval['classcategory_id1'] = '0';
1048        $sqlval['classcategory_id2'] = '0';
1049        $sqlval['product_code'] = $arrList["product_code"];
1050        $sqlval['stock'] = $arrList["stock"];
1051        $sqlval['stock_unlimited'] = $arrList["stock_unlimited"];
1052        $sqlval['price01'] = $arrList['price01'];
1053        $sqlval['price02'] = $arrList['price02'];
1054        $sqlval['creator_id'] = $_SESSION['member_id'];
1055       
1056        if($_SESSION['member_id'] == "") {
1057            $sqlval['creator_id'] = '0';
1058        }
1059       
1060        // INSERT¤Î¼Â¹Ô
1061        $objQuery->insert("dtb_products_class", $sqlval);
1062    }
1063}
1064
1065function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) {
1066    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
1067    $objQuery = new SC_Query();
1068    $ret = $objQuery->get("dtb_products_class", "product_class_id", $where, Array($product_id, $classcategory_id1, $classcategory_id2));
1069    return $ret;
1070}
1071
1072/* ʸËö¤Î¡Ö/¡×¤ò¤Ê¤¯¤¹ */
1073function sfTrimURL($url) {
1074    $ret = ereg_replace("[/]+$", "", $url);
1075    return $ret;
1076}
1077
1078/* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */
1079function sfGetProductsClass($arrID) {
1080    list($product_id, $classcategory_id1, $classcategory_id2) = $arrID;
1081   
1082    if($classcategory_id1 == "") {
1083        $classcategory_id1 = '0';
1084    }
1085    if($classcategory_id2 == "") {
1086        $classcategory_id2 = '0';
1087    }
1088       
1089    // ¾¦Éʵ¬³Ê¼èÆÀ
1090    $objQuery = new SC_Query();
1091    $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";
1092    $table = "vw_product_class";
1093    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
1094    $objQuery->setorder("rank1 DESC, rank2 DESC");
1095    $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2));
1096    return $arrRet[0];
1097}
1098
1099/* ½¸·×¾ðÊó¤ò¸µ¤ËºÇ½ª·×»» */
1100function sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo, $objCustomer = "") {
1101    // ¾¦Éʤιç·×¸Ä¿ô
1102    $total_quantity = $objCartSess->getTotalQuantity(true);
1103   
1104    // ÀǶâ¤Î¼èÆÀ
1105    $arrData['tax'] = $objPage->tpl_total_tax;
1106    // ¾®·×¤Î¼èÆÀ
1107    $arrData['subtotal'] = $objPage->tpl_total_pretax; 
1108   
1109    // ¹ç·×Á÷ÎÁ¤Î¼èÆÀ
1110    $arrData['deliv_fee'] = 0;
1111       
1112    // ¾¦Éʤ´¤È¤ÎÁ÷ÎÁ¤¬Í­¸ú¤Î¾ì¹ç
1113    if (OPTION_PRODUCT_DELIV_FEE == 1) {
1114        $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee();
1115    }
1116   
1117    // ÇÛÁ÷¶È¼Ô¤ÎÁ÷ÎÁ¤¬Í­¸ú¤Î¾ì¹ç
1118    if (OPTION_DELIV_FEE == 1) {
1119        // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë
1120        $arrData['deliv_fee']+= sfGetDelivFee($arrData['deliv_pref'], $arrData['payment_id']);
1121    }
1122   
1123    // Á÷ÎÁ̵ÎÁ¤Î¹ØÆþ¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç
1124    if(DELIV_FREE_AMOUNT > 0) {
1125        if($total_quantity >= DELIV_FREE_AMOUNT) {
1126            $arrData['deliv_fee'] = 0;
1127        }   
1128    }
1129       
1130    // Á÷ÎÁ̵ÎÁ¾ò·ï¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç
1131    if($arrInfo['free_rule'] > 0) {
1132        // ¾®·×¤¬ÌµÎÁ¾ò·ï¤òͤ¨¤Æ¤¤¤ë¾ì¹ç
1133        if($arrData['subtotal'] >= $arrInfo['free_rule']) {
1134            $arrData['deliv_fee'] = 0;
1135        }
1136    }
1137
1138    // ¹ç·×¤Î·×»»
1139    $arrData['total'] = $objPage->tpl_total_pretax; // ¾¦Éʹç·×
1140    $arrData['total']+= $arrData['deliv_fee'];      // Á÷ÎÁ
1141    $arrData['total']+= $arrData['charge'];         // ¼ê¿ôÎÁ
1142    // ¤ª»Ùʧ¤¤¹ç·×
1143    $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE);
1144    // ²Ã»»¥Ý¥¤¥ó¥È¤Î·×»»
1145    $arrData['add_point'] = sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo);
1146   
1147    if($objCustomer != "") {
1148        // ÃÂÀ¸Æü·î¤Ç¤¢¤Ã¤¿¾ì¹ç
1149        if($objCustomer->isBirthMonth()) {
1150            $arrData['birth_point'] = BIRTH_MONTH_POINT;
1151            $arrData['add_point'] += $arrData['birth_point'];
1152        }
1153    }
1154   
1155    if($arrData['add_point'] < 0) {
1156        $arrData['add_point'] = 0;
1157    }
1158   
1159    return $arrData;
1160}
1161
1162/* ¥«¡¼¥ÈÆâ¾¦Éʤν¸·×½èÍý */
1163function sfTotalCart($objPage, $objCartSess, $arrInfo) {
1164    // µ¬³Ê̾°ìÍ÷
1165    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
1166    // µ¬³ÊʬÎà̾°ìÍ÷
1167    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
1168   
1169    $objPage->tpl_total_pretax = 0;     // ÈñÍѹç·×(Àǹþ¤ß)
1170    $objPage->tpl_total_tax = 0;        // ¾ÃÈñÀǹç·×
1171    $objPage->tpl_total_point = 0;      // ¥Ý¥¤¥ó¥È¹ç·×
1172   
1173    // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ
1174    $arrCart = $objCartSess->getCartList();
1175    $max = count($arrCart);
1176    $cnt = 0;
1177
1178    for ($i = 0; $i < $max; $i++) {
1179        // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
1180        $arrData = sfGetProductsClass($arrCart[$i]['id']);
1181               
1182        // DB¤Ë¸ºß¤¹¤ë¾¦ÉÊ
1183        if (count($arrData) > 0) {
1184           
1185            // ¹ØÆþÀ©¸Â¿ô¤òµá¤á¤ë¡£         
1186            if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') {
1187                if($arrData['sale_limit'] < $arrData['stock']) {
1188                    $limit = $arrData['sale_limit'];
1189                } else {
1190                    $limit = $arrData['stock'];
1191                }
1192            } else {
1193                if ($arrData['sale_unlimited'] != '1') {
1194                    $limit = $arrData['sale_limit'];
1195                }
1196                if ($arrData['stock_unlimited'] != '1') {
1197                    $limit = $arrData['stock'];
1198                }
1199            }
1200                       
1201            if($limit != "" && $limit < $arrCart[$i]['quantity']) {
1202                // ¥«¡¼¥ÈÆâ¾¦ÉÊ¿ô¤òÀ©¸Â¤Ë¹ç¤ï¤»¤ë
1203                $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit);
1204                $quantity = $limit;
1205                $objPage->tpl_message = "¢¨¡Ö" . $arrData['name'] . "¡×¤ÏÈÎÇäÀ©¸Â¤·¤Æ¤ª¤ê¤Þ¤¹¡¢°ìÅ٤ˤ³¤ì°Ê¾å¤Î¹ØÆþ¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
1206            } else {
1207                $quantity = $arrCart[$i]['quantity'];
1208            }
1209           
1210            $objPage->arrProductsClass[$cnt] = $arrData;
1211            $objPage->arrProductsClass[$cnt]['quantity'] = $quantity;
1212            $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no'];
1213            $objPage->arrProductsClass[$cnt]['class_name1'] = $arrClassName[$arrData['class_id1']];
1214            $objPage->arrProductsClass[$cnt]['class_name2'] = $arrClassName[$arrData['class_id2']];
1215            $objPage->arrProductsClass[$cnt]['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
1216            $objPage->arrProductsClass[$cnt]['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
1217           
1218            // ²Á³Ê¤ÎÅÐÏ¿
1219            if ($arrData['price02'] != "") {
1220                $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']);
1221                $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02'];
1222            } else {
1223                $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']);
1224                $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01'];
1225            }
1226            // ¥Ý¥¤¥ó¥ÈÉÕͿΨ¤ÎÅÐÏ¿
1227            $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']);
1228            // ¾¦Éʤ´¤È¤Î¹ç·×¶â³Û
1229            $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']);
1230            // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë
1231            $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']);
1232            $cnt++;
1233        } else {
1234            // DB¤Ë¾¦Éʤ¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï¥«¡¼¥È¾¦Éʤκï½ü
1235            $objCartSess->delProductKey('id', $arrCart[$i]['id']);
1236        }
1237    }
1238   
1239    // Á´¾¦Éʹç·×¶â³Û(Àǹþ¤ß)
1240    $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
1241    // Á´¾¦Éʹç·×¾ÃÈñÀÇ
1242    $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo);
1243    // Á´¾¦Éʹç·×¥Ý¥¤¥ó¥È
1244    $objPage->tpl_total_point = $objCartSess->getAllProductsPoint();
1245   
1246    return $objPage;   
1247}
1248
1249/* DB¤«¤é¼è¤ê½Ð¤·¤¿ÆüÉÕ¤Îʸ»úÎó¤òÄ´À°¤¹¤ë¡£*/
1250function sfDispDBDate($dbdate, $time = true) {
1251    list($y, $m, $d, $H, $M) = split("[- :]", $dbdate);
1252
1253    if(strlen($y) > 0 && strlen($m) > 0 && strlen($d) > 0) {
1254        if ($time) {
1255            $str = sprintf("%04d/%02d/%02d %02d:%02d", $y, $m, $d, $H, $M);
1256        } else {
1257            $str = sprintf("%04d/%02d/%02d", $y, $m, $d, $H, $M);                       
1258        }
1259    } else {
1260        $str = "";
1261    }
1262    return $str;
1263}
1264
1265function sfGetDelivTime($payment_id = "") {
1266    $objQuery = new SC_Query();
1267   
1268    $deliv_id = "";
1269   
1270    if($payment_id != "") {
1271        $where = "delete = 0 AND payment_id = ?";
1272        $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
1273        $deliv_id = $arrRet[0]['deliv_id'];
1274    }
1275   
1276    if($deliv_id != "") {
1277        $objQuery->setorder("time_id");
1278        $where = "deliv_id = ?";
1279        $arrRet= $objQuery->select("time_id, time", "dtb_delivtime", $where, array($deliv_id));
1280    }
1281    return $arrRet;
1282}
1283
1284
1285// ÅÔÆ»Éܸ©¡¢»Ùʧ¤¤ÊýË¡¤«¤éÇÛÁ÷ÎÁ¶â¤ò¼èÆÀ¤¹¤ë
1286function sfGetDelivFee($pref, $payment_id = "") {
1287    $objQuery = new SC_Query();
1288   
1289    $deliv_id = "";
1290   
1291    // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢Âбþ¤·¤¿ÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë
1292    if($payment_id != "") {
1293        $where = "delete = 0 AND payment_id = ?";
1294        $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id));
1295        $deliv_id = $arrRet[0]['deliv_id'];
1296    // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÀèÆ¬¤ÎÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë
1297    } else {
1298        $where = "delete = 0";
1299        $objQuery->setOrder("rank DESC");
1300        $objQuery->setLimitOffset(1);
1301        $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where);
1302        $deliv_id = $arrRet[0]['deliv_id'];
1303    }
1304   
1305    // ÇÛÁ÷¶È¼Ô¤«¤éÇÛÁ÷ÎÁ¤ò¼èÆÀ
1306    if($deliv_id != "") {
1307       
1308        // ÅÔÆ»Éܸ©¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÅìµþÅÔ¤ÎÈÖ¹æ¤ò»ØÄꤷ¤Æ¤ª¤¯
1309        if($pref == "") {
1310            $pref = 13;
1311        }
1312       
1313        $objQuery = new SC_Query();
1314        $where = "deliv_id = ? AND pref = ?";
1315        $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref));
1316    }   
1317    return $arrRet[0]['fee'];   
1318}
1319
1320/* »Ùʧ¤¤ÊýË¡¤Î¼èÆÀ */
1321function sfGetPayment() {
1322    $objQuery = new SC_Query();
1323    // ¹ØÆþ¶â³Û¤¬¾ò·ï³Û°Ê²¼¤Î¹àÌܤò¼èÆÀ
1324    $where = "delete = 0";
1325    $objQuery->setorder("fix, rank DESC");
1326    $arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where);
1327    return $arrRet;
1328}
1329
1330/* ÇÛÎó¤ò¥­¡¼Ì¾¤´¤È¤ÎÇÛÎó¤ËÊѹ¹¤¹¤ë */
1331function sfSwapArray($array) {
1332    $max = count($array);
1333    for($i = 0; $i < $max; $i++) {
1334        foreach($array[$i] as $key => $val) {
1335            $arrRet[$key][] = $val;
1336        }
1337    }
1338    return $arrRet;
1339}
1340
1341/* ¤«¤±»»¤ò¤¹¤ë¡ÊSmartyÍÑ) */
1342function sfMultiply($num1, $num2) {
1343    return ($num1 * $num2);
1344}
1345
1346/* DB¤ËÅÐÏ¿¤µ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È¥á¡¼¥ë¤ÎÁ÷¿® */
1347function sfSendTemplateMail($to, $to_name, $template_id, $objPage) {
1348    global $arrMAILTPLPATH;
1349    $objQuery = new SC_Query();
1350    // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ
1351    $where = "template_id = ?";
1352    $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id));
1353    $objPage->tpl_header = $arrRet[0]['header'];
1354    $objPage->tpl_footer = $arrRet[0]['footer'];
1355    $tmp_subject = $arrRet[0]['subject'];
1356   
1357    $objSiteInfo = new SC_SiteInfo();
1358    $arrInfo = $objSiteInfo->data;
1359   
1360    $objMailView = new SC_SiteView();
1361    // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ
1362    $objMailView->assignobj($objPage);
1363    $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]);
1364   
1365    // ¥á¡¼¥ëÁ÷¿®½èÍý
1366    $objSendMail = new GC_SendMail();
1367    $from = $arrInfo['email03'];
1368    $error = $arrInfo['email04'];
1369    $tosubject = $tmp_subject;
1370    $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error);
1371    $objSendMail->setTo($to, $to_name);
1372    $objSendMail->sendMail();   // ¥á¡¼¥ëÁ÷¿®
1373}
1374
1375/* ¼õÃí´°Î»¥á¡¼¥ëÁ÷¿® */
1376function sfSendOrderMail($order_id, $template_id, $subject = "", $header = "", $footer = "", $send = true) {
1377    global $arrMAILTPLPATH;
1378   
1379    $objPage = new LC_Page();
1380    $objSiteInfo = new SC_SiteInfo();
1381    $arrInfo = $objSiteInfo->data;
1382    $objPage->arrInfo = $arrInfo;
1383   
1384    $objQuery = new SC_Query();
1385       
1386    if($subject == "" && $header == "" && $footer == "") {
1387        // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ
1388        $where = "template_id = ?";
1389        $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array('1'));
1390        $objPage->tpl_header = $arrRet[0]['header'];
1391        $objPage->tpl_footer = $arrRet[0]['footer'];
1392        $tmp_subject = $arrRet[0]['subject'];
1393    } else {
1394        $objPage->tpl_header = $header;
1395        $objPage->tpl_footer = $footer;
1396        $tmp_subject = $subject;
1397    }
1398   
1399    // ¼õÃí¾ðÊó¤Î¼èÆÀ
1400    $where = "order_id = ?";
1401    $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
1402    $arrOrder = $arrRet[0];
1403    $arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id));
1404   
1405    /*
1406    // È÷¹Í¤ò256¥Ð¥¤¥È¤Çʬ³ä
1407    $arrMessage = explode("\n",$arrOrder['message']);
1408   
1409    sfprintr($arrMessage);
1410    $Message_tmp = "";
1411    foreach($arrMessage as $key => $val){
1412        if (strlen($val) > 256) {
1413            $Message_tmp .= wordwrap($val,256,"\n", 1);
1414        } else {
1415            $Message_tmp .= $val."\n";
1416        }
1417    }
1418    $objPage->Message_tmp = $Message_tmp;   
1419    */
1420    $objPage->Message_tmp = $arrOrder['message'];
1421       
1422    // ¸ÜµÒ¾ðÊó¤Î¼èÆÀ
1423    $customer_id = $arrOrder['customer_id'];
1424    $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
1425    $arrCustomer = $arrRet[0];
1426
1427    $objPage->arrCustomer = $arrCustomer;
1428    $objPage->arrOrder = $arrOrder;
1429
1430    //¥³¥ó¥Ó¥Ë·èºÑ¾ðÊó
1431    if($arrOrder['conveni_data'] != "") {
1432        global $arrCONVENIENCE;
1433        global $arrCONVENIMESSAGE;
1434        $objPage->arrCONVENIENCE = $arrCONVENIENCE;
1435        $objPage->arrCONVENIMESSAGE = $arrCONVENIMESSAGE;
1436        $arrConv = unserialize($arrOrder['conveni_data']);
1437        $objPage->arrConv = $arrConv;
1438    }
1439
1440    // ÅÔÆ»Éܸ©ÊÑ´¹
1441    global $arrPref;
1442    $objPage->arrOrder['deliv_pref'] = $arrPref[$objPage->arrOrder['deliv_pref']];
1443   
1444    $objPage->arrOrderDetail = $arrOrderDetail;
1445   
1446    $objCustomer = new SC_Customer();
1447    $objPage->tpl_user_point = $objCustomer->getValue('point');
1448   
1449    $objMailView = new SC_SiteView();
1450    // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ
1451    $objMailView->assignobj($objPage);
1452    $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]);
1453   
1454    // ¥á¡¼¥ëÁ÷¿®½èÍý
1455    $objSendMail = new GC_SendMail();
1456    $bcc = $arrInfo['email01'];
1457    $from = $arrInfo['email03'];
1458    $error = $arrInfo['email04'];
1459   
1460    $tosubject = sfMakeSubject($tmp_subject);
1461   
1462    $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
1463    $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." ÍÍ");
1464
1465
1466    // Á÷¿®¥Õ¥é¥°:true¤Î¾ì¹ç¤Ï¡¢Á÷¿®¤¹¤ë¡£
1467    if($send) {
1468        if ($objSendMail->sendMail()) {
1469            sfSaveMailHistory($order_id, $template_id, $tosubject, $body);
1470        }
1471    }
1472
1473    return $objSendMail;
1474}
1475
1476// ¥Æ¥ó¥×¥ì¡¼¥È¤ò»ÈÍѤ·¤¿¥á¡¼¥ë¤ÎÁ÷¿®
1477function sfSendTplMail($to, $subject, $tplpath, $objPage) {
1478    $objMailView = new SC_SiteView();
1479    $objSiteInfo = new SC_SiteInfo();
1480    $arrInfo = $objSiteInfo->data;
1481    // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ
1482    $objPage->tpl_shopname=$arrInfo['shop_name'];
1483    $objPage->tpl_infoemail = $arrInfo['email02'];
1484    $objMailView->assignobj($objPage);
1485    $body = $objMailView->fetch($tplpath);
1486    // ¥á¡¼¥ëÁ÷¿®½èÍý
1487    $objSendMail = new GC_SendMail();
1488    $to = mb_encode_mimeheader($to);
1489    $bcc = $arrInfo['email01'];
1490    $from = $arrInfo['email03'];
1491    $error = $arrInfo['email04'];
1492    $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
1493    $objSendMail->sendMail();   
1494}
1495
1496// Ä̾ï¤Î¥á¡¼¥ëÁ÷¿®
1497function sfSendMail($to, $subject, $body) {
1498    $objSiteInfo = new SC_SiteInfo();
1499    $arrInfo = $objSiteInfo->data;
1500    // ¥á¡¼¥ëÁ÷¿®½èÍý
1501    $objSendMail = new GC_SendMail();
1502    $bcc = $arrInfo['email01'];
1503    $from = $arrInfo['email03'];
1504    $error = $arrInfo['email04'];
1505    $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
1506    $objSendMail->sendMail();
1507}
1508
1509//·ï̾¤Ë¥Æ¥ó¥×¥ì¡¼¥È¤òÍѤ¤¤ë
1510function sfMakeSubject($subject){
1511   
1512    $objQuery = new SC_Query();
1513    $objMailView = new SC_SiteView();
1514    $objPage = new LC_Page();
1515   
1516    $arrInfo = $objQuery->select("*","dtb_baseinfo");
1517    $arrInfo = $arrInfo[0];
1518    $objPage->tpl_shopname=$arrInfo['shop_name'];
1519    $objPage->tpl_infoemail=$subject;
1520    $objMailView->assignobj($objPage);
1521    $mailtitle = $objMailView->fetch('mail_templates/mail_title.tpl');
1522    $ret = $mailtitle.$subject;
1523    return $ret;
1524}
1525
1526// ¥á¡¼¥ëÇÛ¿®ÍúÎò¤Ø¤ÎÅÐÏ¿
1527function sfSaveMailHistory($order_id, $template_id, $subject, $body) {
1528    $sqlval['subject'] = $subject;
1529    $sqlval['order_id'] = $order_id;
1530    $sqlval['template_id'] = $template_id;
1531    $sqlval['send_date'] = "Now()";
1532    if($_SESSION['member_id'] != "") {
1533        $sqlval['creator_id'] = $_SESSION['member_id'];
1534    } else {
1535        $sqlval['creator_id'] = '0';
1536    }
1537    $sqlval['mail_body'] = $body;
1538   
1539    $objQuery = new SC_Query();
1540    $objQuery->insert("dtb_mail_history", $sqlval);
1541}
1542
1543/* ²ñ°÷¾ðÊó¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */
1544function sfGetCustomerSqlVal($uniqid, $sqlval) {
1545    $objCustomer = new SC_Customer();
1546    // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý
1547    if ($objCustomer->isLoginSuccess()) {
1548        // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
1549        $sqlval['order_temp_id'] = $uniqid;
1550        $sqlval['update_date'] = 'Now()';
1551        $sqlval['customer_id'] = $objCustomer->getValue('customer_id');
1552        $sqlval['order_name01'] = $objCustomer->getValue('name01');
1553        $sqlval['order_name02'] = $objCustomer->getValue('name02');
1554        $sqlval['order_kana01'] = $objCustomer->getValue('kana01');
1555        $sqlval['order_kana02'] = $objCustomer->getValue('kana02');
1556        $sqlval['order_sex'] = $objCustomer->getValue('sex');
1557        $sqlval['order_zip01'] = $objCustomer->getValue('zip01');
1558        $sqlval['order_zip02'] = $objCustomer->getValue('zip02');
1559        $sqlval['order_pref'] = $objCustomer->getValue('pref');
1560        $sqlval['order_addr01'] = $objCustomer->getValue('addr01');
1561        $sqlval['order_addr02'] = $objCustomer->getValue('addr02');
1562        $sqlval['order_tel01'] = $objCustomer->getValue('tel01');
1563        $sqlval['order_tel02'] = $objCustomer->getValue('tel02');
1564        $sqlval['order_tel03'] = $objCustomer->getValue('tel03');
1565        $sqlval['order_email'] = $objCustomer->getValue('email');
1566        $sqlval['order_job'] = $objCustomer->getValue('job');
1567        $sqlval['order_birth'] = $objCustomer->getValue('birth');
1568    }
1569    return $sqlval;
1570}
1571
1572// ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ø¤Î½ñ¤­¹þ¤ß½èÍý
1573function sfRegistTempOrder($uniqid, $sqlval) {
1574    if($uniqid != "") {
1575        // ´û¸¥Ç¡¼¥¿¤Î¥Á¥§¥Ã¥¯
1576        $objQuery = new SC_Query();
1577        $where = "order_temp_id = ?";
1578        $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid));
1579        // ´û¸¥Ç¡¼¥¿¤¬¤Ê¤¤¾ì¹ç
1580        if ($cnt == 0) {
1581            // ½é²ó½ñ¤­¹þ¤ß»þ¤Ë²ñ°÷¤ÎÅÐÏ¿ºÑ¤ß¾ðÊó¤ò¼è¤ê¹þ¤à
1582            $sqlval = sfGetCustomerSqlVal($uniqid, $sqlval);
1583            $objQuery->insert("dtb_order_temp", $sqlval);
1584        } else {
1585            $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
1586        }
1587    }
1588}
1589
1590/* ²ñ°÷¤Î¥á¥ë¥Þ¥¬ÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤Î¥Á¥§¥Ã¥¯(²¾²ñ°÷¤ò´Þ¤Þ¤Ê¤¤) */
1591function sfCheckCustomerMailMaga($email) {
1592    $col = "T1.email, T1.mail_flag, T2.customer_id";
1593    $from = "dtb_customer_mail AS T1 LEFT JOIN dtb_customer AS T2 ON T1.email = T2.email";
1594    $where = "T1.email = ? AND T2.status = 2";
1595    $objQuery = new SC_Query();
1596    $arrRet = $objQuery->select($col, $from, $where, array($email));
1597    // ²ñ°÷¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë
1598    if($arrRet[0]['customer_id'] != "") {
1599        return true;
1600    }
1601    return false;
1602}
1603
1604// ¥«¡¼¥É¤Î½èÍý·ë²Ì¤òÊÖ¤¹
1605function sfGetAuthonlyResult($dir, $file_name, $name01, $name02, $card_no, $card_exp, $amount, $order_id, $jpo_info = "10"){
1606
1607    $path = $dir .$file_name;       // cgi¥Õ¥¡¥¤¥ë¤Î¥Õ¥ë¥Ñ¥¹À¸À®
1608    $now_dir = getcwd();            // require¤¬¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¤Î¤Ç¡¢cgi¼Â¹Ô¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Üư¤¹¤ë
1609    chdir($dir);
1610   
1611    // ¥Ñ¥¤¥×ÅϤ·¤Ç¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤écgiµ¯Æ°
1612    $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info";
1613
1614    $tmpResult = popen($cmd, "r");
1615   
1616    // ·ë²Ì¼èÆÀ
1617    while( ! FEOF ( $tmpResult ) ) {
1618        $result .= FGETS($tmpResult);
1619    }
1620    pclose($tmpResult);             //  ¥Ñ¥¤¥×¤òÊĤ¸¤ë
1621    chdir($now_dir);                //¡¡¸µ¤Ë¤¤¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ëµ¢¤ë
1622   
1623    // ·ë²Ì¤òÏ¢ÁÛÇÛÎ󤨳ÊǼ
1624    $result = ereg_replace("&$", "", $result);
1625    foreach (explode("&",$result) as $data) {
1626        list($key, $val) = explode("=", $data, 2);
1627        $return[$key] = $val;
1628    }
1629   
1630    return $return;
1631}
1632
1633// ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤«¤é¾ðÊó¤ò¼èÆÀ¤¹¤ë
1634function sfGetOrderTemp($order_temp_id) {
1635    $objQuery = new SC_Query();
1636    $where = "order_temp_id = ?";
1637    $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id));
1638    return $arrRet[0];
1639}
1640
1641// ¥«¥Æ¥´¥êID¼èÆÀȽÄêÍѤΥ°¥í¡¼¥Ð¥ëÊÑ¿ô(°ìÅÙ¼èÆÀ¤µ¤ì¤Æ¤¤¤¿¤éºÆ¼èÆÀ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë)
1642$g_category_on = false;
1643$g_category_id = "";
1644
1645/* ÁªÂòÃæ¤Î¥«¥Æ¥´¥ê¤ò¼èÆÀ¤¹¤ë */
1646function sfGetCategoryId($product_id, $category_id) {
1647    global $g_category_on;
1648    global $g_category_id;
1649    if(!$g_category_on) {
1650        $g_category_on = true;
1651        if(sfIsInt($category_id) && sfIsRecord("dtb_category","category_id", $category_id)) {
1652            $g_category_id = $category_id;
1653        } else if (sfIsInt($product_id) && sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) {
1654            $objQuery = new SC_Query();
1655            $where = "product_id = ?";
1656            $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id));
1657            $g_category_id = $category_id;
1658        } else {
1659            // ÉÔÀµ¤Ê¾ì¹ç¤Ï¡¢0¤òÊÖ¤¹¡£
1660            $g_category_id = 0;
1661        }
1662    }
1663    return $g_category_id;
1664}
1665
1666// ROOTID¼èÆÀȽÄêÍѤΥ°¥í¡¼¥Ð¥ëÊÑ¿ô(°ìÅÙ¼èÆÀ¤µ¤ì¤Æ¤¤¤¿¤éºÆ¼èÆÀ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë)
1667$g_root_on = false;
1668$g_root_id = "";
1669
1670/* ÁªÂòÃæ¤Î¥¢¥¤¥Æ¥à¤Î¥ë¡¼¥È¥«¥Æ¥´¥êID¤ò¼èÆÀ¤¹¤ë */
1671function sfGetRootId() {
1672    global $g_root_on;
1673    global $g_root_id;
1674    if(!$g_root_on) {
1675        $g_root_on = true;
1676        $objQuery = new SC_Query();
1677        if($_GET['product_id'] != "" || $_GET['category_id'] != "") {
1678            // ÁªÂòÃæ¤Î¥«¥Æ¥´¥êID¤òȽÄꤹ¤ë
1679            $category_id = sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
1680            // ROOT¥«¥Æ¥´¥êID¤Î¼èÆÀ
1681             $arrRet = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
1682             $root_id = $arrRet[0];
1683        } else {
1684            // ROOT¥«¥Æ¥´¥êID¤ò¤Ê¤·¤ËÀßÄꤹ¤ë
1685            $root_id = "";
1686        }
1687        $g_root_id = $root_id;
1688    }
1689    return $g_root_id;
1690}
1691
1692/* ¥«¥Æ¥´¥ê¤«¤é¾¦Éʤò¸¡º÷¤¹¤ë¾ì¹ç¤ÎWHEREʸ¤ÈÃͤòÊÖ¤¹ */
1693function sfGetCatWhere($category_id) {
1694    // »Ò¥«¥Æ¥´¥êID¤Î¼èÆÀ
1695    $arrRet = sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id);
1696    $tmp_where = "";
1697    foreach ($arrRet as $val) {
1698        if($tmp_where == "") {
1699            $tmp_where.= " category_id IN ( ? ";
1700        } else {
1701            $tmp_where.= " ,? ";
1702        }
1703        $arrval[] = $val;
1704    }
1705    $tmp_where.= " ) ";
1706    return array($tmp_where, $arrval);
1707}
1708
1709/* ²Ã»»¥Ý¥¤¥ó¥È¤Î·×»»¼° */
1710function sfGetAddPoint($totalpoint, $use_point, $arrInfo) {
1711    // ¹ØÆþ¾¦Éʤιç·×¥Ý¥¤¥ó¥È¤«¤éÍøÍѤ·¤¿¥Ý¥¤¥ó¥È¤Î¥Ý¥¤¥ó¥È´¹»»²ÁÃͤò°ú¤¯Êý¼°
1712    $add_point = $totalpoint - intval($use_point * ($arrInfo['point_rate'] / 100));
1713   
1714    if($add_point < 0) {
1715        $add_point = '0';
1716    }
1717    return $add_point;
1718}
1719
1720/* °ì°Õ¤«¤Äͽ¬¤µ¤ì¤Ë¤¯¤¤ID */
1721function sfGetUniqRandomId($head = "") {
1722    // ͽ¬¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¥é¥ó¥À¥àʸ»úÎó¤òÉÕÍ¿¤¹¤ë¡£
1723    $random = gfMakePassword(8);
1724    // Ʊ°ì¥Û¥¹¥ÈÆâ¤Ç°ì°Õ¤ÊID¤òÀ¸À®
1725    $id = uniqid($head);
1726    return ($id . $random);
1727}
1728
1729// ¥«¥Æ¥´¥êÊÌ¥ª¥¹¥¹¥áÉʤμèÆÀ
1730function sfGetBestProducts( $conn, $category_id = 0){
1731    // ´û¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÆâÍÆ¤ò¼èÆÀ¤¹¤ë
1732    $sql = "SELECT name, main_image, main_list_image, price01_min, price01_max, price02_min, price02_max, point_rate,
1733             A.product_id, A.comment FROM dtb_best_products as A LEFT JOIN vw_products_allclass as B
1734            USING (product_id) WHERE A.category_id = ? AND A.delete = 0 AND status = 1 ORDER BY A.rank";
1735    $arrItems = $conn->getAll($sql, array($category_id));
1736    return $arrItems;
1737}
1738
1739// ÆÃ¼ìÀ©¸æÊ¸»ú¤Î¼êư¥¨¥¹¥±¡¼¥×
1740function sfManualEscape($data) {
1741    // ÇÛÎó¤Ç¤Ê¤¤¾ì¹ç
1742    if(!is_array($data)) {         
1743        $ret = pg_escape_string($data);
1744        $ret = ereg_replace("%", "\\%", $ret);
1745        $ret = ereg_replace("_", "\\_", $ret);
1746        return $ret;
1747    }
1748   
1749    // ÇÛÎó¤Î¾ì¹ç
1750    foreach($data as $val) {
1751        $ret = pg_escape_string($val);
1752        $ret = ereg_replace("%", "\\%", $ret);
1753        $ret = ereg_replace("_", "\\_", $ret);
1754        $arrRet[] = $ret;
1755    }
1756    return $arrRet;
1757}
1758
1759// ¼õÃíÈÖ¹æ¡¢ÍøÍѥݥ¤¥ó¥È¡¢²Ã»»¥Ý¥¤¥ó¥È¤«¤éºÇ½ª¥Ý¥¤¥ó¥È¤ò¼èÆÀ
1760function sfGetCustomerPoint($order_id, $use_point, $add_point) {
1761    $objQuery = new SC_Query();
1762    $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id));
1763    $customer_id = $arrRet[0]['customer_id'];
1764    if($customer_id != "" && $customer_id >= 1) {
1765        $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id));
1766        $point = $arrRet[0]['point'];
1767        $total_point = $arrRet[0]['point'] - $use_point + $add_point;
1768    } else {
1769        $total_point = "";
1770        $point = "";
1771    }
1772    return array($point, $total_point);
1773}
1774
1775/* ¥É¥á¥¤¥ó´Ö¤ÇÍ­¸ú¤Ê¥»¥Ã¥·¥ç¥ó¤Î¥¹¥¿¡¼¥È */
1776function sfDomainSessionStart() {
1777    $ret = session_id();
1778   
1779/*
1780    ¥Ø¥Ã¥À¡¼¤òÁ÷¿®¤·¤Æ¤¤¤Æ¤âsession_start()¤¬É¬Íפʥڡ¼¥¸¤¬¤¢¤ë¤Î¤Ç
1781    ¥³¥á¥ó¥È¥¢¥¦¥È¤·¤Æ¤ª¤¯
1782    if($ret == "" && !headers_sent()) {
1783*/
1784    if($ret == "") {
1785        /* ¥»¥Ã¥·¥ç¥ó¥Ñ¥é¥á¡¼¥¿¤Î»ØÄê
1786         ¡¦¥Ö¥é¥¦¥¶¤òÊĤ¸¤ë¤Þ¤ÇÍ­¸ú
1787         ¡¦¤¹¤Ù¤Æ¤Î¥Ñ¥¹¤ÇÍ­¸ú
1788         ¡¦Æ±¤¸¥É¥á¥¤¥ó´Ö¤Ç¶¦Í­ */
1789        session_set_cookie_params (0, "/", DOMAIN_NAME);
1790       
1791        if(!ini_get("session.auto_start")){
1792            // ¥»¥Ã¥·¥ç¥ó³«»Ï
1793            session_start();
1794        }
1795    }
1796}
1797
1798/* ʸ»úÎó¤Ë¶¯À©Åª¤Ë²þ¹Ô¤òÆþ¤ì¤ë */
1799function sfPutBR($str, $size) {
1800    $i = 0;
1801    $cnt = 0;
1802    $line = array();
1803    $ret = "";
1804   
1805    while($str[$i] != "") {
1806        $line[$cnt].=$str[$i];
1807        $i++;
1808        if(strlen($line[$cnt]) > $size) {
1809            $line[$cnt].="<br />";
1810            $cnt++;
1811        }
1812    }
1813   
1814    foreach($line as $val) {
1815        $ret.=$val;
1816    }
1817    return $ret;
1818}
1819
1820// Æó²ó°Ê¾å·«¤êÊÖ¤µ¤ì¤Æ¤¤¤ë¥¹¥é¥Ã¥·¥å[/]¤ò°ì¤Ä¤ËÊÑ´¹¤¹¤ë¡£
1821function sfRmDupSlash($istr){
1822    if(ereg("^http://", $istr)) {
1823        $str = substr($istr, 7);
1824        $head = "http://";
1825    } else if(ereg("^https://", $istr)) {
1826        $str = substr($istr, 8);
1827        $head = "https://";
1828    } else {
1829        $str = $istr;
1830    }
1831    $str = ereg_replace("[/]+", "/", $str);
1832    $ret = $head . $str;
1833    return $ret;   
1834}
1835
1836function sfEncodeFile($filepath, $enc_type, $out_dir) {
1837    $ifp = fopen($filepath, "r");
1838   
1839    $basename = basename($filepath);
1840    $outpath = $out_dir . "enc_" . $basename;
1841   
1842    $ofp = fopen($outpath, "w+");
1843   
1844    while(!feof($ifp)) {
1845        $line = fgets($ifp);
1846        $line = mb_convert_encoding($line, $enc_type, "auto");
1847        fwrite($ofp,  $line);
1848    }
1849   
1850    fclose($ofp);
1851    fclose($ifp);
1852   
1853    return  $outpath;
1854}
1855
1856function sfCutString($str, $len, $byte = true) {
1857    if($byte) {
1858        if(strlen($str) > ($len + 2)) {
1859            $ret =substr($str, 0, $len) . "...";
1860        } else {
1861            $ret = $str;
1862        }
1863    } else {
1864        if(mb_strlen($str) > ($len + 1)) {
1865            $ret = mb_substr($str, 0, $len) . "...";
1866        } else {
1867            $ret = $str;
1868        }
1869    }
1870    return $ret;
1871}
1872
1873// ǯ¡¢·î¡¢Äù¤áÆü¤«¤é¡¢Àè·î¤ÎÄù¤áÆü+1¡¢º£·î¤ÎÄù¤áÆü¤òµá¤á¤ë¡£
1874function sfTermMonth($year, $month, $close_day) {
1875    $end_year = $year;
1876    $end_month = $month;
1877   
1878    // ³«»Ï·î¤¬½ªÎ»·î¤ÈƱ¤¸¤«Èݤ«
1879    $same_month = false;
1880   
1881    // ³ºÅö·î¤ÎËöÆü¤òµá¤á¤ë¡£
1882    $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
1883   
1884    // ·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç
1885    if($end_last_day < $close_day) {
1886        // Äù¤áÆü¤ò·îËöÆü¤Ë¹ç¤ï¤»¤ë
1887        $end_day = $end_last_day;
1888    } else {
1889        $end_day = $close_day;
1890    }
1891   
1892    // Á°·î¤Î¼èÆÀ
1893    $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year));
1894    $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year));
1895    // Á°·î¤ÎËöÆü¤òµá¤á¤ë¡£
1896    $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year));
1897   
1898    // Á°·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç
1899    if ($start_last_day < $close_day) {
1900        // ·îËöÆü¤Ë¹ç¤ï¤»¤ë
1901        $tmp_day = $start_last_day;
1902    } else {
1903        $tmp_day = $close_day;
1904    }
1905   
1906    // Àè·î¤ÎËöÆü¤ÎÍâÆü¤ò¼èÆÀ¤¹¤ë
1907    $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
1908    $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
1909    $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
1910   
1911    // ÆüÉդκîÀ®
1912    $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day);
1913    $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day);
1914   
1915    return array($start_date, $end_date);
1916}
1917
1918// PDFÍѤÎRGB¥«¥é¡¼¤òÊÖ¤¹
1919function sfGetPdfRgb($hexrgb) {
1920    $hex = substr($hexrgb, 0, 2);
1921    $r = hexdec($hex) / 255;
1922   
1923    $hex = substr($hexrgb, 2, 2);
1924    $g = hexdec($hex) / 255;
1925   
1926    $hex = substr($hexrgb, 4, 2);
1927    $b = hexdec($hex) / 255;
1928   
1929    return array($r, $g, $b);   
1930}
1931
1932//¥á¥ë¥Þ¥¬²¾ÅÐÏ¿¤È¥á¡¼¥ëÇÛ¿®
1933function sfRegistTmpMailData($mail_flag, $email){
1934    $objQuery = new SC_Query();
1935    $objConn = new SC_DBConn();
1936    $objPage = new LC_Page();
1937   
1938    $random_id = sfGetUniqRandomId();
1939    $arrRegistMailMagazine["mail_flag"] = $mail_flag;
1940    $arrRegistMailMagazine["email"] = $email;
1941    $arrRegistMailMagazine["temp_id"] =$random_id;
1942    $arrRegistMailMagazine["end_flag"]='0';
1943    $arrRegistMailMagazine["update_date"] = 'now()';
1944   
1945    //¥á¥ë¥Þ¥¬²¾ÅÐÏ¿Íѥե饰
1946    $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email));
1947    $objConn->query("BEGIN");
1948    switch ($flag){
1949        case '0':
1950        $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine);
1951        break;
1952   
1953        case '1':
1954        $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = '" .addslashes($email). "'");
1955        break;
1956    }
1957    $objConn->query("COMMIT");
1958    $subject = sfMakeSubject('¥á¥ë¥Þ¥¬²¾ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£');
1959    $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id'];
1960    switch ($mail_flag){
1961        case '1':
1962        $objPage->tpl_name = "ÅÐÏ¿";
1963        $objPage->tpl_kindname = "HTML";
1964        break;
1965       
1966        case '2':
1967        $objPage->tpl_name = "ÅÐÏ¿";
1968        $objPage->tpl_kindname = "¥Æ¥­¥¹¥È";
1969        break;
1970       
1971        case '3':
1972        $objPage->tpl_name = "²ò½ü";
1973        break;
1974    }
1975        $objPage->tpl_email = $email;
1976    sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage);
1977}
1978
1979// ºÆµ¢Åª¤Ë¿ÃÊÇÛÎó¤ò¸¡º÷¤·¤Æ°ì¼¡¸µÇÛÎó(Hidden°úÅϤ·ÍÑÇÛÎó)¤ËÊÑ´¹¤¹¤ë¡£
1980function sfMakeHiddenArray($arrSrc, $arrDst = array(), $parent_key = "") {
1981    if(is_array($arrSrc)) {
1982        foreach($arrSrc as $key => $val) {
1983            if($parent_key != "") {
1984                $keyname = $parent_key . "[". $key . "]";
1985            } else {
1986                $keyname = $key;
1987            }
1988            if(is_array($val)) {
1989                $arrDst = sfMakeHiddenArray($val, $arrDst, $keyname);
1990            } else {
1991                $arrDst[$keyname] = $val;
1992            }
1993        }
1994    }
1995    return $arrDst;
1996}
1997
1998// DB¼èÆÀÆü»þ¤ò¥¿¥¤¥à¤ËÊÑ´¹
1999function sfDBDatetoTime($db_date) {
2000    $date = ereg_replace("\..*$","",$db_date);
2001    $time = strtotime($date);
2002    return $time;
2003}
2004
2005// ½ÐÎϤκݤ˥ƥó¥×¥ì¡¼¥È¤òÀÚ¤êÂØ¤¨¤é¤ì¤ë
2006/*
2007    index.php?tpl=test.tpl
2008*/
2009function sfCustomDisplay($objPage) {
2010    $basename = basename($_SERVER["REQUEST_URI"]);
2011
2012    if($basename == "") {
2013        $path = $_SERVER["REQUEST_URI"] . "index.php";
2014    } else {
2015        $path = $_SERVER["REQUEST_URI"];
2016    }   
2017
2018    if($_GET['tpl'] != "") {
2019        $tpl_name = $_GET['tpl'];
2020    } else {
2021        $tpl_name = ereg_replace("^/", "", $path);
2022        $tpl_name = ereg_replace("/", "_", $tpl_name);
2023        $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name);
2024    }
2025
2026    $template_path = TEMPLATE_FTP_DIR . $tpl_name;
2027
2028    if(file_exists($template_path)) {
2029        $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR);
2030        $objView->assignobj($objPage);
2031        $objView->display($tpl_name);
2032    } else {
2033        $objView = new SC_SiteView();
2034        $objView->assignobj($objPage);
2035        $objView->display(SITE_FRAME);
2036    }
2037}
2038
2039//²ñ°÷ÊÔ½¸ÅÐÏ¿½èÍý
2040function sfEditCustomerData($array, $arrRegistColumn) {
2041    $objQuery = new SC_Query();
2042   
2043    foreach ($arrRegistColumn as $data) {
2044        if ($data["column"] != "password") {
2045            if($array[ $data['column'] ] != "") {
2046                $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
2047            } else {
2048                $arrRegist[ $data['column'] ] = NULL;
2049            }
2050        }
2051    }
2052    if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) {
2053        $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00";
2054    } else {
2055        $arrRegist["birth"] = NULL;
2056    }
2057
2058    //-- ¥Ñ¥¹¥ï¡¼¥É¤Î¹¹¿·¤¬¤¢¤ë¾ì¹ç¤Ï°Å¹æ²½¡£¡Ê¹¹¿·¤¬¤Ê¤¤¾ì¹ç¤ÏUPDATEʸ¤ò¹½À®¤·¤Ê¤¤¡Ë
2059    if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = crypt($array["password"]);
2060    $arrRegist["update_date"] = "NOW()";
2061   
2062    $sqlval['email'] = $array['email'];
2063    $sqlval['mail_flag'] = $array['mail_flag'];
2064    //-- ÊÔ½¸ÅÐÏ¿¼Â¹Ô
2065    $objQuery->begin();
2066    $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id']));
2067    $objQuery->delete("dtb_customer_mail", "email = ?", array($array['email']));
2068    $objQuery->insert("dtb_customer_mail", $sqlval);
2069    $objQuery->commit();
2070}
2071
2072// PHP¤Îmb_convert_encoding´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë
2073function sf_mb_convert_encoding($str, $encode = 'EUC-JP') {
2074    return  mb_convert_encoding($str, $encode);
2075}   
2076
2077// PHP¤Îmktime´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë
2078function sf_mktime($format, $hour=0, $minute=0, $second=0, $month=1, $day=1, $year=1999) {
2079    return  date($format,mktime($hour, $minute, $second, $month, $day, $year));
2080}   
2081
2082// PHP¤Îdate´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë
2083function sf_date($format, $timestamp = '') {
2084    return  date( $format, $timestamp);
2085}
2086
2087// ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤Î·¿¤òÊÑ´¹¤¹¤ë
2088function sfChangeCheckBox($data , $tpl = false){
2089    if ($tpl) {
2090        if ($data == 1){
2091            return 'checked';
2092        }else{
2093            return "";
2094        }
2095    }else{
2096        if ($data == "on"){
2097            return 1;
2098        }else{
2099            return 2;
2100        }
2101    }
2102}
2103
2104function sfCategory_Count($objQuery){
2105    $sql = "";
2106   
2107    //¥Æ¡¼¥Ö¥ëÆâÍÆ¤Îºï½ü
2108    $objQuery->query("DELETE FROM dtb_category_count");
2109    $objQuery->query("DELETE FROM dtb_category_total_count");
2110   
2111    //³Æ¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò¿ô¤¨¤Æ³ÊǼ
2112    $sql = " INSERT INTO dtb_category_count(category_id, product_count) ";
2113    $sql .= " SELECT T1.category_id, count(T2.category_id) FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 ";
2114    $sql .= " ON T1.category_id = T2.category_id  ";
2115    $sql .= " WHERE T2.delete = 0 AND T2.status = 1 ";
2116    $sql .= " GROUP BY T1.category_id, T2.category_id ";
2117    $objQuery->query($sql);
2118   
2119    //»Ò¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò½¸·×¤¹¤ë
2120    $arrCat = $objQuery->getAll("SELECT * FROM dtb_category");
2121   
2122    $sql = "";
2123    foreach($arrCat as $key => $val){
2124       
2125        // »ÒID°ìÍ÷¤ò¼èÆÀ
2126        $arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']);
2127        $line = sfGetCommaList($arrRet);
2128       
2129        $sql = " INSERT INTO dtb_category_total_count(category_id, product_count) ";
2130        $sql .= " SELECT ?, SUM(product_count) FROM dtb_category_count ";
2131        $sql .= " WHERE category_id IN (" . $line . ")";
2132               
2133        $objQuery->query($sql, array($val['category_id']));
2134    }
2135}
2136
2137// 2¤Ä¤ÎÇÛÎó¤òÍѤ¤¤ÆÏ¢ÁÛÇÛÎó¤òºîÀ®¤¹¤ë
2138function sfarrCombine($arrKeys, $arrValues) {
2139
2140    if(count($arrKeys) <= 0 and count($arrValues) <= 0) return array();
2141   
2142    $keys = array_values($arrKeys);
2143    $vals = array_values($arrValues);
2144   
2145    $max = max( count( $keys ), count( $vals ) );
2146    $combine_ary = array();
2147    for($i=0; $i<$max; $i++) {
2148        $combine_ary[$keys[$i]] = $vals[$i];
2149    }
2150    if(is_array($combine_ary)) return $combine_ary;
2151   
2152    return false;
2153}
2154
2155/* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤é»ÒIDÇÛÎó¤ò¼èÆÀ¤¹¤ë */
2156function sfGetChildrenArray($table, $pid_name, $id_name, $id) {
2157    $objQuery = new SC_Query();
2158    $col = $pid_name . "," . $id_name;
2159    $arrData = $objQuery->select($col, $table);
2160   
2161    $arrPID = array();
2162    $arrPID[] = $id;
2163    $arrChildren = array();
2164    $arrChildren[] = $id;
2165   
2166    $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID);
2167   
2168    while(count($arrRet) > 0) {
2169        $arrChildren = array_merge($arrChildren, $arrRet);
2170        $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet);
2171    }
2172   
2173    return $arrChildren;
2174}
2175
2176/* ¿ÆIDľ²¼¤Î»ÒID¤ò¤¹¤Ù¤Æ¼èÆÀ¤¹¤ë */
2177function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) {
2178    $arrChildren = array();
2179    $max = count($arrData);
2180   
2181    for($i = 0; $i < $max; $i++) {
2182        foreach($arrPID as $val) {
2183            if($arrData[$i][$pid_name] == $val) {
2184                $arrChildren[] = $arrData[$i][$id_name];
2185            }
2186        }
2187    }   
2188    return $arrChildren;
2189}
2190
2191
2192/* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤é¿ÆIDÇÛÎó¤ò¼èÆÀ¤¹¤ë */
2193function sfGetParentsArray($table, $pid_name, $id_name, $id) {
2194    $objQuery = new SC_Query();
2195    $col = $pid_name . "," . $id_name;
2196    $arrData = $objQuery->select($col, $table);
2197   
2198    $arrParents = array();
2199    $arrParents[] = $id;
2200    $child = $id;
2201   
2202    $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $child);
2203
2204    while($ret != "") {
2205        $arrParents[] = $ret;
2206        $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret);
2207    }
2208   
2209    $arrParents = array_reverse($arrParents);
2210   
2211    return $arrParents;
2212}
2213
2214/* »ÒID½ê°¤¹¤ë¿ÆID¤ò¼èÆÀ¤¹¤ë */
2215function sfGetParentsArraySub($arrData, $pid_name, $id_name, $child) {
2216    $max = count($arrData);
2217    $parent = "";
2218    for($i = 0; $i < $max; $i++) {
2219        if($arrData[$i][$id_name] == $child) {
2220            $parent = $arrData[$i][$pid_name];
2221            break;
2222        }
2223    }
2224    return $parent;
2225}
2226
2227/* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤éÍ¿¤¨¤é¤ì¤¿ID¤Î·»Äï¤ò¼èÆÀ¤¹¤ë */
2228function sfGetBrothersArray($arrData, $pid_name, $id_name, $arrPID) {
2229    $max = count($arrData);
2230   
2231    $arrBrothers = array();
2232    foreach($arrPID as $id) {
2233        // ¿ÆID¤ò¸¡º÷¤¹¤ë
2234        for($i = 0; $i < $max; $i++) {
2235            if($arrData[$i][$id_name] == $id) {
2236                $parent = $arrData[$i][$pid_name];
2237                break;
2238            }
2239        }
2240        // ·»ÄïID¤ò¸¡º÷¤¹¤ë
2241        for($i = 0; $i < $max; $i++) {
2242            if($arrData[$i][$pid_name] == $parent) {
2243                $arrBrothers[] = $arrData[$i][$id_name];
2244            }
2245        }                   
2246    }
2247    return $arrBrothers;
2248}
2249
2250/* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤éÍ¿¤¨¤é¤ì¤¿ID¤Îľ°¤Î»Ò¤ò¼èÆÀ¤¹¤ë */
2251function sfGetUnderChildrenArray($arrData, $pid_name, $id_name, $parent) {
2252    $max = count($arrData);
2253   
2254    $arrChildren = array();
2255    // »ÒID¤ò¸¡º÷¤¹¤ë
2256    for($i = 0; $i < $max; $i++) {
2257        if($arrData[$i][$pid_name] == $parent) {
2258            $arrChildren[] = $arrData[$i][$id_name];
2259        }
2260    }                   
2261    return $arrChildren;
2262}
2263
2264
2265// ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ
2266function sfGetCatTree($parent_category_id, $count_check = false) {
2267    $objQuery = new SC_Query();
2268    $col = "*";
2269    $from = "dtb_category left join dtb_category_total_count using (category_id)";
2270    // ÅÐÏ¿¾¦ÉÊ¿ô¤Î¥Á¥§¥Ã¥¯
2271    if($count_check) {
2272        $where = "delete = 0 AND product_count > 0";
2273    } else {
2274        $where = "delete = 0";
2275    }
2276    $objQuery->setoption("ORDER BY rank DESC");
2277    $arrRet = $objQuery->select($col, $from, $where);
2278   
2279    $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
2280       
2281    foreach($arrRet as $key => $array) {
2282        foreach($arrParentID as $val) {
2283            if($array['category_id'] == $val) {
2284                $arrRet[$key]['display'] = 1;
2285                break;
2286            }
2287        }
2288    }
2289    return $arrRet;
2290}
2291
2292// ¿Æ¥«¥Æ¥´¥ê¡¼¤òÏ¢·ë¤·¤¿Ê¸»úÎó¤ò¼èÆÀ¤¹¤ë
2293function sfGetCatCombName($category_id){
2294    // ¾¦Éʤ¬Â°¤¹¤ë¥«¥Æ¥´¥êID¤ò½Ä¤Ë¼èÆÀ
2295    $objQuery = new SC_Query();
2296    $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
2297    $ConbName = "";
2298   
2299    // ¥«¥Æ¥´¥ê¡¼Ì¾¾Î¤ò¼èÆÀ¤¹¤ë
2300    foreach($arrCatID as $key => $val){
2301        $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
2302        $arrVal = array($val);
2303        $CatName = $objQuery->getOne($sql,$arrVal);
2304        $ConbName .= $CatName . ' | ';
2305    }
2306    // ºÇ¸å¤Î ¡Ã ¤ò¥«¥Ã¥È¤¹¤ë
2307    $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2);
2308   
2309    return $ConbName;
2310}
2311
2312// »ØÄꤷ¤¿¥«¥Æ¥´¥ê¡¼ID¤ÎÂ祫¥Æ¥´¥ê¡¼¤ò¼èÆÀ¤¹¤ë
2313function GetFirstCat($category_id){
2314    // ¾¦Éʤ¬Â°¤¹¤ë¥«¥Æ¥´¥êID¤ò½Ä¤Ë¼èÆÀ
2315    $objQuery = new SC_Query();
2316    $arrRet = array();
2317    $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
2318    $arrRet['id'] = $arrCatID[0];
2319   
2320    // ¥«¥Æ¥´¥ê¡¼Ì¾¾Î¤ò¼èÆÀ¤¹¤ë
2321    $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
2322    $arrVal = array($arrRet['id']);
2323    $arrRet['name'] = $objQuery->getOne($sql,$arrVal);
2324   
2325    return $arrRet;
2326}
2327
2328/* ¥Ç¥Ð¥Ã¥°ÍÑ ------------------------------------------------------------------------------------------------*/
2329function sfPrintR($obj) {
2330    print("<div style='font-size: 12px'>\n");
2331    print("<strong>**¥Ç¥Ð¥Ã¥°Ãæ**</strong><br />\n");
2332    print("<pre>\n");
2333    print_r($obj);
2334    print("</pre>\n");
2335    print("<strong>**¥Ç¥Ð¥Ã¥°Ãæ**</strong></div>\n");
2336}
2337
2338?>
Note: See TracBrowser for help on using the repository browser.