Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 368
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ucp_register
0.00% covered (danger)
0.00%
0 / 366
0.00% covered (danger)
0.00%
0 / 3
5852
0.00% covered (danger)
0.00%
0 / 1
 main
0.00% covered (danger)
0.00%
0 / 353
0.00% covered (danger)
0.00%
0 / 1
5112
 get_login_link_data_array
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
12
 get_login_link_data_for_hidden_fields
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
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*/
17if (!defined('IN_PHPBB'))
18{
19    exit;
20}
21
22/**
23* ucp_register
24* Board registration
25*/
26class 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 = 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            $lang_options = phpbb_language_select($db, $user_lang, $lang_row);
161
162            if ($coppa === false && $config['coppa_enable'])
163            {
164                $now = getdate();
165                $coppa_birthday = $user->create_datetime()
166                    ->setDate($now['year'] - 13, $now['mon'], $now['mday'] - 1)
167                    ->setTime(0, 0, 0)
168                    ->format($user->lang['DATE_FORMAT'], true);
169                unset($now);
170
171                $template_vars = array(
172                    'LANG_OPTIONS'        => [
173                        'id'        => 'lang',
174                        'name'        => 'lang',
175                        'options'    => $lang_options,
176                    ],
177                    'L_COPPA_NO'        => $user->lang('UCP_COPPA_BEFORE', $coppa_birthday),
178                    'L_COPPA_YES'        => $user->lang('UCP_COPPA_ON_AFTER', $coppa_birthday),
179
180                    'S_SHOW_COPPA'        => true,
181                    'S_HIDDEN_FIELDS'    => build_hidden_fields($s_hidden_fields),
182                    'S_UCP_ACTION'        => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
183
184                    'COOKIE_NAME'        => $config['cookie_name'],
185                    'COOKIE_PATH'        => $config['cookie_path'],
186                );
187            }
188            else
189            {
190                $template_vars = array(
191                    'LANG_OPTIONS'        => [
192                        'id'        => 'lang',
193                        'name'        => 'lang',
194                        'options'    => $lang_options,
195                    ],
196                    'L_TERMS_OF_USE'    => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()),
197
198                    'S_SHOW_COPPA'        => false,
199                    'S_REGISTRATION'    => true,
200                    'S_HIDDEN_FIELDS'    => build_hidden_fields($s_hidden_fields),
201                    'S_UCP_ACTION'        => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_coppa),
202
203                    'COOKIE_NAME'        => $config['cookie_name'],
204                    'COOKIE_PATH'        => $config['cookie_path'],
205                );
206            }
207
208            $tpl_name = 'ucp_agreement';
209
210            /**
211            * Allows to modify the agreements.
212            *
213            * @event core.ucp_register_agreement_modify_template_data
214            * @var    string    tpl_name            Template file
215            * @var    array    template_vars        Array with data about to be assigned to the template
216            * @var    array    s_hidden_fields        Array with hidden form elements
217            * @var    array    lang_row            Array with available languages, read only
218            * @since 3.2.2-RC1
219            */
220            $vars = array('tpl_name', 'template_vars', 's_hidden_fields', 'lang_row');
221            extract($phpbb_dispatcher->trigger_event('core.ucp_register_agreement_modify_template_data', compact($vars)));
222
223            unset($lang_row);
224
225            $template_vars = array_merge($template_vars, array(
226                'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
227            ));
228
229            $template->assign_vars($template_vars);
230
231            $this->tpl_name = $tpl_name;
232            return;
233        }
234
235        // The CAPTCHA kicks in here. We can't help that the information gets lost on language change.
236        if ($config['enable_confirm'])
237        {
238            /** @var \phpbb\captcha\factory $captcha_factory */
239            $captcha_factory = $phpbb_container->get('captcha.factory');
240            $captcha = $captcha_factory->get_instance($config['captcha_plugin']);
241            $captcha->init(\phpbb\captcha\plugins\confirm_type::REGISTRATION);
242        }
243
244        $timezone = $config['board_timezone'];
245
246        $data = array(
247            'username'            => $request->variable('username', '', true),
248            'new_password'        => $request->variable('new_password', '', true),
249            'password_confirm'    => $request->variable('password_confirm', '', true),
250            'email'                => strtolower($request->variable('email', '')),
251            'lang'                => basename($request->variable('lang', $user->lang_name)),
252            'tz'                => $request->variable('tz', $timezone),
253        );
254        /**
255        * Add UCP register data before they are assigned to the template or submitted
256        *
257        * To assign data to the template, use $template->assign_vars()
258        *
259        * @event core.ucp_register_data_before
260        * @var    bool    submit        Do we display the form only
261        *                            or did the user press submit
262        * @var    array    data        Array with current ucp registration data
263        * @since 3.1.4-RC1
264        */
265        $vars = array('submit', 'data');
266        extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_before', compact($vars)));
267
268        // Check and initialize some variables if needed
269        if ($submit)
270        {
271            $error = validate_data($data, array(
272                'username'            => array(
273                    array('string', false, $config['min_name_chars'], $config['max_name_chars']),
274                    array('username', '')),
275                'new_password'        => array(
276                    array('string', false, $config['min_pass_chars'], 0),
277                    array('password')),
278                'password_confirm'    => array('string', false, $config['min_pass_chars'], 0),
279                'email'                => array(
280                    array('string', false, 6, 60),
281                    array('user_email')),
282                'tz'                => array('timezone'),
283                'lang'                => array('language_iso_name'),
284            ));
285
286            if (!check_form_key('ucp_register'))
287            {
288                $error[] = $user->lang['FORM_INVALID'];
289            }
290
291            // Replace "error" strings with their real, localised form
292            $error = array_map(array($user, 'lang'), $error);
293
294            if ($config['enable_confirm'])
295            {
296                if ($captcha->validate() !== true)
297                {
298                    $error[] = $captcha->get_error();
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_actkey_expiration'    => $user::get_token_expiration(),
393                    'user_ip'                    => $user->ip,
394                    'user_regdate'                => time(),
395                    'user_inactive_reason'        => $user_inactive_reason,
396                    'user_inactive_time'        => $user_inactive_time,
397                );
398
399                if ($config['new_member_post_limit'])
400                {
401                    $user_row['user_new'] = 1;
402                }
403                /**
404                * Add into $user_row before user_add
405                *
406                * user_add allows adding more data into the users table
407                *
408                * @event core.ucp_register_user_row_after
409                * @var    bool    submit        Do we display the form only
410                *                            or did the user press submit
411                * @var    array    data        Array with current ucp registration data
412                * @var    array    cp_data        Array with custom profile fields data
413                * @var    array    user_row    Array with user data that will be inserted
414                * @since 3.1.4-RC1
415                * @changed 3.2.10-RC1 Added data array
416                */
417                $vars = array('submit', 'data', '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 ((bool) $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'])
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                    // Autologin after registration
456                    $user->session_create($user_id, 0, false, 1);
457                }
458
459                if ($config['email_enable'])
460                {
461                    include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
462
463                    $messenger = new messenger(false);
464
465                    $messenger->template($email_template, $data['lang']);
466
467                    $messenger->to($data['email'], $data['username']);
468
469                    $messenger->anti_abuse_headers($config, $user);
470
471                    $messenger->assign_vars(array(
472                        'WELCOME_MSG'    => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
473                        'USERNAME'        => html_entity_decode($data['username'], ENT_COMPAT),
474                        'PASSWORD'        => html_entity_decode($data['new_password'], ENT_COMPAT),
475                        'U_ACTIVATE'    => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey")
476                    );
477
478                    if ($coppa)
479                    {
480                        $messenger->assign_vars(array(
481                            'FAX_INFO'        => $config['coppa_fax'],
482                            'MAIL_INFO'        => $config['coppa_mail'],
483                            'EMAIL_ADDRESS'    => $data['email'])
484                        );
485                    }
486
487                    /**
488                    * Modify messenger data before welcome mail is sent
489                    *
490                    * @event core.ucp_register_welcome_email_before
491                    * @var    array        user_row    Array with user registration data
492                    * @var    array        cp_data        Array with custom profile fields data
493                    * @var    array        data        Array with current ucp registration data
494                    * @var    string        message        Message to be displayed to the user after registration
495                    * @var    string        server_url    Server URL
496                    * @var    int            user_id        New user ID
497                    * @var    string        user_actkey    User activation key
498                    * @var    messenger    messenger    phpBB Messenger
499                    * @since 3.2.4-RC1
500                    */
501                    $vars = array(
502                        'user_row',
503                        'cp_data',
504                        'data',
505                        'message',
506                        'server_url',
507                        'user_id',
508                        'user_actkey',
509                        'messenger',
510                    );
511                    extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars)));
512
513                    $messenger->send(NOTIFY_EMAIL);
514                }
515
516                if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
517                {
518                    /* @var $phpbb_notifications \phpbb\notification\manager */
519                    $phpbb_notifications = $phpbb_container->get('notification_manager');
520                    $phpbb_notifications->add_notifications('notification.type.admin_activate_user', array(
521                        'user_id'        => $user_id,
522                        'user_actkey'    => $user_row['user_actkey'],
523                        'user_regdate'    => $user_row['user_regdate'],
524                    ));
525                }
526
527                // Perform account linking if necessary
528                if (!empty($login_link_data))
529                {
530                    $login_link_data['user_id'] = $user_id;
531
532                    $result = $auth_provider->link_account($login_link_data);
533
534                    if ($result)
535                    {
536                        $message = $message . '<br /><br />' . $user->lang[$result];
537                    }
538                }
539
540                /**
541                * Perform additional actions after user registration
542                *
543                * @event core.ucp_register_register_after
544                * @var    array        user_row    Array with user registration data
545                * @var    array        cp_data        Array with custom profile fields data
546                * @var    array        data        Array with current ucp registration data
547                * @var    string        message        Message to be displayed to the user after registration
548                * @var    string        server_url    Server URL
549                * @var    int            user_id        New user ID
550                * @var    string        user_actkey    User activation key
551                * @since 3.2.4-RC1
552                */
553                $vars = array(
554                    'user_row',
555                    'cp_data',
556                    'data',
557                    'message',
558                    'server_url',
559                    'user_id',
560                    'user_actkey',
561                );
562                extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars)));
563
564                $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
565                trigger_error($message);
566            }
567        }
568
569        $s_hidden_fields = array_merge($s_hidden_fields, array(
570            'agreed'        => 'true',
571            'change_lang'    => 0,
572        ));
573
574        if ($config['coppa_enable'])
575        {
576            $s_hidden_fields['coppa'] = $coppa;
577        }
578
579        if ($config['enable_confirm'])
580        {
581            $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields());
582        }
583
584        // Visual Confirmation - Show images
585        if ($config['enable_confirm'])
586        {
587            $template->assign_vars(array(
588                'CAPTCHA_TEMPLATE'        => $captcha->get_template(),
589            ));
590        }
591
592        //
593        $l_reg_cond = '';
594        switch ($config['require_activation'])
595        {
596            case USER_ACTIVATION_SELF:
597                $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE'];
598            break;
599
600            case USER_ACTIVATION_ADMIN:
601                $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE'];
602            break;
603        }
604
605        /* @var $provider_collection \phpbb\auth\provider_collection */
606        $provider_collection = $phpbb_container->get('auth.provider_collection');
607        $auth_provider = $provider_collection->get_provider();
608
609        $auth_provider_data = $auth_provider->get_login_data();
610        if ($auth_provider_data)
611        {
612            if (isset($auth_provider_data['VARS']))
613            {
614                $template->assign_vars($auth_provider_data['VARS']);
615            }
616
617            if (isset($auth_provider_data['BLOCK_VAR_NAME']))
618            {
619                foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars)
620                {
621                    $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars);
622                }
623            }
624
625            $template->assign_vars(array(
626                'PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'],
627            ));
628        }
629
630        // Assign template vars for timezone select
631        $timezone_select = phpbb_timezone_select($user, $data['tz'], true);
632
633        // Checking amount of available languages
634        $sql = 'SELECT lang_iso, lang_local_name
635            FROM ' . LANG_TABLE . '
636            ORDER BY lang_english_name';
637        $result = $db->sql_query($sql);
638        $lang_row = (array) $db->sql_fetchrowset($result);
639        $db->sql_freeresult($result);
640
641        $lang_options = phpbb_language_select($db, $data['lang'], $lang_row);
642
643        $template_vars = array(
644            'USERNAME'            => $data['username'],
645            'PASSWORD'            => $data['new_password'],
646            'PASSWORD_CONFIRM'    => $data['password_confirm'],
647            'EMAIL'                => $data['email'],
648
649            'L_REG_COND'                => $l_reg_cond,
650            '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'])),
651            'L_PASSWORD_EXPLAIN'        => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS_XY', (int) $config['min_pass_chars'])),
652
653            'LANG_OPTIONS'        => [
654                'id'        => 'lang',
655                'name'        => 'lang',
656                'options'    => $lang_options,
657            ],
658            'TIMEZONE_OPTIONS'    => [
659                'tag'        => 'select',
660                'name'        => 'tz',
661                'options'    => $timezone_select,
662            ],
663            'S_TZ_PRESELECT'    => !$submit,
664            'S_CONFIRM_REFRESH'    => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false,
665            'S_REGISTRATION'    => true,
666            'S_COPPA'            => $coppa,
667            'S_UCP_ACTION'        => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
668
669            'COOKIE_NAME'        => $config['cookie_name'],
670            'COOKIE_PATH'        => $config['cookie_path'],
671        );
672
673        $tpl_name = 'ucp_register';
674
675        /**
676        * Modify template data on the registration page
677        *
678        * @event core.ucp_register_modify_template_data
679        * @var    array    template_vars        Array with template data
680        * @var    array    data                Array with user data, read only
681        * @var    array    error                Array with errors
682        * @var    array    s_hidden_fields        Array with hidden field elements
683        * @var    string    tpl_name            Template name
684        * @since 3.2.2-RC1
685        */
686        $vars = array(
687            'template_vars',
688            'data',
689            'error',
690            's_hidden_fields',
691            'tpl_name',
692        );
693        extract($phpbb_dispatcher->trigger_event('core.ucp_register_modify_template_data', compact($vars)));
694
695        $template_vars = array_merge($template_vars, array(
696            'ERROR'                => (count($error)) ? implode('<br />', $error) : '',
697            'S_HIDDEN_FIELDS'    => build_hidden_fields($s_hidden_fields),
698        ));
699
700        $template->assign_vars($template_vars);
701
702        //
703        $user->profile_fields = array();
704
705        // Generate profile fields -> Template Block Variable profile_fields
706        $cp->generate_profile_fields('register', $user->get_iso_lang_id());
707
708        //
709        $this->tpl_name = $tpl_name;
710    }
711
712    /**
713    * Creates the login_link data array
714    *
715    * @return    array    Returns an array of all POST paramaters whose names
716    *                    begin with 'login_link_'
717    */
718    protected function get_login_link_data_array()
719    {
720        global $request;
721
722        $var_names = $request->variable_names(\phpbb\request\request_interface::POST);
723        $login_link_data = array();
724        $string_start_length = strlen('login_link_');
725
726        foreach ($var_names as $var_name)
727        {
728            if (strpos($var_name, 'login_link_') === 0)
729            {
730                $key_name = substr($var_name, $string_start_length);
731                $login_link_data[$key_name] = $request->variable($var_name, '', false, \phpbb\request\request_interface::POST);
732            }
733        }
734
735        return $login_link_data;
736    }
737
738    /**
739    * Prepends they key names of an associative array with 'login_link_' for
740    * inclusion on the page as hidden fields.
741    *
742    * @param    array    $data    The array to be modified
743    * @return    array    The modified array
744    */
745    protected function get_login_link_data_for_hidden_fields($data)
746    {
747        $new_data = array();
748
749        foreach ($data as $key => $value)
750        {
751            $new_data['login_link_' . $key] = $value;
752        }
753
754        return $new_data;
755    }
756}