function Register($reg_errors = array()) { global $txt, $boarddir, $context, $modSettings, $user_info; global $language, $scripturl, $sourcedir, $cur_profile; // Is this an incoming AJAX check? if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { return RegisterCheckUsername(); } // Check if the administrator has it disabled. if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { fatal_lang_error('registration_disabled', false); } // If this user is an admin - redirect them to the admin registration page. if (allowedTo('moderate_forum') && !$user_info['is_guest']) { redirectexit('action=admin;area=regcenter;sa=register'); } elseif (empty($user_info['is_guest'])) { redirectexit(); } loadLanguage('Login'); EoS_Smarty::loadTemplate('register/base'); // Do we need them to agree to the registration agreement, first? $context['require_agreement'] = !empty($modSettings['requireAgreement']); $context['registration_passed_agreement'] = !empty($_SESSION['registration_agreed']); $context['show_coppa'] = !empty($modSettings['coppaAge']); // Under age restrictions? if ($context['show_coppa']) { $context['skip_coppa'] = false; $context['coppa_agree_above'] = sprintf($txt['agreement_agree_coppa_above'], $modSettings['coppaAge']); $context['coppa_agree_below'] = sprintf($txt['agreement_agree_coppa_below'], $modSettings['coppaAge']); } // What step are we at? $current_step = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : ($context['require_agreement'] ? 1 : 2); // Does this user agree to the registation agreement? if ($current_step == 1 && (isset($_POST['accept_agreement']) || isset($_POST['accept_agreement_coppa']))) { $context['registration_passed_agreement'] = $_SESSION['registration_agreed'] = true; $current_step = 2; // Skip the coppa procedure if the user says he's old enough. if ($context['show_coppa']) { $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); // Are they saying they're under age, while under age registration is disabled? if (empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) { loadLanguage('Login'); fatal_lang_error('under_age_registration_prohibited', false, array($modSettings['coppaAge'])); } } } elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { $current_step = 1; } // Show the user the right form. EoS_Smarty::getConfigInstance()->registerHookTemplate('register_content_area', $current_step == 1 ? 'register/agreement' : 'register/form'); //$context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; // Add the register chain to the link tree. $context['linktree'][] = array('url' => $scripturl . '?action=register', 'name' => $txt['register']); // If you have to agree to the agreement, it needs to be fetched from the file. if ($context['require_agreement']) { // Have we got a localized one? if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); } elseif (file_exists($boarddir . '/agreement.txt')) { $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); } else { $context['agreement'] = ''; } } if (!empty($modSettings['userLanguage'])) { $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; // Do we have any languages? if (empty($context['languages'])) { getLanguages(); } // Try to find our selected language. foreach ($context['languages'] as $key => $lang) { $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); // Found it! if ($selectedLanguage == $lang['filename']) { $context['languages'][$key]['selected'] = true; } } } // Any custom fields we want filled in? require_once $sourcedir . '/Profile.php'; loadCustomFields(0, 'register'); // Or any standard ones? if (!empty($modSettings['registration_fields'])) { require_once $sourcedir . '/Profile-Modify.php'; // Setup some important context. loadLanguage('Profile'); $context['user']['is_owner'] = true; // Here, and here only, emulate the permissions the user would have to do this. $user_info['permissions'] = array_merge($user_info['permissions'], array('profile_account_own', 'profile_extra_own')); $reg_fields = explode(',', $modSettings['registration_fields']); // We might have had some submissions on this front - go check. foreach ($reg_fields as $field) { if (isset($_POST[$field])) { $cur_profile[$field] = commonAPI::htmlspecialchars($_POST[$field]); } } // Load all the fields in question. setupProfileContext($reg_fields); } // Generate a visual verification code to make sure the user is no bot. if (!empty($modSettings['reg_verification'])) { require_once $sourcedir . '/lib/Subs-Editor.php'; $verificationOptions = array('id' => 'register'); $context['visual_verification'] = create_control_verification($verificationOptions); $context['visual_verification_id'] = $verificationOptions['id']; } else { $context['visual_verification'] = false; } // Are they coming from an OpenID login attempt? if (!empty($_SESSION['openid']['verified']) && !empty($_SESSION['openid']['openid_uri'])) { $context['openid'] = $_SESSION['openid']['openid_uri']; $context['username'] = commonAPI::htmlspecialchars(!empty($_POST['user']) ? $_POST['user'] : $_SESSION['openid']['nickname']); $context['email'] = commonAPI::htmlspecialchars(!empty($_POST['email']) ? $_POST['email'] : $_SESSION['openid']['email']); } else { $context += array('openid' => isset($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '', 'username' => isset($_POST['user']) ? commonAPI::htmlspecialchars($_POST['user']) : '', 'email' => isset($_POST['email']) ? commonAPI::htmlspecialchars($_POST['email']) : ''); } // !!! Why isn't this a simple set operation? // Were there any errors? $context['registration_errors'] = array(); if (!empty($reg_errors)) { foreach ($reg_errors as $error) { $context['registration_errors'][] = $error; } } HookAPI::callHook('register_before'); }
/** * Begin the registration process. * Accessed by ?action=register * * @uses Register template, registration_agreement or registration_form sub template * @uses Login language file */ public function action_register() { global $txt, $context, $modSettings, $user_info, $language, $scripturl, $cur_profile; // Is this an incoming AJAX check? if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { return $this->_registerCheckUsername(); } // Check if the administrator has it disabled. if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { fatal_lang_error('registration_disabled', false); } // If this user is an admin - redirect them to the admin registration page. if (allowedTo('moderate_forum') && !$user_info['is_guest']) { redirectexit('action=admin;area=regcenter;sa=register'); } elseif (empty($user_info['is_guest'])) { redirectexit(); } if (isset($_POST['show_contact'])) { redirectexit('action=contact'); } loadLanguage('Login'); loadTemplate('Register'); // Do we need them to agree to the registration agreement, first? $context['require_agreement'] = !empty($modSettings['requireAgreement']); $context['checkbox_agreement'] = !empty($modSettings['checkboxAgreement']); $context['registration_passed_agreement'] = !empty($_SESSION['registration_agreed']); $context['show_coppa'] = !empty($modSettings['coppaAge']); $context['show_contact_button'] = !empty($modSettings['enable_contactform']) && $modSettings['enable_contactform'] == 'registration'; // Under age restrictions? if ($context['show_coppa']) { $context['skip_coppa'] = false; $context['coppa_agree_above'] = sprintf($txt[($context['require_agreement'] ? 'agreement_' : '') . 'agree_coppa_above'], $modSettings['coppaAge']); $context['coppa_agree_below'] = sprintf($txt[($context['require_agreement'] ? 'agreement_' : '') . 'agree_coppa_below'], $modSettings['coppaAge']); } // What step are we at? $current_step = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : ($context['require_agreement'] && !$context['checkbox_agreement'] ? 1 : 2); // Does this user agree to the registration agreement? if ($current_step == 1 && (isset($_POST['accept_agreement']) || isset($_POST['accept_agreement_coppa']))) { $context['registration_passed_agreement'] = $_SESSION['registration_agreed'] = true; $current_step = 2; // Skip the coppa procedure if the user says he's old enough. if ($context['show_coppa']) { $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); // Are they saying they're under age, while under age registration is disabled? if (empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) { loadLanguage('Login'); fatal_lang_error('under_age_registration_prohibited', false, array($modSettings['coppaAge'])); } } } elseif ($current_step > 1 && $context['require_agreement'] && !$context['checkbox_agreement'] && !$context['registration_passed_agreement']) { $current_step = 1; } // Show the user the right form. $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; loadJavascriptFile('register.js'); addInlineJavascript('disableAutoComplete();', true); // Add the register chain to the link tree. $context['linktree'][] = array('url' => $scripturl . '?action=register', 'name' => $txt['register']); // Prepare the time gate! Done like this to allow later steps to reset the limit for any reason if (!isset($_SESSION['register'])) { $_SESSION['register'] = array('timenow' => time(), 'limit' => 8); } else { $_SESSION['register']['timenow'] = time(); } // If you have to agree to the agreement, it needs to be fetched from the file. if ($context['require_agreement']) { // Have we got a localized one? if (file_exists(BOARDDIR . '/agreement.' . $user_info['language'] . '.txt')) { $context['agreement'] = parse_bbc(file_get_contents(BOARDDIR . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); } elseif (file_exists(BOARDDIR . '/agreement.txt')) { $context['agreement'] = parse_bbc(file_get_contents(BOARDDIR . '/agreement.txt'), true, 'agreement'); } else { $context['agreement'] = ''; } // Nothing to show, lets disable registration and inform the admin of this error if (empty($context['agreement'])) { // No file found or a blank file, log the error so the admin knows there is a problem! log_error($txt['registration_agreement_missing'], 'critical'); fatal_lang_error('registration_disabled', false); } } if (!empty($modSettings['userLanguage'])) { // Do we have any languages? $languages = getLanguages(); if (isset($_POST['lngfile']) && isset($languages[$_POST['lngfile']])) { $_SESSION['language'] = $_POST['lngfile']; } $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; // Try to find our selected language. foreach ($languages as $key => $lang) { $context['languages'][$key]['name'] = $lang['name']; // Found it! if ($selectedLanguage == $lang['filename']) { $context['languages'][$key]['selected'] = true; } } } // Any custom fields we want filled in? require_once SUBSDIR . '/Profile.subs.php'; loadCustomFields(0, 'register'); // Or any standard ones? if (!empty($modSettings['registration_fields'])) { // Setup some important context. loadLanguage('Profile'); loadTemplate('Profile'); $context['user']['is_owner'] = true; // Here, and here only, emulate the permissions the user would have to do this. $user_info['permissions'] = array_merge($user_info['permissions'], array('profile_account_own', 'profile_extra_own')); $reg_fields = explode(',', $modSettings['registration_fields']); // We might have had some submissions on this front - go check. foreach ($reg_fields as $field) { if (isset($_POST[$field])) { $cur_profile[$field] = Util::htmlspecialchars($_POST[$field]); } } // Load all the fields in question. setupProfileContext($reg_fields, 'registration'); } // Generate a visual verification code to make sure the user is no bot. if (!empty($modSettings['reg_verification']) && $current_step > 1) { require_once SUBSDIR . '/VerificationControls.class.php'; $verificationOptions = array('id' => 'register'); $context['visual_verification'] = create_control_verification($verificationOptions); $context['visual_verification_id'] = $verificationOptions['id']; } else { $context['visual_verification'] = false; } // Are they coming from an OpenID login attempt? if (!empty($_SESSION['openid']['verified']) && !empty($_SESSION['openid']['openid_uri']) && !empty($_SESSION['openid']['nickname'])) { $context['openid'] = $_SESSION['openid']['openid_uri']; $context['username'] = !empty($_POST['user']) ? Util::htmlspecialchars($_POST['user']) : $_SESSION['openid']['nickname']; $context['email'] = !empty($_POST['email']) ? Util::htmlspecialchars($_POST['email']) : $_SESSION['openid']['email']; } else { $context += array('openid' => isset($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '', 'username' => isset($_POST['user']) ? Util::htmlspecialchars($_POST['user']) : '', 'email' => isset($_POST['email']) ? Util::htmlspecialchars($_POST['email']) : ''); } // Were there any errors? $context['registration_errors'] = array(); $reg_errors = Error_Context::context('register', 0); if ($reg_errors->hasErrors()) { $context['registration_errors'] = $reg_errors->prepareErrors(); } createToken('register'); }
function shd_profile_theme_wrapper($memID) { global $txt, $context, $user_profile, $modSettings, $settings, $user_info, $smcFunc, $sourcedir, $profile_fields; loadTemplate('Profile'); loadTemplate('sd_template/SimpleDesk-Profile'); $lang_strings = array('current_time', 'theme_info', 'date_format', 'return_to_post', 'timeformat_default', 'theme_forum_default', 'theme_forum_default_desc'); // Replace the standard profile strings with SD specific ones. foreach ($lang_strings as $str) { $txt[$str] = $txt['shd_' . $str]; } loadThemeOptions($memID); if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { loadCustomFields($memID, 'theme'); } $context['sub_template'] = 'edit_options'; $context['page_desc'] = $txt['theme_info']; $opts = array('id_theme', 'smiley_set', 'hr', 'time_format', 'time_offset', 'hr', 'theme_settings'); if (!empty($modSettings['shd_display_avatar'])) { $opts = array_merge(array('avatar_choice', 'hr'), $opts); } setupProfileContext($opts); $context['profile_fields']['theme_settings']['callback_func'] = 'shd_theme_settings'; }
function theme($memID) { global $txt, $context, $user_profile, $modSettings, $settings, $user_info, $smcFunc; loadThemeOptions($memID); if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { loadCustomFields($memID, 'theme'); } $context['sub_template'] = 'edit_options'; $context['page_desc'] = $txt['theme_info']; setupProfileContext(array('id_theme', 'smiley_set', 'hr', 'time_format', 'time_offset', 'hr', 'theme_settings')); }
public static function fb_do_custom() { global $context, $sourcedir, $fb_hook_object, $user_info, $smcFunc; if (!empty($fb_hook_object->modSettings['fb_app_enablecp'])) { require_once $sourcedir . '/Profile.php'; loadCustomFields(0, 'register'); if (!empty($fb_hook_object->modSettings['registration_fields'])) { require_once $sourcedir . '/Profile-Modify.php'; loadLanguage('Profile'); loadTemplate('Profile'); $context['user']['is_owner'] = true; $user_info['permissions'] = array_merge($user_info['permissions'], array('profile_account_own', 'profile_extra_own')); $reg_fields = explode(',', $fb_hook_object->modSettings['registration_fields']); foreach ($reg_fields as $field) { if (isset($_POST[$field])) { $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); } } setupProfileContext($reg_fields); } } }
function theme($memID) { global $txt, $context; loadThemeOptions($memID); if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { loadCustomFields($memID, 'theme'); } EoS_Smarty::loadTemplate('profile/profile_base'); EoS_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'profile/edit_options'); //$context['sub_template'] = 'edit_options'; $context['page_desc'] = $txt['theme_info']; setupProfileContext(array('id_theme', 'smiley_set', 'hr', 'time_format', 'time_offset', 'hr', 'theme_settings')); }
/** * Allow the user to pick a theme. * */ public function action_themepick() { global $txt, $context; $memID = currentMemberID(); loadThemeOptions($memID); if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { loadCustomFields($memID, 'theme'); } loadTemplate('ProfileOptions'); $context['sub_template'] = 'edit_options'; $context['page_desc'] = $txt['theme_info']; setupProfileContext(array('id_theme', 'smiley_set', 'hr', 'time_format', 'time_offset', 'hr', 'theme_settings'), 'themepick'); }