Moved all configurations away from $GLOBALS to independent variables
This commit is contained in:
parent
f2a56c2abc
commit
68884270f3
14
index.php
14
index.php
@ -1,19 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start ( );
|
session_start ( );
|
||||||
$GLOBALS [ 'request_uri' ] = explode ( "/", $_GET [ 'URI' ] );
|
$request_uri = explode ( "/", $_GET [ 'URI' ] );
|
||||||
if ( ! file_exists ( 'config.json' ) ) {
|
if ( ! file_exists ( 'config.json' ) ) {
|
||||||
if ( $GLOBALS[ 'request_uri' ] [ 0 ] !== "install" ) {
|
if ( $request_uri [ 0 ] !== "install" ) {
|
||||||
header ( "Location: " . substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ) . "/install" );
|
header ( "Location: " . substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ) . "/install" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $GLOBALS [ 'request_uri' ] [ 0 ] == "install" ) {
|
if ( $request_uri [ 0 ] == "install" ) {
|
||||||
include ( 'lib/php/install.php' );
|
include ( 'lib/php/install.php' );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
require_once ( 'functions.php' );
|
require_once ( 'functions.php' );
|
||||||
$GLOBALS [ 'config' ] = load_config ( );
|
$config = load_config ( );
|
||||||
if ( isset ( $GLOBALS [ 'request_uri' ] [ 0 ] ) && $GLOBALS [ 'request_uri' ] [ 0 ] != "" ) {
|
if ( isset ( $request_uri [ 0 ] ) && $request_uri [ 0 ] != "" ) {
|
||||||
switch ( $GLOBALS [ 'request_uri' ] [ 0 ] ) {
|
switch ( $request_uri [ 0 ] ) {
|
||||||
case "go":
|
case "go":
|
||||||
include ( 'lib/php/go.php' );
|
include ( 'lib/php/go.php' );
|
||||||
break;
|
break;
|
||||||
@ -33,5 +33,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/login" );
|
header ( "Location: " . $config [ 'installation_path' ] . "/login" );
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
|
if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
|
||||||
header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/login" );
|
header ( "Location: " . $config [ 'installation_path' ] . "/login" );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if ( isset ( $GLOBALS [ 'request_uri' ] [ 1 ] ) ) {
|
if ( isset ( $request_uri [ 1 ] ) ) {
|
||||||
switch ( $GLOBALS [ 'request_uri' ] [ 1 ] ) {
|
switch ( $request_uri [ 1 ] ) {
|
||||||
case "manage":
|
case "manage":
|
||||||
include ( 'lib/php/manage.php' );
|
include ( 'lib/php/manage.php' );
|
||||||
break;
|
break;
|
||||||
@ -27,15 +27,15 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
<link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/lib/css/manage.css" rel="stylesheet">
|
<link href="<?=$config['installation_path']?>/lib/css/manage.css" rel="stylesheet">
|
||||||
<title>Dashboard Home | <?=$GLOBALS['config']['website_name']?></title>
|
<title>Dashboard Home | <?=$config['website_name']?></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="userbar">
|
<div class="userbar">
|
||||||
</div>
|
</div>
|
||||||
<a href="<?=$GLOBALS['config']['installation_path']?>/dashboard/manage">Open Management Console</a>
|
<a href="<?=$config['installation_path']?>/dashboard/manage">Open Management Console</a>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
|
$database = new Database ( $config [ 'db' ] );
|
||||||
$database->connect ( );
|
$database->connect ( );
|
||||||
if ( isset ( $_POST [ 'forgot_email' ] ) ) {
|
if ( isset ( $_POST [ 'forgot_email' ] ) ) {
|
||||||
//...
|
//...
|
||||||
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
<link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
||||||
<title>Password Reset | <?=$GLOBALS['config']['website_name']?></title>
|
<title>Password Reset | <?=$config['website_name']?></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
if ( isset ( $GLOBALS [ 'request_uri' ] [ 1 ] ) ) {
|
if ( isset ( $request_uri [ 1 ] ) ) {
|
||||||
$link_id = $GLOBALS [ 'request_uri' ] [ 1 ];
|
$link_id = $request_uri [ 1 ];
|
||||||
if ( ! ctype_digit ( $link_id ) ) {
|
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" );
|
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;
|
$link_id = (int) $link_id;
|
||||||
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
|
$database = new Database ( $config [ 'db' ] );
|
||||||
$database->connect ( );
|
$database->connect ( );
|
||||||
$database->prepare ( "SELECT links.URL FROM links WHERE links.ID = :link_id" );
|
$database->prepare ( "SELECT links.URL FROM links WHERE links.ID = :link_id" );
|
||||||
$database->bind ( [ ':link_id' => $link_id ] );
|
$database->bind ( [ ':link_id' => $link_id ] );
|
||||||
@ -13,7 +13,7 @@
|
|||||||
$result = $database->get_result ( );
|
$result = $database->get_result ( );
|
||||||
if ( $result->rowCount ( ) == 0 ) {
|
if ( $result->rowCount ( ) == 0 ) {
|
||||||
http_response_code ( 404 );
|
http_response_code ( 404 );
|
||||||
include ( $GLOBALS [ 'config' ] [ 'installation_path' ] . '/lib/errors/404.html' );
|
include ( $config [ 'installation_path' ] . '/lib/errors/404.html' );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
<link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
||||||
<title id="title">Redirect in 5 seconds | <?=$GLOBALS['config']['website_name']?></title>
|
<title id="title">Redirect in 5 seconds | <?=$config['website_name']?></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
var seconds = 5;
|
var seconds = 5;
|
||||||
|
|
||||||
function update_timeout(interval) {
|
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;
|
document.getElementById("body-timeout").innerHTML = seconds;
|
||||||
if (seconds == 0) {
|
if (seconds == 0) {
|
||||||
window.location.href = "<?=$row['URL']?>";
|
window.location.href = "<?=$row['URL']?>";
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
if ( isset ( $_SESSION [ 'user_id' ] ) ) {
|
if ( isset ( $_SESSION [ 'user_id' ] ) ) {
|
||||||
header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/dashboard" );
|
header ( "Location: " . $config [ 'installation_path' ] . "/dashboard" );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if ( isset ( $GLOBALS [ 'request_uri' ] [ 1 ] ) && $GLOBALS [ 'request_uri' ] [ 1 ] == "forgot" ) {
|
if ( isset ( $request_uri [ 1 ] ) && $request_uri [ 1 ] == "forgot" ) {
|
||||||
include ( 'lib/php/forgot.php' );
|
include ( 'lib/php/forgot.php' );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -51,10 +51,10 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Login | <?=$GLOBALS['config']['website_name']?></title>
|
<title>Login | <?=$config['website_name']?></title>
|
||||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/lib/css/login.css" rel="stylesheet">
|
<link href="<?=$config['installation_path']?>/lib/css/login.css" rel="stylesheet">
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
<link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="button" class="col-md-6 btnSubmit" value="Login" onclick="login()" />
|
<input type="button" class="col-md-6 btnSubmit" value="Login" onclick="login()" />
|
||||||
<input type="button" class="col-md-6 btnForget" value="Forgot Password?" onclick="window.location.href='<?=$GLOBALS['config']['installation_path']."/login/forgot"?>'">
|
<input type="button" class="col-md-6 btnForget" value="Forgot Password?" onclick="window.location.href='<?=$config['installation_path']."/login/forgot"?>'">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div id="login-response" class="login-response"></div>
|
<div id="login-response" class="login-response"></div>
|
||||||
@ -81,10 +81,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
<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.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
||||||
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/sha512.min.js"></script>
|
<script src="<?=$config['installation_path']?>/lib/js/sha512.min.js"></script>
|
||||||
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/login.js"></script>
|
<script src="<?=$config['installation_path']?>/lib/js/login.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var script_name = "<?=$GLOBALS['config']['installation_path']?>/dashboard";
|
var script_name = "<?=$config['installation_path']?>/dashboard";
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
|
if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
|
||||||
header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/login" );
|
header ( "Location: " . $config [ 'installation_path' ] . "/login" );
|
||||||
}
|
}
|
||||||
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
|
$database = new Database ( $config [ 'db' ] );
|
||||||
$database->connect ( );
|
$database->connect ( );
|
||||||
$database->prepare ( "SELECT links.ID, links.URL FROM links WHERE links.created_by = " . $_SESSION [ 'user_id' ] );
|
$database->prepare ( "SELECT links.ID, links.URL FROM links WHERE links.created_by = " . $_SESSION [ 'user_id' ] );
|
||||||
$database->execute ( );
|
$database->execute ( );
|
||||||
@ -12,10 +12,10 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Management Panel | <?=$GLOBALS['config']['website_name']?></title>
|
<title>Management Panel | <?=$config['website_name']?></title>
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
<link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css" integrity="sha256-39jKbsb/ty7s7+4WzbtELS4vq9udJ+MDjGTD5mtxHZ0=" crossorigin="anonymous" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css" integrity="sha256-39jKbsb/ty7s7+4WzbtELS4vq9udJ+MDjGTD5mtxHZ0=" crossorigin="anonymous" />
|
||||||
<link href="<?=$GLOBALS['config']['installation_path']?>/lib/css/manage.css" rel="stylesheet">
|
<link href="<?=$config['installation_path']?>/lib/css/manage.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -44,10 +44,10 @@
|
|||||||
<button onclick="insertNewURL()">Insert new URL</button><br>
|
<button onclick="insertNewURL()">Insert new URL</button><br>
|
||||||
<div id="responsetext"></div>
|
<div id="responsetext"></div>
|
||||||
<script>
|
<script>
|
||||||
var script_name = "<?=$GLOBALS['config']['installation_path']?>";
|
var script_name = "<?=$config['installation_path']?>";
|
||||||
</script>
|
</script>
|
||||||
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/manage.js"></script>
|
<script src="<?=$config['installation_path']?>/lib/js/manage.js"></script>
|
||||||
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/logout.js"></script>
|
<script src="<?=$config['installation_path']?>/lib/js/logout.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
echo ( json_encode ( $response ) );
|
echo ( json_encode ( $response ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
|
$database = new Database ( $config [ 'db' ] );
|
||||||
$database->connect ( );
|
$database->connect ( );
|
||||||
$database->prepare ( "UPDATE `links` SET `URL`=:url WHERE `ID`=:url_id;" );
|
$database->prepare ( "UPDATE `links` SET `URL`=:url WHERE `ID`=:url_id;" );
|
||||||
$database->bind ( [ ':url' => $_POST [ 'url' ], 'url_id' => $_POST [ 'url_id' ] ] );
|
$database->bind ( [ ':url' => $_POST [ 'url' ], 'url_id' => $_POST [ 'url_id' ] ] );
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
echo ( json_encode ( $response ) );
|
echo ( json_encode ( $response ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
|
$database = new Database ( $config [ 'db' ] );
|
||||||
$database->connect ( );
|
$database->connect ( );
|
||||||
$url = $_POST [ 'url' ];
|
$url = $_POST [ 'url' ];
|
||||||
$database->prepare ( "INSERT INTO `links` ( `URL`, `created_by` ) VALUES ( :url, " . $_SESSION [ 'user_id' ] . " );" );
|
$database->prepare ( "INSERT INTO `links` ( `URL`, `created_by` ) VALUES ( :url, " . $_SESSION [ 'user_id' ] . " );" );
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
$_SESSION [ 'user_id' ] = NULL;
|
$_SESSION [ 'user_id' ] = NULL;
|
||||||
header ( "Location: " . substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ) . "/" );
|
header ( "Location: " . $config [ 'installation_path' ] . "/" );
|
||||||
|
Reference in New Issue
Block a user