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

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