<commit_before><?php

namespace PHPFusion;

use PHPFusion\Database\DatabaseFactory;

class Errors {

    private static $instances = array();

    public $no_notice = 0;

    public $compressed = 0;

    private $error_status = '';

    private $posted_error_id = '';

    private $delete_status = '';

    private $rows = 0;

    private $rowstart = '';

    private $error_id = '';

    private $errors = array();

    private $new_errors = array();

    private $locale = array();

    public static function getInstance($key = 'default') {

        if (!isset(self::$instances[$key])) {
            self::$instances[$key] = new static();
        }
        return self::$instances[$key];

    }

    public function __construct() {

        if (empty($this->locale)) {
            global $locale;
            include LOCALE.LOCALESET."admin/errors.php";
            include LOCALE.LOCALESET."errors.php";
            $this->locale += $locale;
        }

        $this->error_status = filter_input(INPUT_POST, 'error_status', FILTER_VALIDATE_INT, array('min_range' => 0, 'max_range' => 2));

        $this->posted_error_id = filter_input(INPUT_POST, 'error_id', FILTER_VALIDATE_INT);

        $this->delete_status = filter_input(INPUT_POST, 'delete_status', FILTER_VALIDATE_INT, array('min_range' => 0, 'max_range' => 2));

        $this->rowstart = filter_input(INPUT_GET, 'rowstart', FILTER_VALIDATE_INT) ? : 0;

        $this->error_id = filter_input(INPUT_GET, 'error_id', FILTER_VALIDATE_INT);

        if (isnum($this->error_status) && $this->posted_error_id) {
            dbquery("UPDATE ".DB_ERRORS." SET error_status='".$this->error_status."' WHERE error_id='".$this->posted_error_id."'");
            redirect(FUSION_REQUEST);
        }

        if (isset($_POST['delete_entries']) && isnum($this->delete_status)) {
            dbquery("DELETE FROM ".DB_ERRORS." WHERE error_status='".$_POST['delete_status']."'");
            redirect(FUSION_REQUEST);
        }

        if (isset($_POST['delete_all_logs'])) {
            dbquery("DELETE FROM ".DB_ERRORS);
            redirect(FUSION_REQUEST);
        }

        $result = dbquery("SELECT * FROM ".DB_ERRORS." ORDER BY error_timestamp DESC LIMIT ".$this->rowstart.",20");
        while ($data = dbarray($result)) {
            $this->errors[$data['error_id']] = $data;
        }

        $this->rows = $this->errors ? dbcount('(error_id)', DB_ERRORS) : 0;

    }<commit_msg>Test patch #638 - Delete error logs in SEO mode.<commit_after><?php

namespace PHPFusion;

use PHPFusion\Database\DatabaseFactory;

class Errors {

    private static $instances = array();

    public $no_notice = 0;

    public $compressed = 0;

    private $error_status = '';

    private $posted_error_id = '';

    private $delete_status = '';

    private $rows = 0;

    private $rowstart = '';

    private $error_id = '';

    private $errors = array();

    private $new_errors = array();

    private $locale = array();

    public static function getInstance($key = 'default') {

        if (!isset(self::$instances[$key])) {
            self::$instances[$key] = new static();
        }
        return self::$instances[$key];

    }

    public function __construct() {

        if (empty($this->locale)) {
            global $locale;
            include LOCALE.LOCALESET."admin/errors.php";
            include LOCALE.LOCALESET."errors.php";
            $this->locale += $locale;
        }

        $this->error_status = filter_input(INPUT_POST, 'error_status', FILTER_VALIDATE_INT, array('min_range' => 0, 'max_range' => 2));

        $this->posted_error_id = filter_input(INPUT_POST, 'error_id', FILTER_VALIDATE_INT);

        $this->delete_status = filter_input(INPUT_POST, 'delete_status', FILTER_VALIDATE_INT, array('min_range' => 0, 'max_range' => 2));

        $this->rowstart = filter_input(INPUT_GET, 'rowstart', FILTER_VALIDATE_INT) ? : 0;

        $this->error_id = filter_input(INPUT_GET, 'error_id', FILTER_VALIDATE_INT);

        if (isnum($this->error_status) && $this->posted_error_id) {
            dbquery("UPDATE ".DB_ERRORS." SET error_status='".$this->error_status."' WHERE error_id='".$this->posted_error_id."'");
            redirect(FUSION_REQUEST);
        }

        if (isset($_POST['delete_entries']) && isnum($this->delete_status)) {
            dbquery("DELETE FROM ".DB_ERRORS." WHERE error_status='".$_POST['delete_status']."'");
            redirect(FUSION_REQUEST);
        }

        if (isset($_POST['delete_all_logs'])) {
            dbquery("DELETE FROM ".DB_ERRORS);
            redirect((fusion_get_settings("site_seo") ? fusion_get_settings("siteurl") : "").FUSION_REQUEST);
        }

        $result = dbquery("SELECT * FROM ".DB_ERRORS." ORDER BY error_timestamp DESC LIMIT ".$this->rowstart.",20");
        while ($data = dbarray($result)) {
            $this->errors[$data['error_id']] = $data;
        }

        $this->rows = $this->errors ? dbcount('(error_id)', DB_ERRORS) : 0;

    }
{'fraction_non_alphanumeric': 0.1580108281531983, 'fraction_numerical': 0.005013033888109084, 'mean_word_length': 2.887763055339049, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '7375259', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1525, 'n_words': 286}