$value) { if (strlen($value) > MAX_POST_LENGTH) die('the length of some of the $_POST values is too large'); } } } function checkRequestUriLength() { if (MAX_REQUEST_URI_LENGTH !== 0) { if (strlen($_SERVER['REQUEST_URI']) > MAX_REQUEST_URI_LENGTH) die('the length of the REQUEST_URI is too large'); } } function checkRegisterGlobals() { if (ini_get('register_globals')) die('register globals is on: easyGiant works only with register globals off'); } function callHook() { if (MOD_REWRITE_MODULE === true) { $url = isset($_GET['url']) ? $_GET['url'] : DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION; } else { $url = (strcmp(getQueryString(),"") !== 0) ? getQueryString() : DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION; } //rewrite the URL // if (Route::$rewrite === 'yes') // { // $url = rewrite($url); // } // echo $url; $urlArray = array(); $urlArray = explode("/",$url); $controller = DEFAULT_CONTROLLER; $action = DEFAULT_ACTION; if (isset($urlArray[0])) { $controller = (strcmp($urlArray[0],'') !== 0) ? strtolower(trim($urlArray[0])) : DEFAULT_CONTROLLER; } array_shift($urlArray); if (isset($urlArray[0])) { $action = (strcmp($urlArray[0],'') !== 0) ? strtolower(trim($urlArray[0])) : DEFAULT_ACTION; } //set ERROR_CONTROLLER and ERROR_ACTION $errorController = ERROR_CONTROLLER !== false ? ERROR_CONTROLLER : DEFAULT_CONTROLLER; $errorAction = ERROR_ACTION !== false ? ERROR_ACTION : DEFAULT_ACTION; /* VERIFY THE ACTION NAME */ if (method_exists('Controller', $action) or !ctype_alnum($action) or (strcmp($action,'') === 0)) { $controller = $errorController; $action = $errorAction; $urlArray = array(); } /* VERIFY THE CONTROLLER NAME */ if (!ctype_alnum($controller) or (strcmp($controller,'') === 0)) { $controller = $errorController; $action = $errorAction; $urlArray = array(); } //check that the controller class belongs to the application/controllers folder //otherwise set the controller to the default controller if (!file_exists(ROOT.DS.APPLICATION_PATH.DS.'Controllers'.DS.ucwords($controller).'Controller.php')) { $controller = $errorController; $action = $errorAction; $urlArray = array(); } //set the controller class to DEFAULT_CONTROLLER if it doesn't exists if (!class_exists(ucwords($controller).'Controller')) { $controller = $errorController; $action = $errorAction; $urlArray = array(); } //set the action to DEFAULT_ACTION if it doesn't exists if (!method_exists(ucwords($controller).'Controller', $action)) { $controller = $errorController; $action = $errorAction; $urlArray = array(); } /* CHECK COUPLES CONTROLLER,ACTION */ if (!in_array('all',Route::$allowed)) { $couple = "$controller,$action"; if (!in_array($couple,Route::$allowed)) { $controller = $errorController; $action = $errorAction; $urlArray = array(); } } array_shift($urlArray); $queryString = $urlArray; //set the name of the application $application = $controller; $controller = ucwords($controller); $model = $controller; $controller .= 'Controller'; $model .= 'Model'; //include the file containing the set of actions to carry out before the initialization of the controller class Hooks::load(ROOT . DS . APPLICATION_PATH . DS . 'Hooks' . DS . 'BeforeInitialization.php'); if (class_exists($controller)) { $dispatch = new $controller($model,$application,$queryString); //pass the action to the controller object $dispatch->action = $action; $dispatch->currPage = $dispatch->baseUrl.'/'.$dispatch->controller.'/'.$dispatch->action; //require the file containing the set of actions to carry out after the initialization of the controller class Hooks::load(ROOT . DS . APPLICATION_PATH . DS . 'Hooks' . DS . 'AfterInitialization.php'); $templateFlag= true; if (method_exists($controller, $action)) { //pass the action to the theme object $dispatch->theme->action = $action; $dispatch->theme->currPage = $dispatch->baseUrl.'/'.$dispatch->controller.'/'.$dispatch->action; call_user_func_array(array($dispatch,$action),$queryString); } else { $templateFlag= false; } if ($templateFlag) { $dispatch->theme->render(); } } else { echo "