1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | /** |
---|
25 | * アプリケーションの初期設定クラス. |
---|
26 | * |
---|
27 | * @author LOCKON CO.,LTD. |
---|
28 | * @version $Id$ |
---|
29 | */ |
---|
30 | class SC_Initial { |
---|
31 | |
---|
32 | // {{{ cunstructor |
---|
33 | |
---|
34 | /** |
---|
35 | * コンストラクタ. |
---|
36 | */ |
---|
37 | function SC_Initial() { |
---|
38 | |
---|
39 | /** EC-CUBEのバージョン */ |
---|
40 | // XXX SVNのリビジョンを付加できたら良いと思う。(方法が分からない。) |
---|
41 | define('ECCUBE_VERSION', "2.4.1-comu"); |
---|
42 | } |
---|
43 | |
---|
44 | // }}} |
---|
45 | // {{{ functions |
---|
46 | |
---|
47 | /** |
---|
48 | * 初期設定を行う. |
---|
49 | * |
---|
50 | * @access protected |
---|
51 | * @return void |
---|
52 | */ |
---|
53 | function init() { |
---|
54 | $this->requireInitialConfig(); |
---|
55 | $this->defineDSN(); |
---|
56 | $this->setErrorReporting(); |
---|
57 | $this->defineDirectoryIndex(); |
---|
58 | $this->defineErrorType(); |
---|
59 | $this->defineConstants(); |
---|
60 | $this->mbstringInit(); |
---|
61 | $this->createCacheDir(); |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * 初期設定ファイルを読み込む. |
---|
66 | * |
---|
67 | * @access protected |
---|
68 | * @return void |
---|
69 | */ |
---|
70 | function requireInitialConfig() { |
---|
71 | |
---|
72 | require_once(realpath(dirname( __FILE__)) ."/../install.php"); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * DSN を定義する. |
---|
77 | * |
---|
78 | * @access protected |
---|
79 | * @return void |
---|
80 | */ |
---|
81 | function defineDSN() { |
---|
82 | if(defined('DB_TYPE') && defined('DB_USER') && defined('DB_PASSWORD') |
---|
83 | && defined('DB_SERVER') && defined('DB_PORT') && defined('DB_NAME')) { |
---|
84 | /** サイト用DB */ |
---|
85 | define ("DEFAULT_DSN", |
---|
86 | DB_TYPE . "://" . DB_USER . ":" . DB_PASSWORD . "@" |
---|
87 | . DB_SERVER . ":" .DB_PORT . "/" . DB_NAME); |
---|
88 | } else { |
---|
89 | define("DEFAULT_DSN", "pgsql://nobody:password@localhost:5432/eccubedb"); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | /** |
---|
95 | * エラーレベル設定を行う. |
---|
96 | * |
---|
97 | * ・推奨値 |
---|
98 | * 開発時 - E_ALL |
---|
99 | * 運用時 - E_ALL & ~E_NOTICE |
---|
100 | * |
---|
101 | * @access protected |
---|
102 | * @return void |
---|
103 | */ |
---|
104 | function setErrorReporting() { |
---|
105 | error_reporting(E_ALL & ~E_NOTICE); |
---|
106 | // PHP 5.3.0対応 |
---|
107 | if (error_reporting() > 6143) { |
---|
108 | error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); |
---|
109 | } |
---|
110 | } |
---|
111 | |
---|
112 | /** |
---|
113 | * マルチバイト文字列設定を行う. |
---|
114 | * |
---|
115 | * TODO SJIS-win や, eucJP-win への対応 |
---|
116 | * |
---|
117 | * @access protected |
---|
118 | * @return void |
---|
119 | */ |
---|
120 | function mbstringInit() { |
---|
121 | ini_set("mbstring.http_input", CHAR_CODE); |
---|
122 | ini_set("mbstring.http_output", CHAR_CODE); |
---|
123 | ini_set("auto_detect_line_endings", 1); |
---|
124 | ini_set("default_charset", CHAR_CODE); |
---|
125 | ini_set("mbstring.internal_encoding", CHAR_CODE); |
---|
126 | ini_set("mbstring.detect_order", "auto"); |
---|
127 | ini_set("mbstring.substitute_character", "none"); |
---|
128 | |
---|
129 | mb_language('ja'); // mb_internal_encoding() より前に |
---|
130 | // TODO 他に mb_language() している箇所の削除を検討 |
---|
131 | // TODO .htaccess の mbstring.language を削除できないか検討 |
---|
132 | |
---|
133 | mb_internal_encoding(CHAR_CODE); // mb_language() より後で |
---|
134 | // TODO 上の「ini_set("mbstring.internal_encoding", CHAR_CODE);」を削除できないか検討 |
---|
135 | // TODO .htaccess の mbstring.internal_encoding を削除できないか検討 |
---|
136 | |
---|
137 | //ロケールを明示的に設定 |
---|
138 | setlocale(LC_ALL, LOCALE); |
---|
139 | } |
---|
140 | |
---|
141 | /** |
---|
142 | * 定数 DIR_INDEX_URL を設定する. |
---|
143 | * |
---|
144 | * @access protected |
---|
145 | * @return void |
---|
146 | */ |
---|
147 | function defineDirectoryIndex() { |
---|
148 | |
---|
149 | // DirectoryIndex の実ファイル名 |
---|
150 | if (!defined('DIR_INDEX_FILE')) { |
---|
151 | define('DIR_INDEX_FILE', 'index.php'); |
---|
152 | } |
---|
153 | |
---|
154 | // DIR_INDEX_FILE にアクセスする時の URL のファイル名部を定義する |
---|
155 | if (USE_FILENAME_DIR_INDEX === true) { |
---|
156 | // ファイル名を使用する |
---|
157 | define('DIR_INDEX_URL', DIR_INDEX_FILE); |
---|
158 | } else { |
---|
159 | // ファイル名を使用しない |
---|
160 | define('DIR_INDEX_URL', ''); |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | /** |
---|
165 | * 定数を設定する. |
---|
166 | * |
---|
167 | * mtb_constants.php を読み込んで定数を設定する. |
---|
168 | * キャッシュディレクトリに存在しない場合は, 初期データからコピーする. |
---|
169 | * |
---|
170 | * @access protected |
---|
171 | * @return void |
---|
172 | */ |
---|
173 | function defineConstants() { |
---|
174 | |
---|
175 | $errorMessage = "<div style='color: #F00; font-weight: bold; " |
---|
176 | . "background-color: #FEB; text-align: center'>" |
---|
177 | . CACHE_PATH |
---|
178 | . " にユーザ書込み権限(777等)を付与して下さい。</div>"; |
---|
179 | |
---|
180 | // 定数を設定 |
---|
181 | if (is_file(CACHE_PATH . "mtb_constants.php")) { |
---|
182 | require_once(CACHE_PATH . "mtb_constants.php"); |
---|
183 | |
---|
184 | // キャッシュが無ければ, 初期データからコピー |
---|
185 | } elseif (is_file(CACHE_PATH . "../mtb_constants_init.php")) { |
---|
186 | |
---|
187 | $mtb_constants = file_get_contents(CACHE_PATH . "../mtb_constants_init.php"); |
---|
188 | if (is_writable(CACHE_PATH)) { |
---|
189 | $handle = fopen(CACHE_PATH . "mtb_constants.php", "w"); |
---|
190 | if (!$handle) { |
---|
191 | die($errorMessage); |
---|
192 | } |
---|
193 | if (fwrite($handle, $mtb_constants) === false) { |
---|
194 | die($errorMessage); |
---|
195 | } |
---|
196 | fclose($handle); |
---|
197 | |
---|
198 | require_once(CACHE_PATH . "mtb_constants.php"); |
---|
199 | } else { |
---|
200 | die($errorMessage); |
---|
201 | } |
---|
202 | } else { |
---|
203 | die(CACHE_PATH . "../mtb_constants_init.php が存在しません"); |
---|
204 | } |
---|
205 | } |
---|
206 | |
---|
207 | /** |
---|
208 | * 各種キャッシュディレクトリを生成する. |
---|
209 | * |
---|
210 | * Smarty キャッシュディレクトリを生成する. |
---|
211 | * |
---|
212 | * @access protected |
---|
213 | * @return void |
---|
214 | */ |
---|
215 | function createCacheDir() { |
---|
216 | if (defined("HTML_PATH")) { |
---|
217 | umask(0); |
---|
218 | if (!file_exists(COMPILE_DIR)) { |
---|
219 | mkdir(COMPILE_DIR); |
---|
220 | } |
---|
221 | |
---|
222 | if (!file_exists(MOBILE_COMPILE_DIR)) { |
---|
223 | mkdir(MOBILE_COMPILE_DIR); |
---|
224 | } |
---|
225 | |
---|
226 | if (!file_exists(COMPILE_ADMIN_DIR)) { |
---|
227 | mkdir(COMPILE_ADMIN_DIR); |
---|
228 | } |
---|
229 | |
---|
230 | if (!file_exists(COMPILE_FTP_DIR)) { |
---|
231 | mkdir(COMPILE_FTP_DIR); |
---|
232 | } |
---|
233 | } |
---|
234 | } |
---|
235 | |
---|
236 | /** |
---|
237 | * エラー種別を定数定義 |
---|
238 | * |
---|
239 | * @access protected |
---|
240 | * @return void |
---|
241 | */ |
---|
242 | function defineErrorType() { |
---|
243 | // LC_Page_Error用 |
---|
244 | /** 指定商品ページがない */ |
---|
245 | define('PRODUCT_NOT_FOUND', 1); |
---|
246 | /** カート内が空 */ |
---|
247 | define('CART_EMPTY', 2); |
---|
248 | /** ページ推移エラー */ |
---|
249 | define('PAGE_ERROR', 3); |
---|
250 | /** 購入処理中のカート商品追加エラー */ |
---|
251 | define('CART_ADD_ERROR', 4); |
---|
252 | /** 他にも購入手続きが行われた場合 */ |
---|
253 | define('CANCEL_PURCHASE', 5); |
---|
254 | /** 指定カテゴリページがない */ |
---|
255 | define('CATEGORY_NOT_FOUND', 6); |
---|
256 | /** ログインに失敗 */ |
---|
257 | define('SITE_LOGIN_ERROR', 7); |
---|
258 | /** 会員専用ページへのアクセスエラー */ |
---|
259 | define('CUSTOMER_ERROR', 8); |
---|
260 | /** 購入時の売り切れエラー */ |
---|
261 | define('SOLD_OUT', 9); |
---|
262 | /** カート内商品の読込エラー */ |
---|
263 | define('CART_NOT_FOUND', 10); |
---|
264 | /** ポイントの不足 */ |
---|
265 | define('LACK_POINT', 11); |
---|
266 | /** 仮登録者がログインに失敗 */ |
---|
267 | define('TEMP_LOGIN_ERROR', 12); |
---|
268 | /** URLエラー */ |
---|
269 | define('URL_ERROR', 13); |
---|
270 | /** ファイル解凍エラー */ |
---|
271 | define('EXTRACT_ERROR', 14); |
---|
272 | /** FTPダウンロードエラー */ |
---|
273 | define('FTP_DOWNLOAD_ERROR', 15); |
---|
274 | /** FTPログインエラー */ |
---|
275 | define('FTP_LOGIN_ERROR', 16); |
---|
276 | /** FTP接続エラー */ |
---|
277 | define('FTP_CONNECT_ERROR', 17); |
---|
278 | /** DB作成エラー */ |
---|
279 | define('CREATE_DB_ERROR', 18); |
---|
280 | /** DBインポートエラー */ |
---|
281 | define('DB_IMPORT_ERROR', 19); |
---|
282 | /** 設定ファイル存在エラー */ |
---|
283 | define('FILE_NOT_FOUND', 20); |
---|
284 | /** 書き込みエラー */ |
---|
285 | define('WRITE_FILE_ERROR', 21); |
---|
286 | /** DB接続エラー */ |
---|
287 | define('DB_CONNECT_ERROR', 22); |
---|
288 | /** フリーメッセージ */ |
---|
289 | define('FREE_ERROR_MSG', 999); |
---|
290 | |
---|
291 | // LC_Page_Error_DispError用 |
---|
292 | /** ログイン失敗 */ |
---|
293 | define('LOGIN_ERROR', 1); |
---|
294 | /** アクセス失敗(タイムアウト等) */ |
---|
295 | define('ACCESS_ERROR', 2); |
---|
296 | /** アクセス権限違反 */ |
---|
297 | define('AUTH_ERROR', 3); |
---|
298 | /** 不正な遷移エラー */ |
---|
299 | define('INVALID_MOVE_ERRORR', 4); |
---|
300 | } |
---|
301 | } |
---|
302 | ?> |
---|