0
0

Moved all configurations away from $GLOBALS to independent variables

This commit is contained in:
Bryan Pedini
2019-07-18 11:38:03 +02:00
parent f2a56c2abc
commit 68884270f3
9 changed files with 44 additions and 44 deletions

View File

@@ -1,11 +1,11 @@
<?php
if ( isset ( $GLOBALS [ 'request_uri' ] [ 1 ] ) ) {
$link_id = $GLOBALS [ 'request_uri' ] [ 1 ];
if ( isset ( $request_uri [ 1 ] ) ) {
$link_id = $request_uri [ 1 ];
if ( ! ctype_digit ( $link_id ) ) {
die ( "You can't be forwarded to a non numerical URL link ID. If you think this is incorrect, please send an email to shorte@dev.bryanpedini.it with this URL: https://sh.bjphoster.com/go/" . $link_id . " for more investigations" );
}
$link_id = (int) $link_id;
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
$database = new Database ( $config [ 'db' ] );
$database->connect ( );
$database->prepare ( "SELECT links.URL FROM links WHERE links.ID = :link_id" );
$database->bind ( [ ':link_id' => $link_id ] );
@@ -13,7 +13,7 @@
$result = $database->get_result ( );
if ( $result->rowCount ( ) == 0 ) {
http_response_code ( 404 );
include ( $GLOBALS [ 'config' ] [ 'installation_path' ] . '/lib/errors/404.html' );
include ( $config [ 'installation_path' ] . '/lib/errors/404.html' );
exit;
}
else {
@@ -24,8 +24,8 @@
<head>
<meta charset="UTF-8">
<link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
<title id="title">Redirect in 5 seconds | <?=$GLOBALS['config']['website_name']?></title>
<link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
<title id="title">Redirect in 5 seconds | <?=$config['website_name']?></title>
</head>
<body>
@@ -37,7 +37,7 @@
var seconds = 5;
function update_timeout(interval) {
document.getElementById("title").innerHTML = "Redirect in " + seconds + " seconds | <?=$GLOBALS['config']['website_name']?>";
document.getElementById("title").innerHTML = "Redirect in " + seconds + " seconds | <?=$config['website_name']?>";
document.getElementById("body-timeout").innerHTML = seconds;
if (seconds == 0) {
window.location.href = "<?=$row['URL']?>";