コード例 #1
0
/**
 * Include additional module
 * This function should be called before function init_modules()
 *
 * @param string $mod	name of module
 * @access private
 */
function include_module($mod)
{
    global $_SERWEB, $config;
    $config->modules[$mod] = true;
    if (file_exists($_SERWEB["modulesdir"] . $mod . "/include.php")) {
        require_once $_SERWEB["modulesdir"] . $mod . "/include.php";
    }
    /* if other modules has been already initiated, init module imediately */
    if ($GLOBALS['__modules_initiated__']) {
        init_module($mod);
    }
}
コード例 #2
0
ファイル: cores.php プロジェクト: londomloto/immortal
/**
 * Application entry point
 */
function start()
{
    load_config();
    load_libraries();
    validate_uri($_SERVER['REQUEST_URI']);
    $url = parse_url($_SERVER['REQUEST_URI']);
    if (isset($url['path'])) {
        $uri = $url['path'];
    } else {
        $uri = $_SERVER['REQUEST_URI'];
        $pos = strpos($uri, '?');
        $uri = $pos !== FALSE ? substr($uri, 0, $pos) : $uri;
    }
    $qry = isset($url['query']) ? $url['query'] : '';
    $svc = $_SERVER['SCRIPT_NAME'];
    if (isset($svc[0])) {
        $dir = str_replace('\\', '/', dirname($svc));
        if ($dir != '/') {
            if (strpos($uri, $svc) === 0) {
                $uri = (string) substr($uri, strlen($svc));
            } else {
                if (strpos($uri, $dir) === 0) {
                    $uri = (string) substr($uri, strlen($dir));
                }
            }
        }
    }
    if (trim($uri, '/') === '' && strncmp($qry, '/', 1) === 0) {
        $tmp = explode('?', $qry, 2);
        $uri = $tmp[0];
        $_SERVER['QUERY_STRING'] = isset($tmp[1]) ? $tmp[1] : '';
    } else {
        $_SERVER['QUERY_STRING'] = $qry;
    }
    parse_str($_SERVER['QUERY_STRING'], $_GET);
    if ($uri == '') {
        $uri = '/';
    }
    set_var('uri', $uri);
    set_var('qry', $qry);
    $segments = uri_segments();
    $segments = array_pad($segments, 1, '');
    $module = $segments[0];
    if ($uri == '/') {
        $segments = explode('/', get_config('default'));
        $segments = array_pad($segments, 1, '');
        $module = $segments[0];
    }
    $layout = 'main.php';
    if ($module != '') {
        $module = init_module($module);
        if ($module) {
            $layout = $module->layout . '.php';
            $page = array_shift($segments);
            while (count($segments) > 0) {
                $path = implode('/', $segments);
                if (file_exists($module->path . $path . '.php')) {
                    $page = $path;
                    break;
                }
                array_pop($segments);
            }
            if (empty($page) || !file_exists($module->path . $page . '.php')) {
                $page = $module->name;
            }
            $page = $module->path . $page . '.php';
            set_content('file', $page);
        }
    }
    if (!is_ajax()) {
        include BASEPATH . 'layouts/' . $layout;
    } else {
        echo get_content();
    }
}