-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
72 lines (58 loc) · 1.87 KB
/
functions.php
File metadata and controls
72 lines (58 loc) · 1.87 KB
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
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
function autoload($className) {
$includedir = array('/Form/element','/Form/statemachine','/Form/validation');
$classnamearr=explode("\\",$className);
$thisClass=end($classnamearr);
$baseDir = __DIR__.'/';
if (substr($baseDir, -strlen($thisClass)) === $thisClass) {
$baseDir = substr($baseDir, 0, -strlen($thisClass));
}
$className = ltrim($className, '\\');
$fileName = $baseDir;
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if (file_exists($fileName)) {
require_once $fileName;
} else {
foreach ($includedir as $dir) {
$array = glob(__DIR__.$dir.'/*.php');
foreach ($array as $file) {
$temp = explode("/",$file);
if (str_replace(".php","",end($temp))==$className) {
require_once $file;
}
}
}
}
}
function now() {
return date("Y-m-d H:i:s");
}
function whitelist($text,$symbols) {
return preg_replace("/[^" . preg_quote($symbols, '/') . "]/i", "", $text);
}
function escapesql($text) {
return str_replace("'", "''", $text);
}
function debug ($text) {
if (is_array($text)) {
echo "[";
print_r($text);
echo "]<br />";
} else {
echo "[$text]<br />";
}
}
function getBasePath() {
return str_replace($_SERVER["PATH_INFO"], "", $_SERVER["REQUEST_URI"]);
}
?>