0
0
This repository has been archived on 2020-11-15. You can view files and clone it, but cannot push or open issues or pull requests.
OpenShorte.old/functions.php
Bryan 81d21c311f
Minor changes
Moved config into $GLOBALS
Moved request_uri into $GLOBALS
Modified all files accordingly
Modified logout page for future improvements (not deleting the entire $_SESSION)
Fixed LICENSEs, moved LICENSE for PHP files in /lib/php subfolder instead of /lib
2019-04-06 11:57:35 +02:00

25 lines
1.3 KiB
PHP

<?php
require_once ( 'lib/php/classes/Database.php' );
function split_uri_array ( ) : Array {
$uri = substr ( $_SERVER [ 'REQUEST_URI' ], strlen ( substr ( $_SERVER [ 'REQUEST_URI' ], 0, strrpos ( $_SERVER [ 'REQUEST_URI' ], 'index.php' ) ) ), strlen ( $_SERVER [ 'REQUEST_URI' ] ) - strlen ( substr ( $_SERVER [ 'REQUEST_URI' ], 0, strrpos ( $_SERVER [ 'REQUEST_URI' ], 'index.php' ) ) ) );
$arr = Array ( );
$last_arg_pos = 0;
if ( substr ( $uri, strlen ( $uri ) - 1, 1 ) == "/" ) {
$uri = substr ( $uri, 0, strlen ( $uri ) - 1 );
}
for ( $i = 1; $i < ( strlen ( $uri ) ) - 1; $i ++ ) {
if ( substr ( $uri, $i, 1 ) == "/" && substr ( $uri, $i + 1, 1 ) != "/" && substr ( $uri, $i - 1, 1 ) != "/" ) {
$arr [ ] = substr ( $uri, $last_arg_pos, $i - $last_arg_pos);
$last_arg_pos = $i + 1;
}
}
$arr [ ] = substr ( $uri, $last_arg_pos, $i - $last_arg_pos + 1);
return $arr;
}
function load_config ( ) : array {
$config = file_get_contents ( 'config.json' );
$config = json_decode ( $config, true );
$config [ 'installation_path' ] = $_SERVER [ 'DOCUMENT_ROOT' ] . $config [ 'installation_path' ];
return $config;
}