Browse Source

implements ~rwa/devShort#8

implements ~rwa/devShort#6
remotes/origin/HEAD v3.0.0
René Wagner 1 year ago
parent
commit
9c1ac04214
  1. 8
      README.md
  2. 4
      admin-auth.php
  3. 14
      admin.php

8
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)

4
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;
}

14
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"])) {

Loading…
Cancel
Save