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

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