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

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