devshort

private self-hosted shortlink service
git clone https://git.clttr.info/devshort.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 68222d91077a5720f06eccdc6da32b684bc66dee
parent 9c1ac04214527466d329b4b24fd68f61dd9f2d15
Author: René Wagner <rwagner@rw-net.de>
Date:   Thu, 14 May 2020 20:28:18 +0200

fix broken links in admin page

Diffstat:
Madmin.php | 34++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/admin.php b/admin.php @@ -8,19 +8,6 @@ $config_content = json_decode(file_get_contents($config_path), true); $stats_path = implode(DIRECTORY_SEPARATOR, array(__DIR__, "data", "stats.json")); $stats_content = json_decode(file_get_contents($stats_path), true); -// convert the old timestamp format in the stats file to the now used date-format -my $converted = 0; -foreach ( $stats_content as &$stats_entry ) { - foreach ($stats_entry as $key => $value) { - if ( is_numeric($key) ) { - $converted = 1; - unset($sub_stats[$key]); - $sub_stats[date("Y-m-d", $key)] = $value; - } - } -} -if ( $converted ) { file_put_contents($stats_path, json_encode($stats_content, JSON_PRETTY_PRINT)); } - // Check if authentication is valid session_start(); if (!isset($_SESSION["user_authenticated"])) { @@ -31,8 +18,9 @@ if (!isset($_SESSION["user_authenticated"])) { // Deliver stats.json content for the program (make AJAX calls and charts reloading possible) if (isset($_GET["get_data"])) { header("Content-Type: application/json"); + $content = array("shortlinks" => $config_content["shortlinks"], "stats" => $stats_content); - echo json_encode($content); + echo json_encode($content); exit; } @@ -43,15 +31,16 @@ if (isset($_GET["delete"]) || isset($_GET["add"])) { unset($config_content["shortlinks"][$data["name"]]); unset($stats_content[$data["name"]]); } else if (isset($_GET["add"])) { - $filtered = array("name" => strtolower(filter_var($data["name"], FILTER_SANITIZE_STRING)), + $filtered = array("name" => filter_var($data["name"], FILTER_SANITIZE_STRING), "url" => filter_var($data["url"], FILTER_SANITIZE_URL)); if (!filter_var($filtered["url"], FILTER_VALIDATE_URL)) { echo "{\"status\": \"unvalid-url\"}"; exit; } - if (array_key_exists($filtered["name"], $config_content["shortlinks"])) { - echo "{\"status\": \"url-already-exists\"}"; - exit; + if (array_key_exists($filtered["name"], $config_content["shortlinks"])) + { + echo "{\"status\": \"url-already-exists\"}"; + exit; } $config_content["shortlinks"][$filtered["name"]] = $filtered["url"]; $stats_content[$filtered["name"]] = array(); @@ -85,6 +74,7 @@ if ($config_content["settings"]["custom_links"]) { <link href="<?php echo $config_content["settings"]["favicon"]; ?>" rel="icon"> <title>Admin panel | <?php echo $config_content["settings"]["name"]; ?></title> <link href="assets/vendor/bootstrap/bootstrap.min.css" rel="stylesheet"> + <link href="assets/main.css" rel="stylesheet"> </head> <body class="d-flex flex-column h-100"> @@ -129,7 +119,7 @@ if ($config_content["settings"]["custom_links"]) { </div> <div class="card d-none d-md-block mb-3"> <div class="card-body"> - <p class="mb-0" id="version-1">powered by <a href="https://github.com/flokX/devShort">devShort</a></p> + <p class="mb-0" id="version-1">powered by <a href="https://sr.ht/~rwa/devShort/" target="_blank">devShort</a></p> </div> </div> <div class="card d-md-none mb-3"> @@ -148,14 +138,14 @@ if ($config_content["settings"]["custom_links"]) { <chart v-for="(stats, name) in dataObject.stats" v-bind:key="name" :style="displayStyle(name)" v-bind:name="name" v-bind:stats="stats" v-else></chart> </div> </div> - <p class="text-center d-md-none mt-1 mb-5" id="version-2">powered by <a href="https://github.com/flokX/devShort">devShort</a></p> + <p class="text-center d-md-none mt-1 mb-5" id="version-2">powered by <a href="https://sr.ht/~rwa/devShort/" target="_blank">devShort</a></p> </div> </main> <footer class="footer mt-auto py-3 bg-light"> <div class="container"> <div class="d-flex justify-content-between align-items-center"> - <span class="text-muted">&copy; 2020 <?php $config_content["settings"]["author"]; ?> and <a href="https://github.com/flokX/devShort">devShort</a></span> + <span class="text-muted">&copy; <?php echo date("Y") . " " . $config_content["settings"]["author"]; ?> and <a href="https://github.com/flokX/devShort">devShort</a></span> <?php if ($links_string) { echo "<span class=\"text-muted\">$links_string</span>"; } ?> </div> </div> @@ -175,7 +165,7 @@ if ($config_content["settings"]["custom_links"]) { <hr> <div class="overflow-auto" :id="chartId"></div> <hr> - <p class="text-center text-muted mb-0" v-if="this.name === 'index'">Index is an internal entry. It counts the number of front page accesses.</p> + <p class="text-center text-muted mb-0" v-if="this.name === 'Index'">Index is an internal entry. It counts the number of front page accesses.</p> <p class="text-center text-muted mb-0" v-else-if="this.name === '404-request'">404-request is an internal entry. It counts the number of accesses to non-existent shortlinks.</p> <div class="row" v-else> <div class="col-lg-9">