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

Revision 6211, 19.5 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        "../user_data",
261        "../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        if(file_exists($val)) {
271            $mode = lfGetFileMode($val);
272            $real_path = realpath($val);
273                       
274            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
275            if(is_dir($val)) {
276                if($mode == "777") {
277                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
278                } else {
279                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
280                    $err_file = true;                                       
281                }
282            } else {
283                if($mode == "666") {
284                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
285                } else {
286                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
287                    $err_file = true;                           
288                }
289            }           
290        } else {
291            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
292            $err_file = true;
293        }
294    }
295   
296    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
297    if(!$err_file) {
298        $path = "../../data/Smarty/templates_c/admin";
299        if(!file_exists($path)) {
300            mkdir($path);
301        }
302        $path = "../upload/save_image";
303        if(!file_exists($path)) {
304            mkdir($path);
305        }
306        $path = "../upload/temp_image";
307        if(!file_exists($path)) {
308            mkdir($path);
309        }
310        $path = "../upload/graph_image";
311        if(!file_exists($path)) {
312            mkdir($path);
313        }
314        $path = "../upload/csv";
315        if(!file_exists($path)) {
316            mkdir($path);
317        }
318    }
319   
320    $objPage->mess = $mess;
321    $objPage->err_file = $err_file;
322
323    return $objPage;
324}
325
326
327// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
328function lfDispStep0_1($objPage) {
329    global $objWebParam;
330    global $objDBParam;
331    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
332    $objPage->arrHidden = $objWebParam->getHashArray();
333    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
334    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
335    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
336    $objPage->tpl_mainpage = 'step0_1.tpl';
337    $objPage->tpl_mode = 'step0_1';
338    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
339    $objPage->copy_mess = sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess);
340    $objPage->copy_mess = sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess);
341    return $objPage;
342}
343
344function lfGetFileMode($path) {
345    $mode = substr(sprintf('%o', fileperms($path)), -3);
346    return $mode;
347}
348
349// STEP1²èÌ̤Îɽ¼¨
350function lfDispStep1($objPage) {
351    global $objDBParam;
352    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
353    $objPage->arrHidden = $objDBParam->getHashArray();
354    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
355    $objPage->tpl_mainpage = 'step1.tpl';
356    $objPage->tpl_mode = 'step1';
357    return $objPage;
358}
359
360// STEP2²èÌ̤Îɽ¼¨
361function lfDispStep2($objPage) {
362    global $objWebParam;
363    global $objDBParam;
364    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
365    $objPage->arrHidden = $objWebParam->getHashArray();
366    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
367    $objPage->tpl_mainpage = 'step2.tpl';
368    $objPage->tpl_mode = 'step2';
369    return $objPage;
370}
371
372// STEP3²èÌ̤Îɽ¼¨
373function lfDispStep3($objPage) {
374    global $objWebParam;
375    global $objDBParam;
376    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
377    $objPage->arrHidden = $objWebParam->getHashArray();
378    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
379    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
380    $objPage->tpl_db_skip = $_POST['db_skip'];
381    $objPage->tpl_mainpage = 'step3.tpl';
382    $objPage->tpl_mode = 'step3';
383    return $objPage;
384}
385
386// ´°Î»²èÌ̤Îɽ¼¨
387function lfDispComplete($objPage) {
388    global $objWebParam;
389    global $objDBParam;
390    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
391    $objPage->arrHidden = $objWebParam->getHashArray();
392    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
393    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
394    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
395    $objPage->tpl_mainpage = 'complete.tpl';
396    $objPage->tpl_mode = 'complete';
397   
398    $secure_url = $objWebParam->getValue('secure_url');
399    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
400    if (!ereg("/$", $secure_url)) {
401        $secure_url = $secure_url . "/";
402    }
403    $objPage->tpl_sslurl = $secure_url;     
404    return $objPage;
405}
406
407// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
408function lfInitWebParam($objWebParam) {
409   
410    if(defined('HTML_PATH')) {
411        $install_dir = HTML_PATH;
412    } else {
413        $install_dir = realpath(dirname( __FILE__) . "/../") . "/";
414    }
415   
416    if(defined('SITE_URL')) {
417        $normal_url = SITE_URL;
418    } else {
419        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
420        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
421    }
422   
423    if(defined('SSL_URL')) {
424        $secure_url = SSL_URL;
425    } else {
426        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
427        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
428    }
429
430    // Ź̾¡¢´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¼èÆÀ¤¹¤ë¡£(ºÆ¥¤¥ó¥¹¥È¡¼¥ë»þ)
431    if(defined('DEFAULT_DSN')) {
432        $ret = sfTabaleExists("dtb_baseinfo", DEFAULT_DSN);
433       
434        if($ret) {
435            print("ari");
436        } else {
437            print("nasi");
438        }
439       
440        $objQuery = new SC_Query();
441        $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
442        $shop_name = $arrRet[0]['shop_name'];
443        $admin_mail = $arrRet[0]['email01'];
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    global $port;
601       
602    $root_dir = $objWebParam->getValue('install_dir');
603    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
604    if (!ereg("/$", $root_dir)) {
605        $root_dir = $root_dir . "/";
606    }
607   
608    $normal_url = $objWebParam->getValue('normal_url');
609    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
610    if (!ereg("/$", $normal_url)) {
611        $normal_url = $normal_url . "/";
612    }
613   
614    $secure_url = $objWebParam->getValue('secure_url');
615    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
616    if (!ereg("/$", $secure_url)) {
617        $secure_url = $secure_url . "/";
618    }
619   
620    // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¼èÆÀ
621    $url_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $normal_url);
622   
623    $data_path = $root_dir . "../data/";
624           
625    $filepath = $data_path . "install.inc";
626   
627    $config_data =
628    "<?php\n".
629    "    define ('ECCUBE_INSTALL', 'ON');\n" .
630    "    define ('HTML_PATH', '" . $root_dir . "');\n" .     
631    "    define ('SITE_URL', '" . $normal_url . "');\n" .
632    "    define ('SSL_URL', '" . $secure_url . "');\n" .
633    "    define ('URL_DIR', '" . $url_dir . "');\n" .   
634    "    define ('DOMAIN_NAME', '" . $objWebParam->getValue('domain') . "');\n" .
635    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
636    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
637    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
638    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
639    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
640    "    define ('DB_PORT', '" . $objDBParam->getValue('db_port') .  "');\n" .
641    "    define('DATA_PATH', '".$data_path."');\n" .
642    "?>";
643   
644    if($fp = fopen($filepath,"w")) {
645        fwrite($fp, $config_data);
646        fclose($fp);
647    }
648}
649
650?>
Note: See TracBrowser for help on using the repository browser.