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

Revision 6980, 21.6 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 * 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    $objPage->arrErr = lfAddTable("dtb_module", $dsn);  // ¥»¥Ã¥·¥ç¥ó´ÉÍý¥Æ¡¼¥Ö¥ë
95       
96    if(count($objPage->arrErr) == 0) {
97        // ¥¹¥­¥Ã¥×¤¹¤ë¾ì¹ç¤Ë¤Ï¼¡²èÌ̤ØÁ«°Ü
98        $skip = $_POST["db_skip"];
99        if ($skip == "on") {
100            // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
101            lfMakeConfigFile();
102            //$objPage = lfDispComplete($objPage);
103            $objPage = lfDispStep4($objPage);
104            break;
105        }
106    }
107   
108    // ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
109    $objPage->arrErr = lfExecuteSQL("./sql/create_table_".$arrRet['db_type'].".sql", $dsn);
110    if(count($objPage->arrErr) == 0) {
111        $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
112    } else {
113        $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
114    }
115
116    // ¥Ó¥å¡¼¤ÎºîÀ®
117    if(count($objPage->arrErr) == 0 and $arrRet['db_type'] == 'pgsql') {
118        // ¥Ó¥å¡¼¤ÎºîÀ®
119        $objPage->arrErr = lfExecuteSQL("./sql/create_view.sql", $dsn);
120        if(count($objPage->arrErr) == 0) {
121            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
122        } else {
123            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
124        }
125    }   
126   
127    // ½é´ü¥Ç¡¼¥¿¤ÎºîÀ®
128    if(count($objPage->arrErr) == 0) {
129        $objPage->arrErr = lfExecuteSQL("./sql/insert_data.sql", $dsn);
130        if(count($objPage->arrErr) == 0) {
131            $objPage->tpl_message.="¡û¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
132        } else {
133            $objPage->tpl_message.="¡ß¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
134        }
135    }   
136   
137    // ¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
138    if(count($objPage->arrErr) == 0) {
139        $objPage->arrErr = lfExecuteSQL("./sql/column_comment.sql", $dsn);
140        if(count($objPage->arrErr) == 0) {
141            $objPage->tpl_message.="¡û¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
142        } else {
143            $objPage->tpl_message.="¡ß¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
144        }
145    }   
146   
147    // ¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
148    if(count($objPage->arrErr) == 0) {
149        $objPage->arrErr = lfExecuteSQL("./sql/table_comment.sql", $dsn);
150        if(count($objPage->arrErr) == 0) {
151            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
152        } else {
153            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
154        }
155    }
156
157    if(count($objPage->arrErr) == 0) {
158        // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
159        lfMakeConfigFile();
160        $objPage = lfDispStep3($objPage);
161        $objPage->tpl_mode = 'step4';
162    } else {
163        $objPage = lfDispStep3($objPage);
164    }
165    break;
166case 'step4':
167    $objPage = lfDispStep4($objPage);
168    break;
169   
170// ¥Æ¡¼¥Ö¥ëÎàºï½ü
171case 'drop':
172    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
173    $arrRet =  $objDBParam->getHashArray();
174    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
175       
176    if ($arrRet['db_type'] == 'pgsql'){
177        // ¥Ó¥å¡¼¤Îºï½ü
178        $objPage->arrErr = lfExecuteSQL("./sql/drop_view.sql", $dsn, false);
179        if(count($objPage->arrErr) == 0) {
180            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
181        } else {
182            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
183        }
184    }
185
186    // ¥Æ¡¼¥Ö¥ë¤Îºï½ü
187    if(count($objPage->arrErr) == 0) {
188        $objPage->arrErr = lfExecuteSQL("./sql/drop_table.sql", $dsn, false);
189        if(count($objPage->arrErr) == 0) {
190            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
191        } else {
192            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
193        }
194    }
195    $objPage = lfDispStep3($objPage);
196    break;
197// ´°Î»²èÌÌ
198case 'complete':
199    // ¥·¥ç¥Ã¥×¥Þ¥¹¥¿¾ðÊó¤Î½ñ¤­¹þ¤ß
200    $arrRet =  $objDBParam->getHashArray();
201   
202    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
203    $sqlval['shop_name'] = $objWebParam->getValue('shop_name');
204    $sqlval['email01'] = $objWebParam->getValue('admin_mail');
205    $sqlval['email02'] = $objWebParam->getValue('admin_mail');
206    $sqlval['email03'] = $objWebParam->getValue('admin_mail');
207    $sqlval['email04'] = $objWebParam->getValue('admin_mail');
208    $sqlval['email05'] = $objWebParam->getValue('admin_mail');
209    $sqlval['top_tpl'] = "default1";
210    $sqlval['product_tpl'] = "default1";
211    $sqlval['detail_tpl'] = "default1";
212    $sqlval['mypage_tpl'] = "default1";
213    $objQuery = new SC_Query($dsn);
214    $cnt = $objQuery->count("dtb_baseinfo");
215    if($cnt > 0) {
216        $objQuery->update("dtb_baseinfo", $sqlval);
217    } else {       
218        $objQuery->insert("dtb_baseinfo", $sqlval);     
219    }
220    global $GLOBAL_ERR;
221    $GLOBAL_ERR = "";
222    $objPage = lfDispComplete($objPage);
223   
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(str_replace("senddata_", "", $key) => $val);
238                $arrSendData = array_merge($arrSendData, $arrSendDataTmp);
239            }
240        }
241       
242        $req->addPostDataArray($arrSendData);
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/downloads",
312        "../../data/logs"
313    );
314   
315    $mess = "";
316    $err_file = false;
317    foreach($arrWriteFile as $val) {
318        if(file_exists($val)) {
319            $mode = lfGetFileMode($val);
320            $real_path = realpath($val);
321                       
322            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
323            if(is_dir($val)) {
324                if($mode == "777") {
325                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
326                } else {
327                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
328                    $err_file = true;                                       
329                }
330            } else {
331                if($mode == "666") {
332                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
333                } else {
334                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
335                    $err_file = true;                           
336                }
337            }           
338        } else {
339            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
340            $err_file = true;
341        }
342    }
343   
344    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
345    if(!$err_file) {
346        $path = "../../data/Smarty/templates_c/admin";
347        if(!file_exists($path)) {
348            mkdir($path);
349        }
350        $path = "../upload/save_image";
351        if(!file_exists($path)) {
352            mkdir($path);
353        }
354        $path = "../upload/temp_image";
355        if(!file_exists($path)) {
356            mkdir($path);
357        }
358        $path = "../upload/graph_image";
359        if(!file_exists($path)) {
360            mkdir($path);
361        }
362        $path = "../upload/csv";
363        if(!file_exists($path)) {
364            mkdir($path);
365        }
366        $path = "../../data/downloads/module";
367        if(!file_exists($path)) {
368            mkdir($path);
369        }
370        $path = "../../data/downloads/update";
371        if(!file_exists($path)) {
372            mkdir($path);
373        }       
374    }
375   
376    $objPage->mess = $mess;
377    $objPage->err_file = $err_file;
378
379    return $objPage;
380}
381
382
383// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
384function lfDispStep0_1($objPage) {
385    global $objWebParam;
386    global $objDBParam;
387    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
388    $objPage->arrHidden = $objWebParam->getHashArray();
389    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
390    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
391    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
392    $objPage->tpl_mainpage = 'step0_1.tpl';
393    $objPage->tpl_mode = 'step0_1';
394    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
395    $objPage->copy_mess = sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess);
396    $objPage->copy_mess = sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess);
397    return $objPage;
398}
399
400function lfGetFileMode($path) {
401    $mode = substr(sprintf('%o', fileperms($path)), -3);
402    return $mode;
403}
404
405// STEP1²èÌ̤Îɽ¼¨
406function lfDispStep1($objPage) {
407    global $objDBParam;
408    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
409    $objPage->arrHidden = $objDBParam->getHashArray();
410    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
411    $objPage->tpl_mainpage = 'step1.tpl';
412    $objPage->tpl_mode = 'step1';
413    return $objPage;
414}
415
416// STEP2²èÌ̤Îɽ¼¨
417function lfDispStep2($objPage) {
418    global $objWebParam;
419    global $objDBParam;
420    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
421    $objPage->arrHidden = $objWebParam->getHashArray();
422    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
423    $objPage->tpl_mainpage = 'step2.tpl';
424    $objPage->tpl_mode = 'step2';
425    return $objPage;
426}
427
428// STEP3²èÌ̤Îɽ¼¨
429function lfDispStep3($objPage) {
430    global $objWebParam;
431    global $objDBParam;
432    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
433    $objPage->arrHidden = $objWebParam->getHashArray();
434    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
435    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
436    $objPage->tpl_db_skip = $_POST['db_skip'];
437    $objPage->tpl_mainpage = 'step3.tpl';
438    $objPage->tpl_mode = 'step3';
439    return $objPage;
440}
441
442// STEP4²èÌ̤Îɽ¼¨
443function lfDispStep4($objPage) {
444    global $objWebParam;
445    global $objDBParam;
446    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
447    $objPage->arrHidden = $objWebParam->getHashArray();
448    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
449    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
450   
451    $normal_url = $objWebParam->getValue('normal_url');
452    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
453    if (!ereg("/$", $normal_url)) $normal_url = $normal_url . "/";
454   
455    $arrDbParam = $objDBParam->getHashArray();
456    $dsn = $arrDbParam['db_type']."://".$arrDbParam['db_user'].":".$arrDbParam['db_password']."@".$arrDbParam['db_server'].":".$arrDbParam['db_port']."/".$arrDbParam['db_name'];
457   
458    $objPage->tpl_site_url = $normal_url;
459    $objPage->tpl_shop_name = $objWebParam->getValue('shop_name');
460    $objPage->tpl_cube_ver = ECCUBE_VERSION;
461    $objPage->tpl_php_ver = phpversion();
462    $objPage->tpl_db_ver = sfGetDBVersion($dsn);
463    $objPage->tpl_db_skip = $_POST['db_skip'];
464    $objPage->tpl_mainpage = 'step4.tpl';
465    $objPage->tpl_mode = 'complete';
466    return $objPage;
467}
468
469// ´°Î»²èÌ̤Îɽ¼¨
470function lfDispComplete($objPage) {
471    global $objWebParam;
472    global $objDBParam;
473    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
474    $objPage->arrHidden = $objWebParam->getHashArray();
475    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
476    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
477    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
478    $objPage->tpl_mainpage = 'complete.tpl';
479    $objPage->tpl_mode = 'complete';
480   
481    $secure_url = $objWebParam->getValue('secure_url');
482    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
483    if (!ereg("/$", $secure_url)) {
484        $secure_url = $secure_url . "/";
485    }
486    $objPage->tpl_sslurl = $secure_url;     
487    return $objPage;
488}
489
490// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
491function lfInitWebParam($objWebParam) {
492   
493    if(defined('HTML_PATH')) {
494        $install_dir = HTML_PATH;
495    } else {
496        $install_dir = realpath(dirname( __FILE__) . "/../") . "/";
497    }
498   
499    if(defined('SITE_URL')) {
500        $normal_url = SITE_URL;
501    } else {
502        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
503        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
504    }
505   
506    if(defined('SSL_URL')) {
507        $secure_url = SSL_URL;
508    } else {
509        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
510        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
511    }
512
513    // Ź̾¡¢´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¼èÆÀ¤¹¤ë¡£(ºÆ¥¤¥ó¥¹¥È¡¼¥ë»þ)
514    if(defined('DEFAULT_DSN')) {
515        $ret = sfTabaleExists("dtb_baseinfo", DEFAULT_DSN);
516        if($ret) {
517            $objQuery = new SC_Query();
518            $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
519            $shop_name = $arrRet[0]['shop_name'];
520            $admin_mail = $arrRet[0]['email01'];
521        }
522    }
523
524    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $shop_name);
525    $objWebParam->addParam("´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
526    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
527    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
528    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
529    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("MAX_LENGTH_CHECK"));
530
531    return $objWebParam;
532}
533
534// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
535function lfInitDBParam($objDBParam) {
536       
537    if(defined('DB_SERVER')) {
538        $db_server = DB_SERVER;
539    } else {
540        $db_server = "127.0.0.1";
541    }
542   
543    if(defined('DB_TYPE')) {
544        $db_type = DB_TYPE;
545    } else {
546        $db_type = "";
547    }
548   
549    if(defined('DB_PORT')) {
550        $db_port = DB_PORT;
551    } else {
552        $db_port = "";
553    }
554       
555    if(defined('DB_NAME')) {
556        $db_name = DB_NAME;
557    } else {
558        $db_name = "eccube_db";
559    }
560       
561    if(defined('DB_USER')) {
562        $db_user = DB_USER;
563    } else {
564        $db_user = "eccube_db_user";               
565    }
566           
567    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_type);
568    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
569    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
570    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
571    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
572    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
573       
574    return $objDBParam;
575}
576
577// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
578function lfCheckWebError($objFormParam) {
579    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
580    $arrRet =  $objFormParam->getHashArray();
581    $objErr = new SC_CheckError($arrRet);
582    $objErr->arrErr = $objFormParam->checkError();
583   
584    // ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¤ß¼èÆÀ¤¹¤ë
585    $normal_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['normal_url']);
586    $secure_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['secure_url']);
587   
588    if($normal_dir != $secure_dir) {
589        $objErr->arrErr['normal_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
590        $objErr->arrErr['secure_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";     
591    }
592   
593    return $objErr->arrErr;
594}
595
596// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
597function lfCheckDBError($objFormParam) {
598    global $objPage;
599   
600    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
601    $arrRet =  $objFormParam->getHashArray();
602   
603    $objErr = new SC_CheckError($arrRet);
604    $objErr->arrErr = $objFormParam->checkError();
605   
606    if(count($objErr->arrErr) == 0) {
607        // Àܳ³Îǧ
608        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
609        // Debug¥â¡¼¥É»ØÄê
610        $options['debug'] = PEAR_DB_DEBUG;
611        $objDB = DB::connect($dsn, $options);
612        // ÀܳÀ®¸ù
613        if(!PEAR::isError($objDB)) {
614            // ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤Î¼èÆÀ
615            $objPage->tpl_db_version = sfGetDBVersion($dsn);           
616        } else {
617            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
618            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
619            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
620            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
621            gfPrintLog($objDB->userinfo, "./temp/install.log");
622        }
623    }
624    return $objErr->arrErr;
625}
626
627// SQLʸ¤Î¼Â¹Ô
628function lfExecuteSQL($filepath, $dsn, $disp_err = true) {
629    $arrErr = array();
630   
631    if(!file_exists($filepath)) {
632        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
633    } else {
634        if($fp = fopen($filepath,"r")) {
635            $sql = fread($fp, filesize($filepath));
636            fclose($fp);
637        }
638        // Debug¥â¡¼¥É»ØÄê
639        $options['debug'] = PEAR_DB_DEBUG;
640        $objDB = DB::connect($dsn, $options);
641        // Àܳ¥¨¥é¡¼
642        if(!PEAR::isError($objDB)) {
643            // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹
644            $sql = preg_replace("/[\r\n\t]/"," ",$sql);
645            $sql_split = split(";",$sql);
646            foreach($sql_split as $key => $val){
647                if (trim($val) != "") {
648                    $ret = $objDB->query($val);
649                    if(PEAR::isError($ret) && $disp_err) {
650                        $arrErr['all'] = ">> " . $ret->message . "<br>";
651                        // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
652                        ereg("\[(.*)\]", $ret->userinfo, $arrKey);
653                        $arrErr['all'].= $arrKey[0] . "<br>";
654                        $objPage->update_mess.=">> ¥Æ¡¼¥Ö¥ë¹½À®¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";
655                        gfPrintLog($ret->userinfo, "./temp/install.log");
656                    }
657                }
658            }           
659        } else {
660            $arrErr['all'] = ">> " . $objDB->message;
661            gfPrintLog($objDB->userinfo, "./temp/install.log");
662        }
663    }
664    return $arrErr;
665}
666
667// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎºîÀ®
668function lfMakeConfigFile() {
669    global $objWebParam;
670    global $objDBParam;
671       
672    $root_dir = $objWebParam->getValue('install_dir');
673    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
674    if (!ereg("/$", $root_dir)) {
675        $root_dir = $root_dir . "/";
676    }
677   
678    $normal_url = $objWebParam->getValue('normal_url');
679    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
680    if (!ereg("/$", $normal_url)) {
681        $normal_url = $normal_url . "/";
682    }
683   
684    $secure_url = $objWebParam->getValue('secure_url');
685    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
686    if (!ereg("/$", $secure_url)) {
687        $secure_url = $secure_url . "/";
688    }
689   
690    // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¼èÆÀ
691    $url_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $normal_url);
692   
693    $data_path = $root_dir . "../data/";
694    $filepath = $data_path . "install.inc";
695   
696    $config_data =
697    "<?php\n".
698    "    define ('ECCUBE_INSTALL', 'ON');\n" .
699    "    define ('HTML_PATH', '" . $root_dir . "');\n" .     
700    "    define ('SITE_URL', '" . $normal_url . "');\n" .
701    "    define ('SSL_URL', '" . $secure_url . "');\n" .
702    "    define ('URL_DIR', '" . $url_dir . "');\n" .   
703    "    define ('DOMAIN_NAME', '" . $objWebParam->getValue('domain') . "');\n" .
704    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
705    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
706    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
707    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
708    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
709    "    define ('DB_PORT', '" . $objDBParam->getValue('db_port') .  "');\n" .
710    "    define ('DATA_PATH', '".$data_path."');\n" .
711    "?>";
712   
713    if($fp = fopen($filepath,"w")) {
714        fwrite($fp, $config_data);
715        fclose($fp);
716    }
717}
718
719// ¥Æ¡¼¥Ö¥ë¤ÎÄɲáʴû¤Ë¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ë¾ì¹ç¤ÏºîÀ®¤·¤Ê¤¤¡Ë
720function lfAddTable($table_name, $dsn) {
721    $arrErr = array();
722    if(!sfTabaleExists($table_name, $dsn)) {
723        list($db_type) = split(":", $dsn);
724        $sql_path = "./sql/add/". $table_name . "_" .$db_type .".sql";
725        $arrErr = lfExecuteSQL($sql_path, $dsn);
726    }
727    return $arrErr;
728}
729?>
Note: See TracBrowser for help on using the repository browser.