Example #1
0
            return $litefile;
        }
        if (!file_exists($phpfile) || filesize($phpfile) == 0) {
            return $phpfile;
        }
        $phptime = filemtime($phpfile);
        $lite = json_decode(file_get_contents($litefile), true);
        $resources = @$lite[0];
        if (is_array($resources)) {
            foreach ($resources as $spath) {
                $file = $this->root . $spath;
                if (file_exists($file)) {
                    if (filemtime($file) > $phptime) {
                        return $file;
                    }
                } else {
                    return $file;
                }
            }
            return false;
        }
        return $litefile;
    }
}
if (realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $_SERVER['SCRIPT_NAME']) == realpath(__FILE__)) {
    //direct access from remote
    $service = new LiteService();
    $service->execute();
} else {
    //included
}
Example #2
0
/**
 * 装载模板函数
 * @return function name
 */
function lite_render($path, $context)
{
    global $lite_engine;
    $file = $lite_engine->litecode . strtr($path, '/', '^') . '.php';
    $fn = 'lite_template' . str_replace(array('.', '/', '-', '!', '%'), '_', $path);
    if ($lite_engine->debug) {
        require "LiteService.php";
        $engine = new LiteService();
        $engine->debug($path, $context);
    } else {
        require_once $file;
        $fn($context);
    }
}