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

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