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

Revision 6243, 18.9 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    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
84   
85    /*
86        ¥Ð¡¼¥¸¥ç¥ó¥¢¥Ã¥×Åù¤ÇÄɲåơ¼¥Ö¥ë¤¬È¯À¸¤·¤¿ºÝ¤Ïµ­ºÜ¤¹¤ë
87        ¡Ê£Ä£Â¹½À®¤Î²¼°Ì¸ß´¹¤Î¤¿¤á¥¹¥­¥Ã¥×»þ¤â¶¯À©¡Ë
88    */
89   
90   
91    if(count($objPage->arrErr) == 0) {
92        // ¥¹¥­¥Ã¥×¤¹¤ë¾ì¹ç¤Ë¤Ï´°Î»²èÌ̤ØÁ«°Ü
93        $skip = $_POST["db_skip"];
94        if ($skip == "on") {
95            // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
96            lfMakeConfigFile();
97            $objPage = lfDispComplete($objPage);
98            break;
99        }
100    }
101   
102    // ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
103    $objPage->arrErr = lfExecuteSQL("./sql/create_table_".$arrRet['db_type'].".sql", $dsn);
104    if(count($objPage->arrErr) == 0) {
105        $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
106    } else {
107        $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
108    }
109
110    // ¥Ó¥å¡¼¤ÎºîÀ®
111    if(count($objPage->arrErr) == 0 and $arrRet['db_type'] == 'pgsql') {
112        // ¥Ó¥å¡¼¤ÎºîÀ®
113        $objPage->arrErr = lfExecuteSQL("./sql/create_view.sql", $dsn);
114        if(count($objPage->arrErr) == 0) {
115            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
116        } else {
117            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
118        }
119    }   
120   
121    // ½é´ü¥Ç¡¼¥¿¤ÎºîÀ®
122    if(count($objPage->arrErr) == 0) {
123        $objPage->arrErr = lfExecuteSQL("./sql/insert_data.sql", $dsn);
124        if(count($objPage->arrErr) == 0) {
125            $objPage->tpl_message.="¡û¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
126        } else {
127            $objPage->tpl_message.="¡ß¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
128        }
129    }   
130   
131    // ¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
132    if(count($objPage->arrErr) == 0) {
133        $objPage->arrErr = lfExecuteSQL("./sql/column_comment.sql", $dsn);
134        if(count($objPage->arrErr) == 0) {
135            $objPage->tpl_message.="¡û¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
136        } else {
137            $objPage->tpl_message.="¡ß¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
138        }
139    }   
140   
141    // ¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
142    if(count($objPage->arrErr) == 0) {
143        $objPage->arrErr = lfExecuteSQL("./sql/table_comment.sql", $dsn);
144        if(count($objPage->arrErr) == 0) {
145            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
146        } else {
147            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
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("./sql/drop_view.sql", $dsn, 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("./sql/drop_table.sql", $dsn, 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'].":".$arrRet['db_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        "../user_data",
268        "../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        if(file_exists($val)) {
278            $mode = lfGetFileMode($val);
279            $real_path = realpath($val);
280                       
281            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
282            if(is_dir($val)) {
283                if($mode == "777") {
284                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
285                } else {
286                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
287                    $err_file = true;                                       
288                }
289            } else {
290                if($mode == "666") {
291                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
292                } else {
293                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
294                    $err_file = true;                           
295                }
296            }           
297        } else {
298            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
299            $err_file = true;
300        }
301    }
302   
303    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
304    if(!$err_file) {
305        $path = "../../data/Smarty/templates_c/admin";
306        if(!file_exists($path)) {
307            mkdir($path);
308        }
309        $path = "../upload/save_image";
310        if(!file_exists($path)) {
311            mkdir($path);
312        }
313        $path = "../upload/temp_image";
314        if(!file_exists($path)) {
315            mkdir($path);
316        }
317        $path = "../upload/graph_image";
318        if(!file_exists($path)) {
319            mkdir($path);
320        }
321        $path = "../upload/csv";
322        if(!file_exists($path)) {
323            mkdir($path);
324        }
325    }
326   
327    $objPage->mess = $mess;
328    $objPage->err_file = $err_file;
329
330    return $objPage;
331}
332
333
334// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
335function lfDispStep0_1($objPage) {
336    global $objWebParam;
337    global $objDBParam;
338    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
339    $objPage->arrHidden = $objWebParam->getHashArray();
340    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
341    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
342    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
343    $objPage->tpl_mainpage = 'step0_1.tpl';
344    $objPage->tpl_mode = 'step0_1';
345    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
346    $objPage->copy_mess = sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess);
347    $objPage->copy_mess = sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess);
348    return $objPage;
349}
350
351function lfGetFileMode($path) {
352    $mode = substr(sprintf('%o', fileperms($path)), -3);
353    return $mode;
354}
355
356// STEP1²èÌ̤Îɽ¼¨
357function lfDispStep1($objPage) {
358    global $objDBParam;
359    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
360    $objPage->arrHidden = $objDBParam->getHashArray();
361    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
362    $objPage->tpl_mainpage = 'step1.tpl';
363    $objPage->tpl_mode = 'step1';
364    return $objPage;
365}
366
367// STEP2²èÌ̤Îɽ¼¨
368function lfDispStep2($objPage) {
369    global $objWebParam;
370    global $objDBParam;
371    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
372    $objPage->arrHidden = $objWebParam->getHashArray();
373    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
374    $objPage->tpl_mainpage = 'step2.tpl';
375    $objPage->tpl_mode = 'step2';
376    return $objPage;
377}
378
379// STEP3²èÌ̤Îɽ¼¨
380function lfDispStep3($objPage) {
381    global $objWebParam;
382    global $objDBParam;
383    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
384    $objPage->arrHidden = $objWebParam->getHashArray();
385    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
386    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
387    $objPage->tpl_db_skip = $_POST['db_skip'];
388    $objPage->tpl_mainpage = 'step3.tpl';
389    $objPage->tpl_mode = 'step3';
390    return $objPage;
391}
392
393// ´°Î»²èÌ̤Îɽ¼¨
394function lfDispComplete($objPage) {
395    global $objWebParam;
396    global $objDBParam;
397    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
398    $objPage->arrHidden = $objWebParam->getHashArray();
399    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
400    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
401    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
402    $objPage->tpl_mainpage = 'complete.tpl';
403    $objPage->tpl_mode = 'complete';
404   
405    $secure_url = $objWebParam->getValue('secure_url');
406    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
407    if (!ereg("/$", $secure_url)) {
408        $secure_url = $secure_url . "/";
409    }
410    $objPage->tpl_sslurl = $secure_url;     
411    return $objPage;
412}
413
414// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
415function lfInitWebParam($objWebParam) {
416   
417    if(defined('HTML_PATH')) {
418        $install_dir = HTML_PATH;
419    } else {
420        $install_dir = realpath(dirname( __FILE__) . "/../") . "/";
421    }
422   
423    if(defined('SITE_URL')) {
424        $normal_url = SITE_URL;
425    } else {
426        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
427        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
428    }
429   
430    if(defined('SSL_URL')) {
431        $secure_url = SSL_URL;
432    } else {
433        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
434        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
435    }
436
437    // Ź̾¡¢´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¼èÆÀ¤¹¤ë¡£(ºÆ¥¤¥ó¥¹¥È¡¼¥ë»þ)
438    if(defined('DEFAULT_DSN')) {
439        $ret = sfTabaleExists("dtb_baseinfo", DEFAULT_DSN);
440        if($ret) {
441            $objQuery = new SC_Query();
442            $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
443            $shop_name = $arrRet[0]['shop_name'];
444            $admin_mail = $arrRet[0]['email01'];
445        }
446    }
447
448    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $shop_name);
449    $objWebParam->addParam("´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
450    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
451    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
452    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
453    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("MAX_LENGTH_CHECK"));
454
455    return $objWebParam;
456}
457
458// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
459function lfInitDBParam($objDBParam) {
460   
461    if(defined('DB_SERVER')) {
462        $db_server = DB_SERVER;
463    } else {
464        $db_server = "127.0.0.1";
465    }
466   
467    if(defined('DB_PORT')) {
468        $db_port = DB_PORT;
469    } else {
470        $db_port = "";
471    }
472       
473    if(defined('DB_NAME')) {
474        $db_name = DB_NAME;
475    } else {
476        $db_name = "eccube_db";
477    }
478       
479    if(defined('DB_USER')) {
480        $db_user = DB_USER;
481    } else {
482        $db_user = "eccube_db_user";               
483    }
484           
485    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
486    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
487    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
488    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
489    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
490    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
491       
492    return $objDBParam;
493}
494
495// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
496function lfCheckWebError($objFormParam) {
497    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
498    $arrRet =  $objFormParam->getHashArray();
499    $objErr = new SC_CheckError($arrRet);
500    $objErr->arrErr = $objFormParam->checkError();
501   
502    // ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¤ß¼èÆÀ¤¹¤ë
503    $normal_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['normal_url']);
504    $secure_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['secure_url']);
505   
506    if($normal_dir != $secure_dir) {
507        $objErr->arrErr['normal_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
508        $objErr->arrErr['secure_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";     
509    }
510   
511    return $objErr->arrErr;
512}
513
514// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
515function lfCheckDBError($objFormParam) {
516    global $objPage;
517   
518    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
519    $arrRet =  $objFormParam->getHashArray();
520   
521    $objErr = new SC_CheckError($arrRet);
522    $objErr->arrErr = $objFormParam->checkError();
523   
524    if(count($objErr->arrErr) == 0) {
525        // Àܳ³Îǧ
526        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
527        // Debug¥â¡¼¥É»ØÄê
528        $options['debug'] = 9;
529        $objDB = DB::connect($dsn, $options);
530        // Àܳ¥¨¥é¡¼
531        if(PEAR::isError($objDB)) {
532            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
533            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
534            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
535            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
536            gfPrintLog($objDB->userinfo, "./temp/install.log");
537        } else {
538            if($arrRet['db_type'] == 'mysql') {
539                $arrRet = $objDB->getAll("SHOW VARIABLES");
540                foreach($arrRet as $array) {
541                    if($array[0] == 'version') {
542                        $objPage->tpl_db_version = "MySQL " . $array[1];
543                    }
544                }
545            }
546            if($arrRet['db_type'] == 'pgsql') {
547                $arrRet = $objDB->getAll("select version()");
548                $arrLine = split(" " , $arrRet[0][0]);
549                $objPage->tpl_db_version = $arrLine[0] . " " . $arrLine[1];
550            }
551        }
552    }
553    return $objErr->arrErr;
554}
555
556// SQLʸ¤Î¼Â¹Ô
557function lfExecuteSQL($filepath, $dsn, $disp_err = true) {
558    $arrErr = array();
559
560    if(!file_exists($filepath)) {
561        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
562    } else {
563        if($fp = fopen($filepath,"r")) {
564            $sql = fread($fp, filesize($filepath));
565            fclose($fp);
566        }
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// ¥Æ¡¼¥Ö¥ë¤ÎÄɲÃ
649function lfAddTable($table_name) {
650    if(!sfTabaleExists($table_name)) {
651       
652    }
653}
654
655?>
Note: See TracBrowser for help on using the repository browser.