Location: PHPKode > projects > PhxENGINE > index.php
<?php

define('phxENGINE', true);

// config
require_once('./config.php');
if(ERRORS === true) {
    ini_set('display_errors', 'on');
    error_reporting(E_ALL);
}
date_default_timezone_set(TIMEZONE);

// autoloader
function __autoload($class) {
    $data = explode('_', $class);
    switch(strtolower($data[1])) {
        case 'core':    $dir = DIR_CRE; break;
        case 'helper':  $dir = DIR_HLP; break;
        case 'hook':    $dir = DIR_HOK; break;
        case 'library': $dir = DIR_LIB; break;
        case 'module':  $dir = DIR_MDL; break;
        default:        $dir = DIR_MDL; break;
    }
    $filepath = $dir.'/'.strtolower($data[0]).'.php';
    if(file_exists($filepath)) {
        require_once($filepath);
    } else {
        die('Can not load <b>'.strtolower($data[1]).'</b> file named <b>'.strtolower($data[0]).'</b> from <i>'.$filepath.'</i>.');
    }
}

// preparing $call array
if(isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
    $data = explode('/', $_SERVER['QUERY_STRING']);
    array_shift($data);
    if(MULTILANG === true) $call['lang'] = array_shift($data); else $call['lang'] = DEF_LNG;
    if(class_exists(ucfirst($data[0]).'_Module')) $call['parse'] = array_shift($data); else $call['parse'] = DEF_MDL;
    $call['module'] = ucfirst($call['parse']).'_Module';
    if(method_exists($call['module'], $data[0])) $call['method'] = array_shift($data); else $call['method'] = DEF_MTH;
    $call['params'] = $data;
} else {
    $call['lang']   = DEF_LNG;
    $call['parse']  = strtolower(DEF_MDL);
    $call['module'] = ucfirst($call['parse']).'_Module';
    $call['method'] = strtolower(DEF_MTH);
    $call['params'] = array();
}

// loading specified module, language file and catching PDO exceptions
try {
    $filepath = PATH.'/'.DIR_LNG.'/'.$call['lang'].'/'.$call['parse'].'.lang';
    if(file_exists($filepath)) {
        require_once($filepath);
    } else {
        die('Can not load <b>'.strtoupper($call['lang']).' language</b> file named <b>'.strtolower($call['parse']).'</b> from <i>'.$filepath.'</i>.');
    }
    $called = new $call['module'];
    if(MULTILANG === true) $called->alang = $call['lang'];
    call_user_func_array(array($called, $call['method']), $call['params']);
    $called->tpl->assign('lang', $lang);
    $called->tpl->display($call['parse'].'/'.$call['method'].'.html');
} catch(PDOException $e) {
    die($e->getMessage());
}

?>
Return current item: PhxENGINE