[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

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

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * @ignore
  16  */
  17  if (!defined('IN_PHPBB'))
  18  {
  19      exit;
  20  }
  21  
  22  /**
  23  * ucp_register
  24  * Board registration
  25  */
  26  class ucp_register
  27  {
  28      var $u_action;
  29  
  30  	function main($id, $mode)
  31      {
  32          global $config, $db, $user, $template, $phpbb_root_path, $phpEx;
  33          global $request, $phpbb_container, $phpbb_dispatcher;
  34  
  35          //
  36          if ($config['require_activation'] == USER_ACTIVATION_DISABLE ||
  37              (in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN)) && !$config['email_enable']))
  38          {
  39              trigger_error('UCP_REGISTER_DISABLE');
  40          }
  41  
  42          $coppa            = $request->is_set('coppa_yes') ? 1 : ($request->is_set('coppa_no') ? 0 : false);
  43          $coppa            = $request->is_set('coppa') ? $request->variable('coppa', 0) : $coppa;
  44          $agreed            = $request->variable('agreed', false);
  45          $submit            = $request->is_set_post('submit');
  46          $change_lang    = $request->variable('change_lang', '');
  47          $user_lang        = $request->variable('lang', $user->lang_name);
  48  
  49          if ($agreed && !check_form_key('ucp_register'))
  50          {
  51              $agreed = false;
  52          }
  53  
  54          if ($coppa !== false && !check_form_key('ucp_register'))
  55          {
  56              $coppa = false;
  57          }
  58  
  59          /**
  60          * Add UCP register data before they are assigned to the template or submitted
  61          *
  62          * To assign data to the template, use $template->assign_vars()
  63          *
  64          * @event core.ucp_register_requests_after
  65          * @var    bool    coppa        Is set coppa
  66          * @var    bool    agreed        Did user agree to coppa?
  67          * @var    bool    submit        Is set post submit?
  68          * @var    string    change_lang    Change language request
  69          * @var    string    user_lang    User language request
  70          * @since 3.1.11-RC1
  71          */
  72          $vars = array(
  73              'coppa',
  74              'agreed',
  75              'submit',
  76              'change_lang',
  77              'user_lang',
  78          );
  79          extract($phpbb_dispatcher->trigger_event('core.ucp_register_requests_after', compact($vars)));
  80  
  81          add_form_key('ucp_register');
  82  
  83          if ($change_lang || $user_lang != $config['default_lang'])
  84          {
  85              $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang);
  86  
  87              if (!validate_language_iso_name($use_lang))
  88              {
  89                  if ($change_lang)
  90                  {
  91                      $submit = false;
  92  
  93                      // Setting back agreed to let the user view the agreement in his/her language
  94                      $agreed = false;
  95                  }
  96  
  97                  $user_lang = $use_lang;
  98              }
  99              else
 100              {
 101                  $change_lang = '';
 102                  $user_lang = $user->lang_name;
 103              }
 104          }
 105  
 106          /* @var $cp \phpbb\profilefields\manager */
 107          $cp = $phpbb_container->get('profilefields.manager');
 108  
 109          $error = $cp_data = $cp_error = array();
 110          $s_hidden_fields = array();
 111  
 112          // Handle login_link data added to $_hidden_fields
 113          $login_link_data = $this->get_login_link_data_array();
 114  
 115          if (!empty($login_link_data))
 116          {
 117              // Confirm that we have all necessary data
 118              /* @var $provider_collection \phpbb\auth\provider_collection */
 119              $provider_collection = $phpbb_container->get('auth.provider_collection');
 120              $auth_provider = $provider_collection->get_provider($request->variable('auth_provider', ''));
 121  
 122              $result = $auth_provider->login_link_has_necessary_data($login_link_data);
 123              if ($result !== null)
 124              {
 125                  $error[] = $user->lang[$result];
 126              }
 127  
 128              $s_hidden_fields = array_merge($s_hidden_fields, $this->get_login_link_data_for_hidden_fields($login_link_data));
 129          }
 130  
 131          if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable']))
 132          {
 133              $add_coppa = ($coppa !== false) ? '&amp;coppa=' . $coppa : '';
 134  
 135              $s_hidden_fields = array_merge($s_hidden_fields, array(
 136                  'change_lang'    => '',
 137              ));
 138  
 139              // If we change the language, we want to pass on some more possible parameter.
 140              if ($change_lang)
 141              {
 142                  // We do not include the password
 143                  $s_hidden_fields = array_merge($s_hidden_fields, array(
 144                      'username'            => $request->variable('username', '', true),
 145                      'email'                => strtolower($request->variable('email', '')),
 146                      'lang'                => $user->lang_name,
 147                      'tz'                => $request->variable('tz', $config['board_timezone']),
 148                  ));
 149  
 150              }
 151  
 152              // Checking amount of available languages
 153              $sql = 'SELECT lang_iso, lang_local_name
 154                  FROM ' . LANG_TABLE . '
 155                  ORDER BY lang_english_name';
 156              $result = $db->sql_query($sql);
 157              $lang_row = (array) $db->sql_fetchrowset($result);
 158              $db->sql_freeresult($result);
 159  
 160              if ($coppa === false && $config['coppa_enable'])
 161              {
 162                  $now = getdate();
 163                  $coppa_birthday = $user->create_datetime()
 164                      ->setDate($now['year'] - 13, $now['mon'], $now['mday'] - 1)
 165                      ->setTime(0, 0, 0)
 166                      ->format($user->lang['DATE_FORMAT'], true);
 167                  unset($now);
 168  
 169                  $template_vars = array(
 170                      'S_LANG_OPTIONS'    => (count($lang_row) > 1) ? language_select($user_lang, $lang_row) : '',
 171                      'L_COPPA_NO'        => $user->lang('UCP_COPPA_BEFORE', $coppa_birthday),
 172                      'L_COPPA_YES'        => $user->lang('UCP_COPPA_ON_AFTER', $coppa_birthday),
 173  
 174                      'S_SHOW_COPPA'        => true,
 175                      'S_HIDDEN_FIELDS'    => build_hidden_fields($s_hidden_fields),
 176                      'S_UCP_ACTION'        => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
 177  
 178                      'COOKIE_NAME'        => $config['cookie_name'],
 179                      'COOKIE_PATH'        => $config['cookie_path'],
 180                  );
 181              }
 182              else
 183              {
 184                  $template_vars = array(
 185                      'S_LANG_OPTIONS'    => (count($lang_row) > 1) ? language_select($user_lang, $lang_row) : '',
 186                      'L_TERMS_OF_USE'    => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()),
 187  
 188                      'S_SHOW_COPPA'        => false,
 189                      'S_REGISTRATION'    => true,
 190                      'S_HIDDEN_FIELDS'    => build_hidden_fields($s_hidden_fields),
 191                      'S_UCP_ACTION'        => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_coppa),
 192  
 193                      'COOKIE_NAME'        => $config['cookie_name'],
 194                      'COOKIE_PATH'        => $config['cookie_path'],
 195                  );
 196              }
 197  
 198              $tpl_name = 'ucp_agreement';
 199  
 200              /**
 201              * Allows to modify the agreements.
 202              *
 203              * @event core.ucp_register_agreement_modify_template_data
 204              * @var    string    tpl_name            Template file
 205              * @var    array    template_vars        Array with data about to be assigned to the template
 206              * @var    array    s_hidden_fields        Array with hidden form elements
 207              * @var    array    lang_row            Array with available languages, read only
 208              * @since 3.2.2-RC1
 209              */
 210              $vars = array('tpl_name', 'template_vars', 's_hidden_fields', 'lang_row');
 211              extract($phpbb_dispatcher->trigger_event('core.ucp_register_agreement_modify_template_data', compact($vars)));
 212  
 213              unset($lang_row);
 214  
 215              $template_vars = array_merge($template_vars, array(
 216                  'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
 217              ));
 218  
 219              $template->assign_vars($template_vars);
 220  
 221              /**
 222              * Allows to modify the agreements.
 223              *
 224              * To assign data to the template, use $template->assign_vars()
 225              *
 226              * @event core.ucp_register_agreement
 227              * @since 3.1.6-RC1
 228              * @deprecated 3.2.2-RC1 Replaced by core.ucp_register_agreement_modify_template_data and to be removed in 3.3.0-RC1
 229              */
 230              $phpbb_dispatcher->dispatch('core.ucp_register_agreement');
 231  
 232              $this->tpl_name = $tpl_name;
 233              return;
 234          }
 235  
 236          // The CAPTCHA kicks in here. We can't help that the information gets lost on language change.
 237          if ($config['enable_confirm'])
 238          {
 239              $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']);
 240              $captcha->init(CONFIRM_REG);
 241          }
 242  
 243          $timezone = $config['board_timezone'];
 244  
 245          $data = array(
 246              'username'            => $request->variable('username', '', true),
 247              'new_password'        => $request->variable('new_password', '', true),
 248              'password_confirm'    => $request->variable('password_confirm', '', true),
 249              'email'                => strtolower($request->variable('email', '')),
 250              'lang'                => basename($request->variable('lang', $user->lang_name)),
 251              'tz'                => $request->variable('tz', $timezone),
 252          );
 253          /**
 254          * Add UCP register data before they are assigned to the template or submitted
 255          *
 256          * To assign data to the template, use $template->assign_vars()
 257          *
 258          * @event core.ucp_register_data_before
 259          * @var    bool    submit        Do we display the form only
 260          *                            or did the user press submit
 261          * @var    array    data        Array with current ucp registration data
 262          * @since 3.1.4-RC1
 263          */
 264          $vars = array('submit', 'data');
 265          extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_before', compact($vars)));
 266  
 267          // Check and initialize some variables if needed
 268          if ($submit)
 269          {
 270              $error = validate_data($data, array(
 271                  'username'            => array(
 272                      array('string', false, $config['min_name_chars'], $config['max_name_chars']),
 273                      array('username', '')),
 274                  'new_password'        => array(
 275                      array('string', false, $config['min_pass_chars'], 0),
 276                      array('password')),
 277                  'password_confirm'    => array('string', false, $config['min_pass_chars'], 0),
 278                  'email'                => array(
 279                      array('string', false, 6, 60),
 280                      array('user_email')),
 281                  'tz'                => array('timezone'),
 282                  'lang'                => array('language_iso_name'),
 283              ));
 284  
 285              if (!check_form_key('ucp_register'))
 286              {
 287                  $error[] = $user->lang['FORM_INVALID'];
 288              }
 289  
 290              // Replace "error" strings with their real, localised form
 291              $error = array_map(array($user, 'lang'), $error);
 292  
 293              if ($config['enable_confirm'])
 294              {
 295                  $vc_response = $captcha->validate($data);
 296                  if ($vc_response !== false)
 297                  {
 298                      $error[] = $vc_response;
 299                  }
 300  
 301                  if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts'])
 302                  {
 303                      trigger_error('TOO_MANY_REGISTERS');
 304                  }
 305              }
 306  
 307              // DNSBL check
 308              if ($config['check_dnsbl'])
 309              {
 310                  if (($dnsbl = $user->check_dnsbl('register')) !== false)
 311                  {
 312                      $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]);
 313                  }
 314              }
 315  
 316              // validate custom profile fields
 317              $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error);
 318  
 319              if (!count($error))
 320              {
 321                  if ($data['new_password'] != $data['password_confirm'])
 322                  {
 323                      $error[] = $user->lang['NEW_PASSWORD_ERROR'];
 324                  }
 325              }
 326              /**
 327              * Check UCP registration data after they are submitted
 328              *
 329              * @event core.ucp_register_data_after
 330              * @var    bool    submit        Do we display the form only
 331              *                            or did the user press submit
 332              * @var    array     data        Array with current ucp registration data
 333              * @var    array    cp_data        Array with custom profile fields data
 334              * @var    array     error        Array with list of errors
 335              * @since 3.1.4-RC1
 336              */
 337              $vars = array('submit', 'data', 'cp_data', 'error');
 338              extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_after', compact($vars)));
 339  
 340              if (!count($error))
 341              {
 342                  $server_url = generate_board_url();
 343  
 344                  // Which group by default?
 345                  $group_name = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED';
 346  
 347                  $sql = 'SELECT group_id
 348                      FROM ' . GROUPS_TABLE . "
 349                      WHERE group_name = '" . $db->sql_escape($group_name) . "'
 350                          AND group_type = " . GROUP_SPECIAL;
 351                  $result = $db->sql_query($sql);
 352                  $row = $db->sql_fetchrow($result);
 353                  $db->sql_freeresult($result);
 354  
 355                  if (!$row)
 356                  {
 357                      trigger_error('NO_GROUP');
 358                  }
 359  
 360                  $group_id = $row['group_id'];
 361  
 362                  if (($coppa ||
 363                      $config['require_activation'] == USER_ACTIVATION_SELF ||
 364                      $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable'])
 365                  {
 366                      $user_actkey = strtolower(gen_rand_string(32));
 367                      $user_type = USER_INACTIVE;
 368                      $user_inactive_reason = INACTIVE_REGISTER;
 369                      $user_inactive_time = time();
 370                  }
 371                  else
 372                  {
 373                      $user_type = USER_NORMAL;
 374                      $user_actkey = '';
 375                      $user_inactive_reason = 0;
 376                      $user_inactive_time = 0;
 377                  }
 378  
 379                  // Instantiate passwords manager
 380                  /* @var $passwords_manager \phpbb\passwords\manager */
 381                  $passwords_manager = $phpbb_container->get('passwords.manager');
 382  
 383                  $user_row = array(
 384                      'username'                => $data['username'],
 385                      'user_password'            => $passwords_manager->hash($data['new_password']),
 386                      'user_email'            => $data['email'],
 387                      'group_id'                => (int) $group_id,
 388                      'user_timezone'            => $data['tz'],
 389                      'user_lang'                => $data['lang'],
 390                      'user_type'                => $user_type,
 391                      'user_actkey'            => $user_actkey,
 392                      'user_ip'                => $user->ip,
 393                      'user_regdate'            => time(),
 394                      'user_inactive_reason'    => $user_inactive_reason,
 395                      'user_inactive_time'    => $user_inactive_time,
 396                  );
 397  
 398                  if ($config['new_member_post_limit'])
 399                  {
 400                      $user_row['user_new'] = 1;
 401                  }
 402                  /**
 403                  * Add into $user_row before user_add
 404                  *
 405                  * user_add allows adding more data into the users table
 406                  *
 407                  * @event core.ucp_register_user_row_after
 408                  * @var    bool    submit        Do we display the form only
 409                  *                            or did the user press submit
 410                  * @var    array    data        Array with current ucp registration data
 411                  * @var    array    cp_data        Array with custom profile fields data
 412                  * @var    array    user_row    Array with user data that will be inserted
 413                  * @since 3.1.4-RC1
 414                  * @changed 3.2.10-RC1 Added data array
 415                  */
 416                  $vars = array('submit', 'data', 'cp_data', 'user_row');
 417                  extract($phpbb_dispatcher->trigger_event('core.ucp_register_user_row_after', compact($vars)));
 418  
 419                  // Register user...
 420                  $user_id = user_add($user_row, $cp_data);
 421  
 422                  // This should not happen, because the required variables are listed above...
 423                  if ((bool) $user_id === false)
 424                  {
 425                      trigger_error('NO_USER', E_USER_ERROR);
 426                  }
 427  
 428                  // Okay, captcha, your job is done.
 429                  if ($config['enable_confirm'] && isset($captcha))
 430                  {
 431                      $captcha->reset();
 432                  }
 433  
 434                  if ($coppa && $config['email_enable'])
 435                  {
 436                      $message = $user->lang['ACCOUNT_COPPA'];
 437                      $email_template = 'coppa_welcome_inactive';
 438                  }
 439                  else if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable'])
 440                  {
 441                      $message = $user->lang['ACCOUNT_INACTIVE'];
 442                      $email_template = 'user_welcome_inactive';
 443                  }
 444                  else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable'])
 445                  {
 446                      $message = $user->lang['ACCOUNT_INACTIVE_ADMIN'];
 447                      $email_template = 'admin_welcome_inactive';
 448                  }
 449                  else
 450                  {
 451                      $message = $user->lang['ACCOUNT_ADDED'];
 452                      $email_template = 'user_welcome';
 453  
 454                      // Autologin after registration
 455                      $user->session_create($user_id, 0, false, 1);
 456                  }
 457  
 458                  if ($config['email_enable'])
 459                  {
 460                      include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 461  
 462                      $messenger = new messenger(false);
 463  
 464                      $messenger->template($email_template, $data['lang']);
 465  
 466                      $messenger->to($data['email'], $data['username']);
 467  
 468                      $messenger->anti_abuse_headers($config, $user);
 469  
 470                      $messenger->assign_vars(array(
 471                          'WELCOME_MSG'    => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
 472                          'USERNAME'        => html_entity_decode($data['username'], ENT_COMPAT),
 473                          'PASSWORD'        => html_entity_decode($data['new_password'], ENT_COMPAT),
 474                          'U_ACTIVATE'    => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey")
 475                      );
 476  
 477                      if ($coppa)
 478                      {
 479                          $messenger->assign_vars(array(
 480                              'FAX_INFO'        => $config['coppa_fax'],
 481                              'MAIL_INFO'        => $config['coppa_mail'],
 482                              'EMAIL_ADDRESS'    => $data['email'])
 483                          );
 484                      }
 485  
 486                      /**
 487                      * Modify messenger data before welcome mail is sent
 488                      *
 489                      * @event core.ucp_register_welcome_email_before
 490                      * @var    array        user_row    Array with user registration data
 491                      * @var    array        cp_data        Array with custom profile fields data
 492                      * @var    array        data        Array with current ucp registration data
 493                      * @var    string        message        Message to be displayed to the user after registration
 494                      * @var    string        server_url    Server URL
 495                      * @var    int            user_id        New user ID
 496                      * @var    string        user_actkey    User activation key
 497                      * @var    messenger    messenger    phpBB Messenger
 498                      * @since 3.2.4-RC1
 499                      */
 500                      $vars = array(
 501                          'user_row',
 502                          'cp_data',
 503                          'data',
 504                          'message',
 505                          'server_url',
 506                          'user_id',
 507                          'user_actkey',
 508                          'messenger',
 509                      );
 510                      extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars)));
 511  
 512                      $messenger->send(NOTIFY_EMAIL);
 513                  }
 514  
 515                  if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
 516                  {
 517                      /* @var $phpbb_notifications \phpbb\notification\manager */
 518                      $phpbb_notifications = $phpbb_container->get('notification_manager');
 519                      $phpbb_notifications->add_notifications('notification.type.admin_activate_user', array(
 520                          'user_id'        => $user_id,
 521                          'user_actkey'    => $user_row['user_actkey'],
 522                          'user_regdate'    => $user_row['user_regdate'],
 523                      ));
 524                  }
 525  
 526                  // Perform account linking if necessary
 527                  if (!empty($login_link_data))
 528                  {
 529                      $login_link_data['user_id'] = $user_id;
 530  
 531                      $result = $auth_provider->link_account($login_link_data);
 532  
 533                      if ($result)
 534                      {
 535                          $message = $message . '<br /><br />' . $user->lang[$result];
 536                      }
 537                  }
 538  
 539                  /**
 540                  * Perform additional actions after user registration
 541                  *
 542                  * @event core.ucp_register_register_after
 543                  * @var    array        user_row    Array with user registration data
 544                  * @var    array        cp_data        Array with custom profile fields data
 545                  * @var    array        data        Array with current ucp registration data
 546                  * @var    string        message        Message to be displayed to the user after registration
 547                  * @var    string        server_url    Server URL
 548                  * @var    int            user_id        New user ID
 549                  * @var    string        user_actkey    User activation key
 550                  * @since 3.2.4-RC1
 551                  */
 552                  $vars = array(
 553                      'user_row',
 554                      'cp_data',
 555                      'data',
 556                      'message',
 557                      'server_url',
 558                      'user_id',
 559                      'user_actkey',
 560                  );
 561                  extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars)));
 562  
 563                  $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
 564                  trigger_error($message);
 565              }
 566          }
 567  
 568          $s_hidden_fields = array_merge($s_hidden_fields, array(
 569              'agreed'        => 'true',
 570              'change_lang'    => 0,
 571          ));
 572  
 573          if ($config['coppa_enable'])
 574          {
 575              $s_hidden_fields['coppa'] = $coppa;
 576          }
 577  
 578          if ($config['enable_confirm'])
 579          {
 580              $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields());
 581          }
 582  
 583          // Visual Confirmation - Show images
 584          if ($config['enable_confirm'])
 585          {
 586              $template->assign_vars(array(
 587                  'CAPTCHA_TEMPLATE'        => $captcha->get_template(),
 588              ));
 589          }
 590  
 591          //
 592          $l_reg_cond = '';
 593          switch ($config['require_activation'])
 594          {
 595              case USER_ACTIVATION_SELF:
 596                  $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE'];
 597              break;
 598  
 599              case USER_ACTIVATION_ADMIN:
 600                  $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE'];
 601              break;
 602          }
 603  
 604          /* @var $provider_collection \phpbb\auth\provider_collection */
 605          $provider_collection = $phpbb_container->get('auth.provider_collection');
 606          $auth_provider = $provider_collection->get_provider();
 607  
 608          $auth_provider_data = $auth_provider->get_login_data();
 609          if ($auth_provider_data)
 610          {
 611              if (isset($auth_provider_data['VARS']))
 612              {
 613                  $template->assign_vars($auth_provider_data['VARS']);
 614              }
 615  
 616              if (isset($auth_provider_data['BLOCK_VAR_NAME']))
 617              {
 618                  foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars)
 619                  {
 620                      $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars);
 621                  }
 622              }
 623  
 624              $template->assign_vars(array(
 625                  'PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'],
 626              ));
 627          }
 628  
 629          // Assign template vars for timezone select
 630          phpbb_timezone_select($template, $user, $data['tz'], true);
 631  
 632          // Checking amount of available languages
 633          $sql = 'SELECT lang_iso, lang_local_name
 634              FROM ' . LANG_TABLE . '
 635              ORDER BY lang_english_name';
 636          $result = $db->sql_query($sql);
 637          $lang_row = (array) $db->sql_fetchrowset($result);
 638          $db->sql_freeresult($result);
 639  
 640          $template_vars = array(
 641              'USERNAME'            => $data['username'],
 642              'PASSWORD'            => $data['new_password'],
 643              'PASSWORD_CONFIRM'    => $data['password_confirm'],
 644              'EMAIL'                => $data['email'],
 645  
 646              'L_REG_COND'                => $l_reg_cond,
 647              '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'])),
 648              'L_PASSWORD_EXPLAIN'        => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS_XY', (int) $config['min_pass_chars'])),
 649  
 650              'S_LANG_OPTIONS'    => (count($lang_row) > 1) ? language_select($data['lang'], $lang_row) : '',
 651              'S_TZ_PRESELECT'    => !$submit,
 652              'S_CONFIRM_REFRESH'    => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false,
 653              'S_REGISTRATION'    => true,
 654              'S_COPPA'            => $coppa,
 655              'S_UCP_ACTION'        => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
 656  
 657              'COOKIE_NAME'        => $config['cookie_name'],
 658              'COOKIE_PATH'        => $config['cookie_path'],
 659          );
 660  
 661          $tpl_name = 'ucp_register';
 662  
 663          /**
 664          * Modify template data on the registration page
 665          *
 666          * @event core.ucp_register_modify_template_data
 667          * @var    array    template_vars        Array with template data
 668          * @var    array    data                Array with user data, read only
 669          * @var    array    error                Array with errors
 670          * @var    array    s_hidden_fields        Array with hidden field elements
 671          * @var    string    tpl_name            Template name
 672          * @since 3.2.2-RC1
 673          */
 674          $vars = array(
 675              'template_vars',
 676              'data',
 677              'error',
 678              's_hidden_fields',
 679              'tpl_name',
 680          );
 681          extract($phpbb_dispatcher->trigger_event('core.ucp_register_modify_template_data', compact($vars)));
 682  
 683          $template_vars = array_merge($template_vars, array(
 684              'ERROR'                => (count($error)) ? implode('<br />', $error) : '',
 685              'S_HIDDEN_FIELDS'    => build_hidden_fields($s_hidden_fields),
 686          ));
 687  
 688          $template->assign_vars($template_vars);
 689  
 690          //
 691          $user->profile_fields = array();
 692  
 693          // Generate profile fields -> Template Block Variable profile_fields
 694          $cp->generate_profile_fields('register', $user->get_iso_lang_id());
 695  
 696          //
 697          $this->tpl_name = $tpl_name;
 698      }
 699  
 700      /**
 701      * Creates the login_link data array
 702      *
 703      * @return    array    Returns an array of all POST paramaters whose names
 704      *                    begin with 'login_link_'
 705      */
 706  	protected function get_login_link_data_array()
 707      {
 708          global $request;
 709  
 710          $var_names = $request->variable_names(\phpbb\request\request_interface::POST);
 711          $login_link_data = array();
 712          $string_start_length = strlen('login_link_');
 713  
 714          foreach ($var_names as $var_name)
 715          {
 716              if (strpos($var_name, 'login_link_') === 0)
 717              {
 718                  $key_name = substr($var_name, $string_start_length);
 719                  $login_link_data[$key_name] = $request->variable($var_name, '', false, \phpbb\request\request_interface::POST);
 720              }
 721          }
 722  
 723          return $login_link_data;
 724      }
 725  
 726      /**
 727      * Prepends they key names of an associative array with 'login_link_' for
 728      * inclusion on the page as hidden fields.
 729      *
 730      * @param    array    $data    The array to be modified
 731      * @return    array    The modified array
 732      */
 733  	protected function get_login_link_data_for_hidden_fields($data)
 734      {
 735          $new_data = array();
 736  
 737          foreach ($data as $key => $value)
 738          {
 739              $new_data['login_link_' . $key] = $value;
 740          }
 741  
 742          return $new_data;
 743      }
 744  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1