source: branches/version-2_13-dev/data/class/pages/error/LC_Page_Error_SystemError.php @ 22926

Revision 22926, 5.0 KB checked in by Seasoft, 11 years ago (diff)

#2287 (環境によりデストラクタが正しく動作しないケースがある)
#2288 (リクエスト単位で実行されるべきログ出力がブロックにも適用されている)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 不明確な仕様にコメントを残した。
  • 親デストラクタを呼ぶだけの記述は可読性が悪くなると考え削除した。(上述のチケットで OS の仕様に依存したデストラクタとなるため、敢えてアプリケーション側で記述しておく意義は薄れたという認識のもと。)
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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
24require_once CLASS_REALDIR . 'pages/error/LC_Page_Error.php';
25
26/**
27 * システムエラー表示のページクラス
28 * システムエラーや例外が発生した場合の表示ページ
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Error_SystemError extends LC_Page_Error
35{
36    /** PEAR_Error */
37    var $pearResult;
38
39    /** PEAR_Error がセットされていない場合用のバックトレーススタック */
40    var $backtrace;
41
42    /** デバッグ用のメッセージ配列 */
43    var $arrDebugMsg = array();
44
45    /**
46     * Page を初期化する.
47     *
48     * @return void
49     */
50    function init()
51    {
52        parent::init();
53        $this->tpl_title = 'システムエラー';
54    }
55
56    /**
57     * Page のプロセス。
58     *
59     * @return void
60     */
61    function process()
62    {
63        $this->action();
64        $this->sendResponse();
65    }
66
67    /**
68     * Page のプロセス。
69     *
70     * @return void
71     */
72    function action()
73    {
74        SC_Response_Ex::sendHttpStatus(500);
75
76        $this->tpl_error = 'システムエラーが発生しました。<br />大変お手数ですが、サイト管理者までご連絡ください。';
77
78        if (DEBUG_MODE) {
79            echo '<div class="debug">';
80            echo '<div>▼▼▼ デバッグ情報ここから ▼▼▼</div>';
81            echo '<pre>';
82            echo htmlspecialchars($this->sfGetErrMsg(), ENT_QUOTES, CHAR_CODE);
83            echo '</pre>';
84            echo '<div>▲▲▲ デバッグ情報ここまで ▲▲▲</div>';
85            echo '</div>';
86        }
87
88    }
89
90    /**
91     * Page のレスポンス送信.
92     *
93     * @return void
94     */
95    function sendResponse()
96    {
97        $this->adminPage = GC_Utils_Ex::isAdminFunction();
98
99        if ($this->adminPage) {
100            $this->tpl_mainpage = 'login_error.tpl';
101            $this->template = LOGIN_FRAME;
102            $this->objDisplay->prepare($this, true);
103        } else {
104            $this->objDisplay->prepare($this);
105        }
106
107        $this->objDisplay->response->write();
108    }
109
110    /**
111     * トランザクショントークンに関して処理しないようにオーバーライド
112     */
113    function doValidToken()
114    {
115    }
116
117    /**
118     * トランザクショントークンに関して処理しないようにオーバーライド
119     */
120    function setTokenTo()
121    {
122    }
123
124    /**
125     * エラーメッセージを生成する
126     *
127     * @return string
128     */
129    function sfGetErrMsg()
130    {
131        $errmsg = '';
132        $errmsg .= $this->lfGetErrMsgHead();
133        $errmsg .= "\n";
134
135        // デバッグ用のメッセージが指定されている場合
136        if (!empty($this->arrDebugMsg)) {
137            $errmsg .= implode("\n\n", $this->arrDebugMsg) . "\n";
138        }
139
140        // PEAR エラーを伴う場合
141        if (!is_null($this->pearResult)) {
142            $errmsg .= $this->pearResult->message . "\n\n";
143            $errmsg .= $this->pearResult->userinfo . "\n\n";
144            $errmsg .= GC_Utils_Ex::toStringBacktrace($this->pearResult->backtrace);
145        }
146        // (上に該当せず)バックトレーススタックが指定されている場合
147        else if (is_array($this->backtrace)) {
148            $errmsg .= GC_Utils_Ex::toStringBacktrace($this->backtrace);
149        } else {
150            $arrBacktrace = GC_Utils_Ex::getDebugBacktrace();
151            $errmsg .= GC_Utils_Ex::toStringBacktrace($arrBacktrace);
152        }
153
154        return $errmsg;
155    }
156
157    /**
158     * エラーメッセージの冒頭部を生成する
159     *
160     * @return string
161     */
162    function lfGetErrMsgHead()
163    {
164        $errmsg = '';
165        $errmsg .= GC_Utils_Ex::getUrl() . "\n";
166        $errmsg .= "\n";
167        $errmsg .= 'SERVER_ADDR: ' . $_SERVER['SERVER_ADDR'] . "\n";
168        $errmsg .= 'REMOTE_ADDR: ' . $_SERVER['REMOTE_ADDR'] . "\n";
169        $errmsg .= 'USER_AGENT: ' . $_SERVER['HTTP_USER_AGENT'] . "\n";
170
171        return $errmsg;
172    }
173
174    /**
175     * デバッグ用のメッセージを追加
176     *
177     * @return void
178     */
179    function addDebugMsg($debugMsg)
180    {
181        $this->arrDebugMsg[] = rtrim($debugMsg, "\n");
182    }
183}
Note: See TracBrowser for help on using the repository browser.