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 | // {{{ requires |
---|
25 | require_once(CLASS_PATH . "pages/error/LC_Page_Error.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * システムエラー表示のページクラス |
---|
29 | * システムエラーや例外が発生した場合の表示ページ |
---|
30 | * |
---|
31 | * @package Page |
---|
32 | * @author LOCKON CO.,LTD. |
---|
33 | * @version $Id$ |
---|
34 | */ |
---|
35 | class LC_Page_Error_SystemError extends LC_Page_Error { |
---|
36 | |
---|
37 | /** PEAR_Error */ |
---|
38 | var $pearResult; |
---|
39 | |
---|
40 | /** PEAR_Error がセットされていない場合用のバックトレーススタック */ |
---|
41 | var $backtrace; |
---|
42 | |
---|
43 | /** デバッグ用のメッセージ配列 */ |
---|
44 | var $arrDebugMsg = array(); |
---|
45 | |
---|
46 | // }}} |
---|
47 | // {{{ functions |
---|
48 | |
---|
49 | /** |
---|
50 | * Page を初期化する. |
---|
51 | * |
---|
52 | * @return void |
---|
53 | */ |
---|
54 | function init() { |
---|
55 | parent::init(); |
---|
56 | |
---|
57 | $this->tpl_title = 'システムエラー'; |
---|
58 | $this->adminPage = SC_Utils_Ex::sfIsAdminFunction(); |
---|
59 | |
---|
60 | if ($this->adminPage) { |
---|
61 | $this->tpl_mainpage = 'login_error.tpl'; |
---|
62 | $this->flame = LOGIN_FRAME; |
---|
63 | } else { |
---|
64 | $this->flame = SITE_FRAME; |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | /** |
---|
69 | * Page のプロセス。 |
---|
70 | * |
---|
71 | * @return void |
---|
72 | */ |
---|
73 | function process() { |
---|
74 | require_once CLASS_PATH . 'SC_MobileUserAgent.php'; |
---|
75 | |
---|
76 | $objView = null; |
---|
77 | if (SC_MobileUserAgent::isMobile() && $this->adminPage == false) { |
---|
78 | $objView = new SC_InstallView(MOBILE_TEMPLATE_DIR, MOBILE_COMPILE_DIR); |
---|
79 | } elseif($this->adminPage) { |
---|
80 | $objView = new SC_InstallView(TEMPLATE_ADMIN_DIR, COMPILE_ADMIN_DIR); |
---|
81 | } else { |
---|
82 | $objView = new SC_InstallView(TEMPLATE_DIR, COMPILE_DIR); |
---|
83 | } |
---|
84 | |
---|
85 | $this->tpl_error = "システムエラーが発生しました。<br />大変お手数ですが、サイト管理者までご連絡ください。"; |
---|
86 | |
---|
87 | $objView->assignobj($this); |
---|
88 | $objView->display($this->flame); |
---|
89 | |
---|
90 | if (DEBUG_MODE) { |
---|
91 | echo '<div class="debug">'; |
---|
92 | echo '<div>▼▼▼ デバッグ情報ここから ▼▼▼</div>'; |
---|
93 | echo '<pre>'; |
---|
94 | print_r(htmlspecialchars($this->sfGetErrMsg(), ENT_QUOTES, CHAR_CODE)); |
---|
95 | echo '</pre>'; |
---|
96 | echo '<div>▲▲▲ デバッグ情報ここまで ▲▲▲</div>'; |
---|
97 | echo '</div>'; |
---|
98 | } |
---|
99 | } |
---|
100 | |
---|
101 | /** |
---|
102 | * デストラクタ. |
---|
103 | * |
---|
104 | * @return void |
---|
105 | */ |
---|
106 | function destroy() { |
---|
107 | parent::destroy(); |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * エラーメッセージを生成する |
---|
112 | * |
---|
113 | * @return string |
---|
114 | */ |
---|
115 | function sfGetErrMsg() { |
---|
116 | $errmsg = ''; |
---|
117 | $errmsg .= $this->lfGetErrMsgHead(); |
---|
118 | $errmsg .= "\n"; |
---|
119 | |
---|
120 | // デバッグ用のメッセージが指定されている場合 |
---|
121 | if (!empty($this->arrDebugMsg)) { |
---|
122 | $errmsg .= implode("\n\n", $this->arrDebugMsg) . "\n"; |
---|
123 | $errmsg .= "\n"; |
---|
124 | } |
---|
125 | |
---|
126 | // PEAR エラーを伴う場合 |
---|
127 | if (!is_null($this->pearResult)) { |
---|
128 | $errmsg .= $this->pearResult->message . "\n\n"; |
---|
129 | $errmsg .= $this->pearResult->userinfo . "\n\n"; |
---|
130 | $errmsg .= SC_Utils_Ex::sfBacktraceToString($this->pearResult->backtrace); |
---|
131 | } |
---|
132 | // (上に該当せず)バックトレーススタックが指定されている場合 |
---|
133 | else if (is_array($this->backtrace)) { |
---|
134 | $errmsg .= SC_Utils_Ex::sfBacktraceToString($this->backtrace); |
---|
135 | } |
---|
136 | // (上に該当せず)バックトレースを生成できる環境(一般的には PHP 4 >= 4.3.0, PHP 5)の場合 |
---|
137 | else if (function_exists("debug_backtrace")) { |
---|
138 | $errmsg .= SC_Utils_Ex::sfBacktraceToString(array_slice(debug_backtrace(), 2)); |
---|
139 | } |
---|
140 | |
---|
141 | return $errmsg; |
---|
142 | } |
---|
143 | |
---|
144 | /** |
---|
145 | * エラーメッセージの冒頭部を生成する |
---|
146 | * |
---|
147 | * @return string |
---|
148 | */ |
---|
149 | function lfGetErrMsgHead() { |
---|
150 | $errmsg = ''; |
---|
151 | $errmsg .= SC_Utils_Ex::sfGetUrl() . "\n"; |
---|
152 | $errmsg .= "\n"; |
---|
153 | $errmsg .= "SERVER_ADDR: " . $_SERVER['SERVER_ADDR'] . "\n"; |
---|
154 | $errmsg .= "REMOTE_ADDR: " . $_SERVER['REMOTE_ADDR'] . "\n"; |
---|
155 | $errmsg .= "USER_AGENT: " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
---|
156 | |
---|
157 | return $errmsg; |
---|
158 | } |
---|
159 | |
---|
160 | /** |
---|
161 | * デバッグ用のメッセージを追加 |
---|
162 | * |
---|
163 | * @return void |
---|
164 | */ |
---|
165 | function addDebugMsg($debugMsg) { |
---|
166 | $this->arrDebugMsg[] = rtrim($debugMsg, "\n"); |
---|
167 | } |
---|
168 | } |
---|
169 | ?> |
---|