vogelor
2010-05-02 ae3a8a06e9783dd420fab3d5ba144e984366f580
Improved app errorhandling
1 files added
1 files modified
54 ■■■■■ changed files
interface/lib/app.inc.php 46 ●●●● patch | view | raw | blame | history
interface/web/themes/default/templates/error.tpl.htm 8 ●●●●● patch | view | raw | blame | history
interface/lib/app.inc.php
@@ -41,8 +41,7 @@
    private $_loaded_classes = array();
    private $_conf;
    public function __construct()
    {
    public function __construct() {
        global $conf;
        
        if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']) || isset($_REQUEST['s']) || isset($_REQUEST['s_old']) || isset($_REQUEST['conf'])) {
@@ -68,8 +67,7 @@
        $this->uses('auth,plugin');
    }
    public function uses($classes)
    {
    public function uses($classes) {
        $cl = explode(',', $classes);
        if(is_array($cl)) {
            foreach($cl as $classname){
@@ -84,8 +82,7 @@
        }
    }
    public function load($files)
    {
    public function load($files) {
        $fl = explode(',', $files);
        if(is_array($fl)) {
            foreach($fl as $file){
@@ -96,8 +93,7 @@
    }
    /** Priority values are: 0 = DEBUG, 1 = WARNING,  2 = ERROR */
    public function log($msg, $priority = 0)
    {
    public function log($msg, $priority = 0) {
        global $conf;
        if($priority >= $this->_conf['log_priority']) {
            // $server_id = $conf["server_id"];
@@ -123,33 +119,15 @@
    } 
    /** Priority values are: 0 = DEBUG, 1 = WARNING,  2 = ERROR */
    public function error($msg, $next_link = '', $stop = true, $priority = 1)
    {
    public function error($msg, $next_link = '', $stop = true, $priority = 1) {
        //$this->uses("error");
        //$this->error->message($msg, $priority);
        if($stop == true){
            $msg = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../themes/default/css/central.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="uniForm">
  <div id="errorMsg">
    <h3>Error</h3>
      <ol>
        <li>'.$msg;
            $content = file_get_contents(dirname(__FILE__) .
                    '/../web/themes/' . $_SESSION['s']['theme'] . '/templates/error.tpl.htm');
            if($next_link != '') $msg .= '<a href="'.$next_link.'">Next</a>';
            $msg .= '</li>
      </ol>
  </div>
</div>
</body>
</html>';
            die($msg);
            $content = str_replace('###ERRORMSG###', $msg, $content);
            die($content);
        } else {
            echo $msg;
            if($next_link != '') echo "<a href='$next_link'>Next</a>";
@@ -157,8 +135,7 @@
    }
    /** Translates strings in current language */
    public function lng($text)
    {
    public function lng($text) {
        if($this->_language_inc != 1) {
            //* loading global Wordbook
            $this->load_language_file('/lib/lang/'.$_SESSION['s']['language'].'.lng');
@@ -196,8 +173,7 @@
        }
    }
    public function tpl_defaults()
    {
    public function tpl_defaults() {
        $this->tpl->setVar('app_title', $this->_conf['app_title']);
        if(isset($_SESSION['s']['user'])) {
            $this->tpl->setVar('app_version', $this->_conf['app_version']);
interface/web/themes/default/templates/error.tpl.htm
New file
@@ -0,0 +1,8 @@
<div class="uniForm">
  <div id="errorMsg">
    <h3>Error</h3>
      <ol>
        <li>###ERRORMSG###</li>
      </ol>
  </div>
</div>