<commit_before><?
class Action {
    public static function index() {
        if (!Action::validate()) {
            $_GET['bars'] = 4;
        }
        Response::render('index', $_GET);
    }

    public static function api() {
        if (!Action::validate()) {
            echo "400 Bad Value for Parameter: bars";
            header('status: 400 Bad Request', true, 400);
            exit();
        }

        header('content-type: application/json; charset=utf-8');
        // enable cors if needed
        // header("access-control-allow-origin: *");
        
        $json = json_encode(array(
            "num_bars" => $_GET['bars']
        ));
        if ($callback = $_GET['callback']) {
            echo $callback . '(' . $json . ')';
        } else {
            echo $json;
        }
    }

    private static function validate() {
        $bars = $_GET['bars'];
        if (!(isset($bars) 
            && is_numeric($bars) 
            && $bars > 0
            // probly another number so browser won't crash.
            && $bars < PHP_INT_MAX
            )) {
            return false;
        }
        return true;
    }
}
?><commit_msg>set max number of bars to 49 so that browser won't crash; PHP_INT_MAX is not a good option here.<commit_after><?
class Action {
    public static function index() {
        if (!Action::validate()) {
            $_GET['bars'] = 4;
        }
        Response::render('index', $_GET);
    }

    public static function api() {
        if (!Action::validate()) {
            echo "400 Bad Value for Parameter: bars";
            header('status: 400 Bad Request', true, 400);
            exit();
        }

        header('content-type: application/json; charset=utf-8');
        // enable cors if needed
        // header("access-control-allow-origin: *");
        
        $json = json_encode(array(
            "num_bars" => $_GET['bars']
        ));
        if ($callback = $_GET['callback']) {
            echo $callback . '(' . $json . ')';
        } else {
            echo $json;
        }
    }

    private static function validate() {
        $bars = $_GET['bars'];
        if (!(isset($bars) 
            && is_numeric($bars) 
            && $bars > 0
            // 50 is meaningful than PHP_INT_MAX here.
            && $bars < 50
            )) {
            return false;
        }
        return true;
    }
}
?>
{'fraction_non_alphanumeric': 0.14777497900923595, 'fraction_numerical': 0.012594458438287154, 'mean_word_length': 1.5216931216931218, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1918483', 'n_tokens_mistral': 680, 'n_tokens_neox': 641, 'n_words': 173}