<commit_before><?php
require_once dirname(__FILE__).'/accesscheck.php';

if (TEST) {
  print $GLOBALS['I18N']->get('default login is')." admin, ".$GLOBALS['I18N']->get('with password')." phplist";
}

$page = '';
if (isset($_GET['page']) && $_GET["page"]) {
  $page = $_GET["page"];
  if (!is_file($page.".php") || $page == "logout") {
    $page = $GLOBALS['homepage'];
  }
} else {
  $page = $GLOBALS['homepage'];
}
if (!isset($GLOBALS['msg'])) $GLOBALS['msg'] = '';
?>
<?php echo $GLOBALS['msg']?>


<script language="Javascript" type="text/javascript">
//<![CDATA[
if (!navigator.cookieEnabled) {
  document.writeln('<div class="error"><?php echo $GLOBALS['I18N']->get('In order to login, you need to enable cookies in your browser')?><\/div>');
}
//]]>
</script>
<?php
function footer(){
  echo '<form method="post" id="forgotpassword-form" action="">';
  echo '  <hr width="50%" size="3"/><p class="login">';
  echo $GLOBALS['I18N']->get('Forgot password').':';
  echo $GLOBALS['I18N']->get('Enter your email address').': <input type="text" name="forgotpassword" value="" size="30" />';
  echo '  <input class="submit" type="submit" name="process" value="'.$GLOBALS['I18N']->get('Send password').'" />';
  echo '</p></form>';
}

#Delete from the DB every token older than certain elapsed time.
function deleteOldTokens(){
#  echo "<script>alert('".PASSWORD_CHANGE_TIMEFRAME."');</script>";
  //DELETE FROM phplist_admin_password_request WHERE date_add( date, INTERVAL 1 year ) < now( )  
  $SQLquery = sprintf('delete from %s where date_add( date, INTERVAL %s) < now( )', $GLOBALS['tables']['admin_password_request'], PASSWORD_CHANGE_TIMEFRAME);
  $query = Sql_Query($SQLquery);
}

//if (ENCRYPT_PASSWORDS) {
  if (isset($_POST['password1']) && isset($_POST['password2'])) {
    $SQLquery = sprintf('select date, admin from %s where key_value = "%s" and admin = %d', $GLOBALS['tables']['admin_password_request'],sql_escape($_GET['token']),$_POST['admin']);
    $tokenData = Sql_Fetch_Row_Query($SQLquery);
    $p1 = $_POST['password1'];
    $p2 = $_POST['password2'];
    $adminId = $tokenData[1];
    $SQLquery=sprintf("select loginname from %s where id = %d;", $GLOBALS['tables']['admin'], $adminId);
    $adminData = Sql_Fetch_Row_Query($SQLquery);
    $admin = $adminData[0];
    if ($p1 == $p2 && !empty($admin)) {
      #Database update.
      if (ENCRYPT_ADMIN_PASSWORDS) {
        $SQLquery=sprintf("update %s set password='%s', passwordchanged=now() where loginname = '%s';", $GLOBALS['tables']['admin'], md5($p1), $admin);
      }
      else {
        $SQLquery=sprintf("update %s set password='%s', passwordchanged=now() where loginname = '%s';", $GLOBALS['tables']['admin'], sql_escape($p1), $admin);<commit_msg>cosmetic<commit_after><?php
require_once dirname(__FILE__).'/accesscheck.php';

if (TEST) {
  print $GLOBALS['I18N']->get('default login is')." admin, ".$GLOBALS['I18N']->get('with password')." phplist";
}

$page = '';
if (isset($_GET['page']) && $_GET["page"]) {
  $page = $_GET["page"];
  if (!is_file($page.".php") || $page == "logout") {
    $page = $GLOBALS['homepage'];
  }
} else {
  $page = $GLOBALS['homepage'];
}
if (!isset($GLOBALS['msg'])) $GLOBALS['msg'] = '';
?>
<?php echo $GLOBALS['msg']?>


<script language="Javascript" type="text/javascript">
//<![CDATA[
if (!navigator.cookieEnabled) {
  document.writeln('<div class="error"><?php echo $GLOBALS['I18N']->get('In order to login, you need to enable cookies in your browser')?><\/div>');
}
//]]>
</script>
<?php
function footer(){
  echo '<form method="post" id="forgotpassword-form" action="">';
  echo '  <hr width="50%" size="3"/><p class="login">';
  echo $GLOBALS['I18N']->get('Forgot password').' ';
  echo $GLOBALS['I18N']->get('Enter your email address').': <input type="text" name="forgotpassword" value="" size="30" />';
  echo '  <input class="submit" type="submit" name="process" value="'.$GLOBALS['I18N']->get('Send password').'" />';
  echo '</p></form>';
}

#Delete from the DB every token older than certain elapsed time.
function deleteOldTokens(){
#  echo "<script>alert('".PASSWORD_CHANGE_TIMEFRAME."');</script>";
  //DELETE FROM phplist_admin_password_request WHERE date_add( date, INTERVAL 1 year ) < now( )  
  $SQLquery = sprintf('delete from %s where date_add( date, INTERVAL %s) < now( )', $GLOBALS['tables']['admin_password_request'], PASSWORD_CHANGE_TIMEFRAME);
  $query = Sql_Query($SQLquery);
}

//if (ENCRYPT_PASSWORDS) {
  if (isset($_POST['password1']) && isset($_POST['password2'])) {
    $SQLquery = sprintf('select date, admin from %s where key_value = "%s" and admin = %d', $GLOBALS['tables']['admin_password_request'],sql_escape($_GET['token']),$_POST['admin']);
    $tokenData = Sql_Fetch_Row_Query($SQLquery);
    $p1 = $_POST['password1'];
    $p2 = $_POST['password2'];
    $adminId = $tokenData[1];
    $SQLquery=sprintf("select loginname from %s where id = %d;", $GLOBALS['tables']['admin'], $adminId);
    $adminData = Sql_Fetch_Row_Query($SQLquery);
    $admin = $adminData[0];
    if ($p1 == $p2 && !empty($admin)) {
      #Database update.
      if (ENCRYPT_ADMIN_PASSWORDS) {
        $SQLquery=sprintf("update %s set password='%s', passwordchanged=now() where loginname = '%s';", $GLOBALS['tables']['admin'], md5($p1), $admin);
      }
      else {
        $SQLquery=sprintf("update %s set password='%s', passwordchanged=now() where loginname = '%s';", $GLOBALS['tables']['admin'], sql_escape($p1), $admin);
{'fraction_non_alphanumeric': 0.2265639332232618, 'fraction_numerical': 0.011374059805540267, 'mean_word_length': 5.444444444444445, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 49, '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': '3725659', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1853, 'n_words': 399}