function activate()
 {
     $setup = Config::get('RPC');
     $class = URL::getPathPart($setup['class']);
     $method = URL::getPathPart($setup['method']);
     list($action, $type) = explode('.', URL::getPathPart($setup['action']), 2);
     $path = $setup["path"] . "/" . $class . "/" . ucwords($method) . ucwords($action) . "Controller";
     if (file_exists(Loader::getPath("controller", $path))) {
         Debugger::log("CONTROLLER: <span style=\"color: #990000\">" . ucwords($method) . ucwords($action) . "Controller</span>");
         $controller = Loader::loadNew("controller", $path);
         $controller->activate();
         if (is_callable(array($controller, $type))) {
             echo $controller->{$type}();
         }
         return;
     }
     $controller_class = ucwords($class) . ucwords($method) . ucwords($action) . "Controller";
     Debugger::log("CONTROLLER: <span style=\"color: #990000\">{$controller_class}</span>");
     if (file_exists(Loader::getPath("controller", "{$setup['path']}/{$controller_class}"))) {
         $controller = Loader::loadNew("controller", "{$setup['path']}/{$controller_class}");
         $controller->activate();
     } else {
         Loader::load("utility", "Server");
         $ip = Server::getIP();
         $self = Server::getSelf();
         Debugger::log("Possible RPC Injection: RPC call to non-existent controller at path {$setup["path"]}/{$controller_class} {$ip} {$self}");
         error_log("Possible RPC Injection: RPC call to non-existent controller at path {$setup['path']}/{$controller_class} {$ip} {$self}");
     }
 }
Ejemplo n.º 2
0
 /**
  * Get layout path
  *
  * @param $layout
  * @return string
  */
 private function getLayoutPath($layout)
 {
     $segments = explode('\\', get_class($this));
     $path_to_pkg = \Loader::getPath(array_shift($segments));
     $view_dir_name = str_replace('Controller', '', array_pop($segments));
     return realpath($path_to_pkg . '/views/' . $view_dir_name . '/' . $layout . '.php');
 }
 protected function error404()
 {
     $controller = '/controller/Error404Controller';
     if (file_exists(Loader::getPath('controller', 'Error404Controller'))) {
         $controller = 'Error404Controller';
     }
     Loader::loadNew('controller', $controller)->activate();
     exit;
 }
Ejemplo n.º 4
0
 /**
  * Render full path to $layout. Finally '/var/www/mindkblog.com/src/Blog/views/Post/index.html.php'.
  *
  * @param $layout
  * @param null $data
  * @return Response
  */
 public function render($layout, $data = null)
 {
     $controller_class = get_class($this);
     $segments = explode('\\', $controller_class);
     $root_namespace = array_shift($segments);
     $path_to_pkg = \Loader::getPath($root_namespace);
     $ctrl = array_pop($segments);
     $view_dir_name = str_replace('Controller', '', $ctrl);
     $layout_full_path = realpath($path_to_pkg . '/views/' . $view_dir_name . '/' . $layout . '.php');
     $renderer = new Renderer($layout_full_path, $data);
     $response = new Response($renderer->render());
     return $response;
 }
Ejemplo n.º 5
0
function detect_fatal_error()
{
    $last_error = error_get_last();
    if ($last_error && ($last_error['type'] == E_ERROR || $last_error['type'] == E_PARSE) && class_exists('Loader')) {
        try {
            Loader::load('utility', 'Template');
            if (file_exists(Loader::getPath('view', 'FatalError'))) {
                Debugger::log("Type {$last_error["type"]}: {$last_error["message"]} in {$last_error["file"]} on line {$last_error["line"]}");
                ob_clean();
                header('HTTP/1.1 503 Service Temporarily Unavailable');
                header('Status: 503 Service Temporarily Unavailable');
                Template::insert('FatalError');
                error_log("[Error Caught] {$last_error['message']} in {$last_error['file']} on line {$last_error['line']}");
                ob_end_flush();
            }
        } catch (Exception $e) {
            //echo "We've encountered an error. Please go back and try again.";
        }
    }
}
Ejemplo n.º 6
0
 static function getControllerFromUrl($url = null)
 {
     if (!isset($url)) {
         $url = self::getCurrent();
     }
     $url = self::parsePath($url);
     $controller = self::findDynamicPath($url);
     if (!$controller) {
         $controller = self::findParamPath($url);
     }
     if (!$controller) {
         $controller = self::findStaticPath($url);
     }
     if (!$controller) {
         $controller = '/controller/Error404Controller';
         if (file_exists(Loader::getPath('controller', 'Error404Controller'))) {
             $controller = 'Error404Controller';
         }
     }
     if (substr($controller, 0, 10) == 'redirect=>') {
         $controller = self::parseRedirect($url, $controller);
     }
     return $controller;
 }
 static function insert($view_file, $args = array())
 {
     extract($args);
     include Loader::getPath('view', $view_file);
 }