init.php (3030B)
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 define('MIN_VERSION','5.4'); 19 20 if ( version_compare(phpversion(),MIN_VERSION,"<") ) 21 throw new ValidationException('This version of PHP is not supported any more. Minimum required: '.MIN_VERSION); 22 23 24 define('PHP_EXT' ,'php' ); 25 26 define('IMG_EXT' ,'.gif' ); 27 define('IMG_ICON_EXT' ,'.png' ); 28 29 require(__DIR__.'/version.php'); 30 define('OR_TITLE' ,'OpenRat CMS'); 31 32 define( 'CMS_ROOT_DIR',__DIR__.'/../../'); 33 34 define('OR_MODULES_DIR' ,CMS_ROOT_DIR.'modules/'); 35 define('OR_DYNAMICCLASSES_DIR',OR_MODULES_DIR.'cms-macros/macro/' ); 36 define('OR_SERVICECLASSES_DIR',OR_MODULES_DIR.'util/' ); 37 define('OR_AUTHCLASSES_DIR' ,OR_MODULES_DIR.'cms-core/auth/' ); 38 define('OR_TMP_DIR' ,CMS_ROOT_DIR.'tmp/' ); 39 40 define('START_TIME' ,time() ); 41 define('REQUEST_ID' ,'req0' ); // Nicht mehr notwendig, kann entfallen. 42 43 // Must be relative to HTML-Path! 44 define('OR_HTML_MODULES_DIR' ,'./modules/' ); 45 define('OR_THEMES_DIR' ,OR_HTML_MODULES_DIR.'cms-ui/themes/'); 46 47 48 49 /** 50 * Wandelt jeden Fehler in eine ErrorException um. 51 */ 52 function exception_error_handler($severity, $message, $file, $line) { 53 if ( !(error_reporting() & $severity) ) 54 { 55 // Dieser Fehlercode ist nicht in error_reporting enthalten 56 return; 57 } 58 throw new ErrorException($message, 0, $severity, $file, $line); 59 } 60 61 set_error_handler("exception_error_handler"); 62 63 64 /** 65 * Ermöglicht das Loggen von Fatal-Errors. 66 */ 67 function fatal_handler() { 68 69 $error = error_get_last(); 70 71 if( !is_null($error) ) 72 { 73 $errno = $error["type"]; 74 $errfile = $error["file"]; 75 $errline = $error["line"]; 76 $errstr = $error["message"]; 77 78 $message = 'Error '.$errno .' '. $errstr.' in '. $errfile.':'. $errline; 79 if(class_exists('Logger')) 80 Logger::error( $message); 81 else 82 { 83 error_log($message); 84 } 85 86 // It is not possibile to throw an exception out of a shutdown function! 87 // PHP will exit the request directly after executing this method, so a 88 // Exception would never reach a caller. 89 //throw new ErrorException($errstr, $errno, 1, $errfile, $errline); 90 } 91 92 } 93 94 register_shutdown_function( "fatal_handler"); 95 96 97 98 ?>