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

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