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

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