class Core { public function __construct(){ $this->pageNotFound = '404.php'; if( !array_key_exists( "loggedin", $_SESSION ) ) { $_SESSION['loggedin'] = 0; } $this->loggedin = $_SESSION['loggedin']; // Set default role to 'public' if it's not already set if (!isset($_SESSION['role'])) { $_SESSION['role'] = 'public'; } // List of valid roles $validRoles = ['administrator', 'fan', 'public']; // Assign role from session if valid, otherwise set to 'public' $this->role = in_array($_SESSION['role'], $validRoles) ? $_SESSION['role'] : 'public'; // Update the session if the role was invalid $_SESSION['role'] = $this->role; } public function router() { // Parse the URL to get the segments $url = trim($_SERVER['REQUEST_URI'], '/'); $urlSegments = explode('/', $url); // Assuming URL format: shows/[showname]/[episodename] $base = $urlSegments[0] ?? null; $showName = $urlSegments[1] ?? null; $episodeName = $urlSegments[2] ?? null; if ($base === 'shows') { if ($showName && $episodeName) { // Load the Watch page for the specific episode $this->loadWatchPage($showName, $episodeName); } elseif ($showName) { // Load the Show page for the specific show $this->loadShowPage($showName); } else { // Load the Home page $this->loadHomePage(); } } else { // Load the pageNotFound page require_once($this->pageNotFound); } } // Define the methods to load specific pages private function loadHomePage() { // Logic for loading the home page } private function loadShowPage($showName) { // Logic for loading a specific show page } private function loadWatchPage($showName, $episodeName) { // Logic for loading the watch page for an episode } }