<commit_before><?php
$page['auth'] = 5;
require "include/functions.inc";
require "include/mysql.inc";
?>
<html>
    <head>
        <title>Points Submitted</title>
        <?php include "include/head.inc"; ?>
    </head>
    <body>
        <?php
        require "include/header.inc";
        $errormsg = null;
        do {
            $quantity = filter_input(INPUT_POST, 'quantity', FILTER_SANITIZE_NUMBER_INT);
            if (!isset($_POST['code']) || empty($_POST['code']) || strlen($_POST['code']) < 4 || strlen($_POST['code']) > 5) {
                $errormsg = "Error: CODE is not set!";
                break;
            }
            if (!isset($quantity) || empty($quantity)) {
                $errormsg = "Error: QUANTITY is not set!";
                break;
            }
            if ($quantity > 20 || $quantity < 0) {
                $errormsg = "Error: QUANTITY out of range [1-20]! $quantity";
                break;
            }
            if ($_POST['multiple'] !== "on" && !isset($_POST['awardedto'])) {
                $errormsg = "Error: AWARDEDTO is not set!";
                break;
            }
            if ($_POST['multiple'] == "on") {
                $awardto = split(",", $_POST['awardedtomultiple']);
                for ($i = 0; $i < count($awardto); $i++) {
                    $awardto[$i] = trim($awardto[$i]);
                    if (!valid_net_id($awardto[$i]))
                        continue;
                    $query = sprintf("INSERT INTO `$mysql_db`.`points_awarded` (`pointid`, `timestamp`, `awardedto`, `code`, `quantity`, `awardedby`, `comments`) VALUES "
                            . "(NULL, CURRENT_TIMESTAMP, '%s', '%s', '%d', '%s', '%s');", mysql_escape_string($awardto[$i]), mysql_escape_string($_POST['code']), intval($quantity), mysql_escape_string($_SESSION['user']), mysql_escape_string($_POST['comments']));
                    $result = mysql_query($query) or ( $errormsg = ('Invalid query: ' . mysql_error()));
                }
            } else {
                $query = sprintf("INSERT INTO `$mysql_db`.`points_awarded` (`pointid`, `timestamp`, `awardedto`, `code`, `quantity`, `awardedby`, `comments`) VALUES "
                        . "(NULL, CURRENT_TIMESTAMP, '%s', '%s', '%d', '%s', '%s');", mysql_escape_string($_POST['awardedto']), mysql_escape_string($_POST['code']), intval($quantity), mysql_escape_string($_SESSION['user']), mysql_escape_string($_POST['comments']));
                $result = mysql_query($query) or ( $errormsg = ('Invalid query: ' . mysql_error()));
            }
        } while (false);
        ?>
        <form id="awardpts" action="submitaward.php" method="POST" ><commit_msg>fixed errors with add multiple points<commit_after><?php
$page['auth'] = 5;
require "include/functions.inc";
require "include/mysql.inc";
?>
<html>
    <head>
        <title>Points Submitted</title>
        <?php include "include/head.inc"; ?>
    </head>
    <body>
        <?php
        require "include/header.inc";
        $errormsg = null;
        do {
            $quantity = filter_input(INPUT_POST, 'quantity', FILTER_SANITIZE_NUMBER_INT);
            if (!isset($_POST['code']) || empty($_POST['code']) || strlen($_POST['code']) < 4 || strlen($_POST['code']) > 5) {
                $errormsg = "Error: CODE is not set!";
                break;
            }
            if (!isset($quantity) || empty($quantity)) {
                $errormsg = "Error: QUANTITY is not set!";
                break;
            }
            if ($quantity > 20 || $quantity < 0) {
                $errormsg = "Error: QUANTITY out of range [1-20]! $quantity";
                break;
            }
            if ($_POST['multiple'] !== "on" && !isset($_POST['awardedto'])) {
                $errormsg = "Error: AWARDEDTO is not set!";
                break;
            }
            if ($_POST['multiple'] == "on") {
                $awardto = split(",", $_POST['awardedtomultiple']);
                for ($i = 0; $i < count($awardto); $i++) {
                    $awardto[$i] = trim($awardto[$i]);
                    if (!valid_net_id($awardto[$i]) || empty($awardto[$i]))
                        continue;
                    $query = sprintf("INSERT INTO `$mysql_db`.`points_awarded` (`pointid`, `timestamp`, `awardedto`, `code`, `quantity`, `awardedby`, `comments`) VALUES "
                            . "(NULL, CURRENT_TIMESTAMP, '%s', '%s', '%d', '%s', '%s');", mysql_escape_string($awardto[$i]), mysql_escape_string($_POST['code']), intval($quantity), mysql_escape_string($_SESSION['user']), mysql_escape_string($_POST['comments']));
                    $result = mysql_query($query) or ( $errormsg = ('Invalid query: ' . mysql_error()));
                }
            } else {
                $query = sprintf("INSERT INTO `$mysql_db`.`points_awarded` (`pointid`, `timestamp`, `awardedto`, `code`, `quantity`, `awardedby`, `comments`) VALUES "
                        . "(NULL, CURRENT_TIMESTAMP, '%s', '%s', '%d', '%s', '%s');", mysql_escape_string($_POST['awardedto']), mysql_escape_string($_POST['code']), intval($quantity), mysql_escape_string($_SESSION['user']), mysql_escape_string($_POST['comments']));
                $result = mysql_query($query) or ( $errormsg = ('Invalid query: ' . mysql_error()));
            }
        } while (false);
        ?>
        <form id="awardpts" action="submitaward.php" method="POST" >
{'fraction_non_alphanumeric': 0.1888745148771022, 'fraction_numerical': 0.0036961744594344852, 'mean_word_length': 2.248499399759904, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, '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': '457276', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1600, 'n_words': 328}