0
0

Minor bug fixes, added URL link on redirect page.

This commit is contained in:
Bryan Pedini 2019-02-07 11:51:47 +01:00
parent 9e8f7ed464
commit 9210890eda
No known key found for this signature in database
GPG Key ID: 688D440AE31B40C2
4 changed files with 17 additions and 11 deletions

View File

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

View File

@ -60,7 +60,7 @@
elseif ( isset ( $_GET [ 'logout' ] ) ) { elseif ( isset ( $_GET [ 'logout' ] ) ) {
$_SESSION = array ( ); $_SESSION = array ( );
session_destroy ( ); session_destroy ( );
header ( "Location: /" ); header ( "Location: " . $_SERVER [ 'SCRIPT_NAME' ] );
} }
else { else {
if ( ! isset ( $_SESSION [ 'user_id' ] ) ) { if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
@ -77,6 +77,7 @@
<div id="responsetext"></div> <div id="responsetext"></div>
<script src="js/sha512.min.js"></script> <script src="js/sha512.min.js"></script>
<script src="js/login.js"></script> <script src="js/login.js"></script>
<script>var script_name = "<?php echo $_SERVER['SCRIPT_NAME']?>";</script>
</body> </body>
</html> </html>
<?php <?php
@ -134,6 +135,7 @@
<button onclick="urlinsert()">Insert new URL</button><br> <button onclick="urlinsert()">Insert new URL</button><br>
<div id="responsetext"></div> <div id="responsetext"></div>
<script src="js/insertnew.js"></script> <script src="js/insertnew.js"></script>
<script>var script_name = "<?=$_SERVER['SCRIPT_NAME']?>";</script>
</body> </body>
</html> </html>
<?php <?php

View File

@ -28,5 +28,5 @@ function urlinsert() {
xhr.send( data ); xhr.send( data );
} }
function logout ( ) { function logout ( ) {
window.location.href = "/?logout"; window.location.href = script_name+"?logout";
} }

View File

@ -10,7 +10,7 @@ function login() {
var response = xhr.responseText; var response = xhr.responseText;
response = JSON.parse ( response ); response = JSON.parse ( response );
if ( response [ 'status' ] == 200 ) { if ( response [ 'status' ] == 200 ) {
window.location.href = "/"; window.location.href = script_name;
} }
else { else {
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ]; document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];