devshort

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

commit 9c1ac04214527466d329b4b24fd68f61dd9f2d15
parent f1b9df0fdea4bc455e5209c6a11833fc24823db0
Author: René Wagner <rwagner@rw-net.de>
Date:   Fri,  1 May 2020 21:29:14 +0200

implements ~rwa/devShort#8
implements ~rwa/devShort#6

Diffstat:
MREADME.md | 8+++++++-
Madmin-auth.php | 4+---
Madmin.php | 14++++++++++++++
3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md @@ -34,9 +34,15 @@ The devShort URL shortener is the perfect choice for web developers, admins and 1. Download the latest [release](https://git.sr.ht/~rwa/devshort/refs) and upload it to the desired installation place 2. Move `admin/config.json.example` to `admin/config.json` and `admin/stats.json.example` to `admin/stats.json` -3. Adjust the configuration in `admin/config.json`, especially **insert a admin password** +3. Adjust the configuration in `admin/config.json`, especially **insert a admin password** +The passwort will be securely hashed at the first login on the admin page. 4. Start using devShort! +## 1-2-3 Step update + +1. Download the latest [release](https://git.sr.ht/~rwa/devshort/refs) and upload it to the installation place +2. Start using devShort! + ## About Maintainer: [flokX](https://github.com/flokX), Contributors: [René Wagner](https://sr.ht/~rwa) diff --git a/admin-auth.php b/admin-auth.php @@ -7,12 +7,10 @@ $incorrect_password = false; $config_path = implode(DIRECTORY_SEPARATOR, array(__DIR__, "data", "config.json")); $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); // If no password is in the config.json file, redirect to wiki page if (!$config_content["admin_password"]) { - header("Location: https://github.com/flokX/devShort/wiki/Installation#installation"); + header("Location: https://sr.ht/~rwa/devShort/"); exit; } diff --git a/admin.php b/admin.php @@ -1,12 +1,26 @@ <?php // This file is part of the devShort project under the MIT License. Visit https://github.com/flokX/devShort for more information. +// updated by devShort see https://sr.ht/~rwa/devShort $config_path = implode(DIRECTORY_SEPARATOR, array(__DIR__, "data", "config.json")); $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"])) {