foreach (glob('controllers/*.*') as $filename) { #get controller name preg_match('~\\/(.*?)\\.~', $filename, $output); $filename = '/' . $filename; #create controller array $aControllers[$output[1]] = $filename; } # Check if the controller exist in the controller aray (see above) if (array_key_exists($sControllerRequest, $aControllers)) { $sControllerPath = $aControllers[$sControllerRequest]; } else { /* * Check if class could exists * Then search for a matching page in the Database * if a pageControllerPath is found, take this one for displaying */ if (classCouldBeLoaded('PageManager')) { $sControllerPath = PageManager::getControllerPathByUrlPath(getCurrentUrlPath()); } # Path found? GO if (empty($sControllerPath) && !empty($sControllerRequest)) { # non existing controller request and page showHttpError(404); } } # Check if the file excist if (file_exists(DOCUMENT_ROOT . $sControllerPath)) { include_once DOCUMENT_ROOT . $sControllerPath; } else { showHttpError(404); }