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

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