0
0

Website refactoring

Moved PHP files to "lib" folder
Moved Javascript files to "lib" folder
Moved login page inline CSS to "login.css"
Moved database functions to class "Database"
Removed the html template, compensated with a direct HTML code inside PHP "else" statement
This commit is contained in:
Bryan Pedini 2019-03-25 11:27:37 +01:00
parent 5a75d5335e
commit 18dc9b18d3
No known key found for this signature in database
GPG Key ID: 688D440AE31B40C2
12 changed files with 38 additions and 54 deletions

View File

@ -4,7 +4,6 @@ body {
.login-container{
margin-top: 5%;
margin-bottom: 5%;
margin-left: 30%;
}
.login-form-1{
padding: 5%;
@ -19,8 +18,8 @@ body {
}
.btnSubmit
{
width: 50%;
border-radius: 1rem;
width: 40%;
border-radius: 2rem;
padding: 1.5%;
border: none;
cursor: pointer;

View File

@ -18,12 +18,38 @@
$row = $result->fetch_assoc ( );
if ( ! $row ) {
http_response_code ( 404 );
include ( 'errors/404.html' );
include ( $config [ 'installation_path' ] . '/lib/errors/404.html' );
exit;
}
else {
include ( 'templates/redirect.html' );
echo ( '<script>var my_location = "' . $row [ 'URL' ] . '";</script>' );
?>
<!DOCTYPE html>
<html>
<head>
<title id="title">Redirect in 5 seconds</title>
<link href="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/favicon.ico" rel="icon" type="image/x-icon">
</head>
<body>
<center>
<h1>You will be redirected to <?=$row['URL']?> in <span id="body-timeout">5</span></h1>
</center>
<script>
window.onload = function() {
var seconds = 5;
function update_timeout (interval) {
document.getElementById("title").innerHTML = "Redirect in "+seconds+" seconds";
document.getElementById("body-timeout").innerHTML = seconds;
if (seconds == 0) {
window.location.href = "<?=$row['URL']?>";
clearInterval (interval);
}
}
interval = setInterval (function() {update_timeout(interval); seconds = seconds - 1;}, 1000);
}
</script>
</body>
</html>
<?php
}
}
else {

View File

@ -37,6 +37,7 @@
<html>
<head>
<title>BJPHoster URL Shortener | Control Panel</title>
<link href="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/favicon.ico" rel="icon" type="image/x-icon">
</head>
<body>
<button onclick="logout()">Logout</button>
@ -55,7 +56,7 @@
<input type="text" id="form-url" placeholder="URL:">
<button onclick="urlinsert()">Insert new URL</button><br>
<div id="responsetext"></div>
<script src="js/insertnew.js"></script>
<script src="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/lib/js/insertnew.js"></script>
<script>var script_name = "<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>";</script>
</body>
</html>

View File

@ -3,8 +3,8 @@
header ( "Location: " . substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ) . "/insert" );
exit;
}
if ( isset ( $session [ 1 ] ) && $session [ 1 ] == "forgot" ) {
include ( $config [ 'installation_path ' ] . '/lib/php/forgotpassword.php' );
if ( isset ( $request [ 1 ] ) && $request [ 1 ] == "forgot" ) {
include ( $config [ 'installation_path' ] . '/lib/php/forgot.php' );
exit;
}
if ( isset ( $_POST [ 'username' ] ) && isset ( $_POST [ 'password' ] ) ) {
@ -49,7 +49,7 @@
<title>BJPHoster URL Shortener | Login</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/lib/css/login.css" rel="stylesheet">
<link href="favicon.ico" rel="icon" type="image/x-icon">
<link href="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/favicon.ico" rel="icon" type="image/x-icon">
</head>
<body>
<div class="container login-container">
@ -74,8 +74,8 @@
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/sha512.min.js"></script>
<script src="js/login.js"></script>
<script src="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/lib/js/sha512.min.js"></script>
<script src="<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>/lib/js/login.js"></script>
<script>var script_name = "<?=substr($_SERVER['SCRIPT_NAME'],0,-10)?>";</script>
</body>
</html>

View File

@ -1,16 +0,0 @@
Copyright © 2019 - Bryan Pedini
Every file within this folder and it's subfolders is provided
with the website for the correct work of the website itself,
is provided AS IS, comes with NO WARRANTY of scope or
working purposes, and is proprietary software.
Such this code may not be copied without explicit permission from
myself only, this code may not be modified within the website,
you may not copy, edit, share, clone or do anything else but
use the code as is without explicit permission to do so.
Such permissions can be requested at copyright@bryanpedini.it
No permissions to do anything against this license is given
without an explicit and valid motivation to do so, so please
don't email me asking to do so or so without providing why.

View File

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title id="title">Redirect in 5 seconds</title>
</head>
<body>
<center>
<h1>You will be redirected to <span id="redirect-url"></span> in <span id="body-timeout">5</span></h1>
</center>
<script>
window.onload = function() {
var seconds = 5;
document.getElementById("redirect-url").innerHTML = my_location;
function update_timeout (interval) {
document.getElementById("title").innerHTML = "Redirect in "+seconds+" seconds";
document.getElementById("body-timeout").innerHTML = seconds;
if (seconds == 0) {
window.location.href = my_location;
clearInterval (interval);
}
}
interval = setInterval (function() {update_timeout(interval); seconds = seconds - 1;}, 1000);
}
</script>
</body>
</html>