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

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