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

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