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

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

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
  • 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    /**
47     * Page を初期化する.
48     *
49     * @return void
50     */
51    function init()
52    {
53        parent::init();
54        $this->tpl_title = 'システムエラー';
55    }
56
57    /**
58     * Page のプロセス。
59     *
60     * @return void
61     */
62    function process()
63    {
64        $this->action();
65        $this->sendResponse();
66    }
67
68    /**
69     * Page のプロセス。
70     *
71     * @return void
72     */
73    function action()
74    {
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    /**
90     * Page のレスポンス送信.
91     *
92     * @return void
93     */
94    function sendResponse()
95    {
96        $this->adminPage = GC_Utils_Ex::isAdminFunction();
97
98        if ($this->adminPage) {
99            $this->tpl_mainpage = 'login_error.tpl';
100            $this->template = LOGIN_FRAME;
101            $this->objDisplay->prepare($this, true);
102        } else {
103            $this->objDisplay->prepare($this);
104        }
105
106        $this->objDisplay->response->write();
107    }
108
109    /**
110     * デストラクタ.
111     *
112     * @return void
113     */
114    function destroy()
115    {
116        parent::destroy();
117    }
118
119    /**
120     * トランザクショントークンに関して処理しないようにオーバーライド
121     */
122    function doValidToken()
123    {
124    }
125
126    /**
127     * トランザクショントークンに関して処理しないようにオーバーライド
128     */
129    function setTokenTo()
130    {
131    }
132
133    /**
134     * エラーメッセージを生成する
135     *
136     * @return string
137     */
138    function sfGetErrMsg()
139    {
140        $errmsg = '';
141        $errmsg .= $this->lfGetErrMsgHead();
142        $errmsg .= "\n";
143
144        // デバッグ用のメッセージが指定されている場合
145        if (!empty($this->arrDebugMsg)) {
146            $errmsg .= implode("\n\n", $this->arrDebugMsg) . "\n";
147        }
148
149        // PEAR エラーを伴う場合
150        if (!is_null($this->pearResult)) {
151            $errmsg .= $this->pearResult->message . "\n\n";
152            $errmsg .= $this->pearResult->userinfo . "\n\n";
153            $errmsg .= GC_Utils_Ex::toStringBacktrace($this->pearResult->backtrace);
154        }
155        // (上に該当せず)バックトレーススタックが指定されている場合
156        else if (is_array($this->backtrace)) {
157            $errmsg .= GC_Utils_Ex::toStringBacktrace($this->backtrace);
158        } else {
159            $arrBacktrace = GC_Utils_Ex::getDebugBacktrace();
160            $errmsg .= GC_Utils_Ex::toStringBacktrace($arrBacktrace);
161        }
162
163        return $errmsg;
164    }
165
166    /**
167     * エラーメッセージの冒頭部を生成する
168     *
169     * @return string
170     */
171    function lfGetErrMsgHead()
172    {
173        $errmsg = '';
174        $errmsg .= GC_Utils_Ex::getUrl() . "\n";
175        $errmsg .= "\n";
176        $errmsg .= 'SERVER_ADDR: ' . $_SERVER['SERVER_ADDR'] . "\n";
177        $errmsg .= 'REMOTE_ADDR: ' . $_SERVER['REMOTE_ADDR'] . "\n";
178        $errmsg .= 'USER_AGENT: ' . $_SERVER['HTTP_USER_AGENT'] . "\n";
179
180        return $errmsg;
181    }
182
183    /**
184     * デバッグ用のメッセージを追加
185     *
186     * @return void
187     */
188    function addDebugMsg($debugMsg)
189    {
190        $this->arrDebugMsg[] = rtrim($debugMsg, "\n");
191    }
192}
Note: See TracBrowser for help on using the repository browser.