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

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