Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ucp_profile.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 29.83 KiB


 001  <?php
 002  /**
 003  *
 004  * This file is part of the phpBB Forum Software package.
 005  *
 006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007  * @license GNU General Public License, version 2 (GPL-2.0)
 008  *
 009  * For full copyright and license information, please see
 010  * the docs/CREDITS.txt file.
 011  *
 012  */
 013   
 014  /**
 015  * @ignore
 016  */
 017  if (!defined('IN_PHPBB'))
 018  {
 019      exit;
 020  }
 021   
 022  /**
 023  * ucp_profile
 024  * Changing profile settings
 025  *
 026  * @todo what about pertaining user_sig_options?
 027  */
 028  class ucp_profile
 029  {
 030      var $u_action;
 031   
 032      function main($id, $mode)
 033      {
 034          global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
 035          global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
 036   
 037          $user->add_lang('posting');
 038   
 039          $submit        = $request->variable('submit', false, false, \phpbb\request\request_interface::POST);
 040          $error = $data = array();
 041          $s_hidden_fields = '';
 042   
 043          switch ($mode)
 044          {
 045              case 'reg_details':
 046   
 047                  $data = array(
 048                      'username'            => $request->variable('username', $user->data['username'], true),
 049                      'email'                => strtolower($request->variable('email', $user->data['user_email'])),
 050                      'new_password'        => $request->variable('new_password', '', true),
 051                      'cur_password'        => $request->variable('cur_password', '', true),
 052                      'password_confirm'    => $request->variable('password_confirm', '', true),
 053                  );
 054   
 055                  /**
 056                  * Modify user registration data on editing account settings in UCP
 057                  *
 058                  * @event core.ucp_profile_reg_details_data
 059                  * @var    array    data        Array with current or updated user registration data
 060                  * @var    bool    submit        Flag indicating if submit button has been pressed
 061                  * @since 3.1.4-RC1
 062                  */
 063                  $vars = array('data', 'submit');
 064                  extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_data', compact($vars)));
 065   
 066                  add_form_key('ucp_reg_details');
 067   
 068                  if ($submit)
 069                  {
 070                      // Do not check cur_password, it is the old one.
 071                      $check_ary = array(
 072                          'new_password'        => array(
 073                              array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
 074                              array('password')),
 075                          'password_confirm'    => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
 076                          'email'                => array(
 077                              array('string', false, 6, 60),
 078                              array('user_email')),
 079                      );
 080   
 081                      if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
 082                      {
 083                          $check_ary['username'] = array(
 084                              array('string', false, $config['min_name_chars'], $config['max_name_chars']),
 085                              array('username'),
 086                          );
 087                      }
 088   
 089                      $error = validate_data($data, $check_ary);
 090   
 091                      if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password'])
 092                      {
 093                          $error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY';
 094                      }
 095   
 096                      // Instantiate passwords manager
 097                      /* @var $passwords_manager \phpbb\passwords\manager */
 098                      $passwords_manager = $phpbb_container->get('passwords.manager');
 099   
 100                      // Only check the new password against the previous password if there have been no errors
 101                      if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password']))
 102                      {
 103                          $error[] = 'SAME_PASSWORD_ERROR';
 104                      }
 105   
 106                      if (!$passwords_manager->check($data['cur_password'], $user->data['user_password']))
 107                      {
 108                          $error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY';
 109                      }
 110   
 111                      if (!check_form_key('ucp_reg_details'))
 112                      {
 113                          $error[] = 'FORM_INVALID';
 114                      }
 115   
 116                      /**
 117                      * Validate user data on editing registration data in UCP
 118                      *
 119                      * @event core.ucp_profile_reg_details_validate
 120                      * @var    array    data            Array with user profile data
 121                      * @var    bool    submit            Flag indicating if submit button has been pressed
 122                      * @var array    error            Array of any generated errors
 123                      * @since 3.1.4-RC1
 124                      */
 125                      $vars = array('data', 'submit', 'error');
 126                      extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars)));
 127   
 128                      if (!sizeof($error))
 129                      {
 130                          $sql_ary = array(
 131                              'username'            => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'],
 132                              'username_clean'    => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'],
 133                              'user_email'        => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
 134                              'user_email_hash'    => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'],
 135                              'user_password'        => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'],
 136                              'user_passchg'        => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
 137                          );
 138   
 139                          if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
 140                          {
 141                              $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array(
 142                                  'reportee_id' => $user->data['user_id'],
 143                                  $user->data['username'],
 144                                  $data['username']
 145                              ));
 146                          }
 147   
 148                          if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password']))
 149                          {
 150                              $user->reset_login_keys();
 151                              $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array(
 152                                  'reportee_id' => $user->data['user_id'],
 153                                  $user->data['username']
 154                              ));
 155                          }
 156   
 157                          if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'])
 158                          {
 159                              $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array(
 160                                  'reportee_id' => $user->data['user_id'],
 161                                  $user->data['username'],
 162                                  $data['user_email'],
 163                                  $data['email']
 164                              ));
 165                          }
 166   
 167                          $message = 'PROFILE_UPDATED';
 168   
 169                          if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))
 170                          {
 171                              $message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
 172   
 173                              include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 174   
 175                              $server_url = generate_board_url();
 176   
 177                              $user_actkey = gen_rand_string(mt_rand(6, 10));
 178   
 179                              $messenger = new messenger(false);
 180   
 181                              $template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
 182                              $messenger->template($template_file, $user->data['user_lang']);
 183   
 184                              $messenger->to($data['email'], $data['username']);
 185   
 186                              $messenger->anti_abuse_headers($config, $user);
 187   
 188                              $messenger->assign_vars(array(
 189                                  'USERNAME'        => htmlspecialchars_decode($data['username']),
 190                                  'U_ACTIVATE'    => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
 191                              );
 192   
 193                              $messenger->send(NOTIFY_EMAIL);
 194   
 195                              if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
 196                              {
 197                                  $notifications_manager = $phpbb_container->get('notification_manager');
 198                                  $notifications_manager->add_notifications('notification.type.admin_activate_user', array(
 199                                      'user_id'        => $user->data['user_id'],
 200                                      'user_actkey'    => $user_actkey,
 201                                      'user_regdate'    => time(), // Notification time
 202                                  ));
 203                              }
 204   
 205                              user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
 206   
 207                              // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
 208                              $sql_ary['user_actkey'] = $user_actkey;
 209                              $sql_ary['user_newpasswd'] = '';
 210                          }
 211   
 212                          /**
 213                          * Modify user registration data before submitting it to the database
 214                          *
 215                          * @event core.ucp_profile_reg_details_sql_ary
 216                          * @var    array    data        Array with current or updated user registration data
 217                          * @var    array    sql_ary        Array with user registration data to submit to the database
 218                          * @since 3.1.4-RC1
 219                          */
 220                          $vars = array('data', 'sql_ary');
 221                          extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars)));
 222   
 223                          if (sizeof($sql_ary))
 224                          {
 225                              $sql = 'UPDATE ' . USERS_TABLE . '
 226                                  SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
 227                                  WHERE user_id = ' . $user->data['user_id'];
 228                              $db->sql_query($sql);
 229                          }
 230   
 231                          // Need to update config, forum, topic, posting, messages, etc.
 232                          if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
 233                          {
 234                              user_update_name($user->data['username'], $data['username']);
 235                          }
 236   
 237                          // Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
 238                          if (!empty($sql_ary['user_actkey']))
 239                          {
 240                              meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
 241                              $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
 242   
 243                              // Because the user gets deactivated we log him out too, killing his session
 244                              $user->session_kill();
 245                          }
 246                          else
 247                          {
 248                              meta_refresh(3, $this->u_action);
 249                              $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
 250                          }
 251   
 252                          trigger_error($message);
 253                      }
 254   
 255                      // Replace "error" strings with their real, localised form
 256                      $error = array_map(array($user, 'lang'), $error);
 257                  }
 258   
 259                  $template->assign_vars(array(
 260                      'ERROR'                => (sizeof($error)) ? implode('<br />', $error) : '',
 261   
 262                      'USERNAME'            => $data['username'],
 263                      'EMAIL'                => $data['email'],
 264                      'PASSWORD_CONFIRM'    => $data['password_confirm'],
 265                      'NEW_PASSWORD'        => $data['new_password'],
 266                      'CUR_PASSWORD'        => '',
 267   
 268                      'L_USERNAME_EXPLAIN'        => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])),
 269                      'L_CHANGE_PASSWORD_EXPLAIN'    => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])),
 270   
 271                      'S_FORCE_PASSWORD'    => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false,
 272                      'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false,
 273                      'S_CHANGE_EMAIL'    => ($auth->acl_get('u_chgemail')) ? true : false,
 274                      'S_CHANGE_PASSWORD'    => ($auth->acl_get('u_chgpasswd')) ? true : false)
 275                  );
 276              break;
 277   
 278              case 'profile_info':
 279                  // Do not display profile information panel if not authed to do so
 280                  if (!$auth->acl_get('u_chgprofileinfo'))
 281                  {
 282                      send_status_line(403, 'Forbidden');
 283                      trigger_error('NO_AUTH_PROFILEINFO');
 284                  }
 285   
 286                  /* @var $cp \phpbb\profilefields\manager */
 287                  $cp = $phpbb_container->get('profilefields.manager');
 288   
 289                  $cp_data = $cp_error = array();
 290   
 291                  $data = array(
 292                      'jabber'        => $request->variable('jabber', $user->data['user_jabber'], true),
 293                  );
 294   
 295                  if ($config['allow_birthdays'])
 296                  {
 297                      $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
 298   
 299                      if ($user->data['user_birthday'])
 300                      {
 301                          list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
 302                      }
 303   
 304                      $data['bday_day'] = $request->variable('bday_day', $data['bday_day']);
 305                      $data['bday_month'] = $request->variable('bday_month', $data['bday_month']);
 306                      $data['bday_year'] = $request->variable('bday_year', $data['bday_year']);
 307                      $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
 308                  }
 309   
 310                  /**
 311                  * Modify user data on editing profile in UCP
 312                  *
 313                  * @event core.ucp_profile_modify_profile_info
 314                  * @var    array    data        Array with user profile data
 315                  * @var    bool    submit        Flag indicating if submit button has been pressed
 316                  * @since 3.1.4-RC1
 317                  */
 318                  $vars = array('data', 'submit');
 319                  extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars)));
 320   
 321                  add_form_key('ucp_profile_info');
 322   
 323                  if ($submit)
 324                  {
 325                      $validate_array = array(
 326                          'jabber'        => array(
 327                              array('string', true, 5, 255),
 328                              array('jabber')),
 329                      );
 330   
 331                      if ($config['allow_birthdays'])
 332                      {
 333                          $validate_array = array_merge($validate_array, array(
 334                              'bday_day'        => array('num', true, 1, 31),
 335                              'bday_month'    => array('num', true, 1, 12),
 336                              'bday_year'        => array('num', true, 1901, gmdate('Y', time()) + 50),
 337                              'user_birthday' => array('date', true),
 338                          ));
 339                      }
 340   
 341                      $error = validate_data($data, $validate_array);
 342   
 343                      // validate custom profile fields
 344                      $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
 345   
 346                      if (sizeof($cp_error))
 347                      {
 348                          $error = array_merge($error, $cp_error);
 349                      }
 350   
 351                      if (!check_form_key('ucp_profile_info'))
 352                      {
 353                          $error[] = 'FORM_INVALID';
 354                      }
 355   
 356                      /**
 357                      * Validate user data on editing profile in UCP
 358                      *
 359                      * @event core.ucp_profile_validate_profile_info
 360                      * @var    array    data            Array with user profile data
 361                      * @var    bool    submit            Flag indicating if submit button has been pressed
 362                      * @var array    error            Array of any generated errors
 363                      * @since 3.1.4-RC1
 364                      */
 365                      $vars = array('data', 'submit', 'error');
 366                      extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars)));
 367   
 368                      if (!sizeof($error))
 369                      {
 370                          $data['notify'] = $user->data['user_notify_type'];
 371   
 372                          if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
 373                          {
 374                              // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
 375                              // Disable notify by Jabber now for this user.
 376                              $data['notify'] = NOTIFY_EMAIL;
 377                          }
 378   
 379                          $sql_ary = array(
 380                              'user_jabber'    => $data['jabber'],
 381                              'user_notify_type'    => $data['notify'],
 382                          );
 383   
 384                          if ($config['allow_birthdays'])
 385                          {
 386                              $sql_ary['user_birthday'] = $data['user_birthday'];
 387                          }
 388   
 389                          /**
 390                          * Modify profile data in UCP before submitting to the database
 391                          *
 392                          * @event core.ucp_profile_info_modify_sql_ary
 393                          * @var    array    cp_data        Array with the user custom profile fields data
 394                          * @var    array    data        Array with user profile data
 395                          * @var  array    sql_ary        user options data we update
 396                          * @since 3.1.4-RC1
 397                          */
 398                          $vars = array('cp_data', 'data', 'sql_ary');
 399                          extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars)));
 400   
 401                          $sql = 'UPDATE ' . USERS_TABLE . '
 402                              SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
 403                              WHERE user_id = ' . $user->data['user_id'];
 404                          $db->sql_query($sql);
 405   
 406                          // Update Custom Fields
 407                          $cp->update_profile_field_data($user->data['user_id'], $cp_data);
 408   
 409                          meta_refresh(3, $this->u_action);
 410                          $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
 411                          trigger_error($message);
 412                      }
 413   
 414                      // Replace "error" strings with their real, localised form
 415                      $error = array_map(array($user, 'lang'), $error);
 416                  }
 417   
 418                  if ($config['allow_birthdays'])
 419                  {
 420                      $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
 421                      for ($i = 1; $i < 32; $i++)
 422                      {
 423                          $selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
 424                          $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
 425                      }
 426   
 427                      $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
 428                      for ($i = 1; $i < 13; $i++)
 429                      {
 430                          $selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
 431                          $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
 432                      }
 433   
 434                      $now = getdate();
 435                      $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
 436                      for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
 437                      {
 438                          $selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
 439                          $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
 440                      }
 441                      unset($now);
 442   
 443                      $template->assign_vars(array(
 444                          'S_BIRTHDAY_DAY_OPTIONS'    => $s_birthday_day_options,
 445                          'S_BIRTHDAY_MONTH_OPTIONS'    => $s_birthday_month_options,
 446                          'S_BIRTHDAY_YEAR_OPTIONS'    => $s_birthday_year_options,
 447                          'S_BIRTHDAYS_ENABLED'        => true,
 448                      ));
 449                  }
 450   
 451                  $template->assign_vars(array(
 452                      'ERROR'                => (sizeof($error)) ? implode('<br />', $error) : '',
 453                      'S_JABBER_ENABLED'    => $config['jab_enable'],
 454                      'JABBER'            => $data['jabber'],
 455                  ));
 456   
 457                  // Get additional profile fields and assign them to the template block var 'profile_fields'
 458                  $user->get_profile_fields($user->data['user_id']);
 459   
 460                  $cp->generate_profile_fields('profile', $user->get_iso_lang_id());
 461   
 462              break;
 463   
 464              case 'signature':
 465   
 466                  if (!$auth->acl_get('u_sig'))
 467                  {
 468                      send_status_line(403, 'Forbidden');
 469                      trigger_error('NO_AUTH_SIGNATURE');
 470                  }
 471   
 472                  include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
 473                  include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 474   
 475                  $preview    = $request->is_set_post('preview');
 476   
 477                  $enable_bbcode    = ($config['allow_sig_bbcode']) ? $user->optionget('sig_bbcode') : false;
 478                  $enable_smilies    = ($config['allow_sig_smilies']) ? $user->optionget('sig_smilies') : false;
 479                  $enable_urls    = ($config['allow_sig_links']) ? $user->optionget('sig_links') : false;
 480   
 481                  $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0);
 482   
 483                  $decoded_message    = generate_text_for_edit($user->data['user_sig'], $user->data['user_sig_bbcode_uid'], $bbcode_flags);
 484                  $signature            = $request->variable('signature', $decoded_message['text'], true);
 485                  $signature_preview    = '';
 486   
 487                  if ($submit || $preview)
 488                  {
 489                      $enable_bbcode    = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false;
 490                      $enable_smilies    = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false;
 491                      $enable_urls    = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false;
 492   
 493                      if (!check_form_key('ucp_sig'))
 494                      {
 495                          $error[] = 'FORM_INVALID';
 496                      }
 497                  }
 498   
 499                  /**
 500                  * Modify user signature on editing profile in UCP
 501                  *
 502                  * @event core.ucp_profile_modify_signature
 503                  * @var    bool    enable_bbcode        Whether or not bbcode is enabled
 504                  * @var    bool    enable_smilies        Whether or not smilies are enabled
 505                  * @var    bool    enable_urls            Whether or not urls are enabled
 506                  * @var    string    signature            Users signature text
 507                  * @var    array    error                Any error strings
 508                  * @var    bool    submit                Whether or not the form has been sumitted
 509                  * @var    bool    preview                Whether or not the signature is being previewed
 510                  * @since 3.1.10-RC1
 511                  * @change 3.2.0-RC2 Removed message parser
 512                  */
 513                  $vars = array(
 514                      'enable_bbcode',
 515                      'enable_smilies',
 516                      'enable_urls',
 517                      'signature',
 518                      'error',
 519                      'submit',
 520                      'preview',
 521                  );
 522                  extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature', compact($vars)));
 523   
 524                  $bbcode_uid = $bbcode_bitfield = $bbcode_flags = '';
 525                  $warn_msg = generate_text_for_storage(
 526                      $signature,
 527                      $bbcode_uid,
 528                      $bbcode_bitfield,
 529                      $bbcode_flags,
 530                      $enable_bbcode,
 531                      $enable_urls,
 532                      $enable_smilies,
 533                      $config['allow_sig_img'],
 534                      $config['allow_sig_flash'],
 535                      true,
 536                      $config['allow_sig_links'],
 537                      'sig'
 538                  );
 539   
 540                  if (sizeof($warn_msg))
 541                  {
 542                      $error += $warn_msg;
 543                  }
 544   
 545                  if (!$submit)
 546                  {
 547                      // Parse it for displaying
 548                      $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags);
 549                  }
 550                  else
 551                  {
 552                      if (!sizeof($error))
 553                      {
 554                          $user->optionset('sig_bbcode', $enable_bbcode);
 555                          $user->optionset('sig_smilies', $enable_smilies);
 556                          $user->optionset('sig_links', $enable_urls);
 557   
 558                          $sql_ary = array(
 559                              'user_sig'                    => $signature,
 560                              'user_options'                => $user->data['user_options'],
 561                              'user_sig_bbcode_uid'        => $bbcode_uid,
 562                              'user_sig_bbcode_bitfield'    => $bbcode_bitfield
 563                          );
 564   
 565                          /**
 566                          * Modify user registration data before submitting it to the database
 567                          *
 568                          * @event core.ucp_profile_modify_signature_sql_ary
 569                          * @var    array    sql_ary        Array with user signature data to submit to the database
 570                          * @since 3.1.10-RC1
 571                          */
 572                          $vars = array('sql_ary');
 573                          extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature_sql_ary', compact($vars)));
 574   
 575                          $sql = 'UPDATE ' . USERS_TABLE . '
 576                              SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
 577                              WHERE user_id = ' . $user->data['user_id'];
 578                          $db->sql_query($sql);
 579   
 580                          $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
 581                          trigger_error($message);
 582                      }
 583                  }
 584   
 585                  // Replace "error" strings with their real, localised form
 586                  $error = array_map(array($user, 'lang'), $error);
 587   
 588                  if ($request->is_set_post('preview'))
 589                  {
 590                      $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags);
 591                  }
 592   
 593                  /** @var \phpbb\controller\helper $controller_helper */
 594                  $controller_helper = $phpbb_container->get('controller.helper');
 595   
 596                  $template->assign_vars(array(
 597                      'ERROR'                => (sizeof($error)) ? implode('<br />', $error) : '',
 598                      'SIGNATURE'            => $decoded_message['text'],
 599                      'SIGNATURE_PREVIEW'    => $signature_preview,
 600   
 601                      'S_BBCODE_CHECKED'         => (!$enable_bbcode) ? ' checked="checked"' : '',
 602                      'S_SMILIES_CHECKED'     => (!$enable_smilies) ? ' checked="checked"' : '',
 603                      'S_MAGIC_URL_CHECKED'     => (!$enable_urls) ? ' checked="checked"' : '',
 604   
 605                      'BBCODE_STATUS'            => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'),
 606                      'SMILIES_STATUS'        => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
 607                      'IMG_STATUS'            => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
 608                      'FLASH_STATUS'            => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
 609                      'URL_STATUS'            => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
 610                      'MAX_FONT_SIZE'            => (int) $config['max_sig_font_size'],
 611   
 612                      'L_SIGNATURE_EXPLAIN'    => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']),
 613   
 614                      'S_BBCODE_ALLOWED'        => $config['allow_sig_bbcode'],
 615                      'S_SMILIES_ALLOWED'        => $config['allow_sig_smilies'],
 616                      'S_BBCODE_IMG'            => ($config['allow_sig_img']) ? true : false,
 617                      'S_BBCODE_FLASH'        => ($config['allow_sig_flash']) ? true : false,
 618                      'S_LINKS_ALLOWED'        => ($config['allow_sig_links']) ? true : false)
 619                  );
 620   
 621                  add_form_key('ucp_sig');
 622   
 623                  // Build custom bbcodes array
 624                  display_custom_bbcodes();
 625   
 626                  // Generate smiley listing
 627                  generate_smilies('inline', 0);
 628   
 629              break;
 630   
 631              case 'avatar':
 632   
 633                  add_form_key('ucp_avatar');
 634   
 635                  $avatars_enabled = false;
 636   
 637                  if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar'))
 638                  {
 639                      /* @var $phpbb_avatar_manager \phpbb\avatar\manager */
 640                      $phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
 641                      $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
 642   
 643                      // This is normalised data, without the user_ prefix
 644                      $avatar_data = \phpbb\avatar\manager::clean_row($user->data, 'user');
 645   
 646                      if ($submit)
 647                      {
 648                          if (check_form_key('ucp_avatar'))
 649                          {
 650                              $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', ''));
 651   
 652                              if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete'))
 653                              {
 654                                  $driver = $phpbb_avatar_manager->get_driver($driver_name);
 655                                  $result = $driver->process_form($request, $template, $user, $avatar_data, $error);
 656   
 657                                  if ($result && empty($error))
 658                                  {
 659                                      // Success! Lets save the result in the database
 660                                      $result = array(
 661                                          'user_avatar_type' => $driver_name,
 662                                          'user_avatar' => $result['avatar'],
 663                                          'user_avatar_width' => $result['avatar_width'],
 664                                          'user_avatar_height' => $result['avatar_height'],
 665                                      );
 666   
 667                                      /**
 668                                      * Trigger events on successfull avatar change
 669                                      *
 670                                      * @event core.ucp_profile_avatar_sql
 671                                      * @var    array    result    Array with data to be stored in DB
 672                                      * @since 3.1.11-RC1
 673                                      */
 674                                      $vars = array('result');
 675                                      extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_sql', compact($vars)));
 676   
 677                                      $sql = 'UPDATE ' . USERS_TABLE . '
 678                                          SET ' . $db->sql_build_array('UPDATE', $result) . '
 679                                          WHERE user_id = ' . (int) $user->data['user_id'];
 680                                      $db->sql_query($sql);
 681   
 682                                      meta_refresh(3, $this->u_action);
 683                                      $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
 684                                      trigger_error($message);
 685                                  }
 686                              }
 687                          }
 688                          else
 689                          {
 690                              $error[] = 'FORM_INVALID';
 691                          }
 692                      }
 693   
 694                      // Handle deletion of avatars
 695                      if ($request->is_set_post('avatar_delete'))
 696                      {
 697                          if (!confirm_box(true))
 698                          {
 699                              confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array(
 700                                      'avatar_delete'     => true,
 701                                      'i'                 => $id,
 702                                      'mode'              => $mode))
 703                              );
 704                          }
 705                          else
 706                          {
 707                              $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_');
 708   
 709                              meta_refresh(3, $this->u_action);
 710                              $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
 711                              trigger_error($message);
 712                          }
 713                      }
 714   
 715                      $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type']));
 716   
 717                      $template->assign_vars(array(
 718                          'AVATAR_MIN_WIDTH'    => $config['avatar_min_width'],
 719                          'AVATAR_MAX_WIDTH'    => $config['avatar_max_width'],
 720                          'AVATAR_MIN_HEIGHT'    => $config['avatar_min_height'],
 721                          'AVATAR_MAX_HEIGHT'    => $config['avatar_max_height'],
 722                      ));
 723   
 724                      foreach ($avatar_drivers as $current_driver)
 725                      {
 726                          $driver = $phpbb_avatar_manager->get_driver($current_driver);
 727   
 728                          $avatars_enabled = true;
 729                          $template->set_filenames(array(
 730                              'avatar' => $driver->get_template_name(),
 731                          ));
 732   
 733                          if ($driver->prepare_form($request, $template, $user, $avatar_data, $error))
 734                          {
 735                              $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
 736                              $driver_upper = strtoupper($driver_name);
 737   
 738                              $template->assign_block_vars('avatar_drivers', array(
 739                                  'L_TITLE' => $user->lang($driver_upper . '_TITLE'),
 740                                  'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'),
 741   
 742                                  'DRIVER' => $driver_name,
 743                                  'SELECTED' => $current_driver == $selected_driver,
 744                                  'OUTPUT' => $template->assign_display('avatar'),
 745                              ));
 746                          }
 747                      }
 748   
 749                      // Replace "error" strings with their real, localised form
 750                      $error = $phpbb_avatar_manager->localize_errors($user, $error);
 751                  }
 752   
 753                  $avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
 754   
 755                  $template->assign_vars(array(
 756                      'ERROR'            => (sizeof($error)) ? implode('<br />', $error) : '',
 757                      'AVATAR'        => $avatar,
 758   
 759                      'S_FORM_ENCTYPE'    => ' enctype="multipart/form-data"',
 760   
 761                      'L_AVATAR_EXPLAIN'    => phpbb_avatar_explanation_string(),
 762   
 763                      'S_AVATARS_ENABLED'        => ($config['allow_avatar'] && $avatars_enabled),
 764                  ));
 765   
 766              break;
 767   
 768              case 'autologin_keys':
 769   
 770                  add_form_key('ucp_autologin_keys');
 771   
 772                  if ($submit)
 773                  {
 774                      $keys = $request->variable('keys', array(''));
 775   
 776                      if (!check_form_key('ucp_autologin_keys'))
 777                      {
 778                          $error[] = 'FORM_INVALID';
 779                      }
 780   
 781                      if (!sizeof($error))
 782                      {
 783                          if (!empty($keys))
 784                          {
 785                              foreach ($keys as $key => $id)
 786                              {
 787                                  $keys[$key] = $db->sql_like_expression($id . $db->get_any_char());
 788                              }
 789                              $sql_where = '(key_id ' . implode(' OR key_id ', $keys) . ')';
 790                              $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
 791                                  WHERE user_id = ' . (int) $user->data['user_id'] . '
 792                                  AND ' . $sql_where ;
 793   
 794                              $db->sql_query($sql);
 795   
 796                              meta_refresh(3, $this->u_action);
 797                              $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
 798                              trigger_error($message);
 799                          }
 800                      }
 801   
 802                      // Replace "error" strings with their real, localised form
 803                      $error = array_map(array($user, 'lang'), $error);
 804                  }
 805   
 806                  $sql = 'SELECT key_id, last_ip, last_login
 807                      FROM ' . SESSIONS_KEYS_TABLE . '
 808                      WHERE user_id = ' . (int) $user->data['user_id'] . '
 809                      ORDER BY last_login ASC';
 810   
 811                  $result = $db->sql_query($sql);
 812   
 813                  while ($row = $db->sql_fetchrow($result))
 814                  {
 815                      $template->assign_block_vars('sessions', array(
 816                          'KEY' => substr($row['key_id'], 0, 8),
 817                          'IP' => $row['last_ip'],
 818                          'LOGIN_TIME' => $user->format_date($row['last_login']),
 819                      ));
 820                  }
 821   
 822                  $db->sql_freeresult($result);
 823   
 824              break;
 825          }
 826   
 827          $template->assign_vars(array(
 828              'ERROR'        => (sizeof($error)) ? implode('<br />', $error) : '',
 829   
 830              'L_TITLE'    => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
 831   
 832              'S_HIDDEN_FIELDS'    => $s_hidden_fields,
 833              'S_UCP_ACTION'        => $this->u_action)
 834          );
 835   
 836          // Set desired template
 837          $this->tpl_name = 'ucp_profile_' . $mode;
 838          $this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
 839      }
 840  }
 841