Update webapp.php
This commit is contained in:
parent
58578352a1
commit
7602ad2e19
|
|
@ -1,17 +1,37 @@
|
|||
<?php
|
||||
if(!defined("_DEF_RSF_")) set_error_exit("do not allow access");
|
||||
|
||||
$routes = read_route_all();
|
||||
$webapp_root = $_SERVER["DOCUMENT_ROOT"] . "webapp";
|
||||
|
||||
// set DOCUMENT_ROOT forcely
|
||||
$_SERVER["DOCUMENT_ROOT"] = $webapp_root;
|
||||
|
||||
// set file path
|
||||
$appfile_path = $webapp_root . "/" . implode("/", array_slice($routes, 1)) . ".php";
|
||||
|
||||
// load file
|
||||
if(file_exists($appfile_path)) {
|
||||
include($appfile_path);
|
||||
if($routes[0] == "") {
|
||||
renderView("view_welcome");
|
||||
} else {
|
||||
set_error("404 Not Found");
|
||||
show_errors();
|
||||
$webapp_root = $_SERVER["DOCUMENT_ROOT"] . "webapp";
|
||||
$webapp_url = base_url() . "webapp";
|
||||
|
||||
// set DOCUMENT_ROOT forcely
|
||||
$_SERVER["DOCUMENT_ROOT"] = $webapp_root;
|
||||
|
||||
// set file path
|
||||
$appfile = $webapp_root . "/" . implode("/", $routes);
|
||||
$appfile_path = $appfile . ".php";
|
||||
|
||||
// get end of routes
|
||||
$end_route = end($routes);
|
||||
$end_routes_attributes = explode(".", $end_route);
|
||||
if(end($end_routes_attributes) == "php" || count($end_routes_attributes) == 1) {
|
||||
$appfile_path = str_replace(".php.php", ".php", $appfile_path);
|
||||
if(file_exists($appfile_path)) {
|
||||
include($appfile_path);
|
||||
} else {
|
||||
set_error("Webapp 404 Not Found");
|
||||
show_errors();
|
||||
}
|
||||
} else {
|
||||
set_header_content_type(end($end_routes_attributes));
|
||||
$fp = fopen($appfile, "r") or die("file does not exists");
|
||||
$buffer = fread($fp, filesize($appfile));
|
||||
echo $buffer;
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user