source: trunk/forum/includes/ucp/ucp_resend.php

Last change on this file was 702, checked in by george, 15 years ago
  • Upraveno: Aktualizace fóra.
File size: 5.3 KB
Line 
1<?php
2/**
3*
4* @package ucp
5* @version $Id$
6* @copyright (c) 2005 phpBB Group
7* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8*
9*/
10
11/**
12* @ignore
13*/
14if (!defined('IN_PHPBB'))
15{
16 exit;
17}
18
19/**
20* ucp_resend
21* Resending activation emails
22* @package ucp
23*/
24class ucp_resend
25{
26 var $u_action;
27
28 function main($id, $mode)
29 {
30 global $config, $phpbb_root_path, $phpEx;
31 global $db, $user, $auth, $template;
32
33 $username = request_var('username', '', true);
34 $email = strtolower(request_var('email', ''));
35 $submit = (isset($_POST['submit'])) ? true : false;
36
37 add_form_key('ucp_resend');
38
39 if ($submit)
40 {
41 if (!check_form_key('ucp_resend'))
42 {
43 trigger_error('FORM_INVALID');
44 }
45
46 $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason
47 FROM ' . USERS_TABLE . "
48 WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'
49 AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
50 $result = $db->sql_query($sql);
51 $user_row = $db->sql_fetchrow($result);
52 $db->sql_freeresult($result);
53
54 if (!$user_row)
55 {
56 trigger_error('NO_EMAIL_USER');
57 }
58
59 if ($user_row['user_type'] == USER_IGNORE)
60 {
61 trigger_error('NO_USER');
62 }
63
64 if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE)
65 {
66 trigger_error('ACCOUNT_ALREADY_ACTIVATED');
67 }
68
69 if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL))
70 {
71 trigger_error('ACCOUNT_DEACTIVATED');
72 }
73
74 // Determine coppa status on group (REGISTERED(_COPPA))
75 $sql = 'SELECT group_name, group_type
76 FROM ' . GROUPS_TABLE . '
77 WHERE group_id = ' . $user_row['group_id'];
78 $result = $db->sql_query($sql);
79 $row = $db->sql_fetchrow($result);
80 $db->sql_freeresult($result);
81
82 if (!$row)
83 {
84 trigger_error('NO_GROUP');
85 }
86
87 $coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false;
88
89 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
90 $messenger = new messenger(false);
91
92 if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa)
93 {
94 $messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
95 $messenger->to($user_row['user_email'], $user_row['username']);
96
97 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
98 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
99 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
100 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
101
102 $messenger->assign_vars(array(
103 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
104 'USERNAME' => htmlspecialchars_decode($user_row['username']),
105 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
106 );
107
108 if ($coppa)
109 {
110 $messenger->assign_vars(array(
111 'FAX_INFO' => $config['coppa_fax'],
112 'MAIL_INFO' => $config['coppa_mail'],
113 'EMAIL_ADDRESS' => $user_row['user_email'])
114 );
115 }
116
117 $messenger->send(NOTIFY_EMAIL);
118 }
119
120 if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
121 {
122 // Grab an array of user_id's with a_user permissions ... these users can activate a user
123 $admin_ary = $auth->acl_get_list(false, 'a_user', false);
124
125 $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
126 FROM ' . USERS_TABLE . '
127 WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
128 $result = $db->sql_query($sql);
129
130 while ($row = $db->sql_fetchrow($result))
131 {
132 $messenger->template('admin_activate', $row['user_lang']);
133 $messenger->to($row['user_email'], $row['username']);
134 $messenger->im($row['user_jabber'], $row['username']);
135
136 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
137 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
138 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
139 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
140
141 $messenger->assign_vars(array(
142 'USERNAME' => htmlspecialchars_decode($user_row['username']),
143 'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}",
144 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
145 );
146
147 $messenger->send($row['user_notify_type']);
148 }
149 $db->sql_freeresult($result);
150 }
151
152 meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
153
154 $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];
155 $message .= '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
156 trigger_error($message);
157 }
158
159 $template->assign_vars(array(
160 'USERNAME' => $username,
161 'EMAIL' => $email,
162 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act'))
163 );
164
165 $this->tpl_name = 'ucp_resend';
166 $this->page_title = 'UCP_RESEND';
167 }
168}
169
170?>
Note: See TracBrowser for help on using the repository browser.