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

Revision 6935, 21.0 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        if (!PEAR::isError($req->sendRequest())) {
235            $response1 = $req->getResponseBody();
236        } else {
237            $response1 = "";
238        }
239        $req->clearPostData();
240    }
241   
242    break;
243case 'return_step0':
244    $objPage = lfDispStep0($objPage);
245    break; 
246case 'return_step1':
247    $objPage = lfDispStep1($objPage);
248    break;
249case 'return_step2':
250    $objPage = lfDispStep2($objPage);
251    break;
252case 'return_step3':
253    $objPage = lfDispStep3($objPage);
254    break;
255case 'return_welcome':
256default:
257    $objPage = lfDispWelcome($objPage);
258    break;
259}
260
261//¥Õ¥©¡¼¥àÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹
262$objPage->arrForm = $objWebParam->getFormParamList();
263$objPage->arrForm = array_merge($objPage->arrForm, $objDBParam->getFormParamList());
264
265// SiteInfo¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤
266$objView->assignobj($objPage);
267$objView->display('install_frame.tpl');
268//-----------------------------------------------------------------------------------------------------------------------------------
269// ¤è¤¦¤³¤½²èÌ̤Îɽ¼¨
270function lfDispWelcome($objPage) {
271    global $objWebParam;
272    global $objDBParam;
273    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
274    $objPage->arrHidden = $objWebParam->getHashArray();
275    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
276    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
277    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
278    $objPage->tpl_mainpage = 'welcome.tpl';
279    $objPage->tpl_mode = 'welcome';
280    return $objPage;
281}
282
283// STEP0²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¸¢¸Â¥Á¥§¥Ã¥¯)
284function lfDispStep0($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 = 'step0.tpl';
293    $objPage->tpl_mode = 'step0';
294   
295    // ¥×¥í¥°¥é¥à¤Ç½ñ¹þ¤ß¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥ì¥¯¥È¥ê
296    $arrWriteFile = array(
297        "../../data/install.inc",
298        "../user_data",
299        "../upload",
300        "../../data/Smarty/templates_c",       
301        "../../data/logs",
302    );
303   
304    $mess = "";
305    $err_file = false;
306    foreach($arrWriteFile as $val) {
307        if(file_exists($val)) {
308            $mode = lfGetFileMode($val);
309            $real_path = realpath($val);
310                       
311            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
312            if(is_dir($val)) {
313                if($mode == "777") {
314                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
315                } else {
316                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
317                    $err_file = true;                                       
318                }
319            } else {
320                if($mode == "666") {
321                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
322                } else {
323                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
324                    $err_file = true;                           
325                }
326            }           
327        } else {
328            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
329            $err_file = true;
330        }
331    }
332   
333    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
334    if(!$err_file) {
335        $path = "../../data/Smarty/templates_c/admin";
336        if(!file_exists($path)) {
337            mkdir($path);
338        }
339        $path = "../upload/save_image";
340        if(!file_exists($path)) {
341            mkdir($path);
342        }
343        $path = "../upload/temp_image";
344        if(!file_exists($path)) {
345            mkdir($path);
346        }
347        $path = "../upload/graph_image";
348        if(!file_exists($path)) {
349            mkdir($path);
350        }
351        $path = "../upload/csv";
352        if(!file_exists($path)) {
353            mkdir($path);
354        }
355    }
356   
357    $objPage->mess = $mess;
358    $objPage->err_file = $err_file;
359
360    return $objPage;
361}
362
363
364// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
365function lfDispStep0_1($objPage) {
366    global $objWebParam;
367    global $objDBParam;
368    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
369    $objPage->arrHidden = $objWebParam->getHashArray();
370    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
371    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
372    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
373    $objPage->tpl_mainpage = 'step0_1.tpl';
374    $objPage->tpl_mode = 'step0_1';
375    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
376    $objPage->copy_mess = sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess);
377    $objPage->copy_mess = sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess);
378    return $objPage;
379}
380
381function lfGetFileMode($path) {
382    $mode = substr(sprintf('%o', fileperms($path)), -3);
383    return $mode;
384}
385
386// STEP1²èÌ̤Îɽ¼¨
387function lfDispStep1($objPage) {
388    global $objDBParam;
389    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
390    $objPage->arrHidden = $objDBParam->getHashArray();
391    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
392    $objPage->tpl_mainpage = 'step1.tpl';
393    $objPage->tpl_mode = 'step1';
394    return $objPage;
395}
396
397// STEP2²èÌ̤Îɽ¼¨
398function lfDispStep2($objPage) {
399    global $objWebParam;
400    global $objDBParam;
401    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
402    $objPage->arrHidden = $objWebParam->getHashArray();
403    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
404    $objPage->tpl_mainpage = 'step2.tpl';
405    $objPage->tpl_mode = 'step2';
406    return $objPage;
407}
408
409// STEP3²èÌ̤Îɽ¼¨
410function lfDispStep3($objPage) {
411    global $objWebParam;
412    global $objDBParam;
413    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
414    $objPage->arrHidden = $objWebParam->getHashArray();
415    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
416    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
417    $objPage->tpl_db_skip = $_POST['db_skip'];
418    $objPage->tpl_mainpage = 'step3.tpl';
419    $objPage->tpl_mode = 'step3';
420    return $objPage;
421}
422
423// STEP4²èÌ̤Îɽ¼¨
424function lfDispStep4($objPage) {
425    global $objWebParam;
426    global $objDBParam;
427    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
428    $objPage->arrHidden = $objWebParam->getHashArray();
429    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
430    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
431   
432    $normal_url = $objWebParam->getValue('normal_url');
433    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
434    if (!ereg("/$", $normal_url)) $normal_url = $normal_url . "/";
435   
436    $arrDbParam = $objDBParam->getHashArray();
437    $dsn = $arrDbParam['db_type']."://".$arrDbParam['db_user'].":".$arrDbParam['db_password']."@".$arrDbParam['db_server'].":".$arrDbParam['db_port']."/".$arrDbParam['db_name'];
438   
439    $objPage->tpl_site_url = $normal_url;
440    $objPage->tpl_shop_name = $objWebParam->getValue('shop_name');
441    $objPage->tpl_cube_ver = ECCUBE_VERSION;
442    $objPage->tpl_php_ver = phpversion();
443    $objPage->tpl_db_ver = sfGetDBVersion($dsn);
444    $objPage->tpl_db_skip = $_POST['db_skip'];
445    $objPage->tpl_mainpage = 'step4.tpl';
446    $objPage->tpl_mode = 'complete';
447    return $objPage;
448}
449
450// ´°Î»²èÌ̤Îɽ¼¨
451function lfDispComplete($objPage) {
452    global $objWebParam;
453    global $objDBParam;
454    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
455    $objPage->arrHidden = $objWebParam->getHashArray();
456    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
457    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
458    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
459    $objPage->tpl_mainpage = 'complete.tpl';
460    $objPage->tpl_mode = 'complete';
461   
462    $secure_url = $objWebParam->getValue('secure_url');
463    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
464    if (!ereg("/$", $secure_url)) {
465        $secure_url = $secure_url . "/";
466    }
467    $objPage->tpl_sslurl = $secure_url;     
468    return $objPage;
469}
470
471// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
472function lfInitWebParam($objWebParam) {
473   
474    if(defined('HTML_PATH')) {
475        $install_dir = HTML_PATH;
476    } else {
477        $install_dir = realpath(dirname( __FILE__) . "/../") . "/";
478    }
479   
480    if(defined('SITE_URL')) {
481        $normal_url = SITE_URL;
482    } else {
483        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
484        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
485    }
486   
487    if(defined('SSL_URL')) {
488        $secure_url = SSL_URL;
489    } else {
490        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
491        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
492    }
493
494    // Ź̾¡¢´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¼èÆÀ¤¹¤ë¡£(ºÆ¥¤¥ó¥¹¥È¡¼¥ë»þ)
495    if(defined('DEFAULT_DSN')) {
496        $ret = sfTabaleExists("dtb_baseinfo", DEFAULT_DSN);
497        if($ret) {
498            $objQuery = new SC_Query();
499            $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
500            $shop_name = $arrRet[0]['shop_name'];
501            $admin_mail = $arrRet[0]['email01'];
502        }
503    }
504
505    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $shop_name);
506    $objWebParam->addParam("´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
507    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
508    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
509    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
510    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("MAX_LENGTH_CHECK"));
511
512    return $objWebParam;
513}
514
515// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
516function lfInitDBParam($objDBParam) {
517       
518    if(defined('DB_SERVER')) {
519        $db_server = DB_SERVER;
520    } else {
521        $db_server = "127.0.0.1";
522    }
523   
524    if(defined('DB_TYPE')) {
525        $db_type = DB_TYPE;
526    } else {
527        $db_type = "";
528    }
529   
530    if(defined('DB_PORT')) {
531        $db_port = DB_PORT;
532    } else {
533        $db_port = "";
534    }
535       
536    if(defined('DB_NAME')) {
537        $db_name = DB_NAME;
538    } else {
539        $db_name = "eccube_db";
540    }
541       
542    if(defined('DB_USER')) {
543        $db_user = DB_USER;
544    } else {
545        $db_user = "eccube_db_user";               
546    }
547           
548    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_type);
549    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
550    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
551    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
552    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
553    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
554       
555    return $objDBParam;
556}
557
558// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
559function lfCheckWebError($objFormParam) {
560    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
561    $arrRet =  $objFormParam->getHashArray();
562    $objErr = new SC_CheckError($arrRet);
563    $objErr->arrErr = $objFormParam->checkError();
564   
565    // ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¤ß¼èÆÀ¤¹¤ë
566    $normal_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['normal_url']);
567    $secure_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['secure_url']);
568   
569    if($normal_dir != $secure_dir) {
570        $objErr->arrErr['normal_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
571        $objErr->arrErr['secure_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";     
572    }
573   
574    return $objErr->arrErr;
575}
576
577// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
578function lfCheckDBError($objFormParam) {
579    global $objPage;
580   
581    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
582    $arrRet =  $objFormParam->getHashArray();
583   
584    $objErr = new SC_CheckError($arrRet);
585    $objErr->arrErr = $objFormParam->checkError();
586   
587    if(count($objErr->arrErr) == 0) {
588        // Àܳ³Îǧ
589        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
590        // Debug¥â¡¼¥É»ØÄê
591        $options['debug'] = PEAR_DB_DEBUG;
592        $objDB = DB::connect($dsn, $options);
593        // ÀܳÀ®¸ù
594        if(!PEAR::isError($objDB)) {
595            // ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤Î¼èÆÀ
596            $objPage->tpl_db_version = sfGetDBVersion($dsn);           
597        } else {
598            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
599            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
600            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
601            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
602            gfPrintLog($objDB->userinfo, "./temp/install.log");
603        }
604    }
605    return $objErr->arrErr;
606}
607
608// SQLʸ¤Î¼Â¹Ô
609function lfExecuteSQL($filepath, $dsn, $disp_err = true) {
610    $arrErr = array();
611   
612    if(!file_exists($filepath)) {
613        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
614    } else {
615        if($fp = fopen($filepath,"r")) {
616            $sql = fread($fp, filesize($filepath));
617            fclose($fp);
618        }
619        // Debug¥â¡¼¥É»ØÄê
620        $options['debug'] = PEAR_DB_DEBUG;
621        $objDB = DB::connect($dsn, $options);
622        // Àܳ¥¨¥é¡¼
623        if(!PEAR::isError($objDB)) {
624            // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹
625            $sql = preg_replace("/[\r\n\t]/"," ",$sql);
626            $sql_split = split(";",$sql);
627            foreach($sql_split as $key => $val){
628                if (trim($val) != "") {
629                    $ret = $objDB->query($val);
630                    if(PEAR::isError($ret) && $disp_err) {
631                        $arrErr['all'] = ">> " . $ret->message . "<br>";
632                        // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
633                        ereg("\[(.*)\]", $ret->userinfo, $arrKey);
634                        $arrErr['all'].= $arrKey[0] . "<br>";
635                        $objPage->update_mess.=">> ¥Æ¡¼¥Ö¥ë¹½À®¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";
636                        gfPrintLog($ret->userinfo, "./temp/install.log");
637                    }
638                }
639            }           
640        } else {
641            $arrErr['all'] = ">> " . $objDB->message;
642            gfPrintLog($objDB->userinfo, "./temp/install.log");
643        }
644    }
645    return $arrErr;
646}
647
648// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎºîÀ®
649function lfMakeConfigFile() {
650    global $objWebParam;
651    global $objDBParam;
652       
653    $root_dir = $objWebParam->getValue('install_dir');
654    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
655    if (!ereg("/$", $root_dir)) {
656        $root_dir = $root_dir . "/";
657    }
658   
659    $normal_url = $objWebParam->getValue('normal_url');
660    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
661    if (!ereg("/$", $normal_url)) {
662        $normal_url = $normal_url . "/";
663    }
664   
665    $secure_url = $objWebParam->getValue('secure_url');
666    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
667    if (!ereg("/$", $secure_url)) {
668        $secure_url = $secure_url . "/";
669    }
670   
671    // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¼èÆÀ
672    $url_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $normal_url);
673   
674    $data_path = $root_dir . "../data/";
675    $filepath = $data_path . "install.inc";
676   
677    $config_data =
678    "<?php\n".
679    "    define ('ECCUBE_INSTALL', 'ON');\n" .
680    "    define ('HTML_PATH', '" . $root_dir . "');\n" .     
681    "    define ('SITE_URL', '" . $normal_url . "');\n" .
682    "    define ('SSL_URL', '" . $secure_url . "');\n" .
683    "    define ('URL_DIR', '" . $url_dir . "');\n" .   
684    "    define ('DOMAIN_NAME', '" . $objWebParam->getValue('domain') . "');\n" .
685    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
686    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
687    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
688    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
689    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
690    "    define ('DB_PORT', '" . $objDBParam->getValue('db_port') .  "');\n" .
691    "    define ('DATA_PATH', '".$data_path."');\n" .
692    "?>";
693   
694    if($fp = fopen($filepath,"w")) {
695        fwrite($fp, $config_data);
696        fclose($fp);
697    }
698}
699
700// ¥Æ¡¼¥Ö¥ë¤ÎÄɲáʴû¤Ë¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ë¾ì¹ç¤ÏºîÀ®¤·¤Ê¤¤¡Ë
701function lfAddTable($table_name, $dsn) {
702    $arrErr = array();
703    if(!sfTabaleExists($table_name, $dsn)) {
704        list($db_type) = split(":", $dsn);
705        $sql_path = "./sql/add/". $table_name . "_" .$db_type .".sql";
706        $arrErr = lfExecuteSQL($sql_path, $dsn);
707    }
708    return $arrErr;
709}
710?>
Note: See TracBrowser for help on using the repository browser.