1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| if ( $_SERVER['REQUEST_URI'] == '/' ) $page = 'home';
else {
$page = substr($_SERVER['REQUEST_URI'], 1);
if ( !preg_match('/^[A-z0-9]{3,15}$/', $page) ) not_found();
}
$CONNECT = mysqli_connect('localhost', 'root', '', 'db');
//if ( !$CONNECT ) exit('MySQL error');
session_start();
if ( file_exists('all/'.$page.'.php') ) include 'all/'.$page.'.php';
else if ( $_SESSION['id'] and file_exists('auth/'.$page.'.php') ) include 'auth/'.$page.'.php';
else if ( !$_SESSION['id'] and file_exists('guest/'.$page.'.php') ) include 'guest/'.$page.'.php';
else if ( $_SESSION['admin'] and file_exists('admin/'.$page.'.php') ) include 'admin/'.$page.'.php' |
Partager