You've already forked OpenShorte.old
							
							Moved all configurations away from $GLOBALS to independent variables
This commit is contained in:
		
							
								
								
									
										14
									
								
								index.php
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								index.php
									
									
									
									
									
								
							@@ -1,19 +1,19 @@
 | 
			
		||||
<?php
 | 
			
		||||
    session_start ( );
 | 
			
		||||
    $GLOBALS [ 'request_uri' ] = explode ( "/", $_GET [ 'URI' ] );
 | 
			
		||||
    $request_uri = explode ( "/", $_GET [ 'URI' ] );
 | 
			
		||||
    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" );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ( $GLOBALS [ 'request_uri' ] [ 0 ] == "install" ) {
 | 
			
		||||
    if ( $request_uri [ 0 ] == "install" ) {
 | 
			
		||||
        include ( 'lib/php/install.php' );
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    require_once ( 'functions.php' );
 | 
			
		||||
    $GLOBALS [ 'config' ] = load_config ( );
 | 
			
		||||
    if ( isset ( $GLOBALS [ 'request_uri' ] [ 0 ] ) && $GLOBALS [ 'request_uri' ] [ 0 ] != "" ) {
 | 
			
		||||
        switch ( $GLOBALS [ 'request_uri' ] [ 0 ] ) {
 | 
			
		||||
    $config = load_config ( );
 | 
			
		||||
    if ( isset ( $request_uri [ 0 ] ) && $request_uri [ 0 ] != "" ) {
 | 
			
		||||
        switch ( $request_uri [ 0 ] ) {
 | 
			
		||||
            case "go":
 | 
			
		||||
                include ( 'lib/php/go.php' );
 | 
			
		||||
                break;
 | 
			
		||||
@@ -33,5 +33,5 @@
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/login" );
 | 
			
		||||
        header ( "Location: " . $config [ 'installation_path' ] . "/login" );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
<?php
 | 
			
		||||
    if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
 | 
			
		||||
        header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/login" );
 | 
			
		||||
        header ( "Location: " . $config [ 'installation_path' ] . "/login" );
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    if ( isset ( $GLOBALS [ 'request_uri' ] [ 1 ] ) ) {
 | 
			
		||||
        switch ( $GLOBALS [ 'request_uri' ] [ 1 ] ) {
 | 
			
		||||
    if ( isset ( $request_uri [ 1 ] ) ) {
 | 
			
		||||
        switch ( $request_uri [ 1 ] ) {
 | 
			
		||||
            case "manage":
 | 
			
		||||
                include ( 'lib/php/manage.php' );
 | 
			
		||||
                break;
 | 
			
		||||
@@ -27,15 +27,15 @@
 | 
			
		||||
 | 
			
		||||
    <head>
 | 
			
		||||
        <meta charset="UTF-8">
 | 
			
		||||
        <link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
 | 
			
		||||
        <link href="<?=$GLOBALS['config']['installation_path']?>/lib/css/manage.css" rel="stylesheet">
 | 
			
		||||
        <title>Dashboard Home | <?=$GLOBALS['config']['website_name']?></title>
 | 
			
		||||
        <link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
 | 
			
		||||
        <link href="<?=$config['installation_path']?>/lib/css/manage.css" rel="stylesheet">
 | 
			
		||||
        <title>Dashboard Home | <?=$config['website_name']?></title>
 | 
			
		||||
    </head>
 | 
			
		||||
 | 
			
		||||
    <body>
 | 
			
		||||
        <div class="userbar">
 | 
			
		||||
        </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>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
<?php
 | 
			
		||||
    $database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
 | 
			
		||||
    $database = new Database ( $config [ 'db' ] );
 | 
			
		||||
    $database->connect ( );
 | 
			
		||||
    if ( isset ( $_POST [ 'forgot_email' ] ) ) {
 | 
			
		||||
        //...
 | 
			
		||||
@@ -13,8 +13,8 @@
 | 
			
		||||
 | 
			
		||||
    <head>
 | 
			
		||||
        <meta charset="UTF-8">
 | 
			
		||||
        <link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
 | 
			
		||||
        <title>Password Reset | <?=$GLOBALS['config']['website_name']?></title>
 | 
			
		||||
        <link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
 | 
			
		||||
        <title>Password Reset | <?=$config['website_name']?></title>
 | 
			
		||||
    </head>
 | 
			
		||||
 | 
			
		||||
    <body>
 | 
			
		||||
 
 | 
			
		||||
@@ -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']?>";
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
<?php
 | 
			
		||||
    if ( isset ( $_SESSION [ 'user_id' ] ) ) {
 | 
			
		||||
        header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/dashboard" );
 | 
			
		||||
        header ( "Location: " . $config [ 'installation_path' ] . "/dashboard" );
 | 
			
		||||
        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' );
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
@@ -51,10 +51,10 @@
 | 
			
		||||
<html>
 | 
			
		||||
 | 
			
		||||
    <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="<?=$GLOBALS['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']?>/lib/css/login.css" rel="stylesheet">
 | 
			
		||||
        <link href="<?=$config['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
 | 
			
		||||
    </head>
 | 
			
		||||
 | 
			
		||||
    <body>
 | 
			
		||||
@@ -71,7 +71,7 @@
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="form-group">
 | 
			
		||||
                            <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 class="form-group">
 | 
			
		||||
                            <div id="login-response" class="login-response"></div>
 | 
			
		||||
@@ -81,10 +81,10 @@
 | 
			
		||||
            </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.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="<?=$GLOBALS['config']['installation_path']?>/lib/js/login.js"></script>
 | 
			
		||||
            <script src="<?=$config['installation_path']?>/lib/js/sha512.min.js"></script>
 | 
			
		||||
            <script src="<?=$config['installation_path']?>/lib/js/login.js"></script>
 | 
			
		||||
            <script>
 | 
			
		||||
            var script_name = "<?=$GLOBALS['config']['installation_path']?>/dashboard";
 | 
			
		||||
            var script_name = "<?=$config['installation_path']?>/dashboard";
 | 
			
		||||
            </script>
 | 
			
		||||
    </body>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
<?php
 | 
			
		||||
    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->prepare ( "SELECT links.ID, links.URL FROM links WHERE links.created_by = " . $_SESSION [ 'user_id' ] );
 | 
			
		||||
    $database->execute ( );
 | 
			
		||||
@@ -12,10 +12,10 @@
 | 
			
		||||
<html>
 | 
			
		||||
 | 
			
		||||
    <head>
 | 
			
		||||
        <title>Management Panel | <?=$GLOBALS['config']['website_name']?></title>
 | 
			
		||||
        <link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
 | 
			
		||||
        <title>Management Panel | <?=$config['website_name']?></title>
 | 
			
		||||
        <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 href="<?=$GLOBALS['config']['installation_path']?>/lib/css/manage.css" rel="stylesheet">
 | 
			
		||||
        <link href="<?=$config['installation_path']?>/lib/css/manage.css" rel="stylesheet">
 | 
			
		||||
    </head>
 | 
			
		||||
 | 
			
		||||
    <body>
 | 
			
		||||
@@ -44,10 +44,10 @@
 | 
			
		||||
        <button onclick="insertNewURL()">Insert new URL</button><br>
 | 
			
		||||
        <div id="responsetext"></div>
 | 
			
		||||
        <script>
 | 
			
		||||
        var script_name = "<?=$GLOBALS['config']['installation_path']?>";
 | 
			
		||||
        var script_name = "<?=$config['installation_path']?>";
 | 
			
		||||
        </script>
 | 
			
		||||
        <script src="<?=$GLOBALS['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/manage.js"></script>
 | 
			
		||||
        <script src="<?=$config['installation_path']?>/lib/js/logout.js"></script>
 | 
			
		||||
    </body>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@
 | 
			
		||||
        echo ( json_encode ( $response ) );
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    $database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
 | 
			
		||||
    $database = new Database ( $config [ 'db' ] );
 | 
			
		||||
    $database->connect ( );
 | 
			
		||||
    $database->prepare ( "UPDATE `links` SET `URL`=:url WHERE `ID`=:url_id;" );
 | 
			
		||||
    $database->bind ( [ ':url' => $_POST [ 'url' ], 'url_id' => $_POST [ 'url_id' ] ] );
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@
 | 
			
		||||
        echo ( json_encode ( $response ) );
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    $database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
 | 
			
		||||
    $database = new Database ( $config [ 'db' ] );
 | 
			
		||||
    $database->connect ( );
 | 
			
		||||
    $url = $_POST [ 'url' ];
 | 
			
		||||
    $database->prepare ( "INSERT INTO `links` ( `URL`, `created_by` ) VALUES ( :url, " . $_SESSION [ 'user_id' ] . " );" );
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
<?php
 | 
			
		||||
    $_SESSION [ 'user_id' ] = NULL;
 | 
			
		||||
    header ( "Location: " . substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ) . "/" );
 | 
			
		||||
    header ( "Location: " . $config [ 'installation_path' ] . "/" );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user