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

Revision 5371, 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
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
44sfprintr($_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["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());
216sfprintr($objPage->arrForm );
217
218// SiteInfo¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤
219$objView->assignobj($objPage);
220$objView->display('install_frame.tpl');
221//-----------------------------------------------------------------------------------------------------------------------------------
222// ¤è¤¦¤³¤½²èÌ̤Îɽ¼¨
223function lfDispWelcome($objPage) {
224    global $objWebParam;
225    global $objDBParam;
226    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
227    $objPage->arrHidden = $objWebParam->getHashArray();
228    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
229    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
230    $objPage->tpl_mainpage = 'welcome.tpl';
231    $objPage->tpl_mode = 'welcome';
232    return $objPage;
233}
234
235// STEP0²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¸¢¸Â¥Á¥§¥Ã¥¯)
236function lfDispStep0($objPage) {
237    global $objWebParam;
238    global $objDBParam;
239    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
240    $objPage->arrHidden = $objWebParam->getHashArray();
241    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
242    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
243    $objPage->tpl_mainpage = 'step0.tpl';
244    $objPage->tpl_mode = 'step0';
245   
246    // ¥×¥í¥°¥é¥à¤Ç½ñ¹þ¤ß¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥ì¥¯¥È¥ê
247    $arrWriteFile = array(
248        "html/install.inc",
249        "html/user_data",
250        "html/upload",
251        "data/Smarty/templates_c",     
252        "data/update",
253        "data/logs",
254    );
255   
256    $mess = "";
257    $err_file = false;
258    foreach($arrWriteFile as $val) {
259        $path = "../../" . $val;       
260        if(file_exists($path)) {
261            $mode = lfGetFileMode("../../" . $val);
262           
263            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
264            if(is_dir($path)) {
265                if($mode == "777") {
266                    $mess.= ">> ¡û¡§$val($mode) ¤ÏÌäÂꤢ¤ê¤Þ¤»¤ó¡£<br>";                   
267                } else {
268                    $mess.= ">> ¡ß¡§$val($mode) ¤Ë¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
269                    $err_file = true;                                       
270                }
271            } else {
272                if($mode == "666") {
273                    $mess.= ">> ¡û¡§$val($mode) ¤ÏÌäÂꤢ¤ê¤Þ¤»¤ó¡£<br>";                   
274                } else {
275                    $mess.= ">> ¡ß¡§$val($mode) ¤Ë¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
276                    $err_file = true;                           
277                }
278            }   
279           
280        } else {
281            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
282            $err_file = true;
283        }
284    }
285   
286    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
287    if(!$err_file) {
288        $path = "../../data/Smarty/templates_c/admin";
289        if(!file_exists($path)) {
290            mkdir($path);
291        }
292        $path = "../../html/upload/save_image";
293        if(!file_exists($path)) {
294            mkdir($path);
295        }
296        $path = "../../html/upload/temp_image";
297        if(!file_exists($path)) {
298            mkdir($path);
299        }
300        $path = "../../html/upload/graph_image";
301        if(!file_exists($path)) {
302            mkdir($path);
303        }
304        $path = "../../html/upload/csv";
305        if(!file_exists($path)) {
306            mkdir($path);
307        }
308    }
309   
310    $objPage->mess = $mess;
311    $objPage->err_file = $err_file;
312
313    return $objPage;
314}
315
316
317// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
318function lfDispStep0_1($objPage) {
319    global $objWebParam;
320    global $objDBParam;
321    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
322    $objPage->arrHidden = $objWebParam->getHashArray();
323    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
324    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
325    $objPage->tpl_mainpage = 'step0_1.tpl';
326    $objPage->tpl_mode = 'step0_1';
327    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
328    $objPage->copy_mess = lfCopyDir("./user_data/", "../../html/user_data/", $objPage->copy_mess);
329    $objPage->copy_mess = lfCopyDir("./save_image/", "../../html/upload/save_image/", $objPage->copy_mess);
330    return $objPage;
331}
332
333function lfGetFileMode($path) {
334    $mode = substr(sprintf('%o', fileperms($path)), -3);
335    return $mode;
336}
337
338// STEP1²èÌ̤Îɽ¼¨
339function lfDispStep1($objPage) {
340    global $objDBParam;
341    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
342    $objPage->arrHidden = $objDBParam->getHashArray();
343    $objPage->tpl_mainpage = 'step1.tpl';
344    $objPage->tpl_mode = 'step1';
345    return $objPage;
346}
347
348// STEP2²èÌ̤Îɽ¼¨
349function lfDispStep2($objPage) {
350    global $objWebParam;
351    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
352    $objPage->arrHidden = $objWebParam->getHashArray();
353    $objPage->tpl_mainpage = 'step2.tpl';
354    $objPage->tpl_mode = 'step2';
355    return $objPage;
356}
357
358// STEP3²èÌ̤Îɽ¼¨
359function lfDispStep3($objPage) {
360    global $objWebParam;
361    global $objDBParam;
362    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
363    $objPage->arrHidden = $objWebParam->getHashArray();
364    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
365    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
366    $objPage->tpl_mainpage = 'step3.tpl';
367    $objPage->tpl_mode = 'step3';
368    return $objPage;
369}
370
371// ´°Î»²èÌ̤Îɽ¼¨
372function lfDispComplete($objPage) {
373    global $objWebParam;
374    global $objDBParam;
375    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
376    $objPage->arrHidden = $objWebParam->getHashArray();
377    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
378    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
379    $objPage->tpl_mainpage = 'complete.tpl';
380    $objPage->tpl_mode = 'complete';
381    return $objPage;
382}
383
384// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
385function lfInitWebParam($objWebParam) {
386   
387    $install_dir = realpath(dirname( __FILE__) . "/../../") . "/";
388    $normal_url = "http://" . $_SERVER['HTTP_HOST'] . "/";
389    $secure_url = "http://" . $_SERVER['HTTP_HOST'] . "/";
390    $domain = ereg_replace("^[a-zA-Z0-9_~=&\?\/-]+\.", "", $_SERVER['HTTP_HOST']);
391    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
392    $objWebParam->addParam("´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"));
393    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
394    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
395    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
396    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $domain); 
397
398    return $objWebParam;
399}
400
401// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
402function lfInitDBParam($objDBParam) {
403   
404    $db_server = "127.0.0.1";
405    $db_port = "3306";
406    $db_name = "eccube_db";
407    $db_user = "eccube_db_user";
408   
409    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
410    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
411    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
412    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
413    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
414    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
415   
416    $objDBParam->addParam("¥¹¥­¥Ã¥×", "skip");
417   
418    return $objDBParam;
419}
420
421// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
422function lfCheckWebError($objFormParam) {
423    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
424    $arrRet =  $objFormParam->getHashArray();
425    $objErr = new SC_CheckError($arrRet);
426    $objErr->arrErr = $objFormParam->checkError();
427    return $objErr->arrErr;
428}
429
430// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
431function lfCheckDBError($objFormParam) {
432    global $port;
433    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
434    $arrRet =  $objFormParam->getHashArray();
435   
436    $objErr = new SC_CheckError($arrRet);
437    $objErr->arrErr = $objFormParam->checkError();
438   
439    if(count($objErr->arrErr) == 0) {
440        // Àܳ³Îǧ
441        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].$port."/".$arrRet['db_name'];
442        // Debug¥â¡¼¥É»ØÄê
443        $options['debug'] = 3;
444        $objDB = DB::connect($dsn, $options);
445        // Àܳ¥¨¥é¡¼
446        if(PEAR::isError($objDB)) {
447            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
448            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
449            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
450            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
451            gfPrintLog($objDB->userinfo, "./temp/install.log");
452        }
453    }
454    return $objErr->arrErr;
455}
456
457// SQLʸ¤Î¼Â¹Ô
458function lfExecuteSQL($filepath, $db_user, $db_password, $db_server, $db_name, $db_type, $db_port, $disp_err = true) {
459    global $port;
460    $arrErr = array();
461
462    if(!file_exists($filepath)) {
463        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
464    } else {
465        if($fp = fopen($filepath,"r")) {
466            $sql = fread($fp, filesize($filepath));
467            fclose($fp);
468        }
469
470        $dsn = $db_type."://".$db_user.":".$db_password."@".$db_server.$port."/".$db_name;
471       
472        $objDB = DB::connect($dsn);
473        // Àܳ¥¨¥é¡¼
474        if(!PEAR::isError($objDB)) {
475            // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹
476            $sql = preg_replace("/[\r\n\t]/"," ",$sql);
477            $sql_split = split(";",$sql);
478            foreach($sql_split as $key => $val){
479                if (trim($val) != "") {
480                    $ret = $objDB->query($val);
481                    if(PEAR::isError($ret) and $disp_err) {
482                        $arrErr['all'] = ">> " . $ret->message . "<br>";
483                        // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
484                        ereg("\[(.*)\]", $ret->userinfo, $arrKey);
485                        $arrErr['all'].= $arrKey[0] . "<br>";
486                        $objPage->update_mess.=">> ¥Æ¡¼¥Ö¥ë¹½À®¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";
487                        gfPrintLog($ret->userinfo, "./temp/install.log");
488                    }
489                }
490            }
491           
492        } else {
493            $arrErr['all'] = ">> " . $objDB->message;
494            gfPrintLog($objDB->userinfo, "./temp/install.log");
495        }
496    }
497    return $arrErr;
498}
499
500// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎºîÀ®
501function lfMakeConfigFile() {
502    global $objWebParam;
503    global $objDBParam;
504    global $port;
505   
506    $filepath = $objWebParam->getValue('install_dir') . "/html/install.inc";
507    $domain = $objWebParam->getValue('domain');
508    if(!ereg("^\.", $domain)) {
509        $domain = "." . $domain;
510    }
511   
512    $root_dir = $objWebParam->getValue('install_dir');
513    if (!ereg("/$", $root_dir)) {
514        $root_dir = $root_dir . "/";
515    }
516   
517    $config_data =
518    "<?php\n".
519    "    define ('ECCUBE_INSTALL', 'ON');\n" .
520    "    define ('ROOT_DIR', '" . $root_dir . "');\n" .
521    "    define ('SITE_URL', '" . $objWebParam->getValue('normal_url') . "');\n" .
522    "    define ('SSL_URL', '" . $objWebParam->getValue('secure_url') . "');\n" .
523    "    define ('DOMAIN_NAME', '" . $domain . "');\n" .
524    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
525    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
526    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
527    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
528    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
529    "    define ('DB_PORT', '" . $port . "');\n" .
530    "?>";
531   
532    if($fp = fopen($filepath,"w")) {
533        fwrite($fp, $config_data);
534        fclose($fp);
535    }
536}
537
538// ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤òºÆµ¢Åª¤Ë¥³¥Ô¡¼
539function lfCopyDir($src, $des, $mess, $override = false){
540    if(!is_dir($src)){
541        return false;
542    }
543
544    $oldmask = umask(0);
545    $mod= stat($src);
546   
547    // ¥Ç¥£¥ì¥¯¥È¥ê¤¬¤Ê¤±¤ì¤ÐºîÀ®¤¹¤ë
548    if(!file_exists($des)) {
549        mkdir($des, $mod[2]);
550    }
551   
552    $fileArray=glob( $src."*" );
553    foreach( $fileArray as $key => $data_ ){
554        // CVS´ÉÍý¥Õ¥¡¥¤¥ë¤Ï¥³¥Ô¡¼¤·¤Ê¤¤
555        if(ereg("/CVS/Entries", $data_)) {
556            break;
557        }
558        if(ereg("/CVS/Repository", $data_)) {
559            break;
560        }
561        if(ereg("/CVS/Root", $data_)) {
562            break;
563        }
564       
565        mb_ereg("^(.*[\/])(.*)",$data_, $matches);
566        $data=$matches[2];
567        if( is_dir( $data_ ) ){
568            $mess = lfCopyDir( $data_.'/', $des.$data.'/', $mess);
569        }else{
570            if(!$override && file_exists($des.$data)) {
571                $mess.= $des.$data . "¡§¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤¹\n";
572            } else {
573                if(@copy( $data_, $des.$data)) {
574                    $mess.= $des.$data . "¡§¥³¥Ô¡¼À®¸ù\n";
575                } else {
576                    $mess.= $des.$data . "¡§¥³¥Ô¡¼¼ºÇÔ\n";
577                }
578            }
579            $mod=stat($data_ );
580        }
581    }
582    umask($oldmask);
583    return $mess;
584}
585?>
Note: See TracBrowser for help on using the repository browser.