I would really appreciate your feedback because I want my websites as good as possible, thanks!
Download here (http://ge.tt/85L4mpK/v/0) or see below:
index.php
<?php //Check if something is requested if (!empty($_GET['u'])){ if (!preg_match('/^([\/a-zA-Z0-9._])+$/', $_GET['u'])){ //Potential hacker, GTFO! header('Location: /error/404'); exit; } else{ $var = explode("/", strip_tags($_GET['u'])); } } //Set url to GET variable if available, else set it to Home $url = !empty($var[0]) ? $var[0] : 'home'; //Set dynamic variables $a1 = !empty($var[1]) ? $var[1] : false; $a2 = !empty($var[2]) ? $var[2] : false; $a3 = !empty($var[3]) ? $var[3] : false; //Check if .php page exists. if (file_exists('inc/'.$url.'.php')) { require_once 'inc/'.$url.'.php'; //Store the loaded page into a variable $page = new $url($a1,$a2,$a3); } else{ //Page not found, 404 header('Location: /error/404'); exit; } require_once 'design.php'; ?>design.php
<?php $title = isset($page->title) ? $page->title : ucfirst($url); echo '<!DOCTYPE html> <html> <head> <title>'.$title.'</title> <base href="http://'.$_SERVER['HTTP_HOST'].'/" /> </head> <body> '.$page->html.' </body> </html> '; ?>inc/error.php
<?php class error { public $html; public $title; function __construct($error) { //Check if error ID is valid if (!is_numeric($error)){ header('Location: /error/404'); exit; } else{ //Error ID is valid $this->html .= '<h1>'.$error.'</h1><br/><br/>'; switch ($error) { case 404: //Not found $this->title = 'Error: 404'; $this->html .= 'Page not found.'; break; default: header('Location: /error/404'); exit; } } } } ?>inc/home.php
<?php class home { public $html; public $title; function __construct() { $this->title = 'Home'; $this->html .= 'Welcome!'; } } ?>.htaccess
RewriteBase / Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?u=$1 [QSA,L]