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

Revision 5424, 18.2 KB checked in by kakinaka, 20 years ago (diff)

blank

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