devshort

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/devshort.git
Log | Files | Refs | README | LICENSE

commit 9115a0601a254f659066ac0de582721d8f625b33
parent 293c446e06de7141ab9c982841fa917f4ca9914e
Author: René Wagner <rwagner@rw-net.de>
Date:   Tue, 10 Mar 2020 16:35:20 +0100

Merge branch 'master' into develop

Diffstat:
MLICENSE | 2+-
MREADME.md | 14++++++--------
Madmin-auth.php | 5++---
Madmin.php | 11+++++++----
Dassets/main.css | 5-----
Massets/main.js | 10+++++++---
Aassets/vendor/frappe-charts/LICENSE | 21+++++++++++++++++++++
Mdata/stats.json | 2+-
Ddevelopment/admin-panel.png | 0
Ddevelopment/index.png | 0
Mindex.php | 7+++----
Mredirect.php | 7+++----
12 files changed, 51 insertions(+), 33 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019-2020 flokX +Copyright (c) 2019-2020 flokX and devShort contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md @@ -35,13 +35,11 @@ What is a URL shortener? Visit our [wiki article](https://github.com/flokX/devSh 3. Have no hassle with the software because it's slim and easy to configure -## 1-2-3 Click installation +## 1-2-3 Step installation 1. Download the latest [release](https://github.com/flokX/devShort/releases) and upload it to the desired installation place 2. Insert a admin password in the `admin/config.json` -3. Run the `installer.php` - -That's it! If you want to know what else devShort can do, visit our [wiki](https://github.com/flokX/devShort/wiki). +3. Start using devShort! If you want to know what else devShort can do, visit our [wiki](https://github.com/flokX/devShort/wiki). ## Screenshots @@ -50,13 +48,13 @@ To see devShort live and in action check out our [demo](https://devshort.flokx.d | Admin panel | Index | |:-----------:|:-----------:| -| ![Screenshot - Admin panel](https://raw.githubusercontent.com/flokX/devShort/master/development/admin-panel.png) | ![Screenshot - Index](https://raw.githubusercontent.com/flokX/devShort/master/development/index.png) | +| ![Screenshot - Admin panel](https://devshort.flokx.dev/screenshots/admin-panel.png) | ![Screenshot - Index](https://devshort.flokx.dev/screenshots/index.png) | ## About -Maintainer: [flokX](https://github.com/flokX) +Maintainer: [flokX](https://github.com/flokX), Contributors: [René Wagner](https://github.com/guzzisti) -License: The MIT license +License: [The MIT License](https://github.com/flokX/devShort/blob/master/LICENSE) -Third-party credits: [IO-Images](https://pixabay.com/users/io-images-1096650); [Bootstrap](https://getbootstrap.com) and [Frappe Charts](https://github.com/frappe/charts) +Third-party credits: [Vue.js](https://vuejs.org/), [Bootstrap](https://getbootstrap.com), [Frappe Charts](https://github.com/frappe/charts) and [IO-Images](https://pixabay.com/users/io-images-1096650), diff --git a/admin-auth.php b/admin-auth.php @@ -1,6 +1,6 @@ <?php -// All relevant changes can be made in the data file. Please read the docs: https://github.com/flokX/devShort/wiki +// This file is part of the devShort project under the MIT License. Visit https://github.com/flokX/devShort for more information. session_start(); $incorrect_password = false; @@ -66,7 +66,6 @@ if ($config_content["settings"]["custom_links"]) { <link href="<?php echo $config_content["settings"]["favicon"]; ?>" rel="icon"> <title>Login | <?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"> @@ -98,7 +97,7 @@ if ($config_content["settings"]["custom_links"]) { <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; <?php echo date("Y") . " " . $config_content["settings"]["author"]; ?> and <a href="https://github.com/flokX/devShort">devShort</a></span> + <span class="text-muted">&copy; 2020 <?php $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> diff --git a/admin.php b/admin.php @@ -1,6 +1,6 @@ <?php -// All relevant changes can be made in the data file. Please read the docs: https://github.com/flokX/devShort/wiki +// This file is part of the devShort project under the MIT License. Visit https://github.com/flokX/devShort for more information. $config_path = implode(DIRECTORY_SEPARATOR, array(__DIR__, "data", "config.json")); $config_content = json_decode(file_get_contents($config_path), true); @@ -35,6 +35,10 @@ if (isset($_GET["delete"]) || isset($_GET["add"])) { echo "{\"status\": \"unvalid-url\"}"; 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(); } @@ -67,7 +71,6 @@ 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"> @@ -138,7 +141,7 @@ if ($config_content["settings"]["custom_links"]) { <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; <?php echo date("Y") . " " . $config_content["settings"]["author"]; ?> and <a href="https://github.com/flokX/devShort">devShort</a></span> + <span class="text-muted">&copy; 2020 <?php $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> @@ -158,7 +161,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"> diff --git a/assets/main.css b/assets/main.css @@ -1,4 +0,0 @@ -.container { - width: auto; - padding: 0 15px; -} -\ No newline at end of file diff --git a/assets/main.js b/assets/main.js @@ -1,8 +1,9 @@ +// This file is part of the devShort project under the MIT License. Visit https://github.com/flokX/devShort for more information. + // Register variables const currentDate = new Date(); const startDate = new Date(new Date().setFullYear(currentDate.getFullYear() - 1)); const spinner = document.getElementById('spinner'); -const statusDiv = document.getElementById('status'); const template = document.getElementById('chart-template'); const version = "v3.0.0"; @@ -130,10 +131,13 @@ document.getElementById('add-form').addEventListener('submit', function (event) document.getElementById('name').value = ''; document.getElementById('url').value = 'https://'; vm.loadData(); + document.getElementById('status').innerHTML = ''; } else if (data.status === 'unvalid-url') { - statusDiv.insertAdjacentHTML('afterbegin', '<div class="alert alert-danger" role="alert">Unvalid URL. Please provide a valid URL.</div>'); + document.getElementById('status').insertAdjacentHTML('afterbegin', '<div class="alert alert-danger mt-2" role="alert">Unvalid URL. Please provide a valid URL.</div>'); + } else if (data.status === 'url-already-exists') { + document.getElementById('status').insertAdjacentHTML('afterbegin', '<div class="alert alert-danger mt-2" role="alert">Shortlink already exists. Please delete before readding.</div>'); } else { - statusDiv.insertAdjacentHTML('afterbegin', '<div class="alert alert-danger" role="alert">Error. Please try again.</div>'); + document.getElementById('status').insertAdjacentHTML('afterbegin', '<div class="alert alert-danger mt-2" role="alert">Error. Please try again.</div>'); } }); }); diff --git a/assets/vendor/frappe-charts/LICENSE b/assets/vendor/frappe-charts/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Prateeksha Singh + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/data/stats.json b/data/stats.json @@ -1,4 +1,4 @@ { "404-request": [], - "Index": [] + "index": [] } diff --git a/development/admin-panel.png b/development/admin-panel.png Binary files differ. diff --git a/development/index.png b/development/index.png Binary files differ. diff --git a/index.php b/index.php @@ -1,6 +1,6 @@ <?php -// All relevant changes can be made in the data file. Please read the docs: https://github.com/flokX/devShort/wiki +// This file is part of the devShort project under the MIT License. Visit https://github.com/flokX/devShort for more information. $config_path = implode(DIRECTORY_SEPARATOR, array(__DIR__, "data", "config.json")); $config_content = json_decode(file_get_contents($config_path), true); @@ -8,7 +8,7 @@ $stats_path = implode(DIRECTORY_SEPARATOR, array(__DIR__, "data", "stats.json")) $stats_content = json_decode(file_get_contents($stats_path), true); // Count the access -$stats_content["Index"][date("Y-m-d")] += 1; +$stats_content["index"][date("Y-m-d")] += 1; file_put_contents($stats_path, json_encode($stats_content, JSON_PRETTY_PRINT)); // Generate custom buttons for the footer @@ -43,7 +43,6 @@ function show_random_shortlink() { <link href="<?php echo $config_content["settings"]["favicon"]; ?>" rel="icon"> <title><?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"> @@ -72,7 +71,7 @@ function show_random_shortlink() { <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; <?php echo date("Y") . " " . $config_content["settings"]["author"]; ?> and <a href="https://github.com/flokX/devShort">devShort</a></span> + <span class="text-muted">&copy; 2020 <?php $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> diff --git a/redirect.php b/redirect.php @@ -1,10 +1,10 @@ <?php -// All relevant changes can be made in the data file. Please read the docs: https://github.com/flokX/devShort/wiki +// This file is part of the devShort project under the MIT License. Visit https://github.com/flokX/devShort for more information. $short = strtolower(htmlspecialchars($_GET["short"])); -$return_404 = array("favicon.ico", "assets/vendor/bootstrap/bootstrap.min.css.map", "assets/vendor/frappe-charts/frappe-charts.min.iife.js.map"); +$return_404 = array("assets/vendor/bootstrap/bootstrap.min.css.map", "assets/vendor/frappe-charts/frappe-charts.min.iife.js.map"); if (in_array($short, $return_404)) { header("HTTP/1.1 404 Not Found"); exit; @@ -56,7 +56,6 @@ if (array_key_exists($short, $config_content["shortlinks"])) { <link href="<?php echo $config_content["settings"]["favicon"]; ?>" rel="icon"> <title>404 | <?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"> @@ -78,7 +77,7 @@ if (array_key_exists($short, $config_content["shortlinks"])) { <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; <?php echo date("Y") . " " . $config_content["settings"]["author"]; ?> and <a href="https://github.com/flokX/devShort">devShort</a></span> + <span class="text-muted">&copy; 2020 <?php $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>