Esempio n. 1
0
<?php

function do404()
{
    header("404 Not Found");
    echo "<h1>404 Not Found</h1>";
    echo "<p>The requested URL " . htmlspecialchars($_SERVER['REQUEST_URI']) . " not found.</p>";
    exit(0);
}
$request = $_GET['__r'];
unset($_GET['__r']);
$parts = explode("/", $request);
if ($parts[count($parts) - 1] == "") {
    $parts[count($parts)] = "index";
}
$file = realpath(__DIR__ . "/static/" . implode("/", $parts));
if ($file and is_file($file)) {
    if (!$file) {
        do404();
    }
    require_once __DIR__ . "/lib/download.php";
    $x = new \jf\DownloadManager();
    $x->Feed($file);
} else {
    $file = realpath(__DIR__ . "/app/" . implode("/", $parts) . ".php");
    if (!$file) {
        do404();
    }
    require_once __DIR__ . "/load.php";
    require $file;
}
Esempio n. 2
0
function showPage($info, $page, $menu, $name, $user)
{
    # If you are doing development, use without '@'
    # Then switch to '@' when finished
    # include_once("page_$page.php");
    @(include_once "page_{$page}.php");
    $fun = 'show_' . $page;
    if (function_exists($fun)) {
        $fun($info, $page, $menu, $name, $user);
    } else {
        do404();
    }
}
Esempio n. 3
0
        if (!method_exists($classInstance, $methodName)) {
            array_unshift($pieces, $methodName);
            $methodName = 'default_func';
        }
        $classInstance->format = $format;
        $classInstance->ctl = $className;
        $classInstance->action = $methodName;
        $classInstance->set_config($configini);
        $classInstance->filter($methodName);
    } catch (Exception $e) {
        do404($e->getMessage(), $configini);
        exit;
    }
    docontrolandmethod($classInstance, $methodName, $pieces);
} else {
    do404("can not find class {$className}_controller!", $configini);
}
/*
if(preg_match('/gzip/',$_SERVER['HTTP_ACCEPT_ENCODING'])){
	ob_end_flush();
}
*/
function docontrolandmethod(&$classInstance, $methodName, $pieces)
{
    try {
        $re = $classInstance->{$methodName}($pieces);
        //log something if necessary
        if (!preg_match('/cms/', $_SERVER['REQUEST_URI']) && !preg_match('/admin/', $_SERVER['REQUEST_URI'])) {
            //$classInstance->logme(getIP().':'.$_SERVER['REQUEST_URI'].':'.$_SERVER[HTTP_USER_AGENT]);
        }
        if (gettype($re) == "object") {