Blame Extras/phpBB/3.0.4/includes/ucp/ucp_resend.php

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

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