26 lines
1.2 KiB
PHP
26 lines
1.2 KiB
PHP
<?php
|
|
require_once ( 'lib/php/classes/Database.php' );
|
|
function split_uri_array ( string $php_self, string $request_uri ) : Array {
|
|
$uri = substr ( $request_uri, strlen ( substr ( $php_self, 0, strrpos ( $php_self, 'index.php' ) ) ), strlen ( $request_uri ) - strlen ( substr ( $php_self, 0, strrpos ( $php_self, '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;
|
|
}
|
|
?>
|