Revision 1680
Added by darkviper over 12 years ago
globalExceptionHandler.php | ||
---|---|---|
51 | 51 |
} |
52 | 52 |
} // end of class |
53 | 53 |
|
54 |
/* -- several security exceptions ----------------------------------------------------- */ |
|
55 |
class SecurityException extends RuntimeException { } |
|
56 |
|
|
57 |
class SecDirectoryTraversalException extends SecurityException { |
|
58 |
public function __toString() { |
|
59 |
return 'possible directory traversal attack'; |
|
60 |
} |
|
61 |
} |
|
62 |
/* ------------------------------------------------------------------------------------ */ |
|
54 | 63 |
/** |
55 | 64 |
* |
56 | 65 |
* @param Exception $e |
... | ... | |
59 | 68 |
// hide server internals from filename where the exception was thrown |
60 | 69 |
$file = str_replace(dirname(dirname(__FILE__)), '', $e->getFile()); |
61 | 70 |
// select some exceptions for special handling |
62 |
if ($e instanceof IllegalFileException) { |
|
71 |
if ($e instanceof SecurityException) { |
|
72 |
$out = 'Exception: "'.(string)$e.'" @ '; |
|
73 |
$trace = $e->getTrace(); |
|
74 |
if($trace[0]['class'] != '') { |
|
75 |
$out .= $trace[0]['class'].'->'; |
|
76 |
} |
|
77 |
$out .= $trace[0]['function'].'();<br />'; |
|
78 |
$out .= 'in "'.$file.'"'."\n"; |
|
79 |
echo $out; |
|
80 |
}elseif ($e instanceof IllegalFileException) { |
|
63 | 81 |
$sResponse = $_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'; |
64 | 82 |
header($sResponse); |
65 | 83 |
echo $e; |
66 | 84 |
}elseif($e instanceof RuntimeException) { |
67 |
$out ='There was a serious runtime error:'."\n"; |
|
85 |
$out = 'There was a serious runtime error:'."\n";
|
|
68 | 86 |
$out .= $e->getMessage()."\n"; |
69 | 87 |
$out .= 'in line ('.$e->getLine().') of ('.$file.')'."\n"; |
70 | 88 |
echo $out; |
Also available in: Unified diff
renamed file class.database.php to Database.php
renamed class database into Database
classes SecurityException and SecDirectoryTraversalException added in globalExceptionHandler.php
CoreAutoloader() added in initialize.php
new Constants 'WB_REL' and 'DOCUMENT_ROOT' in initialize.php
class Database is able now to create multiple connections at same time
class ModLanguage added for easy handle of languages from modules