-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbritish_config.php
86 lines (77 loc) · 2.6 KB
/
british_config.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
//I am ofcourse assuming that rename_function would work the same way... I don't have access to it, so I don't know
if (!function_exists('rename_function')) {
function rename_function($function_name, $alias_name) {
static $renamed = array();
if (function_exists($alias_name)){
return false;
} elseif(function_exists('__'.$function_name)){
$function_name = '__'.$function_name;
}
if(isset($renamed[$function_name]) && $renamed[$function_name] === $alias_name){
return true;
}
$renamed[$function_name] = $alias_name;
$rf = new ReflectionFunction($function_name);
$fproto = $alias_name . '(';
$fcall = $function_name . '(';
$need_comma = false;
foreach ($rf->getParameters() as $param) {
if ($need_comma) {
$fproto .= ',';
$fcall .= ',';
}
if($param->isPassedByReference()){
$fproto .= '&';
$fcall .= '&';
}
$fproto .= '$' . $param->getName();
$fcall .= '$' . $param->getName();
if ($param->isOptional() && $param->isDefaultValueAvailable()) {
$val = $param->getDefaultValue();
if (is_string($val))
$val = "'$val'";
$fproto .= ' = ' . $val;
}
$need_comma = true;
}
$fproto .= ')';
$fcall .= ')';
$f = "function $fproto" . PHP_EOL;
$f .= '{return ' . $fcall . ';}';
eval($f);
return true;
}
}
// die isn't really a function yo
function __die($message=''){
return die($message);
}
$funcs = array(
'array_shift'=>'array_remove_first_element',
'print_r'=>'print_readable',
'die'=>'cheerio',
'str_*'=>'string_*',
'is_int'=>'is_integer',
'var_dump'=>'variable_dump',
'preg_*'=>'perl_regular_expression_*',
'json_*'=>'javascript_object_notation_*',
'mysql_*'=>'my_structured_query_language_*',
'mysqli_*'=>'my_structured_query_language_improved_*',
);
$defined = get_defined_functions();
foreach($funcs as $old=>$new){
if(strpos($old, '*') !== FALSE){
$old_funcs = array();
$old = str_replace('*', '', $old);
$new = str_replace('*', '', $new);
foreach($defined['internal'] as $d){
if(strpos($d, $old) === 0){
$new_func = str_replace($old, $new, $d);
rename_function($d, $new_func);
}
}
} else {
rename_function($old, $new);
}
}