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
12 changed files with 38 additions and 54 deletions

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>