[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/includes/ucp/ -> ucp_resend.php (source)

   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  */
  14  if (!defined('IN_PHPBB'))
  15  {
  16      exit;
  17  }
  18  
  19  /**
  20  * ucp_resend
  21  * Resending activation emails
  22  * @package ucp
  23  */
  24  class 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->anti_abuse_headers($config, $user);
  98  
  99                  $messenger->assign_vars(array(
 100                      'WELCOME_MSG'    => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
 101                      'USERNAME'        => htmlspecialchars_decode($user_row['username']),
 102                      'U_ACTIVATE'    => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
 103                  );
 104  
 105                  if ($coppa)
 106                  {
 107                      $messenger->assign_vars(array(
 108                          'FAX_INFO'        => $config['coppa_fax'],
 109                          'MAIL_INFO'        => $config['coppa_mail'],
 110                          'EMAIL_ADDRESS'    => $user_row['user_email'])
 111                      );
 112                  }
 113  
 114                  $messenger->send(NOTIFY_EMAIL);
 115              }
 116  
 117              if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
 118              {
 119                  // Grab an array of user_id's with a_user permissions ... these users can activate a user
 120                  $admin_ary = $auth->acl_get_list(false, 'a_user', false);
 121  
 122                  $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
 123                      FROM ' . USERS_TABLE . '
 124                      WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
 125                  $result = $db->sql_query($sql);
 126  
 127                  while ($row = $db->sql_fetchrow($result))
 128                  {
 129                      $messenger->template('admin_activate', $row['user_lang']);
 130                      $messenger->to($row['user_email'], $row['username']);
 131                      $messenger->im($row['user_jabber'], $row['username']);
 132  
 133                      $messenger->anti_abuse_headers($config, $user);
 134  
 135                      $messenger->assign_vars(array(
 136                          'USERNAME'            => htmlspecialchars_decode($user_row['username']),
 137                          'U_USER_DETAILS'    => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}",
 138                          'U_ACTIVATE'        => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
 139                      );
 140  
 141                      $messenger->send($row['user_notify_type']);
 142                  }
 143                  $db->sql_freeresult($result);
 144              }
 145  
 146              meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
 147  
 148              $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT'];
 149              $message .= '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
 150              trigger_error($message);
 151          }
 152  
 153          $template->assign_vars(array(
 154              'USERNAME'            => $username,
 155              'EMAIL'                => $email,
 156              'S_PROFILE_ACTION'    => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act'))
 157          );
 158  
 159          $this->tpl_name = 'ucp_resend';
 160          $this->page_title = 'UCP_RESEND';
 161      }
 162  }
 163  
 164  ?>


Generated: Wed Oct 2 15:03:47 2013 Cross-referenced by PHPXref 0.7.1