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

Revision 6238, 19.6 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__));
9class LC_Page {
10    function LC_Page() {
11        $this->arrDB_TYPE = array(
12            'pgsql' => 'PostgreSQL',
13            'mysql' => 'MySQL' 
14        );
15        $this->arrDB_PORT = array(
16            'pgsql' => '',
17            'mysql' => ''   
18        );
19    }
20}
21
22$objPage = new LC_Page();
23
24// ¥Æ¥ó¥×¥ì¡¼¥È¥³¥ó¥Ñ¥¤¥ë¥Ç¥£¥ì¥¯¥È¥ê¤Î½ñ¹þ¤ß¸¢¸Â¥Á¥§¥Ã¥¯
25$temp_dir = $INSTALL_DIR . '/temp';
26$mode = lfGetFileMode($temp_dir);
27
28if($mode != '777') {
29    sfErrorHeader($temp_dir . "¤Ë¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£", true);
30    exit;
31}
32
33$objView = new SC_InstallView($INSTALL_DIR . '/templates', $INSTALL_DIR . '/temp');
34
35// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
36$objWebParam = new SC_FormParam();
37$objDBParam = new SC_FormParam();
38// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
39$objWebParam = lfInitWebParam($objWebParam);
40$objDBParam = lfInitDBParam($objDBParam);
41
42//¥Õ¥©¡¼¥àÇÛÎó¤Î¼èÆÀ
43$objWebParam->setParam($_POST);
44$objDBParam->setParam($_POST);
45
46switch($_POST['mode']) {
47// ¤è¤¦¤³¤½
48case 'welcome':
49    $objPage = lfDispStep0($objPage);
50    break;
51// ¥¢¥¯¥»¥¹¸¢¸Â¤Î¥Á¥§¥Ã¥¯
52case 'step0':
53    $objPage = lfDispStep0_1($objPage);
54    break; 
55// ¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼
56case 'step0_1':
57    $objPage = lfDispStep1($objPage);
58    break; 
59// WEB¥µ¥¤¥È¤ÎÀßÄê
60case 'step1':
61    //ÆþÎÏÃͤΥ¨¥é¡¼¥Á¥§¥Ã¥¯
62    $objPage->arrErr = lfCheckWEBError($objWebParam);
63    if(count($objPage->arrErr) == 0) {
64        $objPage = lfDispStep2($objPage);
65    } else {
66        $objPage = lfDispStep1($objPage);
67    }
68    break;
69// ¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÀßÄê
70case 'step2':
71    //ÆþÎÏÃͤΥ¨¥é¡¼¥Á¥§¥Ã¥¯
72    $objPage->arrErr = lfCheckDBError($objDBParam);
73    if(count($objPage->arrErr) == 0) {
74        $objPage = lfDispStep3($objPage);
75    } else {
76        $objPage = lfDispStep2($objPage);
77    }
78    break;
79// ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
80case 'step3':
81    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
82    $arrRet =  $objDBParam->getHashArray();
83   
84    $skip = $_POST["db_skip"];
85
86    // ¥¹¥­¥Ã¥×¤¹¤ë¾ì¹ç¤Ë¤Ï´°Î»²èÌ̤ØÁ«°Ü
87    if ($skip == "on") {
88        // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
89        lfMakeConfigFile();
90        $objPage = lfDispComplete($objPage);
91        break;
92    }
93   
94    // ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
95    $objPage->arrErr = lfExecuteSQL("./sql/create_table_".$arrRet['db_type'].".sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
96    if(count($objPage->arrErr) == 0) {
97        $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
98    } else {
99        $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
100    }
101
102    // ¥Ó¥å¡¼¤ÎºîÀ®
103    if(count($objPage->arrErr) == 0 and $arrRet['db_type'] == 'pgsql') {
104        // ¥Ó¥å¡¼¤ÎºîÀ®
105        $objPage->arrErr = lfExecuteSQL("./sql/create_view.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
106        if(count($objPage->arrErr) == 0) {
107            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
108        } else {
109            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
110        }
111    }   
112   
113    // ½é´ü¥Ç¡¼¥¿¤ÎºîÀ®
114    if(count($objPage->arrErr) == 0) {
115        $objPage->arrErr = lfExecuteSQL("./sql/insert_data.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
116        if(count($objPage->arrErr) == 0) {
117            $objPage->tpl_message.="¡û¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
118        } else {
119            $objPage->tpl_message.="¡ß¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
120        }
121    }   
122   
123    // ¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
124    if(count($objPage->arrErr) == 0) {
125        $objPage->arrErr = lfExecuteSQL("./sql/column_comment.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
126        if(count($objPage->arrErr) == 0) {
127            $objPage->tpl_message.="¡û¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
128        } else {
129            $objPage->tpl_message.="¡ß¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
130        }
131    }   
132   
133    // ¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
134    if(count($objPage->arrErr) == 0) {
135        $objPage->arrErr = lfExecuteSQL("./sql/table_comment.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
136        if(count($objPage->arrErr) == 0) {
137            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
138        } else {
139            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
140        }
141    }
142   
143    // ¥Ð¡¼¥¸¥ç¥ó¥¢¥Ã¥×Åù¤ÇÄɲåơ¼¥Ö¥ë¤¬È¯À¸¤·¤¿ºÝ¤Ïµ­ºÜ¤¹¤ë¡£
144    if(count($objPage->arrErr) == 0) {
145       
146       
147    }
148
149    if(count($objPage->arrErr) == 0) {
150        // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
151        lfMakeConfigFile();
152        $objPage = lfDispStep3($objPage);
153        $objPage->tpl_mode = 'complete';
154    } else {
155        $objPage = lfDispStep3($objPage);
156    }
157    break;
158// ¥Æ¡¼¥Ö¥ëÎàºï½ü
159case 'drop':
160    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
161    $arrRet =  $objDBParam->getHashArray();
162   
163    if ($arrRet['db_type'] == 'pgsql'){
164        // ¥Ó¥å¡¼¤Îºï½ü
165        $objPage->arrErr = lfExecuteSQL("./sql/drop_view.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port'], false);
166        if(count($objPage->arrErr) == 0) {
167            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
168        } else {
169            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
170        }
171    }
172
173
174    // ¥Æ¡¼¥Ö¥ë¤Îºï½ü
175    if(count($objPage->arrErr) == 0) {
176        $objPage->arrErr = lfExecuteSQL("./sql/drop_table.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port'], false);
177        if(count($objPage->arrErr) == 0) {
178            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
179        } else {
180            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
181        }
182    }
183    $objPage = lfDispStep3($objPage);
184    break;
185// ´°Î»²èÌÌ
186case 'complete':
187
188    // ¥·¥ç¥Ã¥×¥Þ¥¹¥¿¾ðÊó¤Î½ñ¤­¹þ¤ß
189    $arrRet =  $objDBParam->getHashArray();
190   
191    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
192    $sqlval['shop_name'] = $objWebParam->getValue('shop_name');
193    $sqlval['email01'] = $objWebParam->getValue('admin_mail');
194    $sqlval['email02'] = $objWebParam->getValue('admin_mail');
195    $sqlval['email03'] = $objWebParam->getValue('admin_mail');
196    $sqlval['email04'] = $objWebParam->getValue('admin_mail');
197    $sqlval['email05'] = $objWebParam->getValue('admin_mail');
198    $sqlval['top_tpl'] = "default1";
199    $sqlval['product_tpl'] = "default1";
200    $sqlval['detail_tpl'] = "default1";
201    $sqlval['mypage_tpl'] = "default1";
202    $objQuery = new SC_Query($dsn);
203    $cnt = $objQuery->count("dtb_baseinfo");
204    if($cnt > 0) {
205        $objQuery->update("dtb_baseinfo", $sqlval);
206    } else {       
207        $objQuery->insert("dtb_baseinfo", $sqlval);     
208    }
209    global $GLOBAL_ERR;
210    $GLOBAL_ERR = "";
211    $objPage = lfDispComplete($objPage);
212    break;
213case 'return_step0':
214    $objPage = lfDispStep0($objPage);
215    break; 
216case 'return_step1':
217    $objPage = lfDispStep1($objPage);
218    break;
219case 'return_step2':
220    $objPage = lfDispStep2($objPage);
221    break;
222case 'return_welcome':
223default:
224    $objPage = lfDispWelcome($objPage);
225    break;
226}
227
228//¥Õ¥©¡¼¥àÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹
229$objPage->arrForm = $objWebParam->getFormParamList();
230$objPage->arrForm = array_merge($objPage->arrForm, $objDBParam->getFormParamList());
231
232// SiteInfo¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤
233$objView->assignobj($objPage);
234$objView->display('install_frame.tpl');
235//-----------------------------------------------------------------------------------------------------------------------------------
236// ¤è¤¦¤³¤½²èÌ̤Îɽ¼¨
237function lfDispWelcome($objPage) {
238    global $objWebParam;
239    global $objDBParam;
240    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
241    $objPage->arrHidden = $objWebParam->getHashArray();
242    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
243    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
244    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
245    $objPage->tpl_mainpage = 'welcome.tpl';
246    $objPage->tpl_mode = 'welcome';
247    return $objPage;
248}
249
250// STEP0²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¸¢¸Â¥Á¥§¥Ã¥¯)
251function lfDispStep0($objPage) {
252    global $objWebParam;
253    global $objDBParam;
254    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
255    $objPage->arrHidden = $objWebParam->getHashArray();
256    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
257    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
258    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
259    $objPage->tpl_mainpage = 'step0.tpl';
260    $objPage->tpl_mode = 'step0';
261   
262    // ¥×¥í¥°¥é¥à¤Ç½ñ¹þ¤ß¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥ì¥¯¥È¥ê
263    $arrWriteFile = array(
264        "../../data/install.inc",
265        "../user_data",
266        "../upload",
267        "../../data/Smarty/templates_c",       
268        "../../data/update",
269        "../../data/logs",
270    );
271   
272    $mess = "";
273    $err_file = false;
274    foreach($arrWriteFile as $val) {
275        if(file_exists($val)) {
276            $mode = lfGetFileMode($val);
277            $real_path = realpath($val);
278                       
279            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
280            if(is_dir($val)) {
281                if($mode == "777") {
282                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
283                } else {
284                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
285                    $err_file = true;                                       
286                }
287            } else {
288                if($mode == "666") {
289                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
290                } else {
291                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
292                    $err_file = true;                           
293                }
294            }           
295        } else {
296            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
297            $err_file = true;
298        }
299    }
300   
301    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
302    if(!$err_file) {
303        $path = "../../data/Smarty/templates_c/admin";
304        if(!file_exists($path)) {
305            mkdir($path);
306        }
307        $path = "../upload/save_image";
308        if(!file_exists($path)) {
309            mkdir($path);
310        }
311        $path = "../upload/temp_image";
312        if(!file_exists($path)) {
313            mkdir($path);
314        }
315        $path = "../upload/graph_image";
316        if(!file_exists($path)) {
317            mkdir($path);
318        }
319        $path = "../upload/csv";
320        if(!file_exists($path)) {
321            mkdir($path);
322        }
323    }
324   
325    $objPage->mess = $mess;
326    $objPage->err_file = $err_file;
327
328    return $objPage;
329}
330
331
332// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
333function lfDispStep0_1($objPage) {
334    global $objWebParam;
335    global $objDBParam;
336    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
337    $objPage->arrHidden = $objWebParam->getHashArray();
338    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
339    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
340    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
341    $objPage->tpl_mainpage = 'step0_1.tpl';
342    $objPage->tpl_mode = 'step0_1';
343    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
344    $objPage->copy_mess = sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess);
345    $objPage->copy_mess = sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess);
346    return $objPage;
347}
348
349function lfGetFileMode($path) {
350    $mode = substr(sprintf('%o', fileperms($path)), -3);
351    return $mode;
352}
353
354// STEP1²èÌ̤Îɽ¼¨
355function lfDispStep1($objPage) {
356    global $objDBParam;
357    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
358    $objPage->arrHidden = $objDBParam->getHashArray();
359    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
360    $objPage->tpl_mainpage = 'step1.tpl';
361    $objPage->tpl_mode = 'step1';
362    return $objPage;
363}
364
365// STEP2²èÌ̤Îɽ¼¨
366function lfDispStep2($objPage) {
367    global $objWebParam;
368    global $objDBParam;
369    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
370    $objPage->arrHidden = $objWebParam->getHashArray();
371    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
372    $objPage->tpl_mainpage = 'step2.tpl';
373    $objPage->tpl_mode = 'step2';
374    return $objPage;
375}
376
377// STEP3²èÌ̤Îɽ¼¨
378function lfDispStep3($objPage) {
379    global $objWebParam;
380    global $objDBParam;
381    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
382    $objPage->arrHidden = $objWebParam->getHashArray();
383    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
384    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
385    $objPage->tpl_db_skip = $_POST['db_skip'];
386    $objPage->tpl_mainpage = 'step3.tpl';
387    $objPage->tpl_mode = 'step3';
388    return $objPage;
389}
390
391// ´°Î»²èÌ̤Îɽ¼¨
392function lfDispComplete($objPage) {
393    global $objWebParam;
394    global $objDBParam;
395    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
396    $objPage->arrHidden = $objWebParam->getHashArray();
397    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
398    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
399    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
400    $objPage->tpl_mainpage = 'complete.tpl';
401    $objPage->tpl_mode = 'complete';
402   
403    $secure_url = $objWebParam->getValue('secure_url');
404    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
405    if (!ereg("/$", $secure_url)) {
406        $secure_url = $secure_url . "/";
407    }
408    $objPage->tpl_sslurl = $secure_url;     
409    return $objPage;
410}
411
412// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
413function lfInitWebParam($objWebParam) {
414   
415    if(defined('HTML_PATH')) {
416        $install_dir = HTML_PATH;
417    } else {
418        $install_dir = realpath(dirname( __FILE__) . "/../") . "/";
419    }
420   
421    if(defined('SITE_URL')) {
422        $normal_url = SITE_URL;
423    } else {
424        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
425        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
426    }
427   
428    if(defined('SSL_URL')) {
429        $secure_url = SSL_URL;
430    } else {
431        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
432        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
433    }
434
435    // Ź̾¡¢´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¼èÆÀ¤¹¤ë¡£(ºÆ¥¤¥ó¥¹¥È¡¼¥ë»þ)
436    if(defined('DEFAULT_DSN')) {
437        $ret = sfTabaleExists("dtb_baseinfo", DEFAULT_DSN);
438        if($ret) {
439            $objQuery = new SC_Query();
440            $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
441            $shop_name = $arrRet[0]['shop_name'];
442            $admin_mail = $arrRet[0]['email01'];
443        }
444    }
445
446    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $shop_name);
447    $objWebParam->addParam("´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
448    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
449    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
450    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
451    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("MAX_LENGTH_CHECK"));
452
453    return $objWebParam;
454}
455
456// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
457function lfInitDBParam($objDBParam) {
458   
459    if(defined('DB_SERVER')) {
460        $db_server = DB_SERVER;
461    } else {
462        $db_server = "127.0.0.1";
463    }
464   
465    if(defined('DB_PORT')) {
466        $db_port = DB_PORT;
467    } else {
468        $db_port = "";
469    }
470       
471    if(defined('DB_NAME')) {
472        $db_name = DB_NAME;
473    } else {
474        $db_name = "eccube_db";
475    }
476       
477    if(defined('DB_USER')) {
478        $db_user = DB_USER;
479    } else {
480        $db_user = "eccube_db_user";               
481    }
482           
483    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
484    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
485    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
486    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
487    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
488    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
489       
490    return $objDBParam;
491}
492
493// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
494function lfCheckWebError($objFormParam) {
495    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
496    $arrRet =  $objFormParam->getHashArray();
497    $objErr = new SC_CheckError($arrRet);
498    $objErr->arrErr = $objFormParam->checkError();
499   
500    // ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¤ß¼èÆÀ¤¹¤ë
501    $normal_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['normal_url']);
502    $secure_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['secure_url']);
503   
504    if($normal_dir != $secure_dir) {
505        $objErr->arrErr['normal_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
506        $objErr->arrErr['secure_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";     
507    }
508   
509    return $objErr->arrErr;
510}
511
512// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
513function lfCheckDBError($objFormParam) {
514    global $objPage;
515   
516    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
517    $arrRet =  $objFormParam->getHashArray();
518   
519    $objErr = new SC_CheckError($arrRet);
520    $objErr->arrErr = $objFormParam->checkError();
521   
522    if(count($objErr->arrErr) == 0) {
523        // Àܳ³Îǧ
524        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
525        // Debug¥â¡¼¥É»ØÄê
526        $options['debug'] = 9;
527        $objDB = DB::connect($dsn, $options);
528        // Àܳ¥¨¥é¡¼
529        if(PEAR::isError($objDB)) {
530            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
531            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
532            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
533            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
534            gfPrintLog($objDB->userinfo, "./temp/install.log");
535        } else {
536            if($arrRet['db_type'] == 'mysql') {
537                $arrRet = $objDB->getAll("SHOW VARIABLES");
538                foreach($arrRet as $array) {
539                    if($array[0] == 'version') {
540                        $objPage->tpl_db_version = "MySQL " . $array[1];
541                    }
542                }
543            }
544            if($arrRet['db_type'] == 'pgsql') {
545                $arrRet = $objDB->getAll("select version()");
546                $arrLine = split(" " , $arrRet[0][0]);
547                $objPage->tpl_db_version = $arrLine[0] . " " . $arrLine[1];
548            }
549        }
550    }
551    return $objErr->arrErr;
552}
553
554// SQLʸ¤Î¼Â¹Ô
555function lfExecuteSQL($filepath, $db_user, $db_password, $db_server, $db_name, $db_type, $db_port, $disp_err = true) {
556    $arrErr = array();
557
558    if(!file_exists($filepath)) {
559        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
560    } else {
561        if($fp = fopen($filepath,"r")) {
562            $sql = fread($fp, filesize($filepath));
563            fclose($fp);
564        }
565
566        $dsn = $db_type."://".$db_user.":".$db_password."@".$db_server.":".$db_port."/".$db_name;
567       
568        $objDB = DB::connect($dsn);
569        // Àܳ¥¨¥é¡¼
570        if(!PEAR::isError($objDB)) {
571            // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹
572            $sql = preg_replace("/[\r\n\t]/"," ",$sql);
573            $sql_split = split(";",$sql);
574            foreach($sql_split as $key => $val){
575                if (trim($val) != "") {
576                    $ret = $objDB->query($val);
577                    if(PEAR::isError($ret) and $disp_err) {
578                        $arrErr['all'] = ">> " . $ret->message . "<br>";
579                        // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
580                        ereg("\[(.*)\]", $ret->userinfo, $arrKey);
581                        $arrErr['all'].= $arrKey[0] . "<br>";
582                        $objPage->update_mess.=">> ¥Æ¡¼¥Ö¥ë¹½À®¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";
583                        gfPrintLog($ret->userinfo, "./temp/install.log");
584                    }
585                }
586            }
587           
588        } else {
589            $arrErr['all'] = ">> " . $objDB->message;
590            gfPrintLog($objDB->userinfo, "./temp/install.log");
591        }
592    }
593    return $arrErr;
594}
595
596// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎºîÀ®
597function lfMakeConfigFile() {
598    global $objWebParam;
599    global $objDBParam;
600       
601    $root_dir = $objWebParam->getValue('install_dir');
602    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
603    if (!ereg("/$", $root_dir)) {
604        $root_dir = $root_dir . "/";
605    }
606   
607    $normal_url = $objWebParam->getValue('normal_url');
608    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
609    if (!ereg("/$", $normal_url)) {
610        $normal_url = $normal_url . "/";
611    }
612   
613    $secure_url = $objWebParam->getValue('secure_url');
614    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
615    if (!ereg("/$", $secure_url)) {
616        $secure_url = $secure_url . "/";
617    }
618   
619    // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¼èÆÀ
620    $url_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $normal_url);
621   
622    $data_path = $root_dir . "../data/";
623    $filepath = $data_path . "install.inc";
624   
625    $config_data =
626    "<?php\n".
627    "    define ('ECCUBE_INSTALL', 'ON');\n" .
628    "    define ('HTML_PATH', '" . $root_dir . "');\n" .     
629    "    define ('SITE_URL', '" . $normal_url . "');\n" .
630    "    define ('SSL_URL', '" . $secure_url . "');\n" .
631    "    define ('URL_DIR', '" . $url_dir . "');\n" .   
632    "    define ('DOMAIN_NAME', '" . $objWebParam->getValue('domain') . "');\n" .
633    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
634    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
635    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
636    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
637    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
638    "    define ('DB_PORT', '" . $objDBParam->getValue('db_port') .  "');\n" .
639    "    define('DATA_PATH', '".$data_path."');\n" .
640    "?>";
641   
642    if($fp = fopen($filepath,"w")) {
643        fwrite($fp, $config_data);
644        fclose($fp);
645    }
646}
647
648?>
Note: See TracBrowser for help on using the repository browser.