<commit_before><commit_msg>Added changing passwords<commit_after><?php
  session_start();
  include 'auth/AuthFunctions.php';
  include 'config.php';
  
  if(!isset($_SESSION["username"])){
    header('Location: ./');
  }
  if(!isset($_POST["OldPassword"]) || !isset($_POST["NewPassword"])){
    header('Location: ./show_error.php?e=Please%20enter%20your%20old%20password%20and%20new%20password');
    exit;
  }
  $username = $_SESSION["username"];
  $password_hash = GetHashForName($username);
  if(!isset($password_hash)){
    header('Location: ./show_error.php?e=No%20hash%20found');
    exit;
  }

  if(password_verify($_POST["OldPassword"], $password_hash)){
    ReplaceNameHash($_SESSION["username"], password_hash($_POST["NewPassword"], PASSWORD_BCRYPT));
    header('Location: ./');
    exit;
  }else{
    header('Location: ./show_error.php?e=Invalid%20Password');
    exit;
  }
?>
{'fraction_non_alphanumeric': 0.19460067491563554, 'fraction_numerical': 0.02249718785151856, 'mean_word_length': 5.742424242424242, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '321986', 'n_tokens_mistral': 303, 'n_tokens_neox': 288, 'n_words': 34}