mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-22 05:19:56 +01:00
Refactor PHP.
This commit is contained in:
parent
8fd393d34a
commit
903b29c4c0
@ -103,7 +103,7 @@ class Api {
|
||||
$response["all_items"] = $this->app->get_all_items();
|
||||
}
|
||||
|
||||
if (count($_REQUEST)) {
|
||||
if (AS_ADMIN && count($_REQUEST)) {
|
||||
$response["unused"] = $_REQUEST;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
- var app_href = "<?php echo APP_HREF; ?>"
|
||||
- var fallback = "<?php echo FALLBACK; ?>"
|
||||
|
||||
<?php header("Content-type: text/html;charset=utf-8"); ?>
|
||||
doctype 5
|
||||
//if lt IE 10
|
||||
<html class="no-js no-browser" lang="en">
|
||||
|
@ -3,14 +3,18 @@
|
||||
|
||||
function normalize_path($path, $trailing_slash = false) {
|
||||
|
||||
$path = preg_replace("#\\\\+|/+#", "/", $path);
|
||||
$path = preg_replace("#[\\\\/]+#", "/", $path);
|
||||
return preg_match("#^(\w:)?/$#", $path) ? $path : (rtrim($path, "/") . ($trailing_slash ? "/" : ""));
|
||||
}
|
||||
|
||||
|
||||
function json_exit($obj = array()) {
|
||||
|
||||
$obj["code"] = 0;
|
||||
if (!isset($obj["code"])) {
|
||||
$obj["code"] = 0;
|
||||
}
|
||||
|
||||
header("Content-type: application/json;charset=utf-8");
|
||||
echo json_encode($obj);
|
||||
exit;
|
||||
}
|
||||
@ -19,8 +23,7 @@ function json_exit($obj = array()) {
|
||||
function json_fail($code, $msg = "", $cond = true) {
|
||||
|
||||
if ($cond) {
|
||||
echo json_encode(array("code" => $code, "msg" => $msg));
|
||||
exit;
|
||||
json_exit(array("code" => $code, "msg" => $msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ define("PASSHASH", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
|
||||
|
||||
function normalized_require_once($lib) {
|
||||
|
||||
require_once(preg_replace("#\\\\+|/+#", "/", dirname(__FILE__) . "/inc/${lib}.php"));
|
||||
require_once(preg_replace("#[\\\\/]+#", "/", dirname(__FILE__) . "/inc/${lib}.php"));
|
||||
}
|
||||
|
||||
normalized_require_once("util");
|
||||
@ -28,14 +28,9 @@ setup();
|
||||
$app = new App();
|
||||
|
||||
if (has_request_param("action")) {
|
||||
|
||||
header("Content-type: application/json;charset=utf-8");
|
||||
$api = new Api($app);
|
||||
$api->apply();
|
||||
|
||||
} else {
|
||||
|
||||
header("Content-type: text/html;charset=utf-8");
|
||||
define("FALLBACK", $app->get_fallback());
|
||||
normalized_require_once("page");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user