$controller = ucwords($controller); $model = rtrim($controller, 's'); $controller .= 'Controller'; $dispatch = new $controller($model, $controllerName, $action); if ((int) method_exists($controller, $action)) { call_user_func_array(array($dispatch, $action), $queryString); } else { /* Error Generation Code Here */ } } /** Autoload any classes that are required **/ function __autoload($className) { if (file_exists(ROOT . DS . 'library' . DS . strtolower($className) . '.class.php')) { require_once ROOT . DS . 'library' . DS . strtolower($className) . '.class.php'; } else { if (file_exists(ROOT . DS . 'application' . DS . 'controllers' . DS . strtolower($className) . '.php')) { require_once ROOT . DS . 'application' . DS . 'controllers' . DS . strtolower($className) . '.php'; } else { if (file_exists(ROOT . DS . 'application' . DS . 'models' . DS . strtolower($className) . '.php')) { require_once ROOT . DS . 'application' . DS . 'models' . DS . strtolower($className) . '.php'; } else { /* Error Generation Code Here */ } } } } setReporting(); removeMagicQuotes(); unregisterGlobals(); callHook();
define('ADMIN_QUESTIONS', ADMIN_MODULES . 'questions/'); define('ADMIN_USERS', ADMIN_MODULES . 'users/'); define('ADMIN_VIDEOS', ADMIN_MODULES . 'videos/'); define('AUTHENTICATION_MOD', MODULES . 'authentication/'); define('AUTHORIZATION_MOD', MODULES . 'authorization/'); define('CATEGORIES_MOD', MODULES . 'categories/'); define('HOME_MOD', MODULES . 'home/'); define('PROFILE_MOD', MODULES . 'profile/'); define('REGISTRATION_MOD', MODULES . 'signup/'); define('WATCH_VIDEO_MOD', MODULES . 'video_watch/'); define('UTILS', LIB . 'utils/'); define('INTERFACES', UTILS . 'interfaces/'); define('VIDEO_UPLOAD_MOD', MODULES . 'video_upload/'); define('VIDEO_SEARCH_MOD', MODULES . 'search/'); define('TMP_VIDEO', LIB . 'tmp_video/'); setReporting(true); ////ALWAYS SET THIS TO 'FALSE' BEFORE DEPLOYING /** AutoLoad class files as soon as needed ***/ spl_autoload_register('loadClass'); include_once CONFIG . 'settings.php'; $registry = new Registry(); Factory::getRegistry($registry); Factory::getParameters($parameters); //parameter is defined in the settings file // URI will always be of the form /specific_path $request = $_SERVER["REQUEST_URI"]; $path = explode("/", $request); $controller_obj = null; switch ($path[1]) { case '': $controller_obj = new HomeController($path, $registry);