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

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