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}"); } }
private function redirectToComment($commentId) { $url = ''; $url .= $this->fullPath; $url .= "#comment-{$commentId}"; Loader::loadNew('controller', 'Error303Controller', array($url))->activate(); exit; }
protected function error404() { $controller = '/controller/Error404Controller'; if (file_exists(Loader::getPath('controller', 'Error404Controller'))) { $controller = 'Error404Controller'; } Loader::loadNew('controller', $controller)->activate(); exit; }
private function direct() { $link_map = $this->construct_direct_link_map(); $uri = Request::getServer('REQUEST_URI'); if (array_key_exists($uri, $link_map)) { $controller = Loader::loadNew('controller', $link_map[$uri]); } else { $controller = Loader::loadNew('controller', 'Error404Controller'); } $controller->activate(); }
protected function check_for_special_redirect($uri) { if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { $alias = $matches[1]; $alias = str_replace("'", '', $alias); $alias .= '-falls'; $result = WaterfallCollector::getByOldAlias($alias); if ($result !== null) { return "/{$result->watercourse_alias}/{$result->alias}/"; } else { Loader::loadNew('controller', '/Error404Controller')->activate(); } } if (preg_match('@^/photos/([a-z\'-]+)-([^/]+)(/?)$@', $uri, $matches)) { $alias = $matches[1]; $alias = explode('-', $alias); array_pop($alias); $alias = implode('-', $alias); $alias = str_replace("'", '', $alias); $alias .= '-falls'; $result = WaterfallCollector::getByOldAlias($alias); if ($result !== null) { return "/{$result->watercourse_alias}/{$result->alias}/"; } else { Loader::loadNew('controller', '/Error404Controller')->activate(); } } if (preg_match('@/log/([a-z]+-\\d{2}-\\d{4})(/?)$@', $uri, $matches)) { $date = $matches[1]; $date = explode('-', $date); $date = mktime(0, 0, 0, date('n', strtotime($date[0])), $date[1], $date[2]); $date = date('Y-m-d', $date); $result = LogCollector::getByDate($date); if ($result !== null) { return "/journal/{$result->alias}/"; } else { Loader::loadNew('controller', '/Error404Controller')->activate(); } } if (preg_match('@/map/([a-z\'-]+)(/?)$@', $uri, $matches)) { $alias = $matches[1]; $alias = str_replace("'", '', $alias); $alias .= '-falls'; $result = WaterfallCollector::getByOldAlias($alias); if ($result !== null) { return "/map/#{$result->watercourse_alias}/{$result->alias}"; } else { Loader::loadNew('controller', '/Error404Controller')->activate(); } } return $uri; }
protected function check_for_special_redirect($uri) { if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) { global $container; $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); $post = $repository->findPostByPath($matches[2]); if(!$post) { Loader::loadNew('controller', '/Error404Controller') ->activate(); } Loader::load('utility', 'Content'); $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); } else { $post_uri = URLDecode::getPiece(1); if($post_uri !== null) { global $container; $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); $post = $repository->findPostByPath($post_uri); if($post != false) { Loader::load('utility', 'Content'); $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); } } } if($uri == '/search/') { if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) { $uri .= Request::getGet('search'); $uri .= '/'; } } return $uri; }
protected function loadController($controller, $args = array(), $class = null) { Debugger::log("CONTROLLER: <span style=\"color:#4882c0;\">{$controller}"); return Loader::loadNew('controller', $controller, $args, $class); }
function __construct() { parent::__construct(); Config::set('HideDebugger', true); $this->captcha = Loader::loadNew('utility', 'captcha/Captcha'); }
final protected function check_for_redirect($redirect_uri) { foreach($this->get_redirect_array() as $check) { $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); } $redirect_uri = $this->check_for_special_redirect($redirect_uri); if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') $redirect_uri .= '/'; if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; } if($redirect_uri == URLDecode::getURI()) return; $controller_check = $redirect_uri; if(substr($redirect_uri, 0, 4) == 'http') { $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); } $controller = $this->get_controller($controller_check); if($controller == '/Error404Controller') { Loader::loadNew('controller', '/Error404Controller') ->activate(); exit; } if(substr($redirect_uri, 0, 4) != 'http') { $redirect_uri = substr($redirect_uri, 1); $redirect_uri = URLDecode::getBase() . $redirect_uri; } Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) ->activate(); }
protected function eject() { Loader::loadNew('controller', 'Error404Controller')->activate(); }
function loadRouter($router, $args = array(), $class = null) { $this->router = Loader::loadNew('utility', "router/sites/{$router}", $args, $class); }
<?php return; include_once 'utility/Loader.class.inc.php'; error_reporting(-1); date_default_timezone_set('America/Chicago'); Loader::setRoot(dirname(__FILE__)); Loader::load('model', array('DataObject', 'DataCollection')); Loader::load('mutator', 'Mutator'); Loader::loadNew('utility', 'Router');
protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) { if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') { $parameters = array($site_id, $path, $redirect_url, $page_title); $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); } return; }