コード例 #1
0
ファイル: index.php プロジェクト: selenus/dataserver
$params = (require 'config/routes.inc.php');
if (!$params || !isset($params['controller']) || $params['controller'] == 404) {
    header("HTTP/1.0 404 Not Found");
    include 'errors/404.php';
    return;
}
// Parse variables from router
$controllerName = ucwords($params['controller']);
$action = !empty($params['action']) ? $params['action'] : lcfirst($controllerName);
$directory = !empty($params['directory']) ? $params['directory'] . '/' : "";
$extra = !empty($params['extra']) ? $params['extra'] : array();
// Attempt to load controller
$controllerFile = Z_ENV_CONTROLLER_PATH . $directory . $controllerName . 'Controller.php';
Z_Core::debug($_SERVER['REQUEST_METHOD'] . " to " . Z_ENV_SELF);
Z_Core::debug("Controller is {$controllerFile}");
if (file_exists($controllerFile)) {
    require 'mvc/Controller.inc.php';
    require $controllerFile;
    $controllerClass = $controllerName . 'Controller';
    $controller = new $controllerClass($controllerName, $action, $params);
    $controller->init($extra);
    if (method_exists($controllerClass, $action)) {
        call_user_func(array($controller, $action));
        Z_Core::exitClean();
    } else {
        throw new Exception("Action '{$action}' not found in {$controllerFile}");
    }
}
// If controller not found, load error document
header("HTTP/1.0 404 Not Found");
include 'errors/404.php';
コード例 #2
0
ファイル: SyncController.php プロジェクト: selenus/dataserver
 private function error($httpCode = 500, $code, $message = false, $attributes = array(), $elements = array())
 {
     header("Content-Type: text/xml");
     if ($httpCode) {
         header("HTTP/1.1 " . $httpCode);
     }
     $this->responseXML->error['code'] = $code;
     if ($message) {
         $this->responseXML->error = $message;
     }
     foreach ($attributes as $attr => $val) {
         $this->responseXML->error[$attr] = $val;
     }
     foreach ($elements as $name => $val) {
         $this->responseXML->{$name} = $val;
     }
     $xmlstr = $this->responseXML->asXML();
     // Strip XML declaration, since it will be added automatically when in XML mode
     $xmlstr = preg_replace("/<\\?xml.+?>\n/", '', $xmlstr);
     echo $xmlstr;
     $this->logRequestTime();
     Z_Core::exitClean();
 }