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

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