[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/includes/ucp/ -> ucp_activate.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_activate
  21  * User activation
  22  * @package ucp
  23  */
  24  class ucp_activate
  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          $user_id = request_var('u', 0);
  34          $key = request_var('k', '');
  35  
  36          $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
  37              FROM ' . USERS_TABLE . "
  38              WHERE user_id = $user_id";
  39          $result = $db->sql_query($sql);
  40          $user_row = $db->sql_fetchrow($result);
  41          $db->sql_freeresult($result);
  42  
  43          if (!$user_row)
  44          {
  45              trigger_error('NO_USER');
  46          }
  47  
  48          if ($user_row['user_type'] <> USER_INACTIVE && !$user_row['user_newpasswd'])
  49          {
  50              meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
  51              trigger_error('ALREADY_ACTIVATED');
  52          }
  53  
  54          if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL || $user_row['user_actkey'] !== $key)
  55          {
  56              trigger_error('WRONG_ACTIVATION');
  57          }
  58  
  59          // Do not allow activating by non administrators when admin activation is on
  60          // Only activation type the user should be able to do is INACTIVE_REMIND
  61          // or activate a new password which is not an activation state :@
  62          if (!$user_row['user_newpasswd'] && $user_row['user_inactive_reason'] != INACTIVE_REMIND && $config['require_activation'] == USER_ACTIVATION_ADMIN && !$auth->acl_get('a_user'))
  63          {
  64              if (!$user->data['is_registered'])
  65              {
  66                  login_box('', $user->lang['NO_AUTH_OPERATION']);
  67              }
  68              trigger_error('NO_AUTH_OPERATION');
  69          }
  70  
  71          $update_password = ($user_row['user_newpasswd']) ? true : false;
  72  
  73          if ($update_password)
  74          {
  75              $sql_ary = array(
  76                  'user_actkey'        => '',
  77                  'user_password'        => $user_row['user_newpasswd'],
  78                  'user_newpasswd'    => '',
  79                  'user_pass_convert'    => 0,
  80                  'user_login_attempts'    => 0,
  81              );
  82  
  83              $sql = 'UPDATE ' . USERS_TABLE . '
  84                  SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
  85                  WHERE user_id = ' . $user_row['user_id'];
  86              $db->sql_query($sql);
  87  
  88              add_log('user', $user_row['user_id'], 'LOG_USER_NEW_PASSWORD', $user_row['username']);
  89          }
  90  
  91          if (!$update_password)
  92          {
  93              include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
  94  
  95              user_active_flip('activate', $user_row['user_id']);
  96  
  97              $sql = 'UPDATE ' . USERS_TABLE . "
  98                  SET user_actkey = ''
  99                  WHERE user_id = {$user_row['user_id']}";
 100              $db->sql_query($sql);
 101  
 102              // Create the correct logs
 103              add_log('user', $user_row['user_id'], 'LOG_USER_ACTIVE_USER');
 104              if ($auth->acl_get('a_user'))
 105              {
 106                  add_log('admin', 'LOG_USER_ACTIVE', $user_row['username']);
 107              }
 108          }
 109  
 110          if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password)
 111          {
 112              include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 113  
 114              $messenger = new messenger(false);
 115  
 116              $messenger->template('admin_welcome_activated', $user_row['user_lang']);
 117  
 118              $messenger->to($user_row['user_email'], $user_row['username']);
 119  
 120              $messenger->anti_abuse_headers($config, $user);
 121  
 122              $messenger->assign_vars(array(
 123                  'USERNAME'    => htmlspecialchars_decode($user_row['username']))
 124              );
 125  
 126              $messenger->send($user_row['user_notify_type']);
 127  
 128              $message = 'ACCOUNT_ACTIVE_ADMIN';
 129          }
 130          else
 131          {
 132              if (!$update_password)
 133              {
 134                  $message = ($user_row['user_inactive_reason'] == INACTIVE_PROFILE) ? 'ACCOUNT_ACTIVE_PROFILE' : 'ACCOUNT_ACTIVE';
 135              }
 136              else
 137              {
 138                  $message = 'PASSWORD_ACTIVATED';
 139              }
 140          }
 141  
 142          meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
 143          trigger_error($user->lang[$message]);
 144      }
 145  }
 146  
 147  ?>


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