Example #1
0
 private function checkUrlIsValid($url)
 {
     $a_url = explode("/", $url);
     $a_webroot = explode("/", Settings::getItem('webroot'));
     //Se a quantidade de parametros passados na url forem igual a 2 (controller e metodo), verifica se o caminho existe, senão é false
     if (count($a_url) - (count($a_webroot) - 1) == 2) {
         $DirectoryIterator = new RecursiveDirectoryIterator(CONTROLLER_PATH);
         $IteratorIterator = new RecursiveIteratorIterator($DirectoryIterator);
         while ($IteratorIterator->valid()) {
             if (!$IteratorIterator->isDot()) {
                 if (strpos($IteratorIterator->getFileName(), ucfirst($a_url[1]) . "Controller") !== false) {
                     if (method_exists(ucfirst($a_url[1]) . "Controller", $a_url[2])) {
                         return true;
                     }
                 }
             }
             $IteratorIterator->next();
         }
     }
     return false;
 }