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

Revision 5399, 18.0 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
219//¥Õ¥©¡¼¥àÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹
220$objPage->arrForm = $objWebParam->getFormParamList();
221$objPage->arrForm = array_merge($objPage->arrForm, $objDBParam->getFormParamList());
222
223// SiteInfo¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤
224$objView->assignobj($objPage);
225$objView->display('install_frame.tpl');
226//-----------------------------------------------------------------------------------------------------------------------------------
227// ¤è¤¦¤³¤½²èÌ̤Îɽ¼¨
228function lfDispWelcome($objPage) {
229    global $objWebParam;
230    global $objDBParam;
231    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
232    $objPage->arrHidden = $objWebParam->getHashArray();
233    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
234    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
235    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
236    $objPage->tpl_mainpage = 'welcome.tpl';
237    $objPage->tpl_mode = 'welcome';
238    return $objPage;
239}
240
241// STEP0²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¸¢¸Â¥Á¥§¥Ã¥¯)
242function lfDispStep0($objPage) {
243    global $objWebParam;
244    global $objDBParam;
245    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
246    $objPage->arrHidden = $objWebParam->getHashArray();
247    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
248    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
249    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
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->arrHidden['db_skip'] = $_POST['db_skip'];
333    $objPage->tpl_mainpage = 'step0_1.tpl';
334    $objPage->tpl_mode = 'step0_1';
335    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
336    $objPage->copy_mess = lfCopyDir("./user_data/", "../../html/user_data/", $objPage->copy_mess);
337    $objPage->copy_mess = lfCopyDir("./save_image/", "../../html/upload/save_image/", $objPage->copy_mess);
338    return $objPage;
339}
340
341function lfGetFileMode($path) {
342    $mode = substr(sprintf('%o', fileperms($path)), -3);
343    return $mode;
344}
345
346// STEP1²èÌ̤Îɽ¼¨
347function lfDispStep1($objPage) {
348    global $objDBParam;
349    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
350    $objPage->arrHidden = $objDBParam->getHashArray();
351    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
352    $objPage->tpl_mainpage = 'step1.tpl';
353    $objPage->tpl_mode = 'step1';
354    return $objPage;
355}
356
357// STEP2²èÌ̤Îɽ¼¨
358function lfDispStep2($objPage) {
359    global $objWebParam;
360    global $objDBParam;
361    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
362    $objPage->arrHidden = $objWebParam->getHashArray();
363    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
364    $objPage->tpl_mainpage = 'step2.tpl';
365    $objPage->tpl_mode = 'step2';
366    return $objPage;
367}
368
369// STEP3²èÌ̤Îɽ¼¨
370function lfDispStep3($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_db_skip = $_POST['db_skip'];
378    $objPage->tpl_mainpage = 'step3.tpl';
379    $objPage->tpl_mode = 'step3';
380    return $objPage;
381}
382
383// ´°Î»²èÌ̤Îɽ¼¨
384function lfDispComplete($objPage) {
385    global $objWebParam;
386    global $objDBParam;
387    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
388    $objPage->arrHidden = $objWebParam->getHashArray();
389    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
390    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
391    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
392    $objPage->tpl_mainpage = 'complete.tpl';
393    $objPage->tpl_mode = 'complete';
394    return $objPage;
395}
396
397// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
398function lfInitWebParam($objWebParam) {
399   
400    $install_dir = realpath(dirname( __FILE__) . "/../../") . "/";
401    $normal_url = "http://" . $_SERVER['HTTP_HOST'] . "/";
402    $secure_url = "http://" . $_SERVER['HTTP_HOST'] . "/";
403    $domain = ereg_replace("^[a-zA-Z0-9_~=&\?\/-]+\.", "", $_SERVER['HTTP_HOST']);
404    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
405    $objWebParam->addParam("´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"));
406    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
407    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
408    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
409    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $domain); 
410
411    return $objWebParam;
412}
413
414// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
415function lfInitDBParam($objDBParam) {
416   
417    $db_server = "127.0.0.1";
418    $db_port = "3306";
419    $db_name = "eccube_db";
420    $db_user = "eccube_db_user";
421   
422    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));
423    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
424    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
425    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
426    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
427    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
428
429    return $objDBParam;
430}
431
432// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
433function lfCheckWebError($objFormParam) {
434    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
435    $arrRet =  $objFormParam->getHashArray();
436    $objErr = new SC_CheckError($arrRet);
437    $objErr->arrErr = $objFormParam->checkError();
438    return $objErr->arrErr;
439}
440
441// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
442function lfCheckDBError($objFormParam) {
443    global $port;
444    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
445    $arrRet =  $objFormParam->getHashArray();
446   
447    $objErr = new SC_CheckError($arrRet);
448    $objErr->arrErr = $objFormParam->checkError();
449   
450    if(count($objErr->arrErr) == 0) {
451        // Àܳ³Îǧ
452        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].$port."/".$arrRet['db_name'];
453        // Debug¥â¡¼¥É»ØÄê
454        $options['debug'] = 3;
455        $objDB = DB::connect($dsn, $options);
456        // Àܳ¥¨¥é¡¼
457        if(PEAR::isError($objDB)) {
458            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
459            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
460            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
461            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
462            gfPrintLog($objDB->userinfo, "./temp/install.log");
463        }
464    }
465    return $objErr->arrErr;
466}
467
468// SQLʸ¤Î¼Â¹Ô
469function lfExecuteSQL($filepath, $db_user, $db_password, $db_server, $db_name, $db_type, $db_port, $disp_err = true) {
470    global $port;
471    $arrErr = array();
472
473    if(!file_exists($filepath)) {
474        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
475    } else {
476        if($fp = fopen($filepath,"r")) {
477            $sql = fread($fp, filesize($filepath));
478            fclose($fp);
479        }
480
481        $dsn = $db_type."://".$db_user.":".$db_password."@".$db_server.$port."/".$db_name;
482       
483        $objDB = DB::connect($dsn);
484        // Àܳ¥¨¥é¡¼
485        if(!PEAR::isError($objDB)) {
486            // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹
487            $sql = preg_replace("/[\r\n\t]/"," ",$sql);
488            $sql_split = split(";",$sql);
489            foreach($sql_split as $key => $val){
490                if (trim($val) != "") {
491                    $ret = $objDB->query($val);
492                    if(PEAR::isError($ret) and $disp_err) {
493                        $arrErr['all'] = ">> " . $ret->message . "<br>";
494                        // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
495                        ereg("\[(.*)\]", $ret->userinfo, $arrKey);
496                        $arrErr['all'].= $arrKey[0] . "<br>";
497                        $objPage->update_mess.=">> ¥Æ¡¼¥Ö¥ë¹½À®¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";
498                        gfPrintLog($ret->userinfo, "./temp/install.log");
499                    }
500                }
501            }
502           
503        } else {
504            $arrErr['all'] = ">> " . $objDB->message;
505            gfPrintLog($objDB->userinfo, "./temp/install.log");
506        }
507    }
508    return $arrErr;
509}
510
511// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎºîÀ®
512function lfMakeConfigFile() {
513    global $objWebParam;
514    global $objDBParam;
515    global $port;
516   
517    $filepath = $objWebParam->getValue('install_dir') . "/html/install.inc";
518    $domain = $objWebParam->getValue('domain');
519    if(!ereg("^\.", $domain)) {
520        $domain = "." . $domain;
521    }
522   
523    $root_dir = $objWebParam->getValue('install_dir');
524    if (!ereg("/$", $root_dir)) {
525        $root_dir = $root_dir . "/";
526    }
527   
528    $config_data =
529    "<?php\n".
530    "    define ('ECCUBE_INSTALL', 'ON');\n" .
531    "    define ('ROOT_DIR', '" . $root_dir . "');\n" .
532    "    define ('SITE_URL', '" . $objWebParam->getValue('normal_url') . "');\n" .
533    "    define ('SSL_URL', '" . $objWebParam->getValue('secure_url') . "');\n" .
534    "    define ('DOMAIN_NAME', '" . $domain . "');\n" .
535    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
536    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
537    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
538    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
539    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
540    "    define ('DB_PORT', '" . $port . "');\n" .
541    "?>";
542   
543    if($fp = fopen($filepath,"w")) {
544        fwrite($fp, $config_data);
545        fclose($fp);
546    }
547}
548
549// ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤òºÆµ¢Åª¤Ë¥³¥Ô¡¼
550function lfCopyDir($src, $des, $mess, $override = false){
551    if(!is_dir($src)){
552        return false;
553    }
554
555    $oldmask = umask(0);
556    $mod= stat($src);
557   
558    // ¥Ç¥£¥ì¥¯¥È¥ê¤¬¤Ê¤±¤ì¤ÐºîÀ®¤¹¤ë
559    if(!file_exists($des)) {
560        mkdir($des, $mod[2]);
561    }
562   
563    $fileArray=glob( $src."*" );
564    foreach( $fileArray as $key => $data_ ){
565        // CVS´ÉÍý¥Õ¥¡¥¤¥ë¤Ï¥³¥Ô¡¼¤·¤Ê¤¤
566        if(ereg("/CVS/Entries", $data_)) {
567            break;
568        }
569        if(ereg("/CVS/Repository", $data_)) {
570            break;
571        }
572        if(ereg("/CVS/Root", $data_)) {
573            break;
574        }
575       
576        mb_ereg("^(.*[\/])(.*)",$data_, $matches);
577        $data=$matches[2];
578        if( is_dir( $data_ ) ){
579            $mess = lfCopyDir( $data_.'/', $des.$data.'/', $mess);
580        }else{
581            if(!$override && file_exists($des.$data)) {
582                $mess.= $des.$data . "¡§¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤¹\n";
583            } else {
584                if(@copy( $data_, $des.$data)) {
585                    $mess.= $des.$data . "¡§¥³¥Ô¡¼À®¸ù\n";
586                } else {
587                    $mess.= $des.$data . "¡§¥³¥Ô¡¼¼ºÇÔ\n";
588                }
589            }
590            $mod=stat($data_ );
591        }
592    }
593    umask($oldmask);
594    return $mess;
595}
596?>
Note: See TracBrowser for help on using the repository browser.