-
Notifications
You must be signed in to change notification settings - Fork 0
/
pnd.php
63 lines (48 loc) · 1.52 KB
/
pnd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
define('PND_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR);
php_min_version_guard_('5.3.0');
fix_magic_quotes_gpc_();
function php_min_version_guard_($min_php_version)
{
$is_min_php_version = (function_exists('version_compare') and version_compare(PHP_VERSION, $min_php_version, '>='));
if (!$is_min_php_version)
{
list($php_version, ) = explode('-', PHP_VERSION, 2);
trigger_error
(
"Currently running PHP $php_version. Pnd requires at least PHP $min_php_version. Error triggered by Pnd",
E_USER_ERROR
);
}
}
function fix_magic_quotes_gpc_()
{
if (get_magic_quotes_gpc())
{
list($_GET, $_POST, $_COOKIE, $_REQUEST) = array_stripslashes_(array($_GET, $_POST, $_COOKIE, $_REQUEST));
}
}
function array_stripslashes_($value)
{
if (is_array($value)) return array_map(__FUNCTION__, $value);
return stripslashes($value);
}
function requires()
{
$libs = func_get_args();
foreach ($libs as $lib)
{
$lib_file = PND_DIR.$lib.DIRECTORY_SEPARATOR."$lib.php";
if (!file_exists($lib_file)) trigger_error_("Requires non-existent lib $lib", E_USER_ERROR);
require_once $lib_file;
}
}
function trigger_error_($error, $level)
{
$stacktrace = debug_backtrace();
$caller = $stacktrace[1];
$triggered_by = $stacktrace[0];
$me = __FUNCTION__;
trigger_error("$error in {$caller['file']} on line {$caller['line']}. Error triggered by {$caller['function']}() in {$triggered_by['file']} on line {$triggered_by['line']} from {$me}()", $level);
}
?>