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

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