ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
_include.php
Go to the documentation of this file.
1<?php
2
7{
8 if (get_magic_quotes_gpc()) {
9 foreach (array('_GET', '_POST', '_COOKIE', '_REQUEST') as $a) {
10 if (isset($$a) && is_array($$a)) {
11 foreach ($$a as &$v) {
12 // we don't use array-parameters anywhere. Ignore any that may appear
13 if (is_array($v)) {
14 continue;
15 }
16 // unescape the string
17 $v = stripslashes($v);
18 }
19 }
20 }
21 }
22 if (get_magic_quotes_runtime()) {
23 set_magic_quotes_runtime(false);
24 }
25}
26
27if (version_compare(PHP_VERSION, '5.4.0', '<')) {
29}
30
31// initialize the autoloader
32require_once(dirname(dirname(__FILE__)).'/lib/_autoload.php');
33
34// enable assertion handler for all pages
36
37// show error page on unhandled exceptions
38function SimpleSAML_exception_handler($exception)
39{
40 SimpleSAML\Module::callHooks('exception_handler', $exception);
41
42 if ($exception instanceof SimpleSAML_Error_Error) {
43 $exception->show();
44 } elseif ($exception instanceof Exception) {
45 $e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $exception);
46 $e->show();
47 } else {
48 if (class_exists('Error') && $exception instanceof Error) {
49 $code = $exception->getCode();
50 $errno = ($code > 0) ? $code : E_ERROR;
51 $errstr = $exception->getMessage();
52 $errfile = $exception->getFile();
53 $errline = $exception->getLine();
54 SimpleSAML_error_handler($errno, $errstr, $errfile, $errline);
55 }
56 }
57}
58
59set_exception_handler('SimpleSAML_exception_handler');
60
61// log full backtrace on errors and warnings
62function SimpleSAML_error_handler($errno, $errstr, $errfile = null, $errline = 0, $errcontext = null)
63{
64 if (!class_exists('SimpleSAML\Logger')) {
65 /* We are probably logging a deprecation-warning during parsing. Unfortunately, the autoloader is disabled at
66 * this point, so we should stop here.
67 *
68 * See PHP bug: https://bugs.php.net/bug.php?id=47987
69 */
70 return false;
71 }
72
73 if (SimpleSAML\Logger::isErrorMasked($errno)) {
74 // masked error
75 return false;
76 }
77
78 static $limit = 5;
79 $limit -= 1;
80 if ($limit < 0) {
81 // we have reached the limit in the number of backtraces we will log
82 return false;
83 }
84
85 // show an error with a full backtrace
86 $e = new SimpleSAML_Error_Exception('Error '.$errno.' - '.$errstr);
87 $e->logError();
88
89 // resume normal error processing
90 return false;
91}
92
93set_error_handler('SimpleSAML_error_handler');
94
95try {
97} catch (Exception $e) {
98 throw new \SimpleSAML\Error\CriticalConfigurationError(
99 $e->getMessage()
100 );
101}
102
103// set the timezone
SimpleSAML_exception_handler($exception)
Definition: _include.php:38
SimpleSAML_error_handler($errno, $errstr, $errfile=null, $errline=0, $errcontext=null)
Definition: _include.php:62
removeMagicQuotes()
Disable magic quotes if they are enabled.
Definition: _include.php:6
An exception for terminatinating execution or to throw for unit testing.
static callHooks($hook, &$data=null)
Call a hook in all enabled modules.
Definition: Module.php:364
static initTimezone()
Initialize the timezone.
Definition: Time.php:52
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static installHandler()
Install this assertion handler.
Definition: Assertion.php:53
$code
Definition: example_050.php:99
Attribute-related utility methods.