1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/includes/ucp/ucp_resend.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,164 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package ucp
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +*/
1.13 +
1.14 +/**
1.15 +* @ignore
1.16 +*/
1.17 +if (!defined('IN_PHPBB'))
1.18 +{
1.19 + exit;
1.20 +}
1.21 +
1.22 +/**
1.23 +* ucp_resend
1.24 +* Resending activation emails
1.25 +* @package ucp
1.26 +*/
1.27 +class ucp_resend
1.28 +{
1.29 + var $u_action;
1.30 +
1.31 + function main($id, $mode)
1.32 + {
1.33 + global $config, $phpbb_root_path, $phpEx;
1.34 + global $db, $user, $auth, $template;
1.35 +
1.36 + $username = request_var('username', '', true);
1.37 + $email = strtolower(request_var('email', ''));
1.38 + $submit = (isset($_POST['submit'])) ? true : false;
1.39 +
1.40 + add_form_key('ucp_resend');
1.41 +
1.42 + if ($submit)
1.43 + {
1.44 + if (!check_form_key('ucp_resend'))
1.45 + {
1.46 + trigger_error('FORM_INVALID');
1.47 + }
1.48 +
1.49 + $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason
1.50 + FROM ' . USERS_TABLE . "
1.51 + WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'
1.52 + AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
1.53 + $result = $db->sql_query($sql);
1.54 + $user_row = $db->sql_fetchrow($result);
1.55 + $db->sql_freeresult($result);
1.56 +
1.57 + if (!$user_row)
1.58 + {
1.59 + trigger_error('NO_EMAIL_USER');
1.60 + }
1.61 +
1.62 + if ($user_row['user_type'] == USER_IGNORE)
1.63 + {
1.64 + trigger_error('NO_USER');
1.65 + }
1.66 +
1.67 + if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE)
1.68 + {
1.69 + trigger_error('ACCOUNT_ALREADY_ACTIVATED');
1.70 + }
1.71 +
1.72 + if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL))
1.73 + {
1.74 + trigger_error('ACCOUNT_DEACTIVATED');
1.75 + }
1.76 +
1.77 + // Determine coppa status on group (REGISTERED(_COPPA))
1.78 + $sql = 'SELECT group_name, group_type
1.79 + FROM ' . GROUPS_TABLE . '
1.80 + WHERE group_id = ' . $user_row['group_id'];
1.81 + $result = $db->sql_query($sql);
1.82 + $row = $db->sql_fetchrow($result);
1.83 + $db->sql_freeresult($result);
1.84 +
1.85 + if (!$row)
1.86 + {
1.87 + trigger_error('NO_GROUP');
1.88 + }
1.89 +
1.90 + $coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false;
1.91 +
1.92 + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
1.93 + $messenger = new messenger(false);
1.94 +
1.95 + if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa)
1.96 + {
1.97 + $messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
1.98 + $messenger->to($user_row['user_email'], $user_row['username']);
1.99 +
1.100 + $messenger->anti_abuse_headers($config, $user);
1.101 +
1.102 + $messenger->assign_vars(array(
1.103 + 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
1.104 + 'USERNAME' => htmlspecialchars_decode($user_row['username']),
1.105 + 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
1.106 + );
1.107 +
1.108 + if ($coppa)
1.109 + {
1.110 + $messenger->assign_vars(array(
1.111 + 'FAX_INFO' => $config['coppa_fax'],
1.112 + 'MAIL_INFO' => $config['coppa_mail'],
1.113 + 'EMAIL_ADDRESS' => $user_row['user_email'])
1.114 + );
1.115 + }
1.116 +
1.117 + $messenger->send(NOTIFY_EMAIL);
1.118 + }
1.119 +
1.120 + if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
1.121 + {
1.122 + // Grab an array of user_id's with a_user permissions ... these users can activate a user
1.123 + $admin_ary = $auth->acl_get_list(false, 'a_user', false);
1.124 +
1.125 + $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
1.126 + FROM ' . USERS_TABLE . '
1.127 + WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
1.128 + $result = $db->sql_query($sql);
1.129 +
1.130 + while ($row = $db->sql_fetchrow($result))
1.131 + {
1.132 + $messenger->template('admin_activate', $row['user_lang']);
1.133 + $messenger->to($row['user_email'], $row['username']);
1.134 + $messenger->im($row['user_jabber'], $row['username']);
1.135 +
1.136 + $messenger->anti_abuse_headers($config, $user);
1.137 +
1.138 + $messenger->assign_vars(array(
1.139 + 'USERNAME' => htmlspecialchars_decode($user_row['username']),
1.140 + 'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}",
1.141 + 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
1.142 + );
1.143 +
1.144 + $messenger->send($row['user_notify_type']);
1.145 + }
1.146 + $db->sql_freeresult($result);
1.147 + }
1.148 +
1.149 + meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
1.150 +
1.151 + $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];
1.152 + $message .= '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
1.153 + trigger_error($message);
1.154 + }
1.155 +
1.156 + $template->assign_vars(array(
1.157 + 'USERNAME' => $username,
1.158 + 'EMAIL' => $email,
1.159 + 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act'))
1.160 + );
1.161 +
1.162 + $this->tpl_name = 'ucp_resend';
1.163 + $this->page_title = 'UCP_RESEND';
1.164 + }
1.165 +}
1.166 +
1.167 +?>
1.168 \ No newline at end of file