Add CDN and add API class

This commit is contained in:
XlXi 2020-12-13 23:54:38 -05:00
parent c85c329020
commit 986791fea1
4 changed files with 47 additions and 6 deletions

29
WebAssemblies/API.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/*
Platinus API
*/
namespace Platinus;
class API {
function __construct() {
if(http_response_code() == 404){
API::InvokeError(403, "Unauthorized");
}
}
function InvokeError($errorCode, $message) {
http_response_code($errorCode);
header("Content-Type: application/json");
exit(API::PrettyJSONEncode(["error"=>"$message"]));
}
function PrettyJSONEncode($array){
return json_encode($array, JSON_PRETTY_PRINT);
}
}
?>

View File

@ -6,13 +6,11 @@ Platinus Backend Autoloader
*/ */
$webAssemblies = $_SERVER["DOCUMENT_ROOT"] . "/../WebAssemblies/";
function reqMod($mod) { function reqMod($mod) {
global $webAssemblies; require $mod;
require $webAssemblies . $mod;
} }
reqMod("Web.php"); reqMod("Web.php");
reqMod("API.php");
?> ?>

14
public/cdn/www/index.php Normal file
View File

@ -0,0 +1,14 @@
<?php
/*
Platinus CDN Api
*/
require $_SERVER["DOCUMENT_ROOT"] . "/../../../WebAssemblies/loader.php";
$page = new Platinus\API();
$page->InvokeError(403, "Unauthorized");
?>

View File

@ -6,7 +6,7 @@ Platinus Home Page
*/ */
require $_SERVER["DOCUMENT_ROOT"] . "/../WebAssemblies/loader.php"; require $_SERVER["DOCUMENT_ROOT"] . "/../../WebAssemblies/loader.php";
$page = new Platinus\Web(); $page = new Platinus\Web();
@ -18,7 +18,7 @@ $headers = $page->buildHeaders();
?> ?>
<h1>Platinus</h1> <h1>Platinus</h1>
<h3>Yeah</h3> <h3>Simple home page</h3>
<?php <?php
$page->buildPage($headers); $page->buildPage($headers);