4a6630bacb
Moved database function in class "Database"; Corrected database-using webpages accordingly; Moved config file from PHP to JSON with more config variables; Corrected login page redirection on wrong username or password.
23 lines
1.1 KiB
PHP
23 lines
1.1 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;
|
|
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;
|
|
}
|
|
?>
|