<commit_before><?php
require_once('./includes/loader.php');

$sAction = preg_replace('/[^\w\d]/', '', $_GET['action']);

/*
 * If activation email/id is empty, redirect back to index
 */

if (empty($_GET['email']) || empty($_GET['id'])) die(header("Location: index.php", 401));

/*
 * See if an activation code exists for the given email/id
 */

$sEmail = preg_replace('/[^\w\d_\._@+]/', '', $_GET['email']);
$iID    = abs((int) $_GET['id']);

$sActivate = $database->CachedQuery("SELECT * FROM accounts WHERE (`password` = -1 AND `email_address` = :EmailAddress AND `activation_code` = :ActivationCode) || (`email_address` = :EmailAddress AND `forgot` = :ActivationCode)", array('EmailAddress' => $sEmail, 'ActivationCode' => $iID));

/*
 * Redirect to index if there's no need to activate
 */

if (empty($sActivate)) die(header("Location: index.php", 403));


/*
 * Process activation
 */

if ($sAction == 'save')
{
  if (sha1($_POST['password']) == sha1($_POST['passwordagain']))
  {
    $sUser = new User($sActivate->data[0]['id']);
    $sChange = $sUser->change_password($sUser, $_POST['password'], $_POST['passwordagain']);
  } else {
    $sErrors[] = array('Errors' => 'Password and confirmation do not match.');
  }
  if (is_array($sChange))
  {
	$sErrors[] = array("Errors" => $sChange);
  } else {
    die(header("Location: index.php"));
  }
}

/*
 * Display activation result page
 */

echo Templater::AdvancedParse(
       $sTemplate->sValue.'/activate',
	   $locale->strings,
	   array(
	     'Errors'	=> $sErrors,
		 'Id'		=> $iID,
		 'Email'	=> $sEmail
	   )
	 );<commit_msg>fixed activation id filtering, changed type to string<commit_after><?php
require_once('./includes/loader.php');

$sAction = preg_replace('/[^\w\d]/', '', $_GET['action']);

/*
 * If activation email/id is empty, redirect back to index
 */

if (empty($_GET['email']) || empty($_GET['id'])) die(header("Location: index.php", 401));

/*
 * See if an activation code exists for the given email/id
 */

$sEmail = preg_replace('/[^\w\d_\._@+]/', '', $_GET['email']);
$sID    = preg_replace('/[^\w\d_]/', '', $_GET['id']);

$sActivate = $database->CachedQuery("SELECT * FROM accounts WHERE (`password` = -1 AND `email_address` = :EmailAddress AND `activation_code` = :ActivationCode) || (`email_address` = :EmailAddress AND `forgot` = :ActivationCode)", array('EmailAddress' => $sEmail, 'ActivationCode' => $sID));

/*
 * Redirect to index if there's no need to activate
 */

if (empty($sActivate)) die(header("Location: index.php", 403));


/*
 * Process activation
 */

if ($sAction == 'save')
{
  if (sha1($_POST['password']) == sha1($_POST['passwordagain']))
  {
    $sUser = new User($sActivate->data[0]['id']);
    $sChange = $sUser->change_password($sUser, $_POST['password'], $_POST['passwordagain']);
  } else {
    $sErrors[] = array('Errors' => 'Password and confirmation do not match.');
  }
  if (is_array($sChange))
  {
	$sErrors[] = array("Errors" => $sChange);
  } else {
    die(header("Location: index.php"));
  }
}

/*
 * Display activation result page
 */

echo Templater::AdvancedParse(
       $sTemplate->sValue.'/activate',
	   $locale->strings,
	   array(
	     'Errors'	=> $sErrors,
		 'Id'		=> $sID,
		 'Email'	=> $sEmail
	   )
	 );
{'fraction_non_alphanumeric': 0.2165998148719531, 'fraction_numerical': 0.006170934896636841, 'mean_word_length': 4.237479806138934, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7179846', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1083, 'n_words': 245}