<commit_before><?php

/*
The user's umask is ignored for the user running php, so we need
to set it from inside of php to make sure the group read & execute
permissions aren't lost for newly created files & directories. We do this
here as every working file must include functions.php to actuall work.
*/
umask (0027);


use \lib\AutoLoader;
use \lib\Database;
use \lib\ExceptionHandler;
use \lib\Logger;
use \app\models\User;

// get our sweet autoloader!
include __DIR__ . "/../lib/AutoLoader.php";
AutoLoader::registerDirectory(AutoLoader::getPathToRoot(getcwd())."lib", true, "lib");
AutoLoader::registerDirectory(AutoLoader::getPathToRoot(getcwd())."app", true, "app");

$start_time = microtime_float();

////////////////////////////////////////////////////////////////////////////////////////////////////////
// INCLUDES
////////////////////////////////////////////////////////////////////////////////////////////////////////

if (isset($_GET['course'])) {
    $config = __DIR__."/configs/".$_GET['course'].".php";
    if (!file_exists($config)) {
        die("Fatal Error: The config for course=#### does not exist");
    }
}
else {
    die("Fatal Error: You must use course=#### in the URL bar");
}

require_once("configs/master.php");
require_once($config);

$DEBUG = (defined('__DEBUG__')) ? (__DEBUG__): false;
ExceptionHandler::$debug = $DEBUG;
ExceptionHandler::$logExceptions = __LOG_EXCEPTIONS__;
Logger::$log_path = __LOG_PATH__;<commit_msg>Don't allow '/' in $_GET['course'] to prevent potential injections<commit_after><?php

/*
The user's umask is ignored for the user running php, so we need
to set it from inside of php to make sure the group read & execute
permissions aren't lost for newly created files & directories. We do this
here as every working file must include functions.php to actuall work.
*/
umask (0027);


use \lib\AutoLoader;
use \lib\Database;
use \lib\ExceptionHandler;
use \lib\Logger;
use \app\models\User;

// get our sweet autoloader!
include __DIR__ . "/../lib/AutoLoader.php";
AutoLoader::registerDirectory(AutoLoader::getPathToRoot(getcwd())."lib", true, "lib");
AutoLoader::registerDirectory(AutoLoader::getPathToRoot(getcwd())."app", true, "app");

$start_time = microtime_float();

////////////////////////////////////////////////////////////////////////////////////////////////////////
// INCLUDES
////////////////////////////////////////////////////////////////////////////////////////////////////////

if (isset($_GET['course'])) {
    // don't allow the user entered course to potentially point to a different directory via use of ../
    $_GET['course'] = str_replace("/","_",$_GET['course']);
    $config = __DIR__."/configs/".$_GET['course'].".php";
    if (!file_exists($config)) {
        die("Fatal Error: The config for the specified course '{$_GET['course']}' does not exist");
    }
}
else {
    die("Fatal Error: You must use course=#### in the URL bar");
}

require_once("configs/master.php");
require_once($config);

$DEBUG = (defined('__DEBUG__')) ? (__DEBUG__): false;
ExceptionHandler::$debug = $DEBUG;
ExceptionHandler::$logExceptions = __LOG_EXCEPTIONS__;
Logger::$log_path = __LOG_PATH__;
{'fraction_non_alphanumeric': 0.2664556962025316, 'fraction_numerical': 0.002531645569620253, 'mean_word_length': 2.6002277904328017, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3730600', 'n_tokens_mistral': 883, 'n_tokens_neox': 855, 'n_words': 259}