<commit_before><?php
namespace MCPI;

/**
 * Core Controller
 *  - Routes the entire app
 */
class Core_Controller extends Core_Controller_Abstract
{
    static public function route()
    {
        Login_Controller::redirect('/login');
        $code_dir = opendir(DIR_CODE);
        while ($dir = readdir($code_dir))
        {
            if (in_array($dir, ['.','..']) or !is_dir(DIR_CODE . DS . $dir)) continue;
            $file_path = DIR_CODE . DS . $dir . DS . 'controller.php';
            if (is_file($file_path))
            {
                require_once($file_path);
            }
        }
        $response = self::getResponse();
        $response->body = 'Unable to find valid route';
        $response->setCode('404');
        $response->finalize();
    }
}<commit_msg>Fix routing - no longer dependant on alpha-order<commit_after><?php
namespace MCPI;

/**
 * Core Controller
 *  - Routes the entire app
 */
class Core_Controller extends Core_Controller_Abstract
{
    static public function route()
    {
        Login_Controller::redirect('/login');

        // Start with _index controller
        $file_path = DIR_CODE . DS . '_index' . DS . 'controller.php';
        if (is_file($file_path))
        {
            require_once($file_path);
        }

        $code_dir = opendir(DIR_CODE);
        while ($dir = readdir($code_dir))
        {
            if (in_array($dir, ['.','..','_index']) or !is_dir(DIR_CODE . DS . $dir)) continue;
            $file_path = DIR_CODE . DS . $dir . DS . 'controller.php';
            if (is_file($file_path))
            {
                require_once($file_path);
            }
        }
        $response = self::getResponse();
        $response->body = 'Unable to find valid route';
        $response->setCode('404');
        $response->finalize();
    }
}
{'fraction_non_alphanumeric': 0.14301430143014301, 'fraction_numerical': 0.0033003300330033004, 'mean_word_length': 2.021594684385382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4199557', 'n_tokens_mistral': 546, 'n_tokens_neox': 535, 'n_words': 118}