Subversion Repositories ALCASAR

Rev

Rev 2770 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2770 Rev 3100
1
<?php
1
<?php
2
/**
2
/**
3
 * class autoloader
3
 * class autoloader
4
 *
4
 *
5
 * PHP version 5
5
 * PHP version 5
6
 *
6
 *
7
 * @category  PHP
7
 * @category  PHP
8
 * @package   PSI
8
 * @package   PSI
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
10
 * @copyright 2009 phpSysInfo
10
 * @copyright 2009 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
12
 * @version   SVN: $Id: autoloader.inc.php 660 2012-08-27 11:08:40Z namiltd $
12
 * @version   SVN: $Id: autoloader.inc.php 660 2012-08-27 11:08:40Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
14
 */
15
 
15
 
16
error_reporting(E_ALL | E_STRICT);
16
error_reporting(E_ALL | E_STRICT);
17
 
17
 
18
/**
18
/**
19
 * automatic loading classes when using them
19
 * automatic loading classes when using them
20
 *
20
 *
21
 * @param string $class_name name of the class which must be loaded
21
 * @param string $class_name name of the class which must be loaded
22
 *
22
 *
23
 * @return void
23
 * @return void
24
 */
24
 */
25
function psi_autoload($class_name)
25
function psi_autoload($class_name)
26
{
26
{
27
    //$class_name = str_replace('-', '', $class_name);
27
    //$class_name = str_replace('-', '', $class_name);
28
 
28
 
29
    /* case-insensitive folders */
29
    /* case-insensitive folders */
30
    $dirs = array('/plugins/'.strtolower($class_name).'/', '/includes/mb/', '/includes/ups/');
30
    $dirs = array('/plugins/'.strtolower($class_name).'/', '/includes/mb/', '/includes/ups/');
31
 
31
 
32
    foreach ($dirs as $dir) {
32
    foreach ($dirs as $dir) {
33
        if (file_exists(PSI_APP_ROOT.$dir.'class.'.strtolower($class_name).'.inc.php')) {
33
        if (file_exists(PSI_APP_ROOT.$dir.'class.'.strtolower($class_name).'.inc.php')) {
34
            include_once PSI_APP_ROOT.$dir.'class.'.strtolower($class_name).'.inc.php';
34
            include_once PSI_APP_ROOT.$dir.'class.'.strtolower($class_name).'.inc.php';
35
 
35
 
36
            return;
36
            return;
37
        }
37
        }
38
    }
38
    }
39
 
39
 
40
    /* case-sensitive folders */
40
    /* case-sensitive folders */
41
    $dirs = array('/includes/', '/includes/interface/', '/includes/to/', '/includes/to/device/', '/includes/os/', '/includes/plugin/', '/includes/xml/', '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/');
41
    $dirs = array('/includes/', '/includes/interface/', '/includes/to/', '/includes/to/device/', '/includes/os/', '/includes/plugin/', '/includes/xml/', '/includes/web/', '/includes/error/', '/includes/js/', '/includes/output/');
42
 
42
 
43
    foreach ($dirs as $dir) {
43
    foreach ($dirs as $dir) {
44
        if (file_exists(PSI_APP_ROOT.$dir.'class.'.$class_name.'.inc.php')) {
44
        if (file_exists(PSI_APP_ROOT.$dir.'class.'.$class_name.'.inc.php')) {
45
            include_once PSI_APP_ROOT.$dir.'class.'.$class_name.'.inc.php';
45
            include_once PSI_APP_ROOT.$dir.'class.'.$class_name.'.inc.php';
46
 
46
 
47
            return;
47
            return;
48
        }
48
        }
49
    }
49
    }
50
 
50
 
51
    $error = PSI_Error::singleton();
51
    $error = PSI_Error::singleton();
52
 
52
 
53
    $error->addError("psi_autoload(\"".$class_name."\")", "autoloading of class file (class.".$class_name.".inc.php) failed!");
53
    $error->addError("psi_autoload(\"".$class_name."\")", "autoloading of class file (class.".$class_name.".inc.php) failed!");
54
    $error->errorsAsXML();
54
    $error->errorsAsXML();
55
}
55
}
56
 
56
 
57
spl_autoload_register('psi_autoload');
57
spl_autoload_register('psi_autoload');
58
 
58
 
59
/**
59
/**
60
 * sets a user-defined error handler function
60
 * sets a user-defined error handler function
61
 *
61
 *
62
 * @param integer $level   contains the level of the error raised, as an integer.
62
 * @param integer $level   contains the level of the error raised, as an integer.
63
 * @param string  $message contains the error message, as a string.
63
 * @param string  $message contains the error message, as a string.
64
 * @param string  $file    which contains the filename that the error was raised in, as a string.
64
 * @param string  $file    which contains the filename that the error was raised in, as a string.
65
 * @param integer $line    which contains the line number the error was raised at, as an integer.
65
 * @param integer $line    which contains the line number the error was raised at, as an integer.
66
 *
66
 *
67
 * @return void
67
 * @return void
68
 */
68
 */
69
function errorHandlerPsi($level, $message, $file, $line)
69
function errorHandlerPsi($level, $message, $file, $line)
70
{
70
{
71
    $error = PSI_Error::singleton();
71
    $error = PSI_Error::singleton();
72
    if (PSI_DEBUG || (($level !== 2) && ($level !== 8)) || !(preg_match("/^[^:]*: open_basedir /", $message) || preg_match("/^fopen\(/", $message) || preg_match("/^is_readable\(/", $message) || preg_match("/^file_exists\(/", $message) || preg_match("/^fgets\(/", $message))) { // disable open_basedir, fopen, is_readable, file_exists and fgets warnings and notices
72
    if ((PSI_DEBUG && !preg_match("/^fgets\(|^stream_select\(/", $message)) || (($level !== 2) && ($level !== 8)) || !preg_match("/^[^:]*: open_basedir |^fopen\(|^fwrite\(|^is_readable\(|^file_exists\(|^fgets\(|^stream_select\(/", $message)) { // disable open_basedir, fopen, is_readable, file_exists, fgets and stream_select warnings and notices
73
        $error->addPhpError("errorHandlerPsi : ", "Level : ".$level." Message : ".$message." File : ".$file." Line : ".$line);
73
        $error->addPhpError("errorHandlerPsi : ", "Level : ".$level." Message : ".$message." File : ".$file." Line : ".$line);
74
    }
74
    }
75
}
75
}
76
 
76
 
77
set_error_handler('errorHandlerPsi');
77
set_error_handler('errorHandlerPsi');
78
 
78