Refactored the website

Renamed "includes" to "templates"
Added .htaccess to redirect requests to index.php
Added function to split request URL into array
Corrected locations in scripts and pages
This commit is contained in:
Bryan Pedini committed 2019-02-07 12:36:44 +01:00
1 parent 9210890eda
commit 7acb2ca533
8 files changed
+173 -138

No files matched your search

+13
View File
@@ -24,4 +24,17 @@
die ( "Execute failed: (" . $statement->errno . ") " . $statement->error );
}
}
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;
}
?>