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

Revision 22567, 5.1 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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