<commit_before><?php
    /**
     * Class: AjaxController
     * The logic controlling AJAX requests.
     */
    class AjaxController implements Controller {
        # Boolean: $clean
        # Does this controller support clean URLs?
        public $clean = false;

        # Boolean: $feed
        # Is the current page a feed?
        public $feed = false;

        # String: $base
        # The base path for this controller.
        public $base = "ajax";

        /**
         * Function: parse
         * Route constructor calls this to determine the action in the case of a POST request.
         */
        public function parse($route) {
            if (empty($route->action) and isset($_POST['action']))
                return $route->action = $_POST['action'];

            if (!isset($route->action))
                error(__("Error"), __("Missing argument."), null, 400);
        }

        /**
         * Function: exempt
         * Route constructor calls this to determine "view_site" exemptions.
         */
        public function exempt($action) {
            return false;
        }

        /**
         * Function: ajax_destroy_post
         * Destroys a post.
         */
        public function ajax_destroy_post() {
            if (!isset($_POST['hash']) or !authenticate($_POST['hash']))
                show_403(__("Access Denied"), __("Invalid authentication token."));

            if (empty($_POST['id']) or !is_numeric($_POST['id']))
                error(__("No ID Specified"), __("An ID is required to delete a post."), null, 400);

            $post = new Post($_POST['id'], array("drafts" => true));

            if ($post->no_results)<commit_msg>AjaxController: check request header Sec-Fetch-Site<commit_after><?php
    /**
     * Class: AjaxController
     * The logic controlling AJAX requests.
     */
    class AjaxController implements Controller {
        # Boolean: $clean
        # Does this controller support clean URLs?
        public $clean = false;

        # Boolean: $feed
        # Is the current page a feed?
        public $feed = false;

        # String: $base
        # The base path for this controller.
        public $base = "ajax";

        /**
         * Function: parse
         * Route constructor calls this to determine the action in the case of a POST request.
         */
        public function parse($route) {
            if (isset($_SERVER['HTTP_SEC_FETCH_SITE']) and $_SERVER['HTTP_SEC_FETCH_SITE'] != "same-origin")
                show_403();

            if (empty($route->action) and isset($_POST['action']))
                return $route->action = $_POST['action'];

            if (!isset($route->action))
                error(__("Error"), __("Missing argument."), null, 400);
        }

        /**
         * Function: exempt
         * Route constructor calls this to determine "view_site" exemptions.
         */
        public function exempt($action) {
            return false;
        }

        /**
         * Function: ajax_destroy_post
         * Destroys a post.
         */
        public function ajax_destroy_post() {
            if (!isset($_POST['hash']) or !authenticate($_POST['hash']))
                show_403(__("Access Denied"), __("Invalid authentication token."));

            if (empty($_POST['id']) or !is_numeric($_POST['id']))
                error(__("No ID Specified"), __("An ID is required to delete a post."), null, 400);

            $post = new Post($_POST['id'], array("drafts" => true));

            if ($post->no_results)
{'fraction_non_alphanumeric': 0.12895033860045146, 'fraction_numerical': 0.005925507900677201, 'mean_word_length': 1.9200988467874793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2201428', 'n_tokens_mistral': 946, 'n_tokens_neox': 878, 'n_words': 279}