[ Index ]

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


Generated: Sat Oct 26 11:28:42 2019 Cross-referenced by PHPXref 0.7.1