<commit_before><?php

//Burden, Copyright <NAME> (http://github.com/joshf/Burden)

if (!file_exists("../config.php")) {
    die("Error: Config file not found! Please reinstall Burden.");
}

require_once("../config.php");

session_start();
if (!isset($_SESSION["burden_user"])) {
    header("Location: ../login.php");
    exit; 
}

//Connect to database
@$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$con) {
    die("Error: Could not connect to database (" . mysql_error() . "). Check your database settings are correct.");
}

mysql_select_db(DB_NAME, $con);

//Set variables
$task = mysql_real_escape_string($_POST["task"]);
$category = strtolower(mysql_real_escape_string($_POST["category"]));
$priority = mysql_real_escape_string($_POST["priority"]);
$due = mysql_real_escape_string($_POST["due"]);

//Failsafes
if (empty($task) || empty($due)) {
    header("Location: ../add.php?error=emptyfields");
    exit;
}

//Get new ID
$getlasttasknumber = mysql_query("SELECT MAX(id) FROM Data");
$resultgetlasttasknumber = mysql_fetch_assoc($getlasttasknumber);
$id = ($resultgetlasttasknumber["MAX(id)"] + 1);

//Check if ID exists
$checkid = mysql_query("SELECT id FROM Data WHERE id = \"$id\"");
$resultcheckid = mysql_fetch_assoc($checkid); 
if ($resultcheckid != 0) {
    header("Location: ../add.php?error=idexists");
    exit;
}

if (isset($_POST["highpriority"])) {
    $highpriority = "1";
} else {
    $highpriority = "0";
}

mysql_query("INSERT INTO Data (id, category, highpriority, task, due, completed)
VALUES (\"$id\",\"$category\",\"$highpriority\",\"$task\",\"$due\",\"0\")");

mysql_close($con);

header("Location: ../index.php");

exit;

?><commit_msg>Change another check to use mysql_num_rows<commit_after><?php

//Burden, Copyright <NAME> (http://github.com/joshf/Burden)

if (!file_exists("../config.php")) {
    die("Error: Config file not found! Please reinstall Burden.");
}

require_once("../config.php");

session_start();
if (!isset($_SESSION["burden_user"])) {
    header("Location: ../login.php");
    exit; 
}

//Connect to database
@$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$con) {
    die("Error: Could not connect to database (" . mysql_error() . "). Check your database settings are correct.");
}

mysql_select_db(DB_NAME, $con);

//Set variables
$task = mysql_real_escape_string($_POST["task"]);
$category = strtolower(mysql_real_escape_string($_POST["category"]));
$priority = mysql_real_escape_string($_POST["priority"]);
$due = mysql_real_escape_string($_POST["due"]);

//Failsafes
if (empty($task) || empty($due)) {
    header("Location: ../add.php?error=emptyfields");
    exit;
}

//Get new ID
$getlasttasknumber = mysql_query("SELECT MAX(id) FROM Data");
$resultgetlasttasknumber = mysql_fetch_assoc($getlasttasknumber);
$id = ($resultgetlasttasknumber["MAX(id)"] + 1);

//Check if ID exists
$checkid = mysql_query("SELECT id FROM Data WHERE id = \"$id\"");
if (mysql_num_rows($checkid) != 0) {
    header("Location: ../add.php?error=idexists");
    exit;
}

if (isset($_POST["highpriority"])) {
    $highpriority = "1";
} else {
    $highpriority = "0";
}

mysql_query("INSERT INTO Data (id, category, highpriority, task, due, completed)
VALUES (\"$id\",\"$category\",\"$highpriority\",\"$task\",\"$due\",\"0\")");

mysql_close($con);

header("Location: ../index.php");

exit;

?>
{'fraction_non_alphanumeric': 0.20238805970149254, 'fraction_numerical': 0.0029850746268656717, 'mean_word_length': 5.182656826568266, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1015869', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1142, 'n_words': 239}