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

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