-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
executable file
·50 lines (41 loc) · 1.82 KB
/
autoload.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
<?php
/* * * nullify any existing autoloads ** */
spl_autoload_register(null, false);
spl_autoload_extensions('.php,.inc.php,.class.php,.class.singleton.php');
spl_autoload_register('loadClasses');
function loadClasses($className) {
//Get module name
$porciones = explode("_", $className);
$module_name = $porciones[0];
$model_name = "";
//we need have this because if not exist $porciones[1], app will have problems when we sent error (showErrorPage(2..)).
if(isset($porciones[1])){
$model_name = $porciones[1];
$model_name = strtoupper($model_name);
}
//users && products
if (file_exists('module/' . $module_name . '/model/'.$model_name.'/' . $className . '.class.singleton.php')) {//require(BLL_USERS . "user_bll.class.singleton.php");
set_include_path('module/' . $module_name . '/model/'.$model_name.'/');
spl_autoload($className);
}
//model
elseif (file_exists('model/' . $className . '.class.singleton.php')) {//require(MODEL_PATH . "db.class.singleton.php");
set_include_path('model/');
spl_autoload($className);
}
//log
elseif (file_exists('classes/log/' . $className . '.class.singleton.php')) {
set_include_path('classes/log/');
spl_autoload($className);
}
//email
elseif (file_exists('classes/email/' . $className . '.class.singleton.php')) {
set_include_path('classes/email/');
spl_autoload($className);
}
//php_mailer
elseif( file_exists('libs/PHPMailer_v5.1/class.'.$className.'.php' ) ){//require(LIBS . 'PHPMailer_v5.1/class.phpmailer.php');
set_include_path('libs/PHPMailer_v5.1/' );
spl_autoload('class.'.$className);
}
}