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

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