<commit_before><?php
    /**
     * Class: Route
     * Holds information for URLs, redirecting, etc.
     */
    class Route {
        # String: $action
        # The current action.
        public $action = "";

        # Array: $try
        # An array of (string) actions to try until one doesn't return false.
        public $try = array();

        # Boolean: $ajax
        # Shortcut to the AJAX constant (useful for Twig).
        public $ajax = AJAX;

        # Boolean: $success
        # Did <Route.init> call a successful route?
        public $success = false;

        # Variable: $controller
        # The Route's Controller.
        public $controller;

        /**
         * Function: __construct
         * Parse the URL and to determine what to do.
         *
         * Parameters:
         *     $controller - The controller to use.
         */
        private function __construct($controller) {
            $this->controller = $controller;

            $config = Config::current();

            $this->action =& $_GET['action'];

            if (isset($_GET['feed']))
                $this->feed = true;

            # Parse the current URL and extract information.
            $parse = parse_url($config->url);
            fallback($parse["path"], "/");

            if (isset($controller->base))
                $parse["path"] = trim($parse["path"], "/")."/".trim($controller->base, "/")."/";

            $this->safe_path = str_replace("/", "\\/", $parse["path"]);
            $this->request = $parse["path"] == "/" ?
                                 $_SERVER['REQUEST_URI'] :
                                 preg_replace("/{$this->safe_path}?/", "", $_SERVER['REQUEST_URI'], 1) ;
            $this->arg = array_map("urldecode", explode("/", trim($this->request, "/")));

            if (method_exists($controller, "parse"))
                $controller->parse($this);

            $this->try[] = isset($this->action) ?
                               oneof($this->action, "index") :
                               (!substr_count($this->arg[0], "?") ?
                                   oneof(@$this->arg[0], "index") :
                                   "index") ;
        }

        /**
         * Function: init
         * Attempt Controller actions until one of them doesn't return false.
         *
         * This will also call the @[controllername]_xxxxx@ and @route_xxxxx@ triggers.
         */
        public function init() {
            $trigger = Trigger::current();

            $trigger->call("route_init", $this);

            $try = $this->try;

            if (isset($this->action))
                array_unshift($try, $this->action);

            $count = 0;
            foreach ($try as $key => $val) {
                if (is_numeric($key))
                    list($method, $args) = array($val, array());
                else
                    list($method, $args) = array($key, $val);

                $this->action = $method;<commit_msg>Fixed view_site access denied error at /login. [#294 state:resolved]<commit_after><?php
    /**
     * Class: Route
     * Holds information for URLs, redirecting, etc.
     */
    class Route {
        # String: $action
        # The current action.
        public $action = "";

        # Array: $try
        # An array of (string) actions to try until one doesn't return false.
        public $try = array();

        # Boolean: $ajax
        # Shortcut to the AJAX constant (useful for Twig).
        public $ajax = AJAX;

        # Boolean: $success
        # Did <Route.init> call a successful route?
        public $success = false;

        # Variable: $controller
        # The Route's Controller.
        public $controller;

        /**
         * Function: __construct
         * Parse the URL and to determine what to do.
         *
         * Parameters:
         *     $controller - The controller to use.
         */
        private function __construct($controller) {
            $this->controller = $controller;

            $config = Config::current();

            $this->action =& $_GET['action'];

            if (isset($_GET['feed']))
                $this->feed = true;

            # Parse the current URL and extract information.
            $parse = parse_url($config->url);
            fallback($parse["path"], "/");

            if (isset($controller->base))
                $parse["path"] = trim($parse["path"], "/")."/".trim($controller->base, "/")."/";

            $this->safe_path = str_replace("/", "\\/", $parse["path"]);
            $this->request = $parse["path"] == "/" ?
                                 $_SERVER['REQUEST_URI'] :
                                 preg_replace("/{$this->safe_path}?/", "", $_SERVER['REQUEST_URI'], 1) ;
            $this->arg = array_map("urldecode", explode("/", trim($this->request, "/")));

            if (method_exists($controller, "parse"))
                $controller->parse($this);

            $this->try[] = isset($this->action) ?
                               oneof($this->action, "index") :
                               (!substr_count($this->arg[0], "?") ?
                                   oneof(@$this->arg[0], "index") :
                                   "index") ;

            # Guess the action initially.
            # This is only required because of the view_site permission;
            # it has to know if they're viewing /login, in which case
            # it should allow the page to display.
            fallback($this->action, end($this->try));
        }

        /**
         * Function: init
         * Attempt Controller actions until one of them doesn't return false.
         *
         * This will also call the @[controllername]_xxxxx@ and @route_xxxxx@ triggers.
         */
        public function init() {
            $trigger = Trigger::current();

            $trigger->call("route_init", $this);

            $try = $this->try;

            if (isset($this->action))
                array_unshift($try, $this->action);

            $count = 0;
            foreach ($try as $key => $val) {
                if (is_numeric($key))
                    list($method, $args) = array($val, array());
                else
                    list($method, $args) = array($key, $val);

                $this->action = $method;
{'fraction_non_alphanumeric': 0.1490506329113924, 'fraction_numerical': 0.001740506329113924, 'mean_word_length': 1.5123211446740858, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7214666', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1599, 'n_words': 420}