Project

General

Profile

« Previous | Next » 

Revision 1488

Added by DarkViper over 13 years ago

global exception handler activated

View differences:

branches/2.8.x/CHANGELOG
12 12

  
13 13
=============================== FEATURES FREEZE ================================
14 14
----------------------------------- Fixes 2.8.2 --------------------------------
15
11 Aug-2011 Build 1488 Werner v.d.Decken(DarkViper)
16
+ globalExceptionHandler activated
15 17
10 Aug-2011 Build 1487 Werner v.d.Decken(DarkViper)
16 18
# class.order completely recoded to reduce SQL requests
17 19
# all other files: fix SQL-statements to SQL-strict
branches/2.8.x/wb/admin/interface/version.php
52 52

  
53 53
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
54 54
if(!defined('VERSION')) define('VERSION', '2.8.2');
55
if(!defined('REVISION')) define('REVISION', '1487');
55
if(!defined('REVISION')) define('REVISION', '1488');
branches/2.8.x/wb/framework/initialize.php
16 16
 *
17 17
 */
18 18

  
19
//require_once(dirname(__FILE__).'/globalExceptionHandler.php');
20
//// Must include code to stop this file being access directly
21
//if(!defined('WB_PATH')) { throw new Exception('Illegaler Aufruf!'); }
22

  
19
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
23 21
require_once('globalExceptionHandler.php');
24 22
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
25
//if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
26

  
23
/* -------------------------------------------------------- */
27 24
//set_include_path(get_include_path() . PATH_SEPARATOR . WB_PATH);
28 25

  
29 26
if (file_exists(WB_PATH.'/framework/class.database.php')) {
branches/2.8.x/wb/framework/globalExceptionHandler.php
1
<?php
2
/**
3
 * @category        WebsiteBaker
4
 * @package         WebsiteBaker_core
5
 * @author          Werner v.d.Decken
6
 * @copyright       WebsiteBaker.org e.V.
7
 * @link            http://websitebaker2.org
8
 * @license         http://www.gnu.org/licenses/gpl.html
9
 * @version         $Id: class.order.php 1487 2011-08-10 13:20:15Z DarkViper $
10
 * @filesource		$HeadURL: http://svn.websitebaker2.org/branches/2.8.x/wb/framework/class.order.php $
11
 *
12
 * Global exception-handler
13
 * This module will activate a global exception handler to catch all thrown exceptions
14
 *
15
 */
16
/**
17
 * define several default exceptions directly to prevent from extra loading requests
18
 */
19

  
20
/**
21
 * define Exception to show error after accessing a forbidden file
22
 */
23
	class IllegalFileException extends LogicException {
24

  
25
		public function __toString() {
26
			$file = str_replace(dirname(dirname(__FILE__)), '', $e->getFile());
27
			$out  = '<div style="color: #ff0000; text-align: center;"><br /><br /><br /><h1>Illegale file access</h1>';
28
			$out .= '<h2>'.$file.'</h2></div>';
29
			return $out;
30
		}
31

  
32
	} // end of class
33

  
34
/**
35
 *
36
 * @param Exception $e
37
 */
38
	function globalExceptionHandler($e) {
39
		// hide server internals from filename where the exception was thrown
40
		$file = str_replace(dirname(dirname(__FILE__)), '', $e->getFile());
41
		// select some exceptions for special handling
42
		if ($e instanceof IllegalFileException) {
43
			$sResponse  = $_SERVER['SERVER_PROTOCOL'].' 403 Forbidden';
44
			header($sResponse);
45
			echo $e;
46
		}else {
47
		// default exception handling
48
			$out  = 'There was an unknown exception:'."\n";
49
			$out .= $e->getMessage()."\n";
50
			$out .= 'in line ('.$e->getLine().') of ('.$file.')'."\n";
51
			echo $out;
52
		}
53
	}
54
/**
55
 * now activate the new defined handler
56
 */
57
	set_exception_handler('globalExceptionHandler');

Also available in: Unified diff