aboutsummaryrefslogtreecommitdiff
path: root/api/contact
diff options
context:
space:
mode:
Diffstat (limited to 'api/contact')
-rw-r--r--api/contact/count/index.php5
-rw-r--r--api/contact/index.php15
-rw-r--r--api/contact/list/index.php12
3 files changed, 32 insertions, 0 deletions
diff --git a/api/contact/count/index.php b/api/contact/count/index.php
new file mode 100644
index 0000000..809902b
--- /dev/null
+++ b/api/contact/count/index.php
@@ -0,0 +1,5 @@
+<?php
+
+$config = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/data/projects.json"), true);
+header("Content-Type: application/json");
+echo(count($config)); \ No newline at end of file
diff --git a/api/contact/index.php b/api/contact/index.php
new file mode 100644
index 0000000..71cf001
--- /dev/null
+++ b/api/contact/index.php
@@ -0,0 +1,15 @@
+<?php header("Content-Type: text/html"); if (str_ends_with($_SERVER["REQUEST_URI"], "/")) $_SERVER["REQUEST_URI"] = substr($_SERVER["REQUEST_URI"], 0, -1); if (str_contains($_SERVER["REQUEST_URI"], "..")) die(); ?>
+<h1>Available endpoints at <?= $_SERVER['REQUEST_URI'] ?></h1>
+
+<ul>
+ <?php foreach (scandir($_SERVER["DOCUMENT_ROOT"] . $_SERVER['REQUEST_URI']) as $i1): if (is_dir($_SERVER["DOCUMENT_ROOT"] . $_SERVER['REQUEST_URI'] . "/" . $i1) && !str_starts_with($i1, ".")): ?>
+ <li><a href="<?= $_SERVER['REQUEST_URI'] ?>/<?= $i1 ?>"><?= $_SERVER['REQUEST_URI'] ?>/<?= $i1 ?></a><ul>
+
+ <?php foreach (scandir($_SERVER["DOCUMENT_ROOT"] . $_SERVER['REQUEST_URI'] . "/" . $i1) as $i2): if (is_dir($_SERVER["DOCUMENT_ROOT"] . $_SERVER['REQUEST_URI'] . "/" . $i1 . "/" . $i2) && !str_starts_with($i2, ".")): ?>
+ <li><a href="<?= $_SERVER['REQUEST_URI'] ?>/<?= $i1 ?>/<?= $i2 ?>"><?= $_SERVER['REQUEST_URI'] ?>/<?= $i1 ?>/<?= $i2 ?></a></li>
+
+ <?php endif; endforeach; ?>
+ </ul></li>
+ <?php endif; endforeach; ?>
+
+</ul> \ No newline at end of file
diff --git a/api/contact/list/index.php b/api/contact/list/index.php
new file mode 100644
index 0000000..884821c
--- /dev/null
+++ b/api/contact/list/index.php
@@ -0,0 +1,12 @@
+<?php
+
+$config = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/data/projects.json"), true);
+$listed = [];
+header("Content-Type: application/json");
+
+foreach ($config as $project) {
+ unset($project["showcase"]);
+ $listed[] = $project;
+}
+
+die(json_encode($listed)); \ No newline at end of file