From 5860551daa0f60103ad24e93da29f401a653f144 Mon Sep 17 00:00:00 2001
From: RaindropsSys <raindrops@equestria.dev>
Date: Fri, 29 Mar 2024 22:05:35 +0100
Subject: Updated 20 files, added 6 files, deleted 144 files and renamed
 .idea/ponycule.iml (automated)

---
 pages/api/_main.php | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 pages/api/_main.php

(limited to 'pages/api/_main.php')

diff --git a/pages/api/_main.php b/pages/api/_main.php
new file mode 100644
index 0000000..215c1b2
--- /dev/null
+++ b/pages/api/_main.php
@@ -0,0 +1,30 @@
+<?php
+
+if (str_ends_with($_GET['_'], "/")) {
+    $pagename = substr($_GET['_'], 0, strlen($_GET['_']) - 1);
+} else {
+    $pagename = $_GET['_'];
+}
+
+$toplevel = explode("/", $pagename)[1];
+$middlelevel = explode("/", $pagename)[2] ?? null;
+
+if ($toplevel === "_main" || $middlelevel === "_main") {
+    header("HTTP/1.1 404 Not Found");
+    header("Content-Type: text/plain");
+    echo("Endpoint not found");
+    die();
+}
+
+if (isset($middlelevel) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php")) {
+    require_once $_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php";
+} else {
+    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php")) {
+        require_once $_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php";
+    } else {
+        header("HTTP/1.1 404 Not Found");
+        header("Content-Type: text/plain");
+        echo("Endpoint not found");
+        die();
+    }
+}
-- 
cgit