diff options
author | Minteck <nekostarfan@gmail.com> | 2021-08-08 19:58:53 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-08-08 19:58:53 +0200 |
commit | e255736e3f2a95ee82cadc01b0c70749ab946226 (patch) | |
tree | 5164e67e7d00adf24080f4b1246b2d7d789202d3 | |
parent | a20dff82a7e2602738f847fa4f1428af3235aafc (diff) | |
download | main-e255736e3f2a95ee82cadc01b0c70749ab946226.tar.gz main-e255736e3f2a95ee82cadc01b0c70749ab946226.tar.bz2 main-e255736e3f2a95ee82cadc01b0c70749ab946226.zip |
New admin features done
-rw-r--r-- | .idea/workspace.xml | 24 | ||||
-rw-r--r-- | admin/api/createURL.php | 20 | ||||
-rw-r--r-- | admin/api/deleteURL.php | 23 | ||||
-rw-r--r-- | admin/panes/shortens.php | 56 | ||||
-rw-r--r-- | static/apps/unchainedtech.png | bin | 17440 -> 24004 bytes |
5 files changed, 104 insertions, 19 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml index dfd8e4d..1e1b266 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,21 +2,11 @@ <project version="4">
<component name="ChangeListManager">
<list default="true" id="efd4dd1a-d09c-4a08-b9ea-ac28a5f96210" name="Default Changelist" comment="">
- <change afterPath="$PROJECT_DIR$/admin/api/getIpLocation.php" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/admin/panes/audit.php" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/admin/panes/shortens.php" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/admin/private/ipcache.json" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/static/admin/audit.svg" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/static/admin/locked.svg" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/static/admin/shortens.svg" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/admin/api/createURL.php" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/admin/api/deleteURL.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/about/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/about/index.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/admin/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/admin/index.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/contact/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/contact/index.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/includes/header.php" beforeDir="false" afterPath="$PROJECT_DIR$/includes/header.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/version.txt" beforeDir="false" afterPath="$PROJECT_DIR$/version.txt" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/admin/panes/shortens.php" beforeDir="false" afterPath="$PROJECT_DIR$/admin/panes/shortens.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/static/apps/unchainedtech.png" beforeDir="false" afterPath="$PROJECT_DIR$/static/apps/unchainedtech.png" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -67,7 +57,7 @@ <property name="WebServerToolWindowPanel.toolwindow.show.permissions" value="false" />
<property name="WebServerToolWindowPanel.toolwindow.show.size" value="false" />
<property name="add_unversioned_files" value="$PROJECT_DIR$/admin/private/header.php D:/Projets/Minteck.ro.lt/admin/private/footer.php" />
- <property name="last_opened_file_path" value="$PROJECT_DIR$/admin/panes" />
+ <property name="last_opened_file_path" value="$PROJECT_DIR$/admin/api" />
<property name="list.type.of.created.stylesheet" value="CSS" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="reference.settings.deploy.options" />
@@ -75,8 +65,8 @@ </component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
- <recent name="$PROJECT_DIR$/admin/panes" />
<recent name="$PROJECT_DIR$/admin/api" />
+ <recent name="$PROJECT_DIR$/admin/panes" />
<recent name="$PROJECT_DIR$/includes/blog/data" />
<recent name="$PROJECT_DIR$/includes" />
<recent name="$PROJECT_DIR$/admin/NeutronManage" />
@@ -155,7 +145,7 @@ <workItem from="1628335662043" duration="2109000" />
<workItem from="1628417033420" duration="2437000" />
<workItem from="1628420373945" duration="287000" />
- <workItem from="1628426128888" duration="10094000" />
+ <workItem from="1628426128888" duration="13278000" />
</task>
<servers />
</component>
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 diff --git a/admin/panes/shortens.php b/admin/panes/shortens.php index 51afcbb..165c198 100644 --- a/admin/panes/shortens.php +++ b/admin/panes/shortens.php @@ -33,9 +33,61 @@ <h2 style="text-align:center;">Shortened URLs</h2>
<ul class="list-group" style="margin-top:20px;">
- <li class="list-group-item">English (primary) <span style="float:right;"><a href="/admin/panes/editor.php?file=conduct.en&name=Code%20of%20Conduct%20-%20English&context=code">Edit</a> · <a href="/code-of-conduct/?en" target="_blank">View</a></span></li>
- <li class="list-group-item">French <span style="float:right;"><a href="/admin/panes/editor.php?file=conduct.fr&name=Code%20of%20Conduct%20-%20French&context=code">Edit</a> · <a href="/code-of-conduct/?fr" target="_blank">View</a></span></li>
+ <?php
+
+ $links = explode("\n", file_get_contents("/mnt/minteckrolt-urls/links.txt"));
+
+ foreach ($links as $link) {
+ if (trim($link) !== "") {
+ $url = explode(" ", $link)[0];
+ $redirect = explode(" ", $link)[1];
+
+ echo('<li class="list-group-item"><code>https://mt.ro.lt/<a href="https://mt.ro.lt/' . $url . '" target="_blank">' . $url . '</a></code> <span style="float:right;"><a href="#" onclick="deleteURL(\'' . $url . '\')">Delete</a></span></li>');
+ }
+ }
+
+ ?><li class="list-group-item">
+ <form id="creator" action="/admin/api/createURL.php">
+ <code>https://mt.ro.lt/<input type="text" name="shortenedName" placeholder="superurl"></code> → <input type="text" name="redirectsTo" placeholder="https://kde.org"> <span style="float:right;"><a href="#" onclick="document.getElementById('creator').submit();">Create</a></span>
+ </form>
+ </li>
</ul>
</div>
+<script>
+ let currurl;
+
+ function deleteURL(url) {
+ currurl = url;
+
+ $("#myModal").modal()
+ }
+
+ function confirmDelete(url) {
+ location.href = "/admin/api/deleteURL.php?_=" + url;
+ }
+</script>
+
+ <div class="modal" id="myModal">
+ <div class="modal-dialog">
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <h4 class="modal-title">Delete this shortened URL?</h4>
+ <button type="button" class="close" data-dismiss="modal">×</button>
+ </div>
+
+ <div class="modal-body">
+ This cannot be undone and may have unwanted side effects. After this URL is deleted, it will redirect to Minteck's Space's homepage.
+ </div>
+
+ <div class="modal-footer">
+ <button type="button" class="btn btn-success" onclick="confirmDelete(currurl);">Confirm</button>
+ <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
+ </div>
+
+ </div>
+ </div>
+ </div>
+
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?>
\ No newline at end of file diff --git a/static/apps/unchainedtech.png b/static/apps/unchainedtech.png Binary files differindex 8765d06..1edcddc 100644 --- a/static/apps/unchainedtech.png +++ b/static/apps/unchainedtech.png |