2 /***************************************************************************
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: usercp_activate.php,v 1.6.2.9 2005/09/14 18:14:30 acydburn Exp $
12 ***************************************************************************/
14 /***************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
22 ***************************************************************************/
24 if ( !defined('IN_PHPBB') )
26 die('Hacking attempt');
30 $sql = "SELECT user_active, user_id, username, user_email, user_newpasswd, user_lang, user_actkey
31 FROM " . USERS_TABLE . "
32 WHERE user_id = " . intval($HTTP_GET_VARS[POST_USERS_URL]);
33 if ( !($result = $db->sql_query($sql)) )
35 message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql);
38 if ( $row = $db->sql_fetchrow($result) )
40 if ( $row['user_active'] && trim($row['user_actkey']) == '' )
42 $template->assign_vars(array(
43 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
46 message_die(GENERAL_MESSAGE, $lang['Already_activated']);
48 else if ((trim($row['user_actkey']) == trim($HTTP_GET_VARS['act_key'])) && (trim($row['user_actkey']) != ''))
50 if (intval($board_config['require_activation']) == USER_ACTIVATION_ADMIN && $row['user_newpasswd'] == '')
52 if (!$userdata['session_logged_in'])
54 redirect(append_sid('login.' . $phpEx . '?redirect=profile.' . $phpEx . '&mode=activate&' . POST_USERS_URL . '=' . $row['user_id'] . '&act_key=' . trim($HTTP_GET_VARS['act_key'])));
56 else if ($userdata['user_level'] != ADMIN)
58 message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
62 $sql_update_pass = ( $row['user_newpasswd'] != '' ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : '';
64 $sql = "UPDATE " . USERS_TABLE . "
65 SET user_active = 1, user_actkey = ''" . $sql_update_pass . "
66 WHERE user_id = " . $row['user_id'];
67 if ( !($result = $db->sql_query($sql)) )
69 message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql_update);
72 if ( intval($board_config['require_activation']) == USER_ACTIVATION_ADMIN && $sql_update_pass == '' )
74 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
75 $emailer = new emailer($board_config['smtp_delivery']);
77 $emailer->from($board_config['board_email']);
78 $emailer->replyto($board_config['board_email']);
80 $emailer->use_template('admin_welcome_activated', $row['user_lang']);
81 $emailer->email_address($row['user_email']);
82 $emailer->set_subject($lang['Account_activated_subject']);
84 $emailer->assign_vars(array(
85 'SITENAME' => $board_config['sitename'],
86 'USERNAME' => $row['username'],
87 'PASSWORD' => $password_confirm,
88 'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '')
93 $template->assign_vars(array(
94 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
97 message_die(GENERAL_MESSAGE, $lang['Account_active_admin']);
101 $template->assign_vars(array(
102 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
105 $message = ( $sql_update_pass == '' ) ? $lang['Account_active'] : $lang['Password_activated'];
106 message_die(GENERAL_MESSAGE, $message);
111 message_die(GENERAL_MESSAGE, $lang['Wrong_activation']);
116 message_die(GENERAL_MESSAGE, $lang['No_such_user']);