Blame Identity/Webenv/phpBB/3.0.4/includes/ucp/ucp_resend.php

ef5584
ef5584
/**
ef5584
*
ef5584
* @package ucp
ef5584
* @version $Id: ucp_resend.php 8479 2008-03-29 00:22:48Z naderman $
ef5584
* @copyright (c) 2005 phpBB Group
ef5584
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
ef5584
*
ef5584
*/
ef5584
ef5584
/**
ef5584
* @ignore
ef5584
*/
ef5584
if (!defined('IN_PHPBB'))
ef5584
{
ef5584
	exit;
ef5584
}
ef5584
ef5584
/**
ef5584
* ucp_resend
ef5584
* Resending activation emails
ef5584
* @package ucp
ef5584
*/
ef5584
class ucp_resend
ef5584
{
ef5584
	var $u_action;
ef5584
ef5584
	function main($id, $mode)
ef5584
	{
ef5584
		global $config, $phpbb_root_path, $phpEx;
ef5584
		global $db, $user, $auth, $template;
ef5584
ef5584
		$username	= request_var('username', '', true);
ef5584
		$email		= strtolower(request_var('email', ''));
ef5584
		$submit		= (isset($_POST['submit'])) ? true : false;
ef5584
ef5584
		add_form_key('ucp_resend');
ef5584
ef5584
		if ($submit)
ef5584
		{
ef5584
			if (!check_form_key('ucp_resend'))
ef5584
			{
ef5584
				trigger_error('FORM_INVALID');
ef5584
			}
ef5584
ef5584
			$sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason
ef5584
				FROM ' . USERS_TABLE . "
ef5584
				WHERE user_email = '" . $db->sql_escape($email) . "'
ef5584
					AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
ef5584
			$result = $db->sql_query($sql);
ef5584
			$user_row = $db->sql_fetchrow($result);
ef5584
			$db->sql_freeresult($result);
ef5584
ef5584
			if (!$user_row)
ef5584
			{
ef5584
				trigger_error('NO_EMAIL_USER');
ef5584
			}
ef5584
ef5584
			if ($user_row['user_type'] == USER_IGNORE)
ef5584
			{
ef5584
				trigger_error('NO_USER');
ef5584
			}
ef5584
ef5584
			if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE)
ef5584
			{
ef5584
				trigger_error('ACCOUNT_ALREADY_ACTIVATED');
ef5584
			}
ef5584
ef5584
			if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL))
ef5584
			{
ef5584
				trigger_error('ACCOUNT_DEACTIVATED');
ef5584
			}
ef5584
ef5584
			// Determine coppa status on group (REGISTERED(_COPPA))
ef5584
			$sql = 'SELECT group_name, group_type
ef5584
				FROM ' . GROUPS_TABLE . '
ef5584
				WHERE group_id = ' . $user_row['group_id'];
ef5584
			$result = $db->sql_query($sql);
ef5584
			$row = $db->sql_fetchrow($result);
ef5584
			$db->sql_freeresult($result);
ef5584
ef5584
			if (!$row)
ef5584
			{
ef5584
				trigger_error('NO_GROUP');
ef5584
			}
ef5584
ef5584
			$coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false;
ef5584
ef5584
			include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
ef5584
			$messenger = new messenger(false);
ef5584
ef5584
			if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa)
ef5584
			{
ef5584
				$messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
ef5584
				$messenger->to($user_row['user_email'], $user_row['username']);
ef5584
ef5584
				$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
ef5584
				$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
ef5584
				$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
ef5584
				$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
ef5584
ef5584
				$messenger->assign_vars(array(
ef5584
					'WELCOME_MSG'	=> htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
ef5584
					'USERNAME'		=> htmlspecialchars_decode($user_row['username']),
ef5584
					'U_ACTIVATE'	=> generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
ef5584
				);
ef5584
ef5584
				if ($coppa)
ef5584
				{
ef5584
					$messenger->assign_vars(array(
ef5584
						'FAX_INFO'		=> $config['coppa_fax'],
ef5584
						'MAIL_INFO'		=> $config['coppa_mail'],
ef5584
						'EMAIL_ADDRESS'	=> $user_row['user_email'])
ef5584
					);
ef5584
				}
ef5584
ef5584
				$messenger->send(NOTIFY_EMAIL);
ef5584
			}
ef5584
ef5584
			if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
ef5584
			{
ef5584
				// Grab an array of user_id's with a_user permissions ... these users can activate a user
ef5584
				$admin_ary = $auth->acl_get_list(false, 'a_user', false);
ef5584
ef5584
				$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
ef5584
					FROM ' . USERS_TABLE . '
ef5584
					WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
ef5584
				$result = $db->sql_query($sql);
ef5584
ef5584
				while ($row = $db->sql_fetchrow($result))
ef5584
				{
ef5584
					$messenger->template('admin_activate', $row['user_lang']);
ef5584
					$messenger->to($row['user_email'], $row['username']);
ef5584
					$messenger->im($row['user_jabber'], $row['username']);
ef5584
ef5584
					$messenger->assign_vars(array(
ef5584
						'USERNAME'			=> htmlspecialchars_decode($user_row['username']),
ef5584
						'U_USER_DETAILS'	=> generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}",
ef5584
						'U_ACTIVATE'		=> generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
ef5584
					);
ef5584
ef5584
					$messenger->send($row['user_notify_type']);
ef5584
				}
ef5584
				$db->sql_freeresult($result);
ef5584
			}
ef5584
ef5584
			meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
ef5584
ef5584
			$message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];
ef5584
			$message .= '

' . sprintf($user->lang['RETURN_INDEX'], '', '');
ef5584
			trigger_error($message);
ef5584
		}
ef5584
ef5584
		$template->assign_vars(array(
ef5584
			'USERNAME'			=> $username,
ef5584
			'EMAIL'				=> $email,
ef5584
			'S_PROFILE_ACTION'	=> append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act'))
ef5584
		);
ef5584
ef5584
		$this->tpl_name = 'ucp_resend';
ef5584
		$this->page_title = 'UCP_RESEND';
ef5584
	}
ef5584
}
ef5584
ef5584
?>