Repository navigation
Expand file tree
/
Copy pathloader.php
More file actions
85 lines (80 loc) · 2.06 KB
/
Copy pathloader.php
File metadata and controls
85 lines (80 loc) · 2.06 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
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
//xFacility2015
//Loader
//Studio2b
//Michael Son(mson0129@gmail.com)
//22SEP2014(1.0.0.) - Loader is updated.
//16MAR2015(1.1.0.) - Loader is divided from XFObject.class.php of xFacility2014. And path setting is modified. It's set automatically.
//27APR2015(1.1.1.) - Stopping with a non-exist path is corrected.
//22SEP2015(1.2.0.) - Autoloader is added.
function load($className) {
//Autoloader which works with spl_autoload_register();
$paths[0] = __DIR__."/classes";
$j = 1;
for($i=0; $i<$j; $i++) {
$handle = opendir($paths[$i]);
if(is_dir($paths[$i])) {
while(false !==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(!is_dir($paths[$i]."/".$file)) {
if(substr($file, 0, 1)!=".") {
if($file==$className.".class.php") {
if($_GET['debug']==true)
echo $paths[$i]."/".$file;
require_once($paths[$i]."/".$file);
if($_GET['debug']==true)
echo "...OK\n";
break;
}
}
} else {
$paths[] = $paths[$i]."/".$file;
$j = count($paths);
}
}
}
}
}
}
function loadAll($classPath=NULL) {
if(!is_null($classPath)) {
if(substr($classPath, -1)=="/")
$classPath = substr($classPath, 0, -1);
$paths[0] = $_SERVER['DOCUMENT_ROOT'].$classPath;
} else {
$paths[0] = __DIR__."/classes";
}
$j = 1;
for($i=0; $i<$j; $i++) {
$handle = opendir($paths[$i]);
if(is_dir($paths[$i])) {
while(false !==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(!is_dir($paths[$i]."/".$file)) {
if(substr($file, 0, 1)!=".") {
if($_GET['debug']==true)
echo $paths[$i]."/".$file;
require_once($paths[$i]."/".$file);
if($_GET['debug']==true)
echo "...OK\n";
}
} else {
$paths[] = $paths[$i]."/".$file;
$j = count($paths);
}
}
}
}
}
return false;
}
if($_GET[debug]==true) {
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
error_reporting(23);
ini_set("display_errors", 1);
ini_set("html_errors", 1);
}
spl_autoload_register('load');
//loadAll();
?>