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

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