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

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