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

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