<commit_before><?php

namespace Nelliel;

use \PDO;
if (!defined('NELLIEL_VERSION'))
{
    die("NOPE.AVI");
}

class Reports
{
    private $dbh;

    function __construct()
    {
        $this->dbh = nel_database();
    }

    public function collectReportedContent()
    {
        $report_data = array();
        $report_data['board_id'] = (isset($_GET['board_id'])) ? $_GET['board_id'] : null;
        $report_data['reason'] = (isset($_POST['report_reason'])) ? $_POST['report_reason'] : null;
        $report_data['reporter_ip'] = $_SERVER['REMOTE_ADDR'];

        foreach ($_POST as $input)
        {
            $sub = explode('_', $input, 2);

            if($sub[0] == 'deletefile' || $sub[0] == 'deletethread' || $sub[0] == 'deletepost' )
            {
                $report_data['content_id'] = $sub[1];
                $this->addReport($report_data);
            }
        }
    }

    public function addReport($report_data)
    {
        $query = 'INSERT INTO "' . REPORTS_TABLE . '" ("board_id", "content_id", "reason", "reporter_ip") VALUES (?, ?, ?, ?)';
        $prepared = $this->dbh->prepare($query);
        $this->dbh->executePrepared($prepared, array($report_data['board_id'], $report_data['content_id'], $report_data['reason'], $report_data['reporter_ip']));
    }
}
<commit_msg>Encode reporter IP before putting in database<commit_after><?php

namespace Nelliel;

use \PDO;
if (!defined('NELLIEL_VERSION'))
{
    die("NOPE.AVI");
}

class Reports
{
    private $dbh;

    function __construct()
    {
        $this->dbh = nel_database();
    }

    public function collectReportedContent()
    {
        $report_data = array();
        $report_data['board_id'] = (isset($_GET['board_id'])) ? $_GET['board_id'] : null;
        $report_data['reason'] = (isset($_POST['report_reason'])) ? $_POST['report_reason'] : null;
        $report_data['reporter_ip'] = $_SERVER['REMOTE_ADDR'];

        foreach ($_POST as $input)
        {
            $sub = explode('_', $input, 2);

            if($sub[0] == 'deletefile' || $sub[0] == 'deletethread' || $sub[0] == 'deletepost' )
            {
                $report_data['content_id'] = $sub[1];
                $this->addReport($report_data);
            }
        }
    }

    public function addReport($report_data)
    {
        $query = 'INSERT INTO "' . REPORTS_TABLE . '" ("board_id", "content_id", "reason", "reporter_ip") VALUES (?, ?, ?, ?)';
        $prepared = $this->dbh->prepare($query);
        $this->dbh->executePrepared($prepared, array($report_data['board_id'], $report_data['content_id'], $report_data['reason'], @inet_pton($report_data['reporter_ip'])));
    }
}

{'fraction_non_alphanumeric': 0.19056603773584907, 'fraction_numerical': 0.0037735849056603774, 'mean_word_length': 2.8814055636896048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '658247', 'n_tokens_mistral': 895, 'n_tokens_neox': 866, 'n_words': 140}