function __construct() { $url = isset($_GET['url']) ? $_GET['url'] : null; $url = rtrim($url, '/'); $url = filter_var($url, FILTER_SANITIZE_URL); $url = explode('/', $_GET['url']); if (empty($url[0])) { require 'app/controllers/index_controller.php'; $controller = new IndexController(); $controller->index(); return false; } else { $controller = $url[0]; } $file = 'app/controllers/' . $url[0] . '_controller.php'; if (file_exists($file)) { require $file; $controller_class = ucfirst($controller) . 'Controller'; $controller = new $controller_class(); $controller->loadModel($url[0]); if (!$url[1]) { $controller->index(); return false; // Check back on this! } } else { require 'app/controllers/error_controller.php'; $controller = new ErrorController(); $controller->notfound(); exit; } if (isset($url[2])) { $arg = $url[2]; } else { $arg = ''; } if (isset($url[1])) { if (method_exists($controller, $url[1])) { $action = $url[1]; if (empty($arg)) { $controller->{$action}(); } else { $controller->{$action}($arg); } } else { require 'app/controllers/error_controller.php'; $controller = new ErrorController(); $controller->notfound(); exit; } } }
function __construct() { $strUrl = isset($_GET['url']) ? $_GET['url'] : null; $strUrl = rtrim($strUrl, '/'); $arrUrl = explode('/', $strUrl); if (empty($arrUrl[0])) { require 'controller/IndexController.php'; $controller = new IndexController(); $controller->index(); return false; } $strCapitalized = $this->capitalize($arrUrl[0]); $strControllerName = $strCapitalized . 'Controller'; $strModelName = $strCapitalized . 'Model'; $file = 'controller/' . $strControllerName . '.php'; if (file_exists($file)) { require $file; } else { require 'controller/ErrorController.php'; $controller = new ErrorController(); return false; } $controller = new $strControllerName(); $controller->loadModel($strModelName); if (isset($arrUrl[2])) { if (method_exists($controller, $arrUrl[1])) { $controller->{$arrUrl[1]}($arrUrl[2]); } else { require 'controller/ErrorController.php'; $controller = new ErrorController(); return false; } } else { if (isset($arrUrl[1])) { if (method_exists($controller, $arrUrl[1])) { $controller->{$arrUrl[1]}(); } else { require 'controller/ErrorController.php'; $controller = new ErrorController(); return false; } } /*} else { $controller->index(); }*/ } }
function __construct() { $url = isset($_GET["url"]) ? $_GET["url"] : NULL; $url = rtrim($url, '/'); $url = explode('/', $url); if (empty($url[0]) || $url[0] == 'index.php') { require 'controller/IndexController.php'; $controller = new IndexController(); $controller->index(); return FALSE; } $file = 'controller/' . $url[0] . 'Controller.php'; if (file_exists($file)) { require $file; } else { require 'controller/ErrorController.php'; $error = new ErrorController(); $error->index(); return FALSE; } $controllerFullName = $url[0] . "Controller"; $controller = new $controllerFullName(); if (isset($url[2])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}($url[2]); } else { require 'controller/ErrorController.php'; $error = new ErrorController(); $error->index(); return FALSE; } } else { if (isset($url[1])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}(); } else { require 'controller/ErrorController.php'; $error = new ErrorController(); $error->index(); return FALSE; } } else { $controller->index(); } } }
<?php include_once 'helper/Helper.php'; include_once 'controller/WarenkorbController.php'; include_once 'controller/IndexController.php'; if (isset($_GET['controller'])) { include_once 'controller/' . $_GET['controller'] . 'Controller.php'; $cname = $_GET['controller'] . 'Controller'; $controller = new $cname(); if (isset($_GET['action'])) { $controller->{$_GET}['action'](); } //$controller->liste(); } else { $controller = new IndexController(); $controller->index(); } //$controller = new RolleController(); //$controller->liste(); /*include_once 'Rolle.php'; include_once 'Account.php'; $rollea = new Rolle(1,'Admin'); $rollek = new Rolle(2,'Kunde'); //echo $rolle->getName(); $accounts = array(); $accounts[] = new Account(1,"Buchs", "Enrico", "ebuchs", "sagichnicht",$rollea); $accounts[] = new Account(2,"Steffen", "Carlos", "mexicho", "mafia",$rollek); foreach($accounts as $account){ var_dump($account);
/** * Starts application by disassembling the URL request and loading the appropriate controller, * invoking the appropriate method and its parameters (if requested) * */ public function __construct() { // disassembles the inbound URL request into its controller, method, and parameter parts $this->getUrlRequest(); /** * Debugging */ // print_var(URL_WITH_INDEX_FILE); $debug = 0; if ($debug == 1) { echobr('Controller'); print_var($this->urlController); echobr('Method'); print_var($this->urlMethod); echobr('Basename'); var_dump(basename($_SERVER['PHP_SELF'])); } /** * Load default controller otherwise load the controller corresponding to the client URL request * */ if (!$this->urlController) { require APP_PATH . 'controllers/IndexController.php'; $webpage = new IndexController(); $webpage->index(); } elseif (file_exists(APP_PATH . 'controllers/' . $this->urlController . '.php')) { // load the controller corresponding to the client URL request require APP_PATH . 'controllers/' . $this->urlController . '.php'; // instantiate the corresponding controller as an object $this->urlController = new $this->urlController(); /** * Invoke the method requested in the url for previously instantiated object, otherwise invoke * default index() method in the controller * */ if (method_exists($this->urlController, $this->urlMethod)) { // debug // var_dump($this->urlController); // var_dump($this->urlMethod); /** * Pass the parameters to the method if they exist otherwise invoke the method without parameters * */ if (!empty($this->urlParameter)) { // invoke the method and pass the parameters $this->urlController->{$this->urlMethod}($this->urlParameter); //debug // echo('<br>' . 'Requested Parameters: ' . $this->urlParameter . '<br>'); } else { $this->urlController->{$this->urlMethod}(); } } else { /** * Invoke the default index() method for the corresponding controller if no method was requested * otherwise redirect client to error page for tampering with the URL request * */ if ($this->urlMethod == null) { // invoke default index() method $this->urlController->index(); } else { // redirect to error page // echo "REQUESTED METHOD DOES NOT EXIST"; } } } else { // echo "TEST: " . $this->urlController; // redirect to error page // echo "CATASTROPHIC ERROR"; } }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ include_once "includes/sp-load.php"; include_once SP_CTRLPATH . "/index.ctrl.php"; include_once SP_CTRLPATH . "/directory.ctrl.php"; $controller = new IndexController(); $controller->view->menu = 'home'; if ($_SERVER['REQUEST_METHOD'] == 'GET') { switch ($_GET['sec']) { case "news": include_once SP_CTRLPATH . "/information.ctrl.php"; $infoCtrler = new InformationController(); $infoCtrler->showNews($_GET); break; default: $controller->index($_GET); break; } } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { switch ($_POST['sec']) { default: $controller->index($_POST); break; } }
<?php /** * init.php contains the spl_autoloader function which loads all the classes, the controller and the sanitize function. * The controller is then called which initiates the data request from ProductSourceData class. */ require_once 'core/init.php'; IndexController::index();
<?php if (isset($_GET['c']) && isset($_GET['m'])) { require_once "app/controller/{$_GET['c']}.php"; ${$_GET}['c'] = new $_GET['c'](); ${$_GET}['c']->{$_GET}['m'](); } else { require_once 'app/controller/IndexController.php'; $indexController = new IndexController(); $indexController->index(); }
* * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ include_once "includes/sp-load.php"; include_once SP_CTRLPATH . "/index.ctrl.php"; include_once SP_CTRLPATH . "/directory.ctrl.php"; $controller = new IndexController(); $controller->view->menu = 'home'; if ($_SERVER['REQUEST_METHOD'] == 'GET') { switch ($_GET['sec']) { case "news": $controller->showNews($_GET); break; default: $controller->index($_GET); break; } }