source: temp/branches/mobile/html/install/index.php @ 10204

Revision 10204, 25.5 KB checked in by kaki, 16 years ago (diff)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8$INSTALL_DIR = realpath(dirname( __FILE__));
9require_once("../../data/module/Request.php");
10
11define("INSTALL_LOG", "./temp/install.log");
12
13class LC_Page {
14    function LC_Page() {
15        $this->arrDB_TYPE = array(
16            'pgsql' => 'PostgreSQL',
17            'mysql' => 'MySQL' 
18        );
19        $this->arrDB_PORT = array(
20            'pgsql' => '',
21            'mysql' => ''   
22        );
23    }
24}
25
26$objPage = new LC_Page();
27
28// ¥Æ¥ó¥×¥ì¡¼¥È¥³¥ó¥Ñ¥¤¥ë¥Ç¥£¥ì¥¯¥È¥ê¤Î½ñ¹þ¤ß¸¢¸Â¥Á¥§¥Ã¥¯
29$temp_dir = $INSTALL_DIR . '/temp';
30$mode = lfGetFileMode($temp_dir);
31
32if($mode != '777') {
33    sfErrorHeader($temp_dir . "¤Ë¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£", true);
34    exit;
35}
36
37$objView = new SC_InstallView($INSTALL_DIR . '/templates', $INSTALL_DIR . '/temp');
38
39// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
40$objWebParam = new SC_FormParam();
41$objDBParam = new SC_FormParam();
42// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
43$objWebParam = lfInitWebParam($objWebParam);
44$objDBParam = lfInitDBParam($objDBParam);
45
46//¥Õ¥©¡¼¥àÇÛÎó¤Î¼èÆÀ
47$objWebParam->setParam($_POST);
48$objDBParam->setParam($_POST);
49
50switch($_POST['mode']) {
51// ¤è¤¦¤³¤½
52case 'welcome':
53    $objPage = lfDispStep0($objPage);
54    break;
55// ¥¢¥¯¥»¥¹¸¢¸Â¤Î¥Á¥§¥Ã¥¯
56case 'step0':
57    $objPage = lfDispStep0_1($objPage);
58    break; 
59// ¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼
60case 'step0_1':
61    $objPage = lfDispStep1($objPage);
62    break; 
63// WEB¥µ¥¤¥È¤ÎÀßÄê
64case 'step1':
65    //ÆþÎÏÃͤΥ¨¥é¡¼¥Á¥§¥Ã¥¯
66    $objPage->arrErr = lfCheckWEBError($objWebParam);
67    if(count($objPage->arrErr) == 0) {
68        $objPage = lfDispStep2($objPage);
69    } else {
70        $objPage = lfDispStep1($objPage);
71    }
72    break;
73// ¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÀßÄê
74case 'step2':
75    //ÆþÎÏÃͤΥ¨¥é¡¼¥Á¥§¥Ã¥¯
76    $objPage->arrErr = lfCheckDBError($objDBParam);
77    if(count($objPage->arrErr) == 0) {
78        $objPage = lfDispStep3($objPage);
79    } else {
80        $objPage = lfDispStep2($objPage);
81    }
82    break;
83// ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
84case 'step3':
85    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
86    $arrRet =  $objDBParam->getHashArray();
87    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
88   
89    /*
90        lfAddTable¤Ï¡¢¥Ð¡¼¥¸¥ç¥ó¥¢¥Ã¥×Åù¤ÇÄɲåơ¼¥Ö¥ë¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£
91        ¡Ê£Ä£Â¹½À®¤Î²¼°Ì¸ß´¹¤Î¤¿¤á¥¹¥­¥Ã¥×»þ¤â¶¯À©¡Ë
92    */
93    // ¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤ËÄɲ䵤ì¤ë¡£
94    $objPage->arrErr = lfAddTable("dtb_session", $dsn); // ¥»¥Ã¥·¥ç¥ó´ÉÍý¥Æ¡¼¥Ö¥ë
95    // ¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤ËÄɲ䵤ì¤ë¡£
96    $objPage->arrErr = lfAddTable("dtb_module", $dsn);  // ¥»¥Ã¥·¥ç¥ó´ÉÍý¥Æ¡¼¥Ö¥ë
97   
98    // ¥«¥é¥à¤òÄɲÃ
99    lfAddColumn($dsn);
100
101    if(count($objPage->arrErr) == 0) {
102        // ¥¹¥­¥Ã¥×¤¹¤ë¾ì¹ç¤Ë¤Ï¼¡²èÌ̤ØÁ«°Ü
103        $skip = $_POST["db_skip"];
104        if ($skip == "on") {
105            // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
106            lfMakeConfigFile();
107            //$objPage = lfDispComplete($objPage);
108            $objPage = lfDispStep4($objPage);
109            break;
110        }
111    }
112   
113    // ¥Æ¡¼¥Ö¥ë¤ÎºîÀ®
114    $objPage->arrErr = lfExecuteSQL("./sql/create_table_".$arrRet['db_type'].".sql", $dsn);
115    if(count($objPage->arrErr) == 0) {
116        $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
117    } else {
118        $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
119    }
120
121    // ¥Ó¥å¡¼¤ÎºîÀ®
122    if(count($objPage->arrErr) == 0 and $arrRet['db_type'] == 'pgsql') {
123        // ¥Ó¥å¡¼¤ÎºîÀ®
124        $objPage->arrErr = lfExecuteSQL("./sql/create_view.sql", $dsn);
125        if(count($objPage->arrErr) == 0) {
126            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
127        } else {
128            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
129        }
130    }   
131   
132    // ½é´ü¥Ç¡¼¥¿¤ÎºîÀ®
133    if(count($objPage->arrErr) == 0) {
134        $objPage->arrErr = lfExecuteSQL("./sql/insert_data.sql", $dsn);
135       
136        if(count($objPage->arrErr) == 0) {
137            $objPage->tpl_message.="¡û¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
138        } else {
139            $objPage->tpl_message.="¡ß¡§½é´ü¥Ç¡¼¥¿¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
140        }
141    }   
142   
143    // ¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
144    if(count($objPage->arrErr) == 0) {
145        $objPage->arrErr = lfExecuteSQL("./sql/column_comment.sql", $dsn);
146        if(count($objPage->arrErr) == 0) {
147            $objPage->tpl_message.="¡û¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
148        } else {
149            $objPage->tpl_message.="¡ß¡§¥«¥é¥à¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
150        }
151    }   
152   
153    // ¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß
154    if(count($objPage->arrErr) == 0) {
155        $objPage->arrErr = lfExecuteSQL("./sql/table_comment.sql", $dsn);
156        if(count($objPage->arrErr) == 0) {
157            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
158        } else {
159            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¥³¥á¥ó¥È¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
160        }
161    }
162
163    if(count($objPage->arrErr) == 0) {
164        // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÀ¸À®
165        lfMakeConfigFile();
166        $objPage = lfDispStep3($objPage);
167        $objPage->tpl_mode = 'step4';
168    } else {
169        $objPage = lfDispStep3($objPage);
170    }
171    break;
172case 'step4':
173    $objPage = lfDispStep4($objPage);
174    break;
175   
176// ¥Æ¡¼¥Ö¥ëÎàºï½ü
177case 'drop':
178    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
179    $arrRet =  $objDBParam->getHashArray();
180    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
181   
182    // Äɲåơ¼¥Ö¥ë¤¬¤¢¤ì¤Ðºï½ü¤¹¤ë¡£
183    lfDropTable("dtb_module", $dsn);
184    lfDropTable("dtb_session", $dsn);
185       
186    if ($arrRet['db_type'] == 'pgsql'){
187        // ¥Ó¥å¡¼¤Îºï½ü
188        $objPage->arrErr = lfExecuteSQL("./sql/drop_view.sql", $dsn, false);
189        if(count($objPage->arrErr) == 0) {
190            $objPage->tpl_message.="¡û¡§¥Ó¥å¡¼¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
191        } else {
192            $objPage->tpl_message.="¡ß¡§¥Ó¥å¡¼¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";     
193        }
194    }
195
196    // ¥Æ¡¼¥Ö¥ë¤Îºï½ü
197    if(count($objPage->arrErr) == 0) {
198        $objPage->arrErr = lfExecuteSQL("./sql/drop_table.sql", $dsn, false);
199        if(count($objPage->arrErr) == 0) {
200            $objPage->tpl_message.="¡û¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£<br>";
201        } else {
202            $objPage->tpl_message.="¡ß¡§¥Æ¡¼¥Ö¥ë¤Îºï½ü¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";       
203        }
204    }
205    $objPage = lfDispStep3($objPage);
206    break;
207// ´°Î»²èÌÌ
208case 'complete':
209    // ¥·¥ç¥Ã¥×¥Þ¥¹¥¿¾ðÊó¤Î½ñ¤­¹þ¤ß
210    $arrRet =  $objDBParam->getHashArray();
211   
212    $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
213    $sqlval['shop_name'] = $objWebParam->getValue('shop_name');
214    $sqlval['email01'] = $objWebParam->getValue('admin_mail');
215    $sqlval['email02'] = $objWebParam->getValue('admin_mail');
216    $sqlval['email03'] = $objWebParam->getValue('admin_mail');
217    $sqlval['email04'] = $objWebParam->getValue('admin_mail');
218    $sqlval['email05'] = $objWebParam->getValue('admin_mail');
219    $sqlval['top_tpl'] = "default1";
220    $sqlval['product_tpl'] = "default1";
221    $sqlval['detail_tpl'] = "default1";
222    $sqlval['mypage_tpl'] = "default1";
223    $objQuery = new SC_Query($dsn);
224    $cnt = $objQuery->count("dtb_baseinfo");
225    if($cnt > 0) {
226        $objQuery->update("dtb_baseinfo", $sqlval);
227    } else {       
228        $objQuery->insert("dtb_baseinfo", $sqlval);     
229    }
230
231    // ´ÉÍý¼ÔÅÐÏ¿
232    $login_id = $objWebParam->getValue('login_id');
233    $login_pass = sha1($objWebParam->getValue('login_pass') . ":" . AUTH_MAGIC);
234   
235    $sql = "DELETE FROM dtb_member WHERE login_id = ?";
236    $objQuery->query($sql, array($login_id));   
237
238    $sql = "INSERT INTO dtb_member (name, login_id, password, creator_id, authority, work, del_flg, rank, create_date, update_date)
239            VALUES ('´ÉÍý¼Ô',?,?,0,0,1,0,1, now(), now());";
240   
241    $objQuery->query($sql, array($login_id, $login_pass));     
242   
243    global $GLOBAL_ERR;
244    $GLOBAL_ERR = "";
245    $objPage = lfDispComplete($objPage);
246   
247    // ¥µ¥¤¥È¾ðÊó¤òÁ÷¿®¤·¤Æ¤âÎɤ¤¾ì¹ç¤Ë¤ÏÁ÷¤ë
248    if($_POST['send_info'] == "true"){
249        $req = new HTTP_Request("http://www.ec-cube.net/mall/use_site.php");
250        $req->setMethod(HTTP_REQUEST_METHOD_POST);
251       
252        $arrSendData = array();
253        foreach($_POST as $key => $val){
254            if (ereg("^senddata_*", $key)){
255                $arrSendDataTmp = array(str_replace("senddata_", "", $key) => $val);
256                $arrSendData = array_merge($arrSendData, $arrSendDataTmp);
257            }
258        }
259       
260        $req->addPostDataArray($arrSendData);
261       
262        if (!PEAR::isError($req->sendRequest())) {
263            $response1 = $req->getResponseBody();
264        } else {
265            $response1 = "";
266        }
267        $req->clearPostData();
268    }
269   
270    break;
271case 'return_step0':
272    $objPage = lfDispStep0($objPage);
273    break; 
274case 'return_step1':
275    $objPage = lfDispStep1($objPage);
276    break;
277case 'return_step2':
278    $objPage = lfDispStep2($objPage);
279    break;
280case 'return_step3':
281    $objPage = lfDispStep3($objPage);
282    break;
283case 'return_welcome':
284default:
285    $objPage = lfDispWelcome($objPage);
286    break;
287}
288
289//¥Õ¥©¡¼¥àÍѤΥѥé¥á¡¼¥¿¤òÊÖ¤¹
290$objPage->arrForm = $objWebParam->getFormParamList();
291$objPage->arrForm = array_merge($objPage->arrForm, $objDBParam->getFormParamList());
292
293// SiteInfo¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤
294$objView->assignobj($objPage);
295$objView->display('install_frame.tpl');
296//-----------------------------------------------------------------------------------------------------------------------------------
297// ¤è¤¦¤³¤½²èÌ̤Îɽ¼¨
298function lfDispWelcome($objPage) {
299    global $objWebParam;
300    global $objDBParam;
301    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
302    $objPage->arrHidden = $objWebParam->getHashArray();
303    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
304    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
305    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
306    $objPage->tpl_mainpage = 'welcome.tpl';
307    $objPage->tpl_mode = 'welcome';
308    return $objPage;
309}
310
311// STEP0²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¸¢¸Â¥Á¥§¥Ã¥¯)
312function lfDispStep0($objPage) {
313    global $objWebParam;
314    global $objDBParam;
315    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
316    $objPage->arrHidden = $objWebParam->getHashArray();
317    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
318    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
319    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
320    $objPage->tpl_mainpage = 'step0.tpl';
321    $objPage->tpl_mode = 'step0';
322   
323    // ¥×¥í¥°¥é¥à¤Ç½ñ¹þ¤ß¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥ì¥¯¥È¥ê
324    $arrWriteFile = array(
325        "../../data/install.inc",
326        "../user_data",
327        "../upload",
328        "../../data/Smarty/templates_c",       
329        "../../data/downloads",
330        "../../data/logs"
331    );
332   
333    $mess = "";
334    $err_file = false;
335    foreach($arrWriteFile as $val) {
336        if(file_exists($val)) {
337            $mode = lfGetFileMode($val);
338            $real_path = realpath($val);
339                       
340            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç
341            if(is_dir($val)) {
342                if($mode == "777") {
343                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
344                } else {
345                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(777)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
346                    $err_file = true;                                       
347                }
348            } else {
349                if($mode == "666") {
350                    $mess.= ">> ¡û¡§$real_path($mode) <br>¥¢¥¯¥»¥¹¸¢¸Â¤ÏÀµ¾ï¤Ç¤¹¡£<br>";                   
351                } else {
352                    $mess.= ">> ¡ß¡§$real_path($mode) <br>¥æ¡¼¥¶½ñ¹þ¤ß¸¢¸Â(666)¤òÉÕÍ¿¤·¤Æ²¼¤µ¤¤¡£<br>";
353                    $err_file = true;                           
354                }
355            }           
356        } else {
357            $mess.= ">> ¡ß¡§$val ¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£<br>";
358            $err_file = true;
359        }
360    }
361   
362    // ¸¢¸Â¥¨¥é¡¼Åù¤¬È¯À¸¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
363    if(!$err_file) {
364        $path = "../../data/Smarty/templates_c/admin";
365        if(!file_exists($path)) {
366            mkdir($path);
367        }
368        $path = "../upload/save_image";
369        if(!file_exists($path)) {
370            mkdir($path);
371        }
372        $path = "../upload/temp_image";
373        if(!file_exists($path)) {
374            mkdir($path);
375        }
376        $path = "../upload/graph_image";
377        if(!file_exists($path)) {
378            mkdir($path);
379        }
380        $path = "../upload/csv";
381        if(!file_exists($path)) {
382            mkdir($path);
383        }
384        $path = "../../data/downloads/module";
385        if(!file_exists($path)) {
386            mkdir($path);
387        }
388        $path = "../../data/downloads/update";
389        if(!file_exists($path)) {
390            mkdir($path);
391        }       
392    }
393   
394    $objPage->mess = $mess;
395    $objPage->err_file = $err_file;
396
397    return $objPage;
398}
399
400
401// STEP0_1²èÌ̤Îɽ¼¨(¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼)
402function lfDispStep0_1($objPage) {
403    global $objWebParam;
404    global $objDBParam;
405    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
406    $objPage->arrHidden = $objWebParam->getHashArray();
407    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
408    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
409    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
410    $objPage->tpl_mainpage = 'step0_1.tpl';
411    $objPage->tpl_mode = 'step0_1';
412    // ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼
413    $objPage->copy_mess = sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess);
414    $objPage->copy_mess = sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess);
415    return $objPage;
416}
417
418function lfGetFileMode($path) {
419    $mode = substr(sprintf('%o', fileperms($path)), -3);
420    return $mode;
421}
422
423// STEP1²èÌ̤Îɽ¼¨
424function lfDispStep1($objPage) {
425    global $objDBParam;
426    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
427    $objPage->arrHidden = $objDBParam->getHashArray();
428    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
429    $objPage->tpl_mainpage = 'step1.tpl';
430    $objPage->tpl_mode = 'step1';
431    return $objPage;
432}
433
434// STEP2²èÌ̤Îɽ¼¨
435function lfDispStep2($objPage) {
436    global $objWebParam;
437    global $objDBParam;
438    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
439    $objPage->arrHidden = $objWebParam->getHashArray();
440    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
441    $objPage->tpl_mainpage = 'step2.tpl';
442    $objPage->tpl_mode = 'step2';
443    return $objPage;
444}
445
446// STEP3²èÌ̤Îɽ¼¨
447function lfDispStep3($objPage) {
448    global $objWebParam;
449    global $objDBParam;
450    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
451    $objPage->arrHidden = $objWebParam->getHashArray();
452    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
453    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
454    $objPage->tpl_db_skip = $_POST['db_skip'];
455    $objPage->tpl_mainpage = 'step3.tpl';
456    $objPage->tpl_mode = 'step3';
457    return $objPage;
458}
459
460// STEP4²èÌ̤Îɽ¼¨
461function lfDispStep4($objPage) {
462    global $objWebParam;
463    global $objDBParam;
464    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
465    $objPage->arrHidden = $objWebParam->getHashArray();
466    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
467    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
468
469    $normal_url = $objWebParam->getValue('normal_url');
470    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
471    if (!ereg("/$", $normal_url)) $normal_url = $normal_url . "/";
472
473    $arrDbParam = $objDBParam->getHashArray();
474    $dsn = $arrDbParam['db_type']."://".$arrDbParam['db_user'].":".$arrDbParam['db_password']."@".$arrDbParam['db_server'].":".$arrDbParam['db_port']."/".$arrDbParam['db_name'];
475
476    $objPage->tpl_site_url = $normal_url;
477    $objPage->tpl_shop_name = $objWebParam->getValue('shop_name');
478    $objPage->tpl_cube_ver = ECCUBE_VERSION;
479    $objPage->tpl_php_ver = phpversion();
480    $objPage->tpl_db_ver = sfGetDBVersion($dsn);
481    $objPage->tpl_db_skip = $_POST['db_skip'];
482    $objPage->tpl_mainpage = 'step4.tpl';
483    $objPage->tpl_mode = 'complete';
484    return $objPage;
485}
486
487// ´°Î»²èÌ̤Îɽ¼¨
488function lfDispComplete($objPage) {
489    global $objWebParam;
490    global $objDBParam;
491    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
492    $objPage->arrHidden = $objWebParam->getHashArray();
493    // hidden¤ËÆþÎÏÃͤòÊÝ»ý
494    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
495    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
496    $objPage->tpl_mainpage = 'complete.tpl';
497    $objPage->tpl_mode = 'complete';
498   
499    $secure_url = $objWebParam->getValue('secure_url');
500    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
501    if (!ereg("/$", $secure_url)) {
502        $secure_url = $secure_url . "/";
503    }
504    $objPage->tpl_sslurl = $secure_url;     
505    return $objPage;
506}
507
508// WEB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
509function lfInitWebParam($objWebParam) {
510   
511    if(defined('HTML_PATH')) {
512        $install_dir = HTML_PATH;
513    } else {
514        $install_dir = realpath(dirname( __FILE__) . "/../") . "/";
515    }
516   
517    if(defined('SITE_URL')) {
518        $normal_url = SITE_URL;
519    } else {
520        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
521        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
522    }
523   
524    if(defined('SSL_URL')) {
525        $secure_url = SSL_URL;
526    } else {
527        $dir = ereg_replace("install/.*$", "", $_SERVER['REQUEST_URI']);
528        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
529    }
530
531    // Ź̾¡¢´ÉÍý¼Ô¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¼èÆÀ¤¹¤ë¡£(ºÆ¥¤¥ó¥¹¥È¡¼¥ë»þ)
532    if(defined('DEFAULT_DSN')) {
533        $ret = sfTabaleExists("dtb_baseinfo", DEFAULT_DSN);
534        if($ret) {
535            $objQuery = new SC_Query();
536            $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
537            $shop_name = $arrRet[0]['shop_name'];
538            $admin_mail = $arrRet[0]['email01'];
539        }
540    }
541
542    $objWebParam->addParam("Ź̾", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $shop_name);
543    $objWebParam->addParam("´ÉÍý¼Ô¡§¥á¡¼¥ë¥¢¥É¥ì¥¹", "admin_mail", MTEXT_LEN, "", array("EXIST_CHECK","EMAIL_CHECK","EMAIL_CHAR_CHECK","MAX_LENGTH_CHECK"), $admin_mail);
544    $objWebParam->addParam("´ÉÍý¼Ô¡§¥í¥°¥¤¥óID", "login_id", MTEXT_LEN, "", array("EXIST_CHECK","EXIST_CHECK", "ALNUM_CHECK"));
545    $objWebParam->addParam("´ÉÍý¼Ô¡§¥Ñ¥¹¥ï¡¼¥É", "login_pass", MTEXT_LEN, "", array("EXIST_CHECK","EXIST_CHECK", "ALNUM_CHECK"));
546    $objWebParam->addParam("¥¤¥ó¥¹¥È¡¼¥ë¥Ç¥£¥ì¥¯¥È¥ê", "install_dir", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $install_dir);
547    $objWebParam->addParam("URL(Ä̾ï)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $normal_url);
548    $objWebParam->addParam("URL(¥»¥­¥å¥¢)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK","URL_CHECK","MAX_LENGTH_CHECK"), $secure_url);
549    $objWebParam->addParam("¥É¥á¥¤¥ó", "domain", MTEXT_LEN, "", array("MAX_LENGTH_CHECK"));
550   
551    return $objWebParam;
552}
553
554// DB¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
555function lfInitDBParam($objDBParam) {
556       
557    if(defined('DB_SERVER')) {
558        $db_server = DB_SERVER;
559    } else {
560        $db_server = "127.0.0.1";
561    }
562   
563    if(defined('DB_TYPE')) {
564        $db_type = DB_TYPE;
565    } else {
566        $db_type = "";
567    }
568   
569    if(defined('DB_PORT')) {
570        $db_port = DB_PORT;
571    } else {
572        $db_port = "";
573    }
574       
575    if(defined('DB_NAME')) {
576        $db_name = DB_NAME;
577    } else {
578        $db_name = "eccube_db";
579    }
580       
581    if(defined('DB_USER')) {
582        $db_user = DB_USER;
583    } else {
584        $db_user = "eccube_db_user";               
585    }
586           
587    $objDBParam->addParam("DB¤Î¼ïÎà", "db_type", INT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_type);
588    $objDBParam->addParam("DB¥µ¡¼¥Ð", "db_server", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_server);
589    $objDBParam->addParam("DB¥Ý¡¼¥È", "db_port", INT_LEN, "", array("MAX_LENGTH_CHECK"), $db_port);
590    $objDBParam->addParam("DB̾", "db_name", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_name);
591    $objDBParam->addParam("DB¥æ¡¼¥¶", "db_user", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"), $db_user);
592    $objDBParam->addParam("DB¥Ñ¥¹¥ï¡¼¥É", "db_password", MTEXT_LEN, "", array("EXIST_CHECK","MAX_LENGTH_CHECK"));   
593       
594    return $objDBParam;
595}
596
597// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
598function lfCheckWebError($objFormParam) {
599    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
600    $arrRet =  $objFormParam->getHashArray();
601    $objErr = new SC_CheckError($arrRet);
602    $objErr->arrErr = $objFormParam->checkError();
603   
604    // ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¤ß¼èÆÀ¤¹¤ë
605    $normal_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['normal_url']);
606    $secure_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $arrRet['secure_url']);
607   
608    if($normal_dir != $secure_dir) {
609        $objErr->arrErr['normal_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";
610        $objErr->arrErr['secure_url'] = "URL¤Ë°Û¤Ê¤ë³¬Áؤò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£";     
611    }
612   
613    // ¥í¥°¥¤¥óID¥Á¥§¥Ã¥¯
614    $objErr->doFunc(array("´ÉÍý¼Ô¡§¥í¥°¥¤¥óID",'login_id',ID_MIN_LEN , ID_MAX_LEN) ,array("NUM_RANGE_CHECK"));
615   
616    // ¥Ñ¥¹¥ï¡¼¥É¤Î¥Á¥§¥Ã¥¯
617    $objErr->doFunc( array("´ÉÍý¼Ô¡§¥Ñ¥¹¥ï¡¼¥É",'login_pass',4 ,15 ) ,array( "NUM_RANGE_CHECK" ) );
618   
619    return $objErr->arrErr;
620}
621
622// ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯
623function lfCheckDBError($objFormParam) {
624    global $objPage;
625   
626    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
627    $arrRet =  $objFormParam->getHashArray();
628   
629    $objErr = new SC_CheckError($arrRet);
630    $objErr->arrErr = $objFormParam->checkError();
631   
632    if(count($objErr->arrErr) == 0) {
633        // Àܳ³Îǧ
634        $dsn = $arrRet['db_type']."://".$arrRet['db_user'].":".$arrRet['db_password']."@".$arrRet['db_server'].":".$arrRet['db_port']."/".$arrRet['db_name'];
635        // Debug¥â¡¼¥É»ØÄê
636        $options['debug'] = PEAR_DB_DEBUG;
637        $objDB = DB::connect($dsn, $options);
638        // ÀܳÀ®¸ù
639        if(!PEAR::isError($objDB)) {
640            // ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤Î¼èÆÀ
641            $objPage->tpl_db_version = sfGetDBVersion($dsn);           
642        } else {
643            $objErr->arrErr['all'] = ">> " . $objDB->message . "<br>";
644            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
645            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
646            $objErr->arrErr['all'].= $arrKey[0] . "<br>";
647            gfPrintLog($objDB->userinfo, INSTALL_LOG);
648        }
649    }
650    return $objErr->arrErr;
651}
652
653// SQLʸ¤Î¼Â¹Ô
654function lfExecuteSQL($filepath, $dsn, $disp_err = true) {
655    $arrErr = array();
656   
657    if(!file_exists($filepath)) {
658        $arrErr['all'] = ">> ¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó";
659    } else {
660        if($fp = fopen($filepath,"r")) {
661            $sql = fread($fp, filesize($filepath));
662            fclose($fp);
663        }
664        // Debug¥â¡¼¥É»ØÄê
665        $options['debug'] = PEAR_DB_DEBUG;
666        $objDB = DB::connect($dsn, $options);
667        // Àܳ¥¨¥é¡¼
668        if(!PEAR::isError($objDB)) {
669            // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹
670            $sql = preg_replace("/[\r\n\t]/"," ",$sql);
671            $sql_split = split(";",$sql);
672            foreach($sql_split as $key => $val){
673                if (trim($val) != "") {
674                    $ret = $objDB->query($val);
675                    if(PEAR::isError($ret) && $disp_err) {
676                        $arrErr['all'] = ">> " . $ret->message . "<br>";
677                        // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
678                        ereg("\[(.*)\]", $ret->userinfo, $arrKey);
679                        $arrErr['all'].= $arrKey[0] . "<br>";
680                        $objPage->update_mess.=">> ¥Æ¡¼¥Ö¥ë¹½À®¤ÎÊѹ¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£<br>";
681                        gfPrintLog($ret->userinfo, INSTALL_LOG);
682                    }
683                }
684            }           
685        } else {
686            $arrErr['all'] = ">> " . $objDB->message;
687            gfPrintLog($objDB->userinfo, INSTALL_LOG);
688        }
689    }
690    return $arrErr;
691}
692
693// ÀßÄê¥Õ¥¡¥¤¥ë¤ÎºîÀ®
694function lfMakeConfigFile() {
695    global $objWebParam;
696    global $objDBParam;
697   
698    $root_dir = $objWebParam->getValue('install_dir');
699    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
700    if (!ereg("/$", $root_dir)) {
701        $root_dir = $root_dir . "/";
702    }
703   
704    $normal_url = $objWebParam->getValue('normal_url');
705    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
706    if (!ereg("/$", $normal_url)) {
707        $normal_url = $normal_url . "/";
708    }
709   
710    $secure_url = $objWebParam->getValue('secure_url');
711    // ¸ìÈø¤Ë'/'¤ò¤Ä¤±¤ë
712    if (!ereg("/$", $secure_url)) {
713        $secure_url = $secure_url . "/";
714    }
715   
716    // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¼èÆÀ
717    $url_dir = ereg_replace("^https?://[a-zA-Z0-9_~=&\?\.\-]+", "", $normal_url);
718   
719    $data_path = $root_dir . "../data/";
720    $filepath = $data_path . "install.inc";
721   
722    $config_data =
723    "<?php\n".
724    "    define ('ECCUBE_INSTALL', 'ON');\n" .
725    "    define ('HTML_PATH', '" . $root_dir . "');\n" .     
726    "    define ('SITE_URL', '" . $normal_url . "');\n" .
727    "    define ('SSL_URL', '" . $secure_url . "');\n" .
728    "    define ('URL_DIR', '" . $url_dir . "');\n" .   
729    "    define ('DOMAIN_NAME', '" . $objWebParam->getValue('domain') . "');\n" .
730    "    define ('DB_TYPE', '" . $objDBParam->getValue('db_type') . "');\n" .
731    "    define ('DB_USER', '" . $objDBParam->getValue('db_user') . "');\n" .
732    "    define ('DB_PASSWORD', '" . $objDBParam->getValue('db_password') . "');\n" .
733    "    define ('DB_SERVER', '" . $objDBParam->getValue('db_server') . "');\n" .
734    "    define ('DB_NAME', '" . $objDBParam->getValue('db_name') . "');\n" .
735    "    define ('DB_PORT', '" . $objDBParam->getValue('db_port') .  "');\n" .
736    "    define ('DATA_PATH', '".$data_path."');\n" .
737    "?>";
738   
739    if($fp = fopen($filepath,"w")) {
740        fwrite($fp, $config_data);
741        fclose($fp);
742    }
743}
744
745// ¥Æ¡¼¥Ö¥ë¤ÎÄɲáʴû¤Ë¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ë¾ì¹ç¤ÏºîÀ®¤·¤Ê¤¤¡Ë
746function lfAddTable($table_name, $dsn) {
747    $arrErr = array();
748    if(!sfTabaleExists($table_name, $dsn)) {
749        list($db_type) = split(":", $dsn);
750        $sql_path = "./sql/add/". $table_name . "_" .$db_type .".sql";
751        $arrErr = lfExecuteSQL($sql_path, $dsn);
752    }
753    return $arrErr;
754}
755
756// ¥Æ¡¼¥Ö¥ë¤Îºï½ü¡Ê´û¤Ë¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ë¾ì¹ç¤Î¤ßºï½ü¤¹¤ë¡Ë
757function lfDropTable($table_name, $dsn) {
758    $arrErr = array();
759    if(sfTabaleExists($table_name, $dsn)) {
760        // Debug¥â¡¼¥É»ØÄê
761        $options['debug'] = PEAR_DB_DEBUG;
762        $objDB = DB::connect($dsn, $options);
763        // ÀܳÀ®¸ù
764        if(!PEAR::isError($objDB)) {
765            $objDB->query("DROP TABLE " . $table_name);
766        } else {
767            $arrErr['all'] = ">> " . $objDB->message . "<br>";
768            // ¥¨¥é¡¼Ê¸¤ò¼èÆÀ¤¹¤ë
769            ereg("\[(.*)\]", $objDB->userinfo, $arrKey);
770            $arrErr['all'].= $arrKey[0] . "<br>";
771            gfPrintLog($objDB->userinfo, INSTALL_LOG);
772        }
773    }
774    return $arrErr;
775}
776
777// ¥«¥é¥à¤ÎÄɲáʴû¤Ë¥«¥é¥à¤¬Â¸ºß¤¹¤ë¾ì¹ç¤ÏºîÀ®¤·¤Ê¤¤¡Ë
778function lfAddColumn($dsn) {
779    // ¼õÃí¥Æ¡¼¥Ö¥ë
780    sfColumnExists("dtb_order", "memo01", "text", $dsn, true); 
781    sfColumnExists("dtb_order", "memo02", "text", $dsn, true);
782    sfColumnExists("dtb_order", "memo03", "text", $dsn, true);
783    sfColumnExists("dtb_order", "memo04", "text", $dsn, true);
784    sfColumnExists("dtb_order", "memo05", "text", $dsn, true);
785    sfColumnExists("dtb_order", "memo06", "text", $dsn, true);
786    sfColumnExists("dtb_order", "memo07", "text", $dsn, true);
787    sfColumnExists("dtb_order", "memo08", "text", $dsn, true);
788    sfColumnExists("dtb_order", "memo09", "text", $dsn, true);
789    sfColumnExists("dtb_order", "memo10", "text", $dsn, true);
790
791    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë
792    sfColumnExists("dtb_order_temp", "order_id", "text", $dsn, true);   
793    sfColumnExists("dtb_order_temp", "memo01", "text", $dsn, true);
794    sfColumnExists("dtb_order_temp", "memo02", "text", $dsn, true);
795    sfColumnExists("dtb_order_temp", "memo03", "text", $dsn, true);
796    sfColumnExists("dtb_order_temp", "memo04", "text", $dsn, true);
797    sfColumnExists("dtb_order_temp", "memo05", "text", $dsn, true);
798    sfColumnExists("dtb_order_temp", "memo06", "text", $dsn, true);
799    sfColumnExists("dtb_order_temp", "memo07", "text", $dsn, true);
800    sfColumnExists("dtb_order_temp", "memo08", "text", $dsn, true);
801    sfColumnExists("dtb_order_temp", "memo09", "text", $dsn, true);
802    sfColumnExists("dtb_order_temp", "memo10", "text", $dsn, true);
803
804    // »Ùʧ¾ðÊ󥯡¼¥Ö¥ë
805    sfColumnExists("dtb_payment", "charge_flg", "int2 default 1", $dsn, true); 
806    sfColumnExists("dtb_payment", "rule_min", "numeric", $dsn, true);   
807    sfColumnExists("dtb_payment", "upper_rule_max", "numeric", $dsn, true);
808    sfColumnExists("dtb_payment", "module_id", "int4", $dsn, true);
809    sfColumnExists("dtb_payment", "module_path", "text", $dsn, true);
810    sfColumnExists("dtb_payment", "memo01", "text", $dsn, true);   
811    sfColumnExists("dtb_payment", "memo02", "text", $dsn, true);
812    sfColumnExists("dtb_payment", "memo03", "text", $dsn, true);
813    sfColumnExists("dtb_payment", "memo04", "text", $dsn, true);
814    sfColumnExists("dtb_payment", "memo05", "text", $dsn, true);
815    sfColumnExists("dtb_payment", "memo06", "text", $dsn, true);
816    sfColumnExists("dtb_payment", "memo07", "text", $dsn, true);
817    sfColumnExists("dtb_payment", "memo08", "text", $dsn, true);
818    sfColumnExists("dtb_payment", "memo09", "text", $dsn, true);
819    sfColumnExists("dtb_payment", "memo10", "text", $dsn, true);
820}
821
822?>
Note: See TracBrowser for help on using the repository browser.