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

Revision 5379, 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$objPage->arrHidden['db_skip'] = $_POST['db_skip'];
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["skip"];
85    $objPage->arrHidden['db_skip'] = $skip;
86    if ($skip != "on") {
87        // ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
88        $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']);
89        if(count($objPage->arrErr) == 0) {
90            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
91        } else {
92            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
93        }
94   
95        // ¥Ó¥å¡¼¤ÎºîÀ®
96        if(count($objPage->arrErr) == 0 and $arrRet['db_type'] == 'pgsql') {
97            // ¥Ó¥å¡¼¤ÎºîÀ®
98            $objPage->arrErr = lfExecuteSQL("./create_view.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
99            if(count($objPage->arrErr) == 0) {
100                $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
101            } else {
102                $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
103            }
104        }   
105       
106        // ½é´ü¥Ç¡¼¥¿¤ÎºîÀ®
107        if(count($objPage->arrErr) == 0) {
108            $objPage->arrErr = lfExecuteSQL("./insert_data.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
109            if(count($objPage->arrErr) == 0) {
110                $objPage->tpl_message.="¡û¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
111            } else {
112                $objPage->tpl_message.="¡ß¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
113            }
114        }   
115       
116        // ¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
117        if(count($objPage->arrErr) == 0) {
118            $objPage->arrErr = lfExecuteSQL("./column_comment.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
119            if(count($objPage->arrErr) == 0) {
120                $objPage->tpl_message.="¡û¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
121            } else {
122                $objPage->tpl_message.="¡ß¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
123            }
124        }   
125       
126        // ¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
127        if(count($objPage->arrErr) == 0) {
128            $objPage->arrErr = lfExecuteSQL("./table_comment.sql", $arrRet['db_user'], $arrRet['db_password'], $arrRet['db_server'], $arrRet['db_name'], $arrRet['db_type'], $arrRet['db_port']);
129            if(count($objPage->arrErr) == 0) {
130                $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
131            } else {
132                $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
133            }
134        }
135    }
136
137    if(count($objPage->arrErr) == 0) {
138        // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
139        lfMakeConfigFile();
140        $objPage = lfDispStep3($objPage);
141        $objPage->tpl_mode = 'complete';
142    } else {
143        $objPage = lfDispStep3($objPage);
144    }
145    break;
146// ¥Æ¡¼¥Ö¥ëÎàºï½ü
147case 'drop':
148    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
149    $arrRet =  $objDBParam->getHashArray();
150   
151    if ($arrRet['db_type'] == 'pgsql'){
152        // ¥Ó¥å¡¼¤Îºï½ü
153        $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);
154        if(count($objPage->arrErr) == 0) {
155            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
156        } else {
157            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
158        }
159    }
160
161
162    // ¥Æ¡¼¥Ö¥ë¤Îºï½ü
163    if(count($objPage->arrErr) == 0) {
164        $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);
165        if(count($objPage->arrErr) == 0) {
166            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
167        } else {
168            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
169        }
170    }
171    $objPage = lfDispStep3($objPage);
172    break;
173// ´°Î»²èÌÌ
174case 'complete':
175    // ¥·¥ç¥Ã¥×¥Þ¥¹¥¿¾ðÊó¤Î½ñ¤­¹þ¤ß
176    $arrRet =  $objDBParam->getHashArray();
177    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].$port."/".$arrRet['db_name'];
178    $sqlval['shop_name'] = $objWebParam->getValue('shop_name');
179    $sqlval['email01'] = $objWebParam->getValue('admin_mail');
180    $sqlval['email02'] = $objWebParam->getValue('admin_mail');
181    $sqlval['email03'] = $objWebParam->getValue('admin_mail');
182    $sqlval['email04'] = $objWebParam->getValue('admin_mail');
183    $sqlval['email05'] = $objWebParam->getValue('admin_mail');
184    $sqlval['top_tpl'] = "default1";
185    $sqlval['product_tpl'] = "default1";
186    $sqlval['detail_tpl'] = "default1";
187    $sqlval['mypage_tpl'] = "default1";
188    $objQuery = new SC_Query($dsn);
189    $cnt = $objQuery->count("dtb_baseinfo");
190    if($cnt > 0) {
191        $objQuery->update("dtb_baseinfo", $sqlval);
192    } else {       
193        $objQuery->insert("dtb_baseinfo", $sqlval);     
194    }
195    global $GLOBAL_ERR;
196    $GLOBAL_ERR = "";
197    $objPage = lfDispComplete($objPage);
198    break;
199case 'return_step0':
200    $objPage = lfDispStep0($objPage);
201    break; 
202case 'return_step1':
203    $objPage = lfDispStep1($objPage);
204    break;
205case 'return_step2':
206    $objPage = lfDispStep2($objPage);
207    break;
208case 'return_welcome':
209default:
210    $objPage = lfDispWelcome($objPage);
211    break;
212}
213
214//¥Õ¥©¡¼¥àÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹
215$objPage->arrForm = $objWebParam->getFormParamList();
216$objPage->arrForm = array_merge($objPage->arrForm, $objDBParam->getFormParamList());
217
218sfprintr($objPage->arrHidden);
219
220// SiteInfo¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤
221$objView->assignobj($objPage);
222$objView->display('install_frame.tpl');
223//-----------------------------------------------------------------------------------------------------------------------------------
224// ¤è¤¦¤³¤½²èÌ̤Îɽ¼¨
225function lfDispWelcome($objPage) {
226    global $objWebParam;
227    global $objDBParam;
228    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
229    $objPage->arrHidden = $objWebParam->getHashArray();
230    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
231    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
232    $objPage->tpl_mainpage = 'welcome.tpl';
233    $objPage->tpl_mode = 'welcome';
234    return $objPage;
235}
236
237// STEP0²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¸¢¸Â¥Á¥§¥Ã¥¯)
238function lfDispStep0($objPage) {
239    global $objWebParam;
240    global $objDBParam;
241    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
242    $objPage->arrHidden = $objWebParam->getHashArray();
243    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
244    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
245    $objPage->tpl_mainpage = 'step0.tpl';
246    $objPage->tpl_mode = 'step0';
247   
248    // ¥×¥í¥°¥é¥à¤Ç½ñ¹þ¤ß¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥ì¥¯¥È¥ê
249    $arrWriteFile = array(
250        "html/install.inc",
251        "html/user_data",
252        "html/upload",
253        "data/Smarty/templates_c",     
254        "data/update",
255        "data/logs",
256    );
257   
258    $mess = "";
259    $err_file = false;
260    foreach($arrWriteFile as $val) {
261        $path = "../../" . $val;       
262        if(file_exists($path)) {
263            $mode = lfGetFileMode("../../" . $val);
264           
265            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
266            if(is_dir($path)) {
267                if($mode == "777") {
268                    $mess.= ">> ¡û¡§$val($mode) ¤ÏÌäÂꤢ¤ê¤Þ¤»¤ó¡£<br>";                   
269                } else {
270                    $mess.= ">> ¡ß¡§$val($mode) ¤Ë¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
271                    $err_file = true;                                       
272                }
273            } else {
274                if($mode == "666") {
275                    $mess.= ">> ¡û¡§$val($mode) ¤ÏÌäÂꤢ¤ê¤Þ¤»¤ó¡£<br>";                   
276                } else {
277                    $mess.= ">> ¡ß¡§$val($mode) ¤Ë¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
278                    $err_file = true;                           
279                }
280            }   
281           
282        } else {
283            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
284            $err_file = true;
285        }
286    }
287   
288    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
289    if(!$err_file) {
290        $path = "../../data/Smarty/templates_c/admin";
291        if(!file_exists($path)) {
292            mkdir($path);
293        }
294        $path = "../../html/upload/save_image";
295        if(!file_exists($path)) {
296            mkdir($path);
297        }
298        $path = "../../html/upload/temp_image";
299        if(!file_exists($path)) {
300            mkdir($path);
301        }
302        $path = "../../html/upload/graph_image";
303        if(!file_exists($path)) {
304            mkdir($path);
305        }
306        $path = "../../html/upload/csv";
307        if(!file_exists($path)) {
308            mkdir($path);
309        }
310    }
311   
312    $objPage->mess = $mess;
313    $objPage->err_file = $err_file;
314
315    return $objPage;
316}
317
318
319// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
320function lfDispStep0_1($objPage) {
321    global $objWebParam;
322    global $objDBParam;
323    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
324    $objPage->arrHidden = $objWebParam->getHashArray();
325    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
326    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
327    $objPage->tpl_mainpage = 'step0_1.tpl';
328    $objPage->tpl_mode = 'step0_1';
329    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
330    $objPage->copy_mess = lfCopyDir("./user_data/", "../../html/user_data/", $objPage->copy_mess);
331    $objPage->copy_mess = lfCopyDir("./save_image/", "../../html/upload/save_image/", $objPage->copy_mess);
332    return $objPage;
333}
334
335function lfGetFileMode($path) {
336    $mode = substr(sprintf('%o', fileperms($path)), -3);
337    return $mode;
338}
339
340// STEP1²èÌ̤Îɽ¼¨
341function lfDispStep1($objPage) {
342    global $objDBParam;
343    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
344    $objPage->arrHidden = $objDBParam->getHashArray();
345    $objPage->tpl_mainpage = 'step1.tpl';
346    $objPage->tpl_mode = 'step1';
347    return $objPage;
348}
349
350// STEP2²èÌ̤Îɽ¼¨
351function lfDispStep2($objPage) {
352    global $objWebParam;
353    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
354    $objPage->arrHidden = $objWebParam->getHashArray();
355    $objPage->tpl_mainpage = 'step2.tpl';
356    $objPage->tpl_mode = 'step2';
357    return $objPage;
358}
359
360// STEP3²èÌ̤Îɽ¼¨
361function lfDispStep3($objPage) {
362    global $objWebParam;
363    global $objDBParam;
364    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
365    $objPage->arrHidden = $objWebParam->getHashArray();
366    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
367    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
368    $objPage->tpl_mainpage = 'step3.tpl';
369    $objPage->tpl_mode = 'step3';
370    return $objPage;
371}
372
373// ´°Î»²èÌ̤Îɽ¼¨
374function lfDispComplete($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_mainpage = 'complete.tpl';
382    $objPage->tpl_mode = 'complete';
383    return $objPage;
384}
385
386// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
387function lfInitWebParam($objWebParam) {
388   
389    $install_dir = realpath(dirname( __FILE__) . "/../../") . "/";
390    $normal_url = "http://" . $_SERVER['HTTP_HOST'] . "/";
391    $secure_url = "http://" . $_SERVER['HTTP_HOST'] . "/";
392    $domain = ereg_replace("^[a-zA-Z0-9_~=&\?\/-]+\.", "", $_SERVER['HTTP_HOST']);
393    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
394    $objWebParam->addParam("´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"));
395    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
396    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
397    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
398    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $domain); 
399
400    return $objWebParam;
401}
402
403// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
404function lfInitDBParam($objDBParam) {
405   
406    $db_server = "127.0.0.1";
407    $db_port = "3306";
408    $db_name = "eccube_db";
409    $db_user = "eccube_db_user";
410   
411    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
412    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
413    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
414    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
415    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
416    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
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.