openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

init.php (3097B)


      1 <?php
      2 // OpenRat Content Management System
      3 // Copyright (C) 2002-2009 Jan Dankert, cms@jandankert.de
      4 //
      5 // This program is free software; you can redistribute it and/or
      6 // modify it under the terms of the GNU General Public License
      7 // as published by the Free Software Foundation; version 2.
      8 //
      9 // This program is distributed in the hope that it will be useful,
     10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 // GNU General Public License for more details.
     13 //
     14 // You should have received a copy of the GNU General Public License
     15 // along with this program; if not, write to the Free Software
     16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     17 
     18 use logger\Logger;
     19 use util\exception\ValidationException;
     20 
     21 define('MIN_VERSION','5.4');
     22 
     23 if	( version_compare(phpversion(),MIN_VERSION,"<") )
     24     throw new ValidationException('This version of PHP is not supported any more. Minimum required: '.MIN_VERSION);
     25 
     26 
     27 define('PHP_EXT'         ,'php'    );
     28 
     29 define('IMG_EXT'         ,'.gif'   );
     30 define('IMG_ICON_EXT'    ,'.png'   );
     31 
     32 require(__DIR__ . '/version.php');
     33 define('OR_TITLE'        ,'OpenRat CMS');
     34 
     35 define( 'CMS_ROOT_DIR', __DIR__ . '/../../../');
     36 
     37 define('OR_MODULES_DIR'       , __DIR__ . '/../../');
     38 define('OR_DYNAMICCLASSES_DIR',OR_MODULES_DIR.'cms/macros/macro/' );
     39 define('OR_SERVICECLASSES_DIR',OR_MODULES_DIR.'util/' );
     40 define('OR_AUTHCLASSES_DIR'   ,OR_MODULES_DIR.'cms/auth/' );
     41 define('OR_TMP_DIR'           ,CMS_ROOT_DIR.'tmp/'            );
     42 
     43 define('START_TIME'           ,time()              );
     44 define('REQUEST_ID'           ,'req0' ); // Nicht mehr notwendig, kann entfallen.
     45 
     46 // Must be relative to HTML-Path!
     47 define('OR_HTML_MODULES_DIR'  ,'./modules/'      );
     48 define('OR_THEMES_DIR'        ,OR_HTML_MODULES_DIR.'cms/ui/themes/');
     49 
     50 
     51 
     52 /**
     53  * Wandelt jeden Fehler in eine ErrorException um.
     54  */
     55 function exception_error_handler($severity, $message, $file, $line) {
     56 	if	( !(error_reporting() & $severity) )
     57 	{
     58 		// Dieser Fehlercode ist nicht in error_reporting enthalten
     59 		return;
     60 	}
     61 	throw new ErrorException($message, 0, $severity, $file, $line);
     62 }
     63 
     64 set_error_handler("exception_error_handler");
     65 
     66 
     67 /**
     68  * Ermöglicht das Loggen von Fatal-Errors.
     69  */
     70 function fatal_handler() {
     71     
     72     $error = error_get_last();
     73     
     74     if( !is_null($error) )
     75     {
     76         $errno   = $error["type"];
     77         $errfile = $error["file"];
     78         $errline = $error["line"];
     79         $errstr  = $error["message"];
     80 
     81         $message = 'Error '.$errno .' '. $errstr.' in '. $errfile.':'. $errline;
     82         if(class_exists('logger\Logger'))
     83         	Logger::error( $message);
     84         else
     85         {
     86             error_log($message);
     87         }
     88 
     89         // It is not possibile to throw an exception out of a shutdown function!
     90         // PHP will exit the request directly after executing this method, so a
     91         // Exception would never reach a caller.
     92         //throw new ErrorException($errstr, $errno, 1, $errfile, $errline);
     93     }
     94 
     95 }
     96 
     97 register_shutdown_function( "fatal_handler");
     98 
     99 
    100 
    101 ?>