diff -r e3d7322305bf -r 5e1f1e916419 punbb/login.php
--- a/punbb/login.php Sun Sep 02 11:00:57 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,229 +0,0 @@
-escape($form_username).'\'' : 'LOWER(username)=LOWER(\''.$pun_db->escape($form_username).'\')';
-
- $result = $pun_db->query('SELECT id, group_id, password, save_pass FROM '.$pun_db->prefix.'users WHERE '.$username_sql) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
- list($user_id, $group_id, $db_password_hash, $save_pass) = $pun_db->fetch_row($result);
-
- $authorized = false;
-
- if (!empty($db_password_hash))
- {
- $sha1_in_db = (strlen($db_password_hash) == 40) ? true : false;
- $sha1_available = (function_exists('sha1') || function_exists('mhash')) ? true : false;
-
- $form_password_hash = pun_hash($form_password); // This could result in either an SHA-1 or an MD5 hash (depends on $sha1_available)
-
- if ($sha1_in_db && $sha1_available && $db_password_hash == $form_password_hash)
- $authorized = true;
- else if (!$sha1_in_db && $db_password_hash == md5($form_password))
- {
- $authorized = true;
-
- if ($sha1_available) // There's an MD5 hash in the database, but SHA1 hashing is available, so we update the DB
- $pun_db->query('UPDATE '.$pun_db->prefix.'users SET password=\''.$form_password_hash.'\' WHERE id='.$user_id) or error('Unable to update user password', __FILE__, __LINE__, $pun_db->error());
- }
- }
-
- if (!$authorized)
- message($lang_login['Wrong user/pass'].' '.$lang_login['Forgotten pass'].'');
-
- // Update the status if this is the first time the user logged in
- if ($group_id == PUN_UNVERIFIED)
- $pun_db->query('UPDATE '.$pun_db->prefix.'users SET group_id='.$pun_config['o_default_user_group'].' WHERE id='.$user_id) or error('Unable to update user status', __FILE__, __LINE__, $pun_db->error());
-
- // Remove this users guest entry from the online list
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'online WHERE ident=\''.$pun_db->escape(get_remote_address()).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $pun_db->error());
-
- $expire = ($save_pass == '1') ? time() + 31536000 : 0;
- pun_setcookie($user_id, $form_password_hash, $expire);
-
- pun_redirect(htmlspecialchars($_POST['redirect_url']), $lang_login['Login redirect']);
-}
-
-
-else if ($action == 'out')
-{
- if ($pun_user['is_guest'] || !isset($_GET['id']) || $_GET['id'] != $pun_user['id'])
- {
- header('Location: index.php');
- exit;
- }
-
- // Remove user from "users online" list.
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'online WHERE user_id='.$pun_user['id']) or error('Unable to delete from online list', __FILE__, __LINE__, $pun_db->error());
-
- // Update last_visit (make sure there's something to update it with)
- if (isset($pun_user['logged']))
- $pun_db->query('UPDATE '.$pun_db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $pun_db->error());
-
- pun_setcookie(1, random_pass(8), time() + 31536000);
-
- pun_redirect('index.php', $lang_login['Logout redirect']);
-}
-
-
-else if ($action == 'forget' || $action == 'forget_2')
-{
- if (!$pun_user['is_guest'])
- header('Location: index.php');
-
- if (isset($_POST['form_sent']))
- {
- require PUN_ROOT.'include/email.php';
-
- // Validate the email-address
- $email = strtolower(trim($_POST['req_email']));
- if (!is_valid_email($email))
- message($lang_common['Invalid e-mail']);
-
- $result = $pun_db->query('SELECT id, username FROM '.$pun_db->prefix.'users WHERE email=\''.$pun_db->escape($email).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
-
- if ($pun_db->num_rows($result))
- {
- // Load the "activate password" template
- $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/activate_password.tpl'));
-
- // The first row contains the subject
- $first_crlf = strpos($mail_tpl, "\n");
- $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
- $mail_message = trim(substr($mail_tpl, $first_crlf));
-
- // Do the generic replacements first (they apply to all e-mails sent out here)
- $mail_message = str_replace('', $pun_config['o_base_url'].'/', $mail_message);
- $mail_message = str_replace('', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);
-
- // Loop through users we found
- while ($cur_hit = $pun_db->fetch_assoc($result))
- {
- // Generate a new password and a new password activation code
- $new_password = random_pass(8);
- $new_password_key = random_pass(8);
-
- $pun_db->query('UPDATE '.$pun_db->prefix.'users SET activate_string=\''.pun_hash($new_password).'\', activate_key=\''.$new_password_key.'\' WHERE id='.$cur_hit['id']) or error('Unable to update activation data', __FILE__, __LINE__, $pun_db->error());
-
- // Do the user specific replacements to the template
- $cur_mail_message = str_replace('', $cur_hit['username'], $mail_message);
- $cur_mail_message = str_replace('', $pun_config['o_base_url'].'/profile.php?id='.$cur_hit['id'].'&action=change_pass&key='.$new_password_key, $cur_mail_message);
- $cur_mail_message = str_replace('', $new_password, $cur_mail_message);
-
- pun_mail($email, $mail_subject, $cur_mail_message);
- }
-
- message($lang_login['Forget mail'].' '.$pun_config['o_admin_email'].'.');
- }
- else
- message($lang_login['No e-mail match'].' '.htmlspecialchars($email).'.');
- }
-
-
- $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_login['Request pass'];
- $required_fields = array('req_email' => $lang_common['E-mail']);
- $focus_element = array('request_pass', 'req_email');
- require PUN_ROOT.'header.php';
-
-?>
-
- $lang_common['Username'], 'req_password' => $lang_common['Password']);
-$focus_element = array('login', 'req_username');
-require PUN_ROOT.'header.php';
-
-?>
-
-