示例#1
0
/**
 * Dissect the URL and route the request.
 */
function callHook()
{
    $controller = CShell::id();
    $action = 'home';
    $queryString = array();
    try {
        //Remove all get parameters
        $URI = preg_replace('/\\?(.*)/', '', $_SERVER['REQUEST_URI']);
        $urlArray = explode("/", str_replace('-', '_', $URI));
        //The first segment will always be empty
        if (count($urlArray) > 0) {
            array_shift($urlArray);
        }
        if (count($urlArray) > 0 && $urlArray[0] != '') {
            //Ignore the sub-folder if it exists.
            if (PageTool::getSubFolder() != '') {
                array_shift($urlArray);
            }
            /**
             * If an exception is triggered or the dc is set to false set the controller.
             */
            if (count($urlArray) > 0 && (in_array($urlArray[0], CShell::exceptions()) || in_array($urlArray[0], CShell::system()) || !CShell::default_controller())) {
                $controller = $urlArray[0];
                array_shift($urlArray);
            }
            //Set the action.
            if (count($urlArray) > 0) {
                //If GoLink skip assignment of action.
                if ($controller != CShell::GO) {
                    $action = $urlArray[0];
                    array_shift($urlArray);
                }
                //Set the arguments
                if (count($urlArray) > 0) {
                    $queryString = $urlArray;
                }
            }
        }
        $controllerName = $controller;
        $controller = ucwords($controller);
        $controller .= 'Controller';
        if (file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . $controller . '.php')) {
            require_once ROOT . DS . 'app' . DS . 'controllers' . DS . $controller . '.php';
        } elseif (file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . 'system' . DS . $controller . '.php')) {
            require_once ROOT . DS . 'app' . DS . 'controllers' . DS . 'system' . DS . $controller . '.php';
        }
        if (class_exists($controller) && method_exists($controller, $action)) {
            $dispatch = new $controller($controllerName, $action);
        } else {
            header('HTTP/1.0 404 Not Found');
            exit;
        }
        call_user_func_array(array($dispatch, $action), $queryString);
    } catch (Exception $e) {
        SystemTool::sendException($e->getFile(), $e->getMessage(), $e->getTraceAsString());
    }
}
 public static function sendException($file, $message, $trace)
 {
     $body = "<html><body>\n";
     $body .= "<h3>{$file}</h3><p>{$message}</p><p><pre>{$trace}</pre></p>";
     $body .= "</body></html>\n";
     $alt = strip_tags($body);
     $creds = ["from" => self::getWebmasterEmail(), "name" => self::getWebmasterEmail(), "reply" => self::getWebmasterEmail(), "subject" => ENV . '-' . CShell::id() . " Webinar Error", "category" => CShell::id()];
     SystemTool::sendEmail($creds, SystemTool::getWebmasterEmail(), $body, $alt);
 }
示例#3
0
 /**
  * @param string $page
  * @param array $pages
  * @return string
  */
 public static function getVersion($page, $pages)
 {
     $version = CShell::id() . '_' . $page;
     if (isset($pages[$page]["cookies"])) {
         $cookies = $pages[$page]["cookies"];
         for ($i = 0; $i < count($cookies); $i++) {
             if (isset($_COOKIE[$cookies[$i]])) {
                 $version .= '_' . $cookies[$i];
             }
         }
     }
     return $version;
 }
示例#4
0
 function __construct($action)
 {
     $this->page = strtolower(CShell::id()) . DS . $action . '.html.twig';
 }