Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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: 02.04.2025, 15:02 - Dateigröße: 30.65 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'], 0),
074                              array('password')),
075                          'password_confirm'    => array('string', true, $config['min_pass_chars'], 0),
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 (!count($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 (!count($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_password'        => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'],
135                          );
136   
137                          if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
138                          {
139                              $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array(
140                                  'reportee_id' => $user->data['user_id'],
141                                  $user->data['username'],
142                                  $data['username']
143                              ));
144                          }
145   
146                          if ($auth->acl_get('u_chgpasswd') && $data['new_password'])
147                          {
148                              $sql_ary['user_passchg'] = time();
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                                  $user->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'        => html_entity_decode($data['username'], ENT_COMPAT),
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_actkey_expiration'    => $user::get_token_expiration(),
202                                      'user_regdate'                => time(), // Notification time
203                                  ));
204                              }
205   
206                              user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
207   
208                              // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
209                              $sql_ary['user_actkey'] = $user_actkey;
210                              $sql_ary['user_newpasswd'] = '';
211                          }
212   
213                          /**
214                          * Modify user registration data before submitting it to the database
215                          *
216                          * @event core.ucp_profile_reg_details_sql_ary
217                          * @var    array    data        Array with current or updated user registration data
218                          * @var    array    sql_ary        Array with user registration data to submit to the database
219                          * @since 3.1.4-RC1
220                          */
221                          $vars = array('data', 'sql_ary');
222                          extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars)));
223   
224                          if (count($sql_ary))
225                          {
226                              $sql = 'UPDATE ' . USERS_TABLE . '
227                                  SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
228                                  WHERE user_id = ' . $user->data['user_id'];
229                              $db->sql_query($sql);
230                          }
231   
232                          // Need to update config, forum, topic, posting, messages, etc.
233                          if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
234                          {
235                              user_update_name($user->data['username'], $data['username']);
236                          }
237   
238                          // Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
239                          if (!empty($sql_ary['user_actkey']))
240                          {
241                              meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
242                              $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
243   
244                              // Because the user gets deactivated we log him out too, killing his session
245                              $user->session_kill();
246                          }
247                          else
248                          {
249                              meta_refresh(3, $this->u_action);
250                              $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
251                          }
252   
253                          trigger_error($message);
254                      }
255   
256                      // Replace "error" strings with their real, localised form
257                      $error = array_map(array($user, 'lang'), $error);
258                  }
259   
260                  $template->assign_vars(array(
261                      'ERROR'                => (count($error)) ? implode('<br />', $error) : '',
262   
263                      'USERNAME'            => $data['username'],
264                      'EMAIL'                => $data['email'],
265                      'PASSWORD_CONFIRM'    => $data['password_confirm'],
266                      'NEW_PASSWORD'        => $data['new_password'],
267                      'CUR_PASSWORD'        => '',
268   
269                      'L_USERNAME_EXPLAIN'        => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS_XY', (int) $config['min_name_chars']), $user->lang('CHARACTERS_XY', (int) $config['max_name_chars'])),
270                      'L_CHANGE_PASSWORD_EXPLAIN'    => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars'])),
271   
272                      'S_FORCE_PASSWORD'    => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false,
273                      'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false,
274                      'S_CHANGE_EMAIL'    => ($auth->acl_get('u_chgemail')) ? true : false,
275                      'S_CHANGE_PASSWORD'    => ($auth->acl_get('u_chgpasswd')) ? true : false)
276                  );
277              break;
278   
279              case 'profile_info':
280                  // Do not display profile information panel if not authed to do so
281                  if (!$auth->acl_get('u_chgprofileinfo'))
282                  {
283                      send_status_line(403, 'Forbidden');
284                      trigger_error('NO_AUTH_PROFILEINFO');
285                  }
286   
287                  /* @var $cp \phpbb\profilefields\manager */
288                  $cp = $phpbb_container->get('profilefields.manager');
289   
290                  $cp_data = $cp_error = array();
291   
292                  $data = array(
293                      'jabber'        => $request->variable('jabber', $user->data['user_jabber'], true),
294                  );
295   
296                  if ($config['allow_birthdays'])
297                  {
298                      $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
299   
300                      if ($user->data['user_birthday'])
301                      {
302                          list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
303                      }
304   
305                      $data['bday_day'] = $request->variable('bday_day', $data['bday_day']);
306                      $data['bday_month'] = $request->variable('bday_month', $data['bday_month']);
307                      $data['bday_year'] = $request->variable('bday_year', $data['bday_year']);
308                      $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
309                  }
310   
311                  /**
312                  * Modify user data on editing profile in UCP
313                  *
314                  * @event core.ucp_profile_modify_profile_info
315                  * @var    array    data        Array with user profile data
316                  * @var    bool    submit        Flag indicating if submit button has been pressed
317                  * @since 3.1.4-RC1
318                  */
319                  $vars = array('data', 'submit');
320                  extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars)));
321   
322                  add_form_key('ucp_profile_info');
323   
324                  if ($submit)
325                  {
326                      $validate_array = array(
327                          'jabber'        => array(
328                              array('string', true, 5, 255),
329                              array('jabber')),
330                      );
331   
332                      if ($config['allow_birthdays'])
333                      {
334                          $validate_array = array_merge($validate_array, array(
335                              'bday_day'        => array('num', true, 1, 31),
336                              'bday_month'    => array('num', true, 1, 12),
337                              'bday_year'        => array('num', true, 1901, gmdate('Y', time()) + 50),
338                              'user_birthday' => array('date', true),
339                          ));
340                      }
341   
342                      $error = validate_data($data, $validate_array);
343   
344                      // validate custom profile fields
345                      $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
346   
347                      if (count($cp_error))
348                      {
349                          $error = array_merge($error, $cp_error);
350                      }
351   
352                      if (!check_form_key('ucp_profile_info'))
353                      {
354                          $error[] = 'FORM_INVALID';
355                      }
356   
357                      /**
358                      * Validate user data on editing profile in UCP
359                      *
360                      * @event core.ucp_profile_validate_profile_info
361                      * @var    array    data            Array with user profile data
362                      * @var    bool    submit            Flag indicating if submit button has been pressed
363                      * @var array    error            Array of any generated errors
364                      * @since 3.1.4-RC1
365                      */
366                      $vars = array('data', 'submit', 'error');
367                      extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars)));
368   
369                      if (!count($error))
370                      {
371                          $data['notify'] = $user->data['user_notify_type'];
372   
373                          if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
374                          {
375                              // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
376                              // Disable notify by Jabber now for this user.
377                              $data['notify'] = NOTIFY_EMAIL;
378                          }
379   
380                          $sql_ary = array(
381                              'user_jabber'    => $data['jabber'],
382                              'user_notify_type'    => $data['notify'],
383                          );
384   
385                          if ($config['allow_birthdays'])
386                          {
387                              $sql_ary['user_birthday'] = $data['user_birthday'];
388                          }
389   
390                          /**
391                          * Modify profile data in UCP before submitting to the database
392                          *
393                          * @event core.ucp_profile_info_modify_sql_ary
394                          * @var    array    cp_data        Array with the user custom profile fields data
395                          * @var    array    data        Array with user profile data
396                          * @var  array    sql_ary        user options data we update
397                          * @since 3.1.4-RC1
398                          */
399                          $vars = array('cp_data', 'data', 'sql_ary');
400                          extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars)));
401   
402                          $sql = 'UPDATE ' . USERS_TABLE . '
403                              SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
404                              WHERE user_id = ' . $user->data['user_id'];
405                          $db->sql_query($sql);
406   
407                          // Update Custom Fields
408                          $cp->update_profile_field_data($user->data['user_id'], $cp_data);
409   
410                          meta_refresh(3, $this->u_action);
411                          $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
412                          trigger_error($message);
413                      }
414   
415                      // Replace "error" strings with their real, localised form
416                      $error = array_map(array($user, 'lang'), $error);
417                  }
418   
419                  if ($config['allow_birthdays'])
420                  {
421                      $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
422                      for ($i = 1; $i < 32; $i++)
423                      {
424                          $selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
425                          $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
426                      }
427   
428                      $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
429                      for ($i = 1; $i < 13; $i++)
430                      {
431                          $selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
432                          $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
433                      }
434   
435                      $now = getdate();
436                      $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
437                      for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
438                      {
439                          $selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
440                          $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
441                      }
442                      unset($now);
443   
444                      $template->assign_vars(array(
445                          'S_BIRTHDAY_DAY_OPTIONS'    => $s_birthday_day_options,
446                          'S_BIRTHDAY_MONTH_OPTIONS'    => $s_birthday_month_options,
447                          'S_BIRTHDAY_YEAR_OPTIONS'    => $s_birthday_year_options,
448                          'S_BIRTHDAYS_ENABLED'        => true,
449                      ));
450                  }
451   
452                  $template->assign_vars(array(
453                      'ERROR'                => (count($error)) ? implode('<br />', $error) : '',
454                      'S_JABBER_ENABLED'    => $config['jab_enable'],
455                      'JABBER'            => $data['jabber'],
456                  ));
457   
458                  // Get additional profile fields and assign them to the template block var 'profile_fields'
459                  $user->get_profile_fields($user->data['user_id']);
460   
461                  $cp->generate_profile_fields('profile', $user->get_iso_lang_id());
462   
463              break;
464   
465              case 'signature':
466   
467                  if (!$auth->acl_get('u_sig'))
468                  {
469                      send_status_line(403, 'Forbidden');
470                      trigger_error('NO_AUTH_SIGNATURE');
471                  }
472   
473                  if (!function_exists('generate_smilies'))
474                  {
475                      include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
476                  }
477   
478                  if (!function_exists('display_custom_bbcodes'))
479                  {
480                      include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
481                  }
482   
483                  $preview    = $request->is_set_post('preview');
484   
485                  $enable_bbcode    = ($config['allow_sig_bbcode']) ? $user->optionget('sig_bbcode') : false;
486                  $enable_smilies    = ($config['allow_sig_smilies']) ? $user->optionget('sig_smilies') : false;
487                  $enable_urls    = ($config['allow_sig_links']) ? $user->optionget('sig_links') : false;
488   
489                  $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0);
490   
491                  $decoded_message    = generate_text_for_edit($user->data['user_sig'], $user->data['user_sig_bbcode_uid'], $bbcode_flags);
492                  $signature            = $request->variable('signature', $decoded_message['text'], true);
493                  $signature_preview    = '';
494   
495                  if ($submit || $preview)
496                  {
497                      $enable_bbcode    = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false;
498                      $enable_smilies    = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false;
499                      $enable_urls    = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false;
500   
501                      if (!check_form_key('ucp_sig'))
502                      {
503                          $error[] = 'FORM_INVALID';
504                      }
505                  }
506   
507                  /**
508                  * Modify user signature on editing profile in UCP
509                  *
510                  * @event core.ucp_profile_modify_signature
511                  * @var    bool    enable_bbcode        Whether or not bbcode is enabled
512                  * @var    bool    enable_smilies        Whether or not smilies are enabled
513                  * @var    bool    enable_urls            Whether or not urls are enabled
514                  * @var    string    signature            Users signature text
515                  * @var    array    error                Any error strings
516                  * @var    bool    submit                Whether or not the form has been sumitted
517                  * @var    bool    preview                Whether or not the signature is being previewed
518                  * @since 3.1.10-RC1
519                  * @changed 3.2.0-RC2 Removed message parser
520                  */
521                  $vars = array(
522                      'enable_bbcode',
523                      'enable_smilies',
524                      'enable_urls',
525                      'signature',
526                      'error',
527                      'submit',
528                      'preview',
529                  );
530                  extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature', compact($vars)));
531   
532                  $bbcode_uid = $bbcode_bitfield = $bbcode_flags = '';
533                  $warn_msg = generate_text_for_storage(
534                      $signature,
535                      $bbcode_uid,
536                      $bbcode_bitfield,
537                      $bbcode_flags,
538                      $enable_bbcode,
539                      $enable_urls,
540                      $enable_smilies,
541                      $config['allow_sig_img'],
542                      $config['allow_sig_flash'],
543                      true,
544                      $config['allow_sig_links'],
545                      'sig'
546                  );
547   
548                  if (count($warn_msg))
549                  {
550                      $error += $warn_msg;
551                  }
552   
553                  if (!$submit)
554                  {
555                      // Parse it for displaying
556                      $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags);
557                  }
558                  else
559                  {
560                      if (!count($error))
561                      {
562                          $user->optionset('sig_bbcode', $enable_bbcode);
563                          $user->optionset('sig_smilies', $enable_smilies);
564                          $user->optionset('sig_links', $enable_urls);
565   
566                          $sql_ary = array(
567                              'user_sig'                    => $signature,
568                              'user_options'                => $user->data['user_options'],
569                              'user_sig_bbcode_uid'        => $bbcode_uid,
570                              'user_sig_bbcode_bitfield'    => $bbcode_bitfield
571                          );
572   
573                          /**
574                          * Modify user registration data before submitting it to the database
575                          *
576                          * @event core.ucp_profile_modify_signature_sql_ary
577                          * @var    array    sql_ary        Array with user signature data to submit to the database
578                          * @since 3.1.10-RC1
579                          */
580                          $vars = array('sql_ary');
581                          extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature_sql_ary', compact($vars)));
582   
583                          $sql = 'UPDATE ' . USERS_TABLE . '
584                              SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
585                              WHERE user_id = ' . $user->data['user_id'];
586                          $db->sql_query($sql);
587   
588                          $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
589                          trigger_error($message);
590                      }
591                  }
592   
593                  // Replace "error" strings with their real, localised form
594                  $error = array_map(array($user, 'lang'), $error);
595   
596                  if ($request->is_set_post('preview'))
597                  {
598                      $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags);
599                  }
600   
601                  /** @var \phpbb\controller\helper $controller_helper */
602                  $controller_helper = $phpbb_container->get('controller.helper');
603   
604                  $template->assign_vars(array(
605                      'ERROR'                => (count($error)) ? implode('<br />', $error) : '',
606                      'SIGNATURE'            => $decoded_message['text'],
607                      'SIGNATURE_PREVIEW'    => $signature_preview,
608   
609                      'S_BBCODE_CHECKED'         => (!$enable_bbcode) ? ' checked="checked"' : '',
610                      'S_SMILIES_CHECKED'     => (!$enable_smilies) ? ' checked="checked"' : '',
611                      'S_MAGIC_URL_CHECKED'     => (!$enable_urls) ? ' checked="checked"' : '',
612   
613                      'BBCODE_STATUS'            => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'),
614                      'SMILIES_STATUS'        => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
615                      'IMG_STATUS'            => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
616                      'FLASH_STATUS'            => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
617                      'URL_STATUS'            => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
618                      'MAX_FONT_SIZE'            => (int) $config['max_sig_font_size'],
619   
620                      'L_SIGNATURE_EXPLAIN'    => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']),
621   
622                      'S_BBCODE_ALLOWED'        => $config['allow_sig_bbcode'],
623                      'S_SMILIES_ALLOWED'        => $config['allow_sig_smilies'],
624                      'S_BBCODE_IMG'            => ($config['allow_sig_img']) ? true : false,
625                      'S_BBCODE_FLASH'        => ($config['allow_sig_flash']) ? true : false,
626                      'S_LINKS_ALLOWED'        => ($config['allow_sig_links']) ? true : false)
627                  );
628   
629                  add_form_key('ucp_sig');
630   
631                  // Build custom bbcodes array
632                  display_custom_bbcodes();
633   
634                  // Generate smiley listing
635                  generate_smilies('inline', 0);
636   
637              break;
638   
639              case 'avatar':
640   
641                  add_form_key('ucp_avatar');
642   
643                  $avatars_enabled = false;
644   
645                  if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar'))
646                  {
647                      /* @var $phpbb_avatar_manager \phpbb\avatar\manager */
648                      $phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
649                      $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
650   
651                      // This is normalised data, without the user_ prefix
652                      $avatar_data = \phpbb\avatar\manager::clean_row($user->data, 'user');
653   
654                      if ($submit)
655                      {
656                          if (check_form_key('ucp_avatar'))
657                          {
658                              $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', ''));
659   
660                              if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete'))
661                              {
662                                  $driver = $phpbb_avatar_manager->get_driver($driver_name);
663                                  $result = $driver->process_form($request, $template, $user, $avatar_data, $error);
664   
665                                  if ($result && empty($error))
666                                  {
667                                      // Success! Lets save the result in the database
668                                      $result = array(
669                                          'user_avatar_type' => $driver_name,
670                                          'user_avatar' => $result['avatar'],
671                                          'user_avatar_width' => $result['avatar_width'],
672                                          'user_avatar_height' => $result['avatar_height'],
673                                      );
674   
675                                      /**
676                                      * Trigger events on successfull avatar change
677                                      *
678                                      * @event core.ucp_profile_avatar_sql
679                                      * @var    array    result    Array with data to be stored in DB
680                                      * @since 3.1.11-RC1
681                                      */
682                                      $vars = array('result');
683                                      extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_sql', compact($vars)));
684   
685                                      $sql = 'UPDATE ' . USERS_TABLE . '
686                                          SET ' . $db->sql_build_array('UPDATE', $result) . '
687                                          WHERE user_id = ' . (int) $user->data['user_id'];
688                                      $db->sql_query($sql);
689   
690                                      meta_refresh(3, $this->u_action);
691                                      $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
692                                      trigger_error($message);
693                                  }
694                              }
695                          }
696                          else
697                          {
698                              $error[] = 'FORM_INVALID';
699                          }
700                      }
701   
702                      // Handle deletion of avatars
703                      if ($request->is_set_post('avatar_delete'))
704                      {
705                          if (!confirm_box(true))
706                          {
707                              confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array(
708                                      'avatar_delete'     => true,
709                                      'i'                 => $id,
710                                      'mode'              => $mode))
711                              );
712                          }
713                          else
714                          {
715                              $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_');
716   
717                              meta_refresh(3, $this->u_action);
718                              $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
719                              trigger_error($message);
720                          }
721                      }
722   
723                      $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type']));
724   
725                      $template->assign_vars(array(
726                          'AVATAR_MIN_WIDTH'    => $config['avatar_min_width'],
727                          'AVATAR_MAX_WIDTH'    => $config['avatar_max_width'],
728                          'AVATAR_MIN_HEIGHT'    => $config['avatar_min_height'],
729                          'AVATAR_MAX_HEIGHT'    => $config['avatar_max_height'],
730                      ));
731   
732                      foreach ($avatar_drivers as $current_driver)
733                      {
734                          $driver = $phpbb_avatar_manager->get_driver($current_driver);
735   
736                          $avatars_enabled = true;
737                          $template->set_filenames(array(
738                              'avatar' => $driver->get_template_name(),
739                          ));
740   
741                          if ($driver->prepare_form($request, $template, $user, $avatar_data, $error))
742                          {
743                              $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
744                              $driver_upper = strtoupper($driver_name);
745   
746                              $template->assign_block_vars('avatar_drivers', array(
747                                  'L_TITLE' => $user->lang($driver_upper . '_TITLE'),
748                                  'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'),
749   
750                                  'DRIVER' => $driver_name,
751                                  'SELECTED' => $current_driver == $selected_driver,
752                                  'OUTPUT' => $template->assign_display('avatar'),
753                              ));
754                          }
755                      }
756   
757                      // Replace "error" strings with their real, localised form
758                      $error = $phpbb_avatar_manager->localize_errors($user, $error);
759                  }
760   
761                  $avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
762   
763                  $template->assign_vars(array(
764                      'ERROR'            => (count($error)) ? implode('<br />', $error) : '',
765                      'AVATAR'        => $avatar,
766   
767                      'S_FORM_ENCTYPE'    => ' enctype="multipart/form-data"',
768   
769                      'L_AVATAR_EXPLAIN'    => phpbb_avatar_explanation_string(),
770   
771                      'S_AVATARS_ENABLED'        => ($config['allow_avatar'] && $avatars_enabled),
772                  ));
773   
774              break;
775   
776              case 'autologin_keys':
777   
778                  add_form_key('ucp_autologin_keys');
779   
780                  if ($submit)
781                  {
782                      $keys = $request->variable('keys', array(''));
783   
784                      if (!check_form_key('ucp_autologin_keys'))
785                      {
786                          $error[] = 'FORM_INVALID';
787                      }
788   
789                      if (!count($error))
790                      {
791                          if (!empty($keys))
792                          {
793                              foreach ($keys as $key => $id)
794                              {
795                                  $keys[$key] = $db->sql_like_expression($id . $db->get_any_char());
796                              }
797                              $sql_where = '(key_id ' . implode(' OR key_id ', $keys) . ')';
798                              $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
799                                  WHERE user_id = ' . (int) $user->data['user_id'] . '
800                                  AND ' . $sql_where ;
801   
802                              $db->sql_query($sql);
803   
804                              meta_refresh(3, $this->u_action);
805                              $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
806                              trigger_error($message);
807                          }
808                      }
809   
810                      // Replace "error" strings with their real, localised form
811                      $error = array_map(array($user, 'lang'), $error);
812                  }
813   
814                  $sql_ary = [
815                      'SELECT'    => 'sk.key_id, sk.last_ip, sk.last_login',
816                      'FROM'        => [SESSIONS_KEYS_TABLE    => 'sk'],
817                      'WHERE'        => 'sk.user_id = ' . (int) $user->data['user_id'],
818                      'ORDER_BY'    => 'sk.last_login ASC',
819                  ];
820   
821                  /**
822                   * Event allows changing SQL query for autologin keys
823                   *
824                   * @event core.ucp_profile_autologin_keys_sql
825                   * @var    array    sql_ary    Array with autologin keys SQL query
826                   * @since 3.3.2-RC1
827                   */
828                  $vars = ['sql_ary'];
829                  extract($phpbb_dispatcher->trigger_event('core.ucp_profile_autologin_keys_sql', compact($vars)));
830   
831                  $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
832                  $sessions = (array) $db->sql_fetchrowset($result);
833                  $db->sql_freeresult($result);
834   
835                  $template_vars = [];
836                  foreach ($sessions as $row)
837                  {
838                      $key = substr($row['key_id'], 0, 8);
839                      $template_vars[$key] = [
840                          'KEY' => $key,
841                          'IP' => $row['last_ip'],
842                          'LOGIN_TIME' => $user->format_date($row['last_login']),
843                      ];
844                  }
845   
846                  /**
847                   * Event allows changing template variables
848                   *
849                   * @event core.ucp_profile_autologin_keys_template_vars
850                   * @var    array    sessions        Array with session keys data
851                   * @var    array    template_vars    Array with template variables
852                   * @since 3.3.2-RC1
853                   */
854                  $vars = ['sessions', 'template_vars'];
855                  extract($phpbb_dispatcher->trigger_event('core.ucp_profile_autologin_keys_template_vars', compact($vars)));
856   
857                  $template->assign_block_vars_array('sessions', $template_vars);
858   
859              break;
860          }
861   
862          $template->assign_vars(array(
863              'ERROR'        => (count($error)) ? implode('<br />', $error) : '',
864   
865              'L_TITLE'    => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
866   
867              'S_HIDDEN_FIELDS'    => $s_hidden_fields,
868              'S_UCP_ACTION'        => $this->u_action)
869          );
870   
871          // Set desired template
872          $this->tpl_name = 'ucp_profile_' . $mode;
873          $this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
874      }
875  }
876