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

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