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

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