forked from barbatchov/wskomerci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
44 lines (37 loc) · 1.09 KB
/
index.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
<?php
//registering autoload
function findClassPhpFile($directory = '', $class) {
if ($directory == '') return;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST);
$paths = array();
foreach ($iterator as $path => $dir) {
if ($dir->isDir() && !strpos($path, DIRECTORY_SEPARATOR . '.')) {
$file = $path . DIRECTORY_SEPARATOR . $class . '.php';
if (file_exists($file)) {
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
return $file;
}
}
}
}
function autoloader($c) {
$root = realpath(__DIR__);
$f = implode(DIRECTORY_SEPARATOR,
array_merge(explode(DIRECTORY_SEPARATOR, $root), explode('\\', $c))) . '.php';
if (!file_exists($f)) {
$includePaths = explode(PATH_SEPARATOR, get_include_path());
foreach($includePaths as $directory) {
$file = findClassPhpFile(realpath($directory), $c);
if ($file) {
require_once $f;
return;
}
}
}
if (file_exists($f)) {
require_once $f;
}
}
spl_autoload_register('autoloader');