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

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