source: temp/trunk/html/install/index.php @ 10118

Revision 10118, 24.8 KB checked in by kakinaka, 20 years ago (diff)

blank

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8$INSTALL_DIR = realpath(dirname( __FILE__));
9require_once("../../data/module/Request.php");
10
11define("INSTALL_LOG", "./temp/install.log");
12
13class LC_Page {
14    function LC_Page() {
15        $this->arrDB_TYPE = array(
16            'pgsql' => 'PostgreSQL',
17            'mysql' => 'MySQL' 
18        );
19        $this->arrDB_PORT = array(
20            'pgsql' => '',
21            'mysql' => ''   
22        );
23    }
24}
25
26$objPage = new LC_Page();
27
28// ¥Æ¥ó¥×¥ì¡¼¥È¥³¥ó¥Ñ¥¤¥ë¥Ç¥£¥ì¥¯¥È¥ê¤Î½ñ¹þ¤ß¸¢¸Â¥Á¥§¥Ã¥¯
29$temp_dir = $INSTALL_DIR . '/temp';
30$mode = lfGetFileMode($temp_dir);
31
32if($mode != '777') {
33    sfErrorHeader($temp_dir . "¤Ë¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£", true);
34    exit;
35}
36
37$objView = new SC_InstallView($INSTALL_DIR . '/templates', $INSTALL_DIR . '/temp');
38
39// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
40$objWebParam = new SC_FormParam();
41$objDBParam = new SC_FormParam();
42// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
43$objWebParam = lfInitWebParam($objWebParam);
44$objDBParam = lfInitDBParam($objDBParam);
45
46//¥Õ¥©¡¼¥àÇÛÎó¤Î¼èÆÀ
47$objWebParam->setParam($_POST);
48$objDBParam->setParam($_POST);
49
50switch($_POST['mode']) {
51// ¤è¤¦¤³¤½
52case 'welcome':
53    $objPage = lfDispStep0($objPage);
54    break;
55// ¥¢¥¯¥»¥¹¸¢¸Â¤Î¥Á¥§¥Ã¥¯
56case 'step0':
57    $objPage = lfDispStep0_1($objPage);
58    break; 
59// ¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼
60case 'step0_1':
61    $objPage = lfDispStep1($objPage);
62    break; 
63// WEB¥µ¥¤¥È¤ÎÀßÄê
64case 'step1':
65    //ÆþÎÏÃͤΥ¨¥é¡¼¥Á¥§¥Ã¥¯
66    $objPage->arrErr = lfCheckWEBError($objWebParam);
67    if(count($objPage->arrErr) == 0) {
68        $objPage = lfDispStep2($objPage);
69    } else {
70        $objPage = lfDispStep1($objPage);
71    }
72    break;
73// ¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÀßÄê
74case 'step2':
75    //ÆþÎÏÃͤΥ¨¥é¡¼¥Á¥§¥Ã¥¯
76    $objPage->arrErr = lfCheckDBError($objDBParam);
77    if(count($objPage->arrErr) == 0) {
78        $objPage = lfDispStep3($objPage);
79    } else {
80        $objPage = lfDispStep2($objPage);
81    }
82    break;
83// ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
84case 'step3':
85    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
86    $arrRet =  $objDBParam->getHashArray();
87    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
88   
89    /*
90        lfAddTable¤Ï¡¢¥Ð¡¼¥¸¥ç¥ó¥¢¥Ã¥×Åù¤ÇÄɲåơ¼¥Ö¥ë¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£
91        ¡Ê£Ä£Â¹½À®¤Î²¼°Ì¸ß´¹¤Î¤¿¤á¥¹¥­¥Ã¥×»þ¤â¶¯À©¡Ë
92    */
93    // ¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤ËÄɲ䵤ì¤ë¡£
94    $objPage->arrErr = lfAddTable("dtb_session", $dsn); // ¥»¥Ã¥·¥ç¥ó´ÉÍý¥Æ¡¼¥Ö¥ë
95    // ¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤ËÄɲ䵤ì¤ë¡£
96    $objPage->arrErr = lfAddTable("dtb_module", $dsn);  // ¥»¥Ã¥·¥ç¥ó´ÉÍý¥Æ¡¼¥Ö¥ë
97   
98    // ¥«¥é¥à¤òÄɲÃ
99    lfAddColumn($dsn);
100
101    if(count($objPage->arrErr) == 0) {
102        // ¥¹¥­¥Ã¥×¤¹¤ë¾ì¹ç¤Ë¤Ï¼¡²èÌ̤ØÁ«°Ü
103        $skip = $_POST["db_skip"];
104        if ($skip == "on") {
105            // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
106            lfMakeConfigFile();
107            //$objPage = lfDispComplete($objPage);
108            $objPage = lfDispStep4($objPage);
109            break;
110        }
111    }
112   
113    // ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
114    $objPage->arrErr = lfExecuteSQL("./sql/create_table_".$arrRet['db_type'].".sql", $dsn);
115    if(count($objPage->arrErr) == 0) {
116        $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
117    } else {
118        $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
119    }
120
121    // ¥Ó¥å¡¼¤ÎºîÀ®
122    if(count($objPage->arrErr) == 0 and $arrRet['db_type'] == 'pgsql') {
123        // ¥Ó¥å¡¼¤ÎºîÀ®
124        $objPage->arrErr = lfExecuteSQL("./sql/create_view.sql", $dsn);
125        if(count($objPage->arrErr) == 0) {
126            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
127        } else {
128            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
129        }
130    }   
131   
132    // ½é´ü¥Ç¡¼¥¿¤ÎºîÀ®
133    if(count($objPage->arrErr) == 0) {
134        $objPage->arrErr = lfExecuteSQL("./sql/insert_data.sql", $dsn);
135        if(count($objPage->arrErr) == 0) {
136            $objPage->tpl_message.="¡û¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
137        } else {
138            $objPage->tpl_message.="¡ß¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
139        }
140    }   
141   
142    // ¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
143    if(count($objPage->arrErr) == 0) {
144        $objPage->arrErr = lfExecuteSQL("./sql/column_comment.sql", $dsn);
145        if(count($objPage->arrErr) == 0) {
146            $objPage->tpl_message.="¡û¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
147        } else {
148            $objPage->tpl_message.="¡ß¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
149        }
150    }   
151   
152    // ¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
153    if(count($objPage->arrErr) == 0) {
154        $objPage->arrErr = lfExecuteSQL("./sql/table_comment.sql", $dsn);
155        if(count($objPage->arrErr) == 0) {
156            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
157        } else {
158            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
159        }
160    }
161
162    if(count($objPage->arrErr) == 0) {
163        // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
164        lfMakeConfigFile();
165        $objPage = lfDispStep3($objPage);
166        $objPage->tpl_mode = 'step4';
167    } else {
168        $objPage = lfDispStep3($objPage);
169    }
170    break;
171case 'step4':
172    $objPage = lfDispStep4($objPage);
173    break;
174   
175// ¥Æ¡¼¥Ö¥ëÎàºï½ü
176case 'drop':
177    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
178    $arrRet =  $objDBParam->getHashArray();
179    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
180   
181    // Äɲåơ¼¥Ö¥ë¤¬¤¢¤ì¤Ðºï½ü¤¹¤ë¡£
182    lfDropTable("dtb_module", $dsn);
183    lfDropTable("dtb_session", $dsn);
184       
185    if ($arrRet['db_type'] == 'pgsql'){
186        // ¥Ó¥å¡¼¤Îºï½ü
187        $objPage->arrErr = lfExecuteSQL("./sql/drop_view.sql", $dsn, false);
188        if(count($objPage->arrErr) == 0) {
189            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
190        } else {
191            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
192        }
193    }
194
195    // ¥Æ¡¼¥Ö¥ë¤Îºï½ü
196    if(count($objPage->arrErr) == 0) {
197        $objPage->arrErr = lfExecuteSQL("./sql/drop_table.sql", $dsn, false);
198        if(count($objPage->arrErr) == 0) {
199            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
200        } else {
201            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
202        }
203    }
204    $objPage = lfDispStep3($objPage);
205    break;
206// ´°Î»²èÌÌ
207case 'complete':
208    // ¥·¥ç¥Ã¥×¥Þ¥¹¥¿¾ðÊó¤Î½ñ¤­¹þ¤ß
209    $arrRet =  $objDBParam->getHashArray();
210   
211    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
212    $sqlval['shop_name'] = $objWebParam->getValue('shop_name');
213    $sqlval['email01'] = $objWebParam->getValue('');
214    $sqlval['email02'] = $objWebParam->getValue('');
215    $sqlval['email03'] = $objWebParam->getValue('');
216    $sqlval['email04'] = $objWebParam->getValue('');
217    $sqlval['email05'] = $objWebParam->getValue('');
218    $sqlval['top_tpl'] = "default1";
219    $sqlval['product_tpl'] = "default1";
220    $sqlval['detail_tpl'] = "default1";
221    $sqlval['mypage_tpl'] = "default1";
222    $objQuery = new SC_Query($dsn);
223    $cnt = $objQuery->count("dtb_baseinfo");
224    if($cnt > 0) {
225        $objQuery->update("dtb_baseinfo", $sqlval);
226    } else {       
227        $objQuery->insert("dtb_baseinfo", $sqlval);     
228    }
229    global $GLOBAL_ERR;
230    $GLOBAL_ERR = "";
231    $objPage = lfDispComplete($objPage);
232   
233    // ¥µ¥¤¥È¾ðÊó¤òÁ÷¿®¤·¤Æ¤âÎɤ¤¾ì¹ç¤Ë¤ÏÁ÷¤ë
234    if($_POST['send_info'] == "true"){
235        $req = new HTTP_Request("http://www.ec-cube.net/mall/use_site.php");
236        $req->setMethod(HTTP_REQUEST_METHOD_POST);
237       
238        $arrSendData = array();
239        foreach($_POST as $key => $val){
240            if (ereg("^senddata_*", $key)){
241                $arrSendDataTmp = array(str_replace("senddata_", "", $key) => $val);
242                $arrSendData = array_merge($arrSendData, $arrSendDataTmp);
243            }
244        }
245       
246        $req->addPostDataArray($arrSendData);
247       
248        if (!PEAR::isError($req->sendRequest())) {
249            $response1 = $req->getResponseBody();
250        } else {
251            $response1 = "";
252        }
253        $req->clearPostData();
254    }
255   
256    break;
257case 'return_step0':
258    $objPage = lfDispStep0($objPage);
259    break; 
260case 'return_step1':
261    $objPage = lfDispStep1($objPage);
262    break;
263case 'return_step2':
264    $objPage = lfDispStep2($objPage);
265    break;
266case 'return_step3':
267    $objPage = lfDispStep3($objPage);
268    break;
269case 'return_welcome':
270default:
271    $objPage = lfDispWelcome($objPage);
272    break;
273}
274
275//¥Õ¥©¡¼¥àÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹
276$objPage->arrForm = $objWebParam->getFormParamList();
277$objPage->arrForm = array_merge($objPage->arrForm, $objDBParam->getFormParamList());
278
279// SiteInfo¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤
280$objView->assignobj($objPage);
281$objView->display('install_frame.tpl');
282//-----------------------------------------------------------------------------------------------------------------------------------
283// ¤è¤¦¤³¤½²èÌ̤Îɽ¼¨
284function lfDispWelcome($objPage) {
285    global $objWebParam;
286    global $objDBParam;
287    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
288    $objPage->arrHidden = $objWebParam->getHashArray();
289    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
290    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
291    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
292    $objPage->tpl_mainpage = 'welcome.tpl';
293    $objPage->tpl_mode = 'welcome';
294    return $objPage;
295}
296
297// STEP0²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¸¢¸Â¥Á¥§¥Ã¥¯)
298function lfDispStep0($objPage) {
299    global $objWebParam;
300    global $objDBParam;
301    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
302    $objPage->arrHidden = $objWebParam->getHashArray();
303    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
304    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
305    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
306    $objPage->tpl_mainpage = 'step0.tpl';
307    $objPage->tpl_mode = 'step0';
308   
309    // ¥×¥í¥°¥é¥à¤Ç½ñ¹þ¤ß¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥ì¥¯¥È¥ê
310    $arrWriteFile = array(
311        "../../data/install.inc",
312        "../user_data",
313        "../upload",
314        "../../data/Smarty/templates_c",       
315        "../../data/downloads",
316        "../../data/logs"
317    );
318   
319    $mess = "";
320    $err_file = false;
321    foreach($arrWriteFile as $val) {
322        if(file_exists($val)) {
323            $mode = lfGetFileMode($val);
324            $real_path = realpath($val);
325                       
326            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
327            if(is_dir($val)) {
328                if($mode == "777") {
329                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
330                } else {
331                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
332                    $err_file = true;                                       
333                }
334            } else {
335                if($mode == "666") {
336                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
337                } else {
338                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
339                    $err_file = true;                           
340                }
341            }           
342        } else {
343            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
344            $err_file = true;
345        }
346    }
347   
348    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
349    if(!$err_file) {
350        $path = "../../data/Smarty/templates_c/admin";
351        if(!file_exists($path)) {
352            mkdir($path);
353        }
354        $path = "../upload/save_image";
355        if(!file_exists($path)) {
356            mkdir($path);
357        }
358        $path = "../upload/temp_image";
359        if(!file_exists($path)) {
360            mkdir($path);
361        }
362        $path = "../upload/graph_image";
363        if(!file_exists($path)) {
364            mkdir($path);
365        }
366        $path = "../upload/csv";
367        if(!file_exists($path)) {
368            mkdir($path);
369        }
370        $path = "../../data/downloads/module";
371        if(!file_exists($path)) {
372            mkdir($path);
373        }
374        $path = "../../data/downloads/update";
375        if(!file_exists($path)) {
376            mkdir($path);
377        }       
378    }
379   
380    $objPage->mess = $mess;
381    $objPage->err_file = $err_file;
382
383    return $objPage;
384}
385
386
387// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
388function lfDispStep0_1($objPage) {
389    global $objWebParam;
390    global $objDBParam;
391    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
392    $objPage->arrHidden = $objWebParam->getHashArray();
393    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
394    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
395    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
396    $objPage->tpl_mainpage = 'step0_1.tpl';
397    $objPage->tpl_mode = 'step0_1';
398    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
399    $objPage->copy_mess = sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess);
400    $objPage->copy_mess = sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess);
401    return $objPage;
402}
403
404function lfGetFileMode($path) {
405    $mode = substr(sprintf('%o', fileperms($path)), -3);
406    return $mode;
407}
408
409// STEP1²èÌ̤Îɽ¼¨
410function lfDispStep1($objPage) {
411    global $objDBParam;
412    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
413    $objPage->arrHidden = $objDBParam->getHashArray();
414    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
415    $objPage->tpl_mainpage = 'step1.tpl';
416    $objPage->tpl_mode = 'step1';
417    return $objPage;
418}
419
420// STEP2²èÌ̤Îɽ¼¨
421function lfDispStep2($objPage) {
422    global $objWebParam;
423    global $objDBParam;
424    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
425    $objPage->arrHidden = $objWebParam->getHashArray();
426    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
427    $objPage->tpl_mainpage = 'step2.tpl';
428    $objPage->tpl_mode = 'step2';
429    return $objPage;
430}
431
432// STEP3²èÌ̤Îɽ¼¨
433function lfDispStep3($objPage) {
434    global $objWebParam;
435    global $objDBParam;
436    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
437    $objPage->arrHidden = $objWebParam->getHashArray();
438    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
439    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
440    $objPage->tpl_db_skip = $_POST['db_skip'];
441    $objPage->tpl_mainpage = 'step3.tpl';
442    $objPage->tpl_mode = 'step3';
443    return $objPage;
444}
445
446// STEP4²èÌ̤Îɽ¼¨
447function lfDispStep4($objPage) {
448    global $objWebParam;
449    global $objDBParam;
450    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
451    $objPage->arrHidden = $objWebParam->getHashArray();
452    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
453    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
454   
455    $normal_url = $objWebParam->getValue('normal_url');
456    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
457    if (!ereg("/$", $normal_url)) $normal_url = $normal_url . "/";
458   
459    $arrDbParam = $objDBParam->getHashArray();
460    $dsn = $arrDbParam['db_type']."://".$arrDbParam['db_user'].":".$arrDbParam['db_password']."@".$arrDbParam['db_server'].":".$arrDbParam['db_port']."/".$arrDbParam['db_name'];
461   
462    $objPage->tpl_site_url = $normal_url;
463    $objPage->tpl_shop_name = $objWebParam->getValue('shop_name');
464    $objPage->tpl_cube_ver = ECCUBE_VERSION;
465    $objPage->tpl_php_ver = phpversion();
466    $objPage->tpl_db_ver = sfGetDBVersion($dsn);
467    $objPage->tpl_db_skip = $_POST['db_skip'];
468    $objPage->tpl_mainpage = 'step4.tpl';
469    $objPage->tpl_mode = 'complete';
470    return $objPage;
471}
472
473// ´°Î»²èÌ̤Îɽ¼¨
474function lfDispComplete($objPage) {
475    global $objWebParam;
476    global $objDBParam;
477    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
478    $objPage->arrHidden = $objWebParam->getHashArray();
479    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
480    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
481    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
482    $objPage->tpl_mainpage = 'complete.tpl';
483    $objPage->tpl_mode = 'complete';
484   
485    $secure_url = $objWebParam->getValue('secure_url');
486    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
487    if (!ereg("/$", $secure_url)) {
488        $secure_url = $secure_url . "/";
489    }
490    $objPage->tpl_sslurl = $secure_url;     
491    return $objPage;
492}
493
494// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
495function lfInitWebParam($objWebParam) {
496   
497    if(defined('HTML_PATH')) {
498        $install_dir = HTML_PATH;
499    } else {
500        $install_dir = realpath(dirname( __FILE__) . "/../") . "/";
501    }
502   
503    if(defined('SITE_URL')) {
504        $normal_url = SITE_URL;
505    } else {
506        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
507        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
508    }
509   
510    if(defined('SSL_URL')) {
511        $secure_url = SSL_URL;
512    } else {
513        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
514        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
515    }
516
517    // Ź̾¡¢´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¼èÆÀ¤¹¤ë¡£(ºÆ¥¤¥ó¥¹¥È¡¼¥ë»þ)
518    if(defined('DEFAULT_DSN')) {
519        $ret = sfTabaleExists("dtb_baseinfo", DEFAULT_DSN);
520        if($ret) {
521            $objQuery = new SC_Query();
522            $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
523            $shop_name = $arrRet[0]['shop_name'];
524            $admin_mail = $arrRet[0]['email01'];
525        }
526    }
527
528    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $shop_name);
529    $objWebParam->addParam("´ÉÍý¼Ô¡§¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
530//  $objWebParam->addParam("´ÉÍý¼Ô¡§¥í¥°¥¤¥óID", "login_id", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
531//  $objWebParam->addParam("´ÉÍý¼Ô¡§¥Ñ¥¹¥ï¡¼¥É", "login_pass", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
532    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
533    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
534    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
535    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("MAX_LENGTH_CHECK"));
536
537    return $objWebParam;
538}
539
540// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
541function lfInitDBParam($objDBParam) {
542       
543    if(defined('DB_SERVER')) {
544        $db_server = DB_SERVER;
545    } else {
546        $db_server = "127.0.0.1";
547    }
548   
549    if(defined('DB_TYPE')) {
550        $db_type = DB_TYPE;
551    } else {
552        $db_type = "";
553    }
554   
555    if(defined('DB_PORT')) {
556        $db_port = DB_PORT;
557    } else {
558        $db_port = "";
559    }
560       
561    if(defined('DB_NAME')) {
562        $db_name = DB_NAME;
563    } else {
564        $db_name = "eccube_db";
565    }
566       
567    if(defined('DB_USER')) {
568        $db_user = DB_USER;
569    } else {
570        $db_user = "eccube_db_user";               
571    }
572           
573    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_type);
574    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
575    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
576    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
577    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
578    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
579       
580    return $objDBParam;
581}
582
583// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
584function lfCheckWebError($objFormParam) {
585    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
586    $arrRet =  $objFormParam->getHashArray();
587    $objErr = new SC_CheckError($arrRet);
588    $objErr->arrErr = $objFormParam->checkError();
589   
590    // ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¤ß¼èÆÀ¤¹¤ë
591    $normal_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['normal_url']);
592    $secure_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['secure_url']);
593   
594    if($normal_dir != $secure_dir) {
595        $objErr->arrErr['normal_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
596        $objErr->arrErr['secure_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";     
597    }
598   
599    return $objErr->arrErr;
600}
601
602// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
603function lfCheckDBError($objFormParam) {
604    global $objPage;
605   
606    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
607    $arrRet =  $objFormParam->getHashArray();
608   
609    $objErr = new SC_CheckError($arrRet);
610    $objErr->arrErr = $objFormParam->checkError();
611   
612    if(count($objErr->arrErr) == 0) {
613        // Àܳ³Îǧ
614        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
615        // Debug¥â¡¼¥É»ØÄê
616        $options['debug'] = PEAR_DB_DEBUG;
617        $objDB = DB::connect($dsn, $options);
618        // ÀܳÀ®¸ù
619        if(!PEAR::isError($objDB)) {
620            // ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤Î¼èÆÀ
621            $objPage->tpl_db_version = sfGetDBVersion($dsn);           
622        } else {
623            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
624            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
625            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
626            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
627            gfPrintLog($objDB->userinfo, INSTALL_LOG);
628        }
629    }
630    return $objErr->arrErr;
631}
632
633// SQLʸ¤Î¼Â¹Ô
634function lfExecuteSQL($filepath, $dsn, $disp_err = true) {
635    $arrErr = array();
636   
637    if(!file_exists($filepath)) {
638        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
639    } else {
640        if($fp = fopen($filepath,"r")) {
641            $sql = fread($fp, filesize($filepath));
642            fclose($fp);
643        }
644        // Debug¥â¡¼¥É»ØÄê
645        $options['debug'] = PEAR_DB_DEBUG;
646        $objDB = DB::connect($dsn, $options);
647        // Àܳ¥¨¥é¡¼
648        if(!PEAR::isError($objDB)) {
649            // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹
650            $sql = preg_replace("/[\r\n\t]/"," ",$sql);
651            $sql_split = split(";",$sql);
652            foreach($sql_split as $key => $val){
653                if (trim($val) != "") {
654                    $ret = $objDB->query($val);
655                    if(PEAR::isError($ret) && $disp_err) {
656                        $arrErr['all'] = ">> " . $ret->message . "<br>";
657                        // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
658                        ereg("\[(.*)\]", $ret->userinfo, $arrKey);
659                        $arrErr['all'].= $arrKey[0] . "<br>";
660                        $objPage->update_mess.=">> ¥Æ¡¼¥Ö¥ë¹½À®¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";
661                        gfPrintLog($ret->userinfo, INSTALL_LOG);
662                    }
663                }
664            }           
665        } else {
666            $arrErr['all'] = ">> " . $objDB->message;
667            gfPrintLog($objDB->userinfo, INSTALL_LOG);
668        }
669    }
670    return $arrErr;
671}
672
673// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎºîÀ®
674function lfMakeConfigFile() {
675    global $objWebParam;
676    global $objDBParam;
677       
678    $root_dir = $objWebParam->getValue('install_dir');
679    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
680    if (!ereg("/$", $root_dir)) {
681        $root_dir = $root_dir . "/";
682    }
683   
684    $normal_url = $objWebParam->getValue('normal_url');
685    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
686    if (!ereg("/$", $normal_url)) {
687        $normal_url = $normal_url . "/";
688    }
689   
690    $secure_url = $objWebParam->getValue('secure_url');
691    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
692    if (!ereg("/$", $secure_url)) {
693        $secure_url = $secure_url . "/";
694    }
695   
696    // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¼èÆÀ
697    $url_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $normal_url);
698   
699    $data_path = $root_dir . "../data/";
700    $filepath = $data_path . "install.inc";
701   
702    $config_data =
703    "<?php\n".
704    "    define ('ECCUBE_INSTALL', 'ON');\n" .
705    "    define ('HTML_PATH', '" . $root_dir . "');\n" .     
706    "    define ('SITE_URL', '" . $normal_url . "');\n" .
707    "    define ('SSL_URL', '" . $secure_url . "');\n" .
708    "    define ('URL_DIR', '" . $url_dir . "');\n" .   
709    "    define ('DOMAIN_NAME', '" . $objWebParam->getValue('domain') . "');\n" .
710    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
711    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
712    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
713    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
714    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
715    "    define ('DB_PORT', '" . $objDBParam->getValue('db_port') .  "');\n" .
716    "    define ('DATA_PATH', '".$data_path."');\n" .
717    "?>";
718   
719    if($fp = fopen($filepath,"w")) {
720        fwrite($fp, $config_data);
721        fclose($fp);
722    }
723}
724
725// ¥Æ¡¼¥Ö¥ë¤ÎÄɲáʴû¤Ë¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ë¾ì¹ç¤ÏºîÀ®¤·¤Ê¤¤¡Ë
726function lfAddTable($table_name, $dsn) {
727    $arrErr = array();
728    if(!sfTabaleExists($table_name, $dsn)) {
729        list($db_type) = split(":", $dsn);
730        $sql_path = "./sql/add/". $table_name . "_" .$db_type .".sql";
731        $arrErr = lfExecuteSQL($sql_path, $dsn);
732    }
733    return $arrErr;
734}
735
736// ¥Æ¡¼¥Ö¥ë¤Îºï½ü¡Ê´û¤Ë¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ë¾ì¹ç¤Î¤ßºï½ü¤¹¤ë¡Ë
737function lfDropTable($table_name, $dsn) {
738    $arrErr = array();
739    if(sfTabaleExists($table_name, $dsn)) {
740        // Debug¥â¡¼¥É»ØÄê
741        $options['debug'] = PEAR_DB_DEBUG;
742        $objDB = DB::connect($dsn, $options);
743        // ÀܳÀ®¸ù
744        if(!PEAR::isError($objDB)) {
745            $objDB->query("DROP TABLE " . $table_name);
746        } else {
747            $arrErr['all'] = ">> " . $objDB->message . "<br>";
748            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
749            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
750            $arrErr['all'].= $arrKey[0] . "<br>";
751            gfPrintLog($objDB->userinfo, INSTALL_LOG);
752        }
753    }
754    return $arrErr;
755}
756
757// ¥«¥é¥à¤ÎÄɲáʴû¤Ë¥«¥é¥à¤¬Â¸ºß¤¹¤ë¾ì¹ç¤ÏºîÀ®¤·¤Ê¤¤¡Ë
758function lfAddColumn($dsn) {
759    // ¼õÃí¥Æ¡¼¥Ö¥ë
760    sfColumnExists("dtb_order", "memo01", "text", $dsn, true); 
761    sfColumnExists("dtb_order", "memo02", "text", $dsn, true);
762    sfColumnExists("dtb_order", "memo03", "text", $dsn, true);
763    sfColumnExists("dtb_order", "memo04", "text", $dsn, true);
764    sfColumnExists("dtb_order", "memo05", "text", $dsn, true);
765    sfColumnExists("dtb_order", "memo06", "text", $dsn, true);
766    sfColumnExists("dtb_order", "memo07", "text", $dsn, true);
767    sfColumnExists("dtb_order", "memo08", "text", $dsn, true);
768    sfColumnExists("dtb_order", "memo09", "text", $dsn, true);
769    sfColumnExists("dtb_order", "memo10", "text", $dsn, true);
770
771    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë
772    sfColumnExists("dtb_order_temp", "order_id", "text", $dsn, true);   
773    sfColumnExists("dtb_order_temp", "memo01", "text", $dsn, true);
774    sfColumnExists("dtb_order_temp", "memo02", "text", $dsn, true);
775    sfColumnExists("dtb_order_temp", "memo03", "text", $dsn, true);
776    sfColumnExists("dtb_order_temp", "memo04", "text", $dsn, true);
777    sfColumnExists("dtb_order_temp", "memo05", "text", $dsn, true);
778    sfColumnExists("dtb_order_temp", "memo06", "text", $dsn, true);
779    sfColumnExists("dtb_order_temp", "memo07", "text", $dsn, true);
780    sfColumnExists("dtb_order_temp", "memo08", "text", $dsn, true);
781    sfColumnExists("dtb_order_temp", "memo09", "text", $dsn, true);
782    sfColumnExists("dtb_order_temp", "memo10", "text", $dsn, true);
783
784    // »Ùʧ¾ðÊ󥯡¼¥Ö¥ë
785    sfColumnExists("dtb_payment", "charge_flg", "int2 default 1", $dsn, true); 
786    sfColumnExists("dtb_payment", "rule_min", "numeric", $dsn, true);   
787    sfColumnExists("dtb_payment", "upper_rule_max", "numeric", $dsn, true);
788    sfColumnExists("dtb_payment", "module_id", "int4", $dsn, true);
789    sfColumnExists("dtb_payment", "module_path", "text", $dsn, true);
790    sfColumnExists("dtb_payment", "memo01", "text", $dsn, true);   
791    sfColumnExists("dtb_payment", "memo02", "text", $dsn, true);
792    sfColumnExists("dtb_payment", "memo03", "text", $dsn, true);
793    sfColumnExists("dtb_payment", "memo04", "text", $dsn, true);
794    sfColumnExists("dtb_payment", "memo05", "text", $dsn, true);
795    sfColumnExists("dtb_payment", "memo06", "text", $dsn, true);
796    sfColumnExists("dtb_payment", "memo07", "text", $dsn, true);
797    sfColumnExists("dtb_payment", "memo08", "text", $dsn, true);
798    sfColumnExists("dtb_payment", "memo09", "text", $dsn, true);
799    sfColumnExists("dtb_payment", "memo10", "text", $dsn, true);
800}
801
802?>
Note: See TracBrowser for help on using the repository browser.