1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 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 | |
---|
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->frame = LOGIN_FRAME; |
---|
63 | } else { |
---|
64 | $this->frame = SITE_FRAME; |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | /** |
---|
69 | * Page のプロセス。 |
---|
70 | * |
---|
71 | * @return void |
---|
72 | */ |
---|
73 | function process() { |
---|
74 | require_once CLASS_REALDIR . 'SC_MobileUserAgent.php'; |
---|
75 | |
---|
76 | $objView = null; |
---|
77 | if (SC_MobileUserAgent::isMobile() && $this->adminPage == false) { |
---|
78 | $objView = new SC_InstallView(MOBILE_TEMPLATE_REALDIR, MOBILE_COMPILE_REALDIR); |
---|
79 | } elseif($this->adminPage) { |
---|
80 | $objView = new SC_AdminView(); |
---|
81 | } else { |
---|
82 | $objView = new SC_InstallView(TEMPLATE_REALDIR, COMPILE_REALDIR); |
---|
83 | } |
---|
84 | |
---|
85 | $this->tpl_error = "システムエラーが発生しました。<br />大変お手数ですが、サイト管理者までご連絡ください。"; |
---|
86 | |
---|
87 | $objView->assignobj($this); |
---|
88 | $objView->display($this->frame); |
---|
89 | |
---|
90 | if (DEBUG_MODE) { |
---|
91 | echo '<div class="debug">'; |
---|
92 | echo '<div>▼▼▼ デバッグ情報ここから ▼▼▼</div>'; |
---|
93 | echo '<pre>'; |
---|
94 | echo 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 | // PEAR エラーを伴う場合 |
---|
121 | if (!is_null($this->pearResult)) { |
---|
122 | $errmsg .= $this->pearResult->message . "\n\n"; |
---|
123 | $errmsg .= $this->pearResult->userinfo . "\n\n"; |
---|
124 | $errmsg .= SC_Utils_Ex::sfBacktraceToString($this->pearResult->backtrace); |
---|
125 | } |
---|
126 | // (上に該当せず)バックトレーススタックが指定されている場合 |
---|
127 | else if (is_array($this->backtrace)) { |
---|
128 | $errmsg .= SC_Utils_Ex::sfBacktraceToString($this->backtrace); |
---|
129 | } |
---|
130 | // (上に該当せず)バックトレースを生成できる環境(一般的には PHP 4 >= 4.3.0, PHP 5)の場合 |
---|
131 | else if (function_exists("debug_backtrace")) { |
---|
132 | $backtrace = debug_backtrace(); |
---|
133 | |
---|
134 | // バックトレースのうち handle_error 以前は通常不要と考えられるので削除 |
---|
135 | $cnt = 0; |
---|
136 | $offset = 0; |
---|
137 | foreach ($backtrace as $key => $arrLine) { |
---|
138 | $cnt ++; |
---|
139 | if (!isset($arrLine['file']) && $arrLine['function'] === 'handle_error') { |
---|
140 | $offset = $cnt; |
---|
141 | break; |
---|
142 | } |
---|
143 | } |
---|
144 | if ($offset !== 0) { |
---|
145 | $backtrace = array_slice($backtrace, $offset); |
---|
146 | } |
---|
147 | |
---|
148 | $errmsg .= SC_Utils_Ex::sfBacktraceToString($backtrace); |
---|
149 | } |
---|
150 | |
---|
151 | // デバッグ用のメッセージが指定されている場合 |
---|
152 | if (!empty($this->arrDebugMsg)) { |
---|
153 | $errmsg .= implode("\n\n", $this->arrDebugMsg) . "\n"; |
---|
154 | } |
---|
155 | |
---|
156 | return $errmsg; |
---|
157 | } |
---|
158 | |
---|
159 | /** |
---|
160 | * エラーメッセージの冒頭部を生成する |
---|
161 | * |
---|
162 | * @return string |
---|
163 | */ |
---|
164 | function lfGetErrMsgHead() { |
---|
165 | $errmsg = ''; |
---|
166 | $errmsg .= SC_Utils_Ex::sfGetUrl() . "\n"; |
---|
167 | $errmsg .= "\n"; |
---|
168 | $errmsg .= "SERVER_ADDR: " . $_SERVER['SERVER_ADDR'] . "\n"; |
---|
169 | $errmsg .= "REMOTE_ADDR: " . $_SERVER['REMOTE_ADDR'] . "\n"; |
---|
170 | $errmsg .= "USER_AGENT: " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
---|
171 | |
---|
172 | return $errmsg; |
---|
173 | } |
---|
174 | |
---|
175 | /** |
---|
176 | * デバッグ用のメッセージを追加 |
---|
177 | * |
---|
178 | * @return void |
---|
179 | */ |
---|
180 | function addDebugMsg($debugMsg) { |
---|
181 | $this->arrDebugMsg[] = rtrim($debugMsg, "\n"); |
---|
182 | } |
---|
183 | } |
---|
184 | ?> |
---|