aboutsummaryrefslogtreecommitdiff
path: root/admin/api
diff options
context:
space:
mode:
Diffstat (limited to 'admin/api')
-rw-r--r--admin/api/createURL.php20
-rw-r--r--admin/api/deleteURL.php23
2 files changed, 43 insertions, 0 deletions
diff --git a/admin/api/createURL.php b/admin/api/createURL.php
new file mode 100644
index 0000000..dc8a569
--- /dev/null
+++ b/admin/api/createURL.php
@@ -0,0 +1,20 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_GET['shortenedName']) && strpos($_GET['shortenedName'], "/") === false && strpos($_GET['shortenedName'], " ") === false) {
+ $name = $_GET['shortenedName'];
+} else {
+ die();
+}
+
+if (isset($_GET['redirectsTo']) && strpos($_GET['shortenedName'], " ") === false) {
+ $output = $_GET['redirectsTo'];
+} else {
+ die();
+}
+
+file_put_contents("/mnt/minteckrolt-urls/links.txt", file_get_contents("/mnt/minteckrolt-urls/links.txt") . "\n" . $name . " " . $output);
+
+header("Location: /admin/panes/shortens.php");
+die(); \ No newline at end of file
diff --git a/admin/api/deleteURL.php b/admin/api/deleteURL.php
new file mode 100644
index 0000000..895751e
--- /dev/null
+++ b/admin/api/deleteURL.php
@@ -0,0 +1,23 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) {
+ $arg = $_GET['_'];
+} else {
+ die();
+}
+
+$urls = explode("\n", file_get_contents("/mnt/minteckrolt-urls/links.txt"));
+$newUrlsArr = [];
+
+foreach ($urls as $url) {
+ if (explode(" ", $url)[0] !== $arg) {
+ $newUrlsArr[] = $url;
+ }
+}
+
+file_put_contents("/mnt/minteckrolt-urls/links.txt", implode("\n", $newUrlsArr));
+
+header("Location: /admin/panes/shortens.php");
+die(); \ No newline at end of file