1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2011 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_REALDIR . '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 | $this->tpl_title = 'システムエラー'; |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * Page のプロセス。 |
---|
61 | * |
---|
62 | * @return void |
---|
63 | */ |
---|
64 | function process() { |
---|
65 | $this->action(); |
---|
66 | $this->sendResponse(); |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | * Page のプロセス。 |
---|
71 | * |
---|
72 | * @return void |
---|
73 | */ |
---|
74 | function action() { |
---|
75 | $this->tpl_error = 'システムエラーが発生しました。<br />大変お手数ですが、サイト管理者までご連絡ください。'; |
---|
76 | |
---|
77 | if (DEBUG_MODE) { |
---|
78 | echo '<div class="debug">'; |
---|
79 | echo '<div>▼▼▼ デバッグ情報ここから ▼▼▼</div>'; |
---|
80 | echo '<pre>'; |
---|
81 | echo htmlspecialchars($this->sfGetErrMsg(), ENT_QUOTES, CHAR_CODE); |
---|
82 | echo '</pre>'; |
---|
83 | echo '<div>▲▲▲ デバッグ情報ここまで ▲▲▲</div>'; |
---|
84 | echo '</div>'; |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | /** |
---|
89 | * Page のレスポンス送信. |
---|
90 | * |
---|
91 | * @return void |
---|
92 | */ |
---|
93 | function sendResponse() { |
---|
94 | $this->adminPage = GC_Utils_Ex::isAdminFunction(); |
---|
95 | |
---|
96 | if ($this->adminPage) { |
---|
97 | $this->tpl_mainpage = 'login_error.tpl'; |
---|
98 | $this->template = LOGIN_FRAME; |
---|
99 | $this->objDisplay->prepare($this, true); |
---|
100 | } else { |
---|
101 | $this->objDisplay->prepare($this); |
---|
102 | } |
---|
103 | |
---|
104 | $this->objDisplay->response->write(); |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * デストラクタ. |
---|
109 | * |
---|
110 | * @return void |
---|
111 | */ |
---|
112 | function destroy() { |
---|
113 | parent::destroy(); |
---|
114 | } |
---|
115 | |
---|
116 | /** |
---|
117 | * トランザクショントークンに関して処理しないようにオーバーライド |
---|
118 | */ |
---|
119 | function doValidToken() { |
---|
120 | } |
---|
121 | |
---|
122 | /** |
---|
123 | * トランザクショントークンに関して処理しないようにオーバーライド |
---|
124 | */ |
---|
125 | function setTokenTo() { |
---|
126 | } |
---|
127 | |
---|
128 | /** |
---|
129 | * エラーメッセージを生成する |
---|
130 | * |
---|
131 | * @return string |
---|
132 | */ |
---|
133 | function sfGetErrMsg() { |
---|
134 | $errmsg = ''; |
---|
135 | $errmsg .= $this->lfGetErrMsgHead(); |
---|
136 | $errmsg .= "\n"; |
---|
137 | |
---|
138 | // デバッグ用のメッセージが指定されている場合 |
---|
139 | if (!empty($this->arrDebugMsg)) { |
---|
140 | $errmsg .= implode("\n\n", $this->arrDebugMsg) . "\n"; |
---|
141 | } |
---|
142 | |
---|
143 | // PEAR エラーを伴う場合 |
---|
144 | if (!is_null($this->pearResult)) { |
---|
145 | $errmsg .= $this->pearResult->message . "\n\n"; |
---|
146 | $errmsg .= $this->pearResult->userinfo . "\n\n"; |
---|
147 | $errmsg .= GC_Utils_Ex::toStringBacktrace($this->pearResult->backtrace); |
---|
148 | } |
---|
149 | // (上に該当せず)バックトレーススタックが指定されている場合 |
---|
150 | else if (is_array($this->backtrace)) { |
---|
151 | $errmsg .= GC_Utils_Ex::toStringBacktrace($this->backtrace); |
---|
152 | } |
---|
153 | else { |
---|
154 | $arrBacktrace = GC_Utils_Ex::getDebugBacktrace(); |
---|
155 | $errmsg .= GC_Utils_Ex::toStringBacktrace($arrBacktrace); |
---|
156 | } |
---|
157 | |
---|
158 | return $errmsg; |
---|
159 | } |
---|
160 | |
---|
161 | /** |
---|
162 | * エラーメッセージの冒頭部を生成する |
---|
163 | * |
---|
164 | * @return string |
---|
165 | */ |
---|
166 | function lfGetErrMsgHead() { |
---|
167 | $errmsg = ''; |
---|
168 | $errmsg .= SC_Utils_Ex::sfGetUrl() . "\n"; |
---|
169 | $errmsg .= "\n"; |
---|
170 | $errmsg .= 'SERVER_ADDR: ' . $_SERVER['SERVER_ADDR'] . "\n"; |
---|
171 | $errmsg .= 'REMOTE_ADDR: ' . $_SERVER['REMOTE_ADDR'] . "\n"; |
---|
172 | $errmsg .= 'USER_AGENT: ' . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
---|
173 | |
---|
174 | return $errmsg; |
---|
175 | } |
---|
176 | |
---|
177 | /** |
---|
178 | * デバッグ用のメッセージを追加 |
---|
179 | * |
---|
180 | * @return void |
---|
181 | */ |
---|
182 | function addDebugMsg($debugMsg) { |
---|
183 | $this->arrDebugMsg[] = rtrim($debugMsg, "\n"); |
---|
184 | } |
---|
185 | } |
---|