<?php
    session_start ( );
    require_once ( 'functions.php' );
    $GLOBALS [ 'config' ] = load_config ( );
    $GLOBALS [ 'request_uri' ] = explode ( "/", $_GET [ 'URI' ] );
    if ( isset ( $GLOBALS [ 'request_uri' ] [ 0 ] ) && $GLOBALS [ 'request_uri' ] [ 0 ] != "" ) {
        switch ( $GLOBALS [ 'request_uri' ] [ 0 ] ) {
            case "go":
                include ( 'lib/php/go.php' );
                break;
            case "login":
                include ( 'lib/php/login.php' );
                break;
            case "logout":
                include ( 'lib/php/logout.php' );
                break;
            case "insert":
                include ( 'lib/php/insert.php' );
                break;
            default:
                http_response_code ( 404 );
                include ( 'errors/404.html' );
                die ( );
        }
    }
    else {
        header ( "Location: " . substr ( $_SERVER [ 'SCRIPT_NAME' ], 0, -10 ) . "/login" );
    }