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

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