Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Error_SystemError.php

Documentation is available at LC_Page_Error_SystemError.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2011 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: LC_Page_Error_SystemError.php 20764 2011-03-22 06:26:40Z nanasess $
  34.  */
  35.  
  36.     /** PEAR_Error */
  37.     var $pearResult;
  38.  
  39.     /** PEAR_Error がセットされていない場合用のバックトレーススタック */
  40.     var $backtrace;
  41.  
  42.     /** デバッグ用のメッセージ配列 */
  43.     var $arrDebugMsg = array();
  44.  
  45.     // }}}
  46.     // {{{ functions
  47.  
  48.     /**
  49.      * Page を初期化する.
  50.      *
  51.      * @return void 
  52.      */
  53.     function init({
  54.         parent::init();
  55.         $this->tpl_title 'システムエラー';
  56.     }
  57.  
  58.     /**
  59.      * Page のプロセス。
  60.      *
  61.      * @return void 
  62.      */
  63.     function process({
  64.         $this->action();
  65.         $this->sendResponse();
  66.     }
  67.  
  68.     /**
  69.      * Page のプロセス。
  70.      *
  71.      * @return void 
  72.      */
  73.     function action(){
  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_QUOTESCHAR_CODE);
  81.             echo '</pre>';
  82.             echo '<div>▲▲▲ デバッグ情報ここまで ▲▲▲</div>';
  83.             echo '</div>';
  84.         }
  85.     }
  86.  
  87.     /**
  88.      * Page のレスポンス送信.
  89.      *
  90.      * @return void 
  91.      */
  92.     function sendResponse({
  93.         $this->adminPage SC_Utils_Ex::sfIsAdminFunction();
  94.  
  95.         if ($this->adminPage{
  96.             $this->tpl_mainpage 'login_error.tpl';
  97.             $this->template LOGIN_FRAME;
  98.             $this->objDisplay->prepare($thistrue);
  99.         else {
  100.             $this->objDisplay->prepare($this);
  101.         }
  102.  
  103.         $this->objDisplay->response->write();
  104.     }
  105.  
  106.     /**
  107.      * デストラクタ.
  108.      *
  109.      * @return void 
  110.      */
  111.     function destroy({
  112.         parent::destroy();
  113.     }
  114.  
  115.     /**
  116.      * トランザクショントークンに関して処理しないようにオーバーライド
  117.      */
  118.     function doValidToken({
  119.     }
  120.  
  121.     /**
  122.      * トランザクショントークンに関して処理しないようにオーバーライド
  123.      */
  124.     function setTokenTo({
  125.     }
  126.  
  127.     /**
  128.      * エラーメッセージを生成する
  129.      *
  130.      * @return string 
  131.      */
  132.     function sfGetErrMsg({
  133.         $errmsg '';
  134.         $errmsg .= $this->lfGetErrMsgHead();
  135.         $errmsg .= "\n";
  136.  
  137.         // PEAR エラーを伴う場合
  138.         if (!is_null($this->pearResult)) {
  139.             $errmsg .= $this->pearResult->message "\n\n";
  140.             $errmsg .= $this->pearResult->userinfo "\n\n";
  141.             $errmsg .= SC_Utils_Ex::sfBacktraceToString($this->pearResult->backtrace);
  142.         }
  143.         // (上に該当せず)バックトレーススタックが指定されている場合
  144.         else if (is_array($this->backtrace)) {
  145.             $errmsg .= SC_Utils_Ex::sfBacktraceToString($this->backtrace);
  146.         }
  147.         // (上に該当せず)バックトレースを生成できる環境(一般的には PHP 4 >= 4.3.0, PHP 5)の場合
  148.         else if (function_exists("debug_backtrace")) {
  149.             $backtrace debug_backtrace();
  150.  
  151.             // バックトレースのうち handle_error 以前は通常不要と考えられるので削除
  152.             $cnt 0;
  153.             $offset 0;
  154.             foreach ($backtrace as $key => $arrLine{
  155.                 $cnt ++;
  156.                 if (!isset($arrLine['file']&& $arrLine['function'=== 'handle_error'{
  157.                     $offset $cnt;
  158.                     break;
  159.                 }
  160.             }
  161.             if ($offset !== 0{
  162.                 $backtrace array_slice($backtrace$offset);
  163.             }
  164.  
  165.             $errmsg .= SC_Utils_Ex::sfBacktraceToString($backtrace);
  166.         }
  167.  
  168.         // デバッグ用のメッセージが指定されている場合
  169.         if (!empty($this->arrDebugMsg)) {
  170.             $errmsg .= implode("\n\n"$this->arrDebugMsg"\n";
  171.         }
  172.  
  173.         return $errmsg;
  174.     }
  175.  
  176.     /**
  177.      * エラーメッセージの冒頭部を生成する
  178.      *
  179.      * @return string 
  180.      */
  181.     function lfGetErrMsgHead({
  182.         $errmsg '';
  183.         $errmsg .= SC_Utils_Ex::sfGetUrl("\n";
  184.         $errmsg .= "\n";
  185.         $errmsg .= "SERVER_ADDR: " $_SERVER['SERVER_ADDR'"\n";
  186.         $errmsg .= "REMOTE_ADDR: " $_SERVER['REMOTE_ADDR'"\n";
  187.         $errmsg .= "USER_AGENT: " $_SERVER['HTTP_USER_AGENT'"\n";
  188.  
  189.         return $errmsg;
  190.     }
  191.  
  192.     /**
  193.      * デバッグ用のメッセージを追加
  194.      *
  195.      * @return void 
  196.      */
  197.     function addDebugMsg($debugMsg{
  198.         $this->arrDebugMsg[rtrim($debugMsg"\n");
  199.     }
  200. }
  201. ?>

Documentation generated on Fri, 24 Feb 2012 14:01:57 +0900 by Seasoft