Serve HTML if available when no endpoint sent or endpoint not found
This commit is contained in:
parent
e1b3a0cb48
commit
959e4ad698
32
index.php
32
index.php
@ -82,22 +82,34 @@ if (count($route) > 0 && strpos($route[count($route) - 1], "?") === 0) {
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($ENDPOINT)) {
|
||||
if (file_exists(__DIR__ . "/publicsite/index.html")) {
|
||||
http_response_code(200);
|
||||
header("Content-Type: text/html");
|
||||
exit(file_get_contents(__DIR__ . "/publicsite/index.html"));
|
||||
} else {
|
||||
http_response_code(404);
|
||||
die("404 No endpoint specified.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($APIS[$ENDPOINT])) {
|
||||
if (preg_match("/[a-zA-Z0-9_\-]+/", $ENDPOINT) === 1 && file_exists(__DIR__ . "/publicsite/$ENDPOINT.html")) {
|
||||
http_response_code(200);
|
||||
header("Content-Type: text/html");
|
||||
exit(file_get_contents(__DIR__ . "/publicsite/$ENDPOINT.html"));
|
||||
} else {
|
||||
http_response_code(404);
|
||||
die("404 Requested endpoint not known.");
|
||||
}
|
||||
}
|
||||
|
||||
// Deny access if authenticator returns false (add your logic to authenticator.php)
|
||||
if (!authenticaterequest()) {
|
||||
http_response_code(401);
|
||||
die("401 Unauthorized: You need to supply valid credentials.");
|
||||
}
|
||||
|
||||
if (empty($ENDPOINT)) {
|
||||
http_response_code(404);
|
||||
die("404 No endpoint specified.");
|
||||
}
|
||||
|
||||
if (!isset($APIS[$ENDPOINT])) {
|
||||
http_response_code(404);
|
||||
die("404 Requested endpoint not known.");
|
||||
}
|
||||
|
||||
$APIENDPOINTCONFIG = $APIS[$ENDPOINT];
|
||||
|
||||
if (!file_exists(__DIR__ . "/endpoints/" . $APIENDPOINTCONFIG["load"])) {
|
||||
|
69
publicsite/index.html
Normal file
69
publicsite/index.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Data Server</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="https://static.netsyms.net/bootstrap/4/bootstrap.darkly.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-4 col-lg-2" style="text-align: center;">
|
||||
<img src="https://static.netsyms.net/images/netsyms/logo-flat-512.png" class="site-icon" />
|
||||
</div>
|
||||
<div class="col-12 col-md-8 col-lg-10">
|
||||
<div class="d-flex flex-column justify-content-center" style="height: 100%;">
|
||||
<h1 class="display-4">Netsyms Technologies</h1>
|
||||
<h2 class="display-5">Data and API Server</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p>This server is not for public use except when accessed via software and apps
|
||||
released by Netsyms Technologies. Do not use these APIs in other ways
|
||||
without express permission.
|
||||
</p>
|
||||
<p>
|
||||
Source code for this subdomain is available for you to use on your own
|
||||
server with your own third-party API keys.
|
||||
<a href="https://source.netsyms.com/Netsyms/data.netsyms.net">Get the Code</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-12 col-sm-6 col-md-4">
|
||||
<div class="card border-primary">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title d-flex">/gis: Earth, Weather, and Mapping</h4>
|
||||
<ul>
|
||||
<li>geocode/reverse/?latitude=23.45&longitude=32.12</li>
|
||||
<li>weather/?latitude=23.45&longitude=32.12</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-12 col-sm-6 col-md-4">
|
||||
<div class="card border-primary">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title d-flex">/net: Network and Internet</h4>
|
||||
<ul>
|
||||
<li>whois/?domain=ntsm.io</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user