Primo Commit
This commit is contained in:
31
config/getPage.inc.php
Normal file
31
config/getPage.inc.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
// Rileva se l'utente sta usando un dispositivo mobile
|
||||
function isMobile() {
|
||||
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
|
||||
}
|
||||
|
||||
// Recupera l'URL richiesto
|
||||
$request_uri = $_SERVER['REQUEST_URI'];
|
||||
$path = substr(urldecode($request_uri), strlen($base_path));
|
||||
$path = parse_url($path, PHP_URL_PATH);
|
||||
$path = trim($path, '/');
|
||||
|
||||
// Rimuovi parametri GET dall'URL se presenti
|
||||
if (strpos($path, '?') !== false) {
|
||||
$path = substr($path, 0, strpos($path, '?'));
|
||||
}
|
||||
|
||||
$path_parts = explode('/', $path);
|
||||
|
||||
// Rimuovi index.php dall'URL se presente
|
||||
if (isset($path_parts[0]) && $path_parts[0] == 'index.php') {
|
||||
array_shift($path_parts);
|
||||
}
|
||||
|
||||
// Determina la pagina da mostrare in base all'URL
|
||||
$page = isset($path_parts[0]) && !empty($path_parts[0]) ? $path_parts[0] : 'home';
|
||||
$param = isset($path_parts[1]) && !empty($path_parts[1]) ? $path_parts[1] : '';
|
||||
|
||||
// Debug (rimuovi in produzione)
|
||||
error_log("Page: $page, Param: $param, Path: $path");
|
||||
Reference in New Issue
Block a user