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

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