<commit_before><?php
$tage=count($_POST['Dienstplan']);
foreach (array_keys($_POST['Dienstplan']) as $tag => $value) {
  $date = filter_var($_POST['Dienstplan'][$tag]['Datum'][0], FILTER_SANITIZE_STRING);
  /*
  if ($tage == 1) { $period="day"; }
  elseif ($tage > 1 and $tage <= 7){ $period="week";}
  elseif ($tage > 15 and $tage <= 31){ $period="month";}
  else {
  //unknown period of time.
  }
  */
  if (filter_has_var(INPUT_POST, 'submit_approval')) {
    $state="approved";
  } elseif (filter_has_var(INPUT_POST, 'submit_disapproval')) {
    $state="disapproved";
  } else {
    //no state is given.
    // TODO: This is an Exception. Should we fail fast and loud?
    die ("An Error has occurred during approval!");
  }
  //The variable $user is set within the default.php
  $abfrage="INSERT INTO `approval` (date, branch, state, user) values ('$date', '$mandant', '$state', '$user') ON DUPLICATE KEY UPDATE date='$date', branch='$mandant', state='$state', user='$user'";
  $ergebnis = mysqli_query_verbose($abfrage);
}<commit_msg>security: filter user input<commit_after><?php

$Dienstplan = filter_input(INPUT_POST, 'Dienstplan', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY);
$tage = count($Dienstplan);
foreach (array_keys($Dienstplan) as $tag => $value) {
    if (empty($Dienstplan[$tag]['Datum'][0])) {
        continue;
    }
    $date = $Dienstplan[$tag]['Datum'][0];
    if (filter_has_var(INPUT_POST, 'submit_approval')) {
        $state = "approved";
    } elseif (filter_has_var(INPUT_POST, 'submit_disapproval')) {
        $state = "disapproved";
    } else {
        //no state is given.
        // TODO: This is an Exception. Should we fail fast and loud?
        die("An Error has occurred during approval!");
    }
    //The variable $user is set within the default.php
    $abfrage = "INSERT INTO `approval` (date, branch, state, user) values ('$date', '$mandant', '$state', '$user') ON DUPLICATE KEY UPDATE date='$date', branch='$mandant', state='$state', user='$user'";
    $ergebnis = mysqli_query_verbose($abfrage);
}
{'fraction_non_alphanumeric': 0.1787109375, 'fraction_numerical': 0.0048828125, 'mean_word_length': 4.349869451697128, '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': '1738848', 'n_tokens_mistral': 712, 'n_tokens_neox': 705, 'n_words': 178}