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

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