0
0

Refactored database, refactored config file, corrected login redirection

Moved database function in class "Database";
Corrected database-using webpages accordingly;
Moved config file from PHP to JSON with more config variables;
Corrected login page redirection on wrong username or password.
This commit is contained in:
Bryan Pedini
2019-03-21 12:07:23 +01:00
parent 4eaf1d0829
commit 4a6630bacb
10 changed files with 143 additions and 104 deletions

View File

@@ -5,15 +5,16 @@
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;
$db_connection = db_connect ( );
$statement = db_prepare ( $db_connection, "SELECT links.URL FROM links WHERE links.ID = ?" );
$database = new Database ( $config [ 'db' ] );
$database->connect ( );
$database->prepare ( "SELECT links.URL FROM links WHERE links.ID = ?" );
$parameters = [
[ "i" ],
[ &$link_id ],
];
db_bind ( $statement, $parameters );
db_execute ( $statement );
$result = $statement->get_result ( );
$database->bind ( $parameters );
$database->execute ( );
$result = $database->get_result ( );
$row = $result->fetch_assoc ( );
if ( ! $row ) {
http_response_code ( 404 );