/** * Displays the registration form * * @access public * @param array $form_errors * @return void */ public function registerForm($form_errors = array()) { /* INIT */ $final_errors = array(); if ($this->settings['no_reg'] == 1) { $this->registry->output->showError('registration_disabled', 10123); } $coppa = IPSCookie::get('coppa'); if ($coppa == 'yes') { $this->registry->output->showError('awaiting_coppa', 10124); } $this->settings['username_errormsg'] = str_replace('{chars}', $this->settings['username_characters'], $this->settings['username_errormsg']); /* Read T&Cs yet? */ if (!$this->request['termsread']) { if ($this->memberData['member_id']) { require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php'; $this->han_login = new han_login($this->registry); $this->han_login->init(); //----------------------------------------- // Set some cookies //----------------------------------------- IPSCookie::set("member_id", "0"); IPSCookie::set("pass_hash", "0"); IPSCookie::set("anonlogin", "-1"); if (is_array($_COOKIE)) { foreach ($_COOKIE as $cookie => $value) { if (stripos($cookie, $this->settings['cookie_id'] . "ipbforum") !== false) { IPSCookie::set(str_replace($this->settings['cookie_id'], "", $match[0]), '-', -1); } } } //----------------------------------------- // Logout callbacks... //----------------------------------------- $this->han_login->logoutCallback(); //----------------------------------------- // Do it.. //----------------------------------------- $this->member->sessionClass()->convertMemberToGuest(); list($privacy, $loggedin) = explode('&', $this->memberData['login_anonymous']); IPSMember::save($this->memberData['member_id'], array('core' => array('login_anonymous' => "{$privacy}&0", 'last_activity' => time()))); } /* Continue */ $cache = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key='reg_rules'")); $text = $cache['conf_value'] ? $cache['conf_value'] : $cache['conf_default']; /* Load the Parser */ IPSText::getTextClass('bbcode')->bypass_badwords = 1; IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_html = 1; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'global'; $text = IPSText::getTextClass('bbcode')->preDbParse($text); $text = IPSText::getTextClass('bbcode')->preDisplayParse($text); $this->registry->output->setTitle($this->lang->words['registration_form']); $this->registry->output->addNavigation($this->lang->words['registration_form'], ''); $this->output .= $this->registry->output->getTemplate('register')->registerShowTerms($text, $coppa); return; } else { /* Did we agree to the t&c? */ if (!$this->request['agree_to_terms']) { $this->registry->output->showError('must_agree_to_terms', 10125); } } /* Do we have another URL that one needs to visit to register? */ $this->DB->build(array('select' => '*', 'from' => 'login_methods', 'where' => 'login_enabled=1')); $this->DB->execute(); while ($r = $this->DB->fetch()) { if ($r['login_register_url']) { $this->registry->output->silentRedirect($r['login_register_url']); exit; } } /* Continue... */ if ($this->settings['reg_auth_type']) { if ($this->settings['reg_auth_type'] == 'admin_user' or $this->settings['reg_auth_type'] == 'user') { $this->lang->words['std_text'] .= "<br />" . $this->lang->words['email_validate_text']; } /* User then admin? */ if ($this->settings['reg_auth_type'] == 'admin_user') { $this->lang->words['std_text'] .= "<br />" . $this->lang->words['user_admin_validation']; } if ($this->settings['reg_auth_type'] == 'admin') { $this->lang->words['std_text'] .= "<br />" . $this->lang->words['just_admin_validation']; } } $captchaHTML = ''; $qandaHTML = ''; $this->cache->updateCacheWithoutSaving('_hasStep3', 0); /* Q and A Challenge */ if ($this->settings['registration_qanda']) { // Grab a random question... $question = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'question_and_answer', 'order' => 'rand()', 'limit' => array(1))); if (count($question)) { $qandaHTML = $this->registry->output->getTemplate('global_other')->questionAndAnswer($question); } } /* Custom Profile Fields */ $custom_fields_out = array('required', 'optional'); require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $custom_fields = new customProfileFields(); $custom_fields->member_data = $member; $custom_fields->initData('edit'); $custom_fields->parseToEdit('register'); if (count($custom_fields->out_fields)) { $this->cache->updateCacheWithoutSaving('_hasStep3', 1); foreach ($custom_fields->out_fields as $id => $form_element) { if ($custom_fields->cache_data[$id]['pf_not_null'] == 1) { $ftype = 'required'; } else { $ftype = 'optional'; } $custom_fields_out[$ftype][] = array('name' => $custom_fields->field_names[$id], 'desc' => $custom_fields->field_desc[$id], 'field' => $form_element, 'id' => $id, 'error' => $error, 'type' => $custom_fields->cache_data[$id]['pf_type']); } } /* CAPTCHA */ if ($this->settings['bot_antispam']) { $captchaHTML = $this->registry->getClass('class_captcha')->getTemplate(); } $this->registry->output->setTitle($this->lang->words['registration_form']); $this->registry->output->addNavigation($this->lang->words['registration_form'], ''); /* Other errors */ $final_errors = array('username' => NULL, 'dname' => NULL, 'password' => NULL, 'email' => NULL); foreach (array('username', 'dname', 'password', 'email') as $thing) { if (isset($form_errors[$thing]) and is_array($form_errors[$thing]) and count($form_errors[$thing])) { $final_errors[$thing] = implode("<br />", $form_errors[$thing]); } } $this->request['UserName'] = $this->request['UserName'] ? $this->request['UserName'] : ''; $this->request['PassWord'] = $this->request['PassWord'] ? $this->request['PassWord'] : ''; $this->request['EmailAddress'] = $this->request['EmailAddress'] ? $this->request['EmailAddress'] : ''; $this->request['EmailAddress_two'] = $this->request['EmailAddress_two'] ? $this->request['EmailAddress_two'] : ''; $this->request['PassWord_Check'] = $this->request['PassWord_Check'] ? $this->request['PassWord_Check'] : ''; $this->request['members_display_name'] = $this->request['members_display_name'] ? $this->request['members_display_name'] : ''; $this->request['time_offset'] = $this->request['time_offset'] ? $this->request['time_offset'] : ''; $this->request['allow_member_mail'] = $this->request['allow_member_mail'] ? $this->request['allow_member_mail'] : ''; $this->request['dst'] = $this->request['dst'] ? $this->request['dst'] : ''; /* Time zone... */ $this->registry->class_localization->loadLanguageFile(array('public_usercp'), 'core'); $time_select = array(); foreach ($this->lang->words as $k => $v) { if (strpos($k, "time_") === 0) { $k = str_replace("time_", '', $k); if (preg_match("/^[\\-\\d\\.]+\$/", $k)) { $time_select[$k] = $v; } } } ksort($time_select); /* set default.. */ $this->request['time_offset'] = $this->request['time_offset'] ? $this->request['time_offset'] : $this->settings['time_offset']; /* Need username? */ $uses_name = false; foreach ($this->cache->getCache('login_methods') as $method) { if ($method['login_user_id'] == 'username') { $uses_name = true; } } /* Get form HTML */ $this->output .= $this->registry->output->getTemplate('register')->registerForm($form_errors['general'], array('TEXT' => $this->lang->words['std_text'], 'coppa_user' => $coppa, 'captchaHTML' => $captchaHTML, 'qandaHTML' => $qandaHTML, 'requireName' => $uses_name), $final_errors, $time_select, $custom_fields_out); /* Run the member sync module */ IPSLib::runMemberSync('onRegisterForm'); }
/** * Show the profile information * * @access public * @author Matt Mecham * @return string Processed HTML */ public function formProfileInfo() { /* Load Lang File */ $this->registry->class_localization->loadLanguageFile(array('public_profile'), 'members'); /* INIT */ $required_output = ""; $optional_output = ""; /* Permission Check */ if (!$this->memberData['g_edit_profile']) { $this->registry->getClass('output')->showError('members_profile_disabled', 1026); } /* Format the birthday drop boxes.. */ $date = getdate(); $day = array(); $mon = array(); $year = array(); /* Build the day options */ $day[] = array('0', '--'); for ($i = 1; $i < 32; $i++) { $day[] = array($i, $i); } /* Build the month options */ $mon[] = array('0', '--'); for ($i = 1; $i < 13; $i++) { $mon[] = array($i, $this->lang->words['M_' . $i]); } /* Build the years options */ $i = $date['year'] - 1; $j = $date['year'] - 100; $year[] = array('0', '--'); for ($i; $j < $i; $i--) { $year[] = array($i, $i); } /* Custom Fields */ require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $fields = new customProfileFields(); $fields->member_data = $this->member->fetchMemberData(); $fields->initData('edit'); $fields->parseToEdit(); if (count($fields->out_fields)) { foreach ($fields->out_fields as $id => $data) { if ($fields->cache_data[$id]['pf_not_null'] == 1) { $ftype = 'required_output'; } else { $ftype = 'optional_output'; } ${$ftype} .= $this->registry->getClass('output')->getTemplate('ucp')->field_entry($fields->field_names[$id], $fields->field_desc[$id], $data, $id); } } /* Personal Statement */ $personal_statement = IPSText::br2nl($this->memberData['pp_bio_content']); /* Build and return the form */ $template = $this->registry->getClass('output')->getTemplate('ucp')->membersProfileForm($personal_statement, $required_output, $optional_output, $day, $mon, $year); return $template; }
/** * Generate context-menu filter boxes * Pass &_nosave=1 to not store / read from a cookie * * @access private * @author Matt Mecham * @since IPB 3.0.0 * @return void [Outputs to screen] * @todo [Future] Allow multiple filter fields */ private function _generateFilterBoxes() { //----------------------------------------- // INIT //----------------------------------------- $form = array(); $custom_fields = array(); # Filter: Customer contains $member_contains = $this->request['f_member_contains'] ? trim($this->request['f_member_contains']) : ''; $member_contains_type = $this->request['f_member_contains_type'] ? trim($this->request['f_member_contains_type']) : ''; $member_contains_text = $this->request['f_member_contains_text'] ? trim($this->request['f_member_contains_text']) : ''; $_member_contains = array(0 => array('members_display_name', $this->lang->words['m_f_display']), 1 => array('name', $this->lang->words['m_f_login']), 2 => array('member_id', $this->lang->words['m_f_id']), 3 => array('email', $this->lang->words['m_f_email']), 4 => array('ip_address', $this->lang->words['m_f_ip']), 5 => array('signature', $this->lang->words['m_f_sig'])); $_member_contains_type = array(0 => array('contains', $this->lang->words['m_f_contains']), 1 => array('equals', $this->lang->words['m_f_equals']), 2 => array('begins', $this->lang->words['m_f_begins']), 3 => array('ends', $this->lang->words['m_f_ends'])); # Order by $order_by = ''; $order_by = $this->request['order_by'] ? $this->request['order_by'] : 'members_l_display_name'; $_order_by = array(0 => array('joined', $this->lang->words['m_f_joined']), 1 => array('members_l_username', $this->lang->words['m_f_slogin']), 2 => array('members_l_display_name', $this->lang->words['m_f_sdisplay']), 3 => array('email', $this->lang->words['m_f_email'])); # Order direction $order_direction = $this->request['order_direction'] ? $this->request['order_direction'] : 'ASC'; $_order_direction = array(0 => array('asc', $this->lang->words['m_f_orderaz']), 1 => array('desc', $this->lang->words['m_f_orderza'])); # Filter: member type $member_type = $this->request['f_member_type'] ? trim($this->request['f_member_type']) : ''; $_member_type = array(0 => array('all', $this->lang->words['m_f_showall']), 1 => array('suspended', $this->lang->words['m_f_showsusp']), 2 => array('notsuspended', $this->lang->words['m_f_showunsusp'])); # Filter: banned type $banned_type = $this->request['f_banned_type'] ? trim($this->request['f_banned_type']) : ''; $_banned_type = array(0 => array('all', $this->lang->words['m_f_showall']), 1 => array('banned', $this->lang->words['m_f_showbanned']), 2 => array('notbanned', $this->lang->words['m_f_shownotbanned'])); # Filter: SPAM status type $spam_type = $this->request['f_spam_type'] ? trim($this->request['f_spam_type']) : ''; $_spam_type = array(0 => array('all', $this->lang->words['m_f_showall']), 1 => array('spam', $this->lang->words['m_f_showspam']), 2 => array('notspam', $this->lang->words['m_f_shownotspam'])); # Type of search $search_type = $this->request['f_search_type'] ? $this->request['f_search_type'] : 'normal'; $_search_type = array(0 => array('normal', $this->lang->words['m_f_toedit'])); if ($this->registry->getClass('class_permissions')->checkPermission('member_delete')) { $_search_type[1] = array('delete', $this->lang->words['m_f_todelete']); } if ($this->registry->getClass('class_permissions')->checkPermission('member_move')) { $_search_type[2] = array('move', $this->lang->words['m_f_tomove']); } # Date Ranges $date_reg_from = $this->request['f_date_reg_from'] ? trim($this->request['f_date_reg_from']) : ''; $date_reg_to = $this->request['f_date_reg_to'] ? trim($this->request['f_date_reg_to']) : ''; $date_post_from = $this->request['f_date_post_from'] ? trim($this->request['f_date_post_from']) : ''; $date_post_to = $this->request['f_date_post_to'] ? trim($this->request['f_date_post_to']) : ''; $date_active_from = $this->request['f_date_active_from'] ? trim($this->request['f_date_active_from']) : ''; $date_active_to = $this->request['f_date_active_to'] ? trim($this->request['f_date_active_to']) : ''; $primary_group = $this->request['f_primary_group'] ? trim($this->request['f_primary_group']) : 0; $secondary_group = $this->request['f_secondary_group'] ? trim($this->request['f_secondary_group']) : 0; $_primary_group = array(0 => array('0', $this->lang->words['m_f_primany'])); $_secondary_group = array(0 => array('0', $this->lang->words['m_f_secany'])); $post_count = $this->request['f_post_count'] ? trim($this->request['f_post_count']) : ''; $post_count_type = $this->request['f_post_count_type'] ? trim($this->request['f_post_count_type']) : ''; $_post_count_types = array(0 => array('lt', $this->lang->words['pc_lt']), 1 => array('gt', $this->lang->words['pc_gt']), 3 => array('eq', $this->lang->words['pc_eq'])); foreach (ipsRegistry::cache()->getCache('group_cache') as $_gid => $_gdata) { $_primary_group[] = array($_gdata['g_id'], $_gdata['g_title']); $_secondary_group[] = array($_gdata['g_id'], $_gdata['g_title']); } /* Reset Fitlers */ if ($this->request['reset_filters']) { ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', array()); } //----------------------------------------- // Not posted, so er.. get the cookie //----------------------------------------- $custom_field_data = array(); $filters_preset = 0; if (!$this->request['__update'] and !$this->request['_nosave']) { $_cookie_array = ipsRegistry::getClass('adminFunctions')->staffGetCookie('memberFilter'); if ($_cookie_array) { if (is_array($_cookie_array) and count($_cookie_array)) { $member_type = substr($_cookie_array['c_member_type'], 0, 10); $banned_type = substr($_cookie_array['c_banned_type'], 0, 10); $spam_type = substr($_cookie_array['c_spam_type'], 0, 10); $member_contains = substr($_cookie_array['c_member_contains'], 0, 20); $member_contains_type = substr($_cookie_array['c_member_contains_type'], 0, 20); $member_contains_text = substr($_cookie_array['c_member_contains_text'], 0, 50); $post_count = trim(IPSText::alphanumericalClean($_cookie_array['c_post_count'])); $post_count_type = trim(IPSText::alphanumericalClean($_cookie_array['c_post_count_type'])); $order_by = trim(IPSText::alphanumericalClean($_cookie_array['c_order_by'])); $order_direction = trim(IPSText::alphanumericalClean($_cookie_array['c_order_direction'])); $date_reg_from = trim(IPSText::alphanumericalClean($_cookie_array['c_date_reg_from'], '/-')); $date_reg_to = trim(IPSText::alphanumericalClean($_cookie_array['c_date_reg_to'], '/-')); $date_post_from = trim(IPSText::alphanumericalClean($_cookie_array['c_date_post_from'], '/-')); $date_post_to = trim(IPSText::alphanumericalClean($_cookie_array['c_date_post_to'], '/-')); $date_active_from = trim(IPSText::alphanumericalClean($_cookie_array['c_date_active_from'], '/-')); $date_active_to = trim(IPSText::alphanumericalClean($_cookie_array['c_date_active_to'], '/-')); $primary_group = trim(IPSText::alphanumericalClean($_cookie_array['c_primary_group'], '/-')); $secondary_group = trim(IPSText::alphanumericalClean($_cookie_array['c_secondary_group'], '/-')); $custom_field_cookie = explode('||', $_cookie_array['c_custom_fields']); if ($member_type || $member_contains || $member_contains_type || $member_contains_text || $order_by || $order_direction || $date_reg_from || $date_reg_to || $date_post_from || $date_post_to || $date_active_from || $date_active_to || $primary_group || $secondary_group || $post_count || $post_count_type) { $filters_preset = 1; } if (is_array($custom_field_cookie) and count($custom_field_cookie)) { foreach ($custom_field_cookie as $field) { $data = explode('==', $field); $custom_field_data['field_' . $data[0]] = $data[1]; ipsRegistry::$request['field_' . $data[0]] = $data[1]; if ($data[1]) { $filters_preset = 1; } } } } } } $custom_field_data = count($custom_field_data) ? $custom_field_data : $_POST; foreach ($custom_field_data as $k => $v) { if (strpos($k, 'ignore_field_') === 0) { $key = substr($k, 13); $custom_field_data['field_' . $key] = ''; } } //----------------------------------------- // Get custom profile information //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $fields = new customProfileFields(); $fields->member_data = $custom_field_data; $fields->initData('edit', 1); $fields->parseToEdit(); //----------------------------------------- // Finish forms... //----------------------------------------- $form['_member_contains'] = $this->registry->output->formDropdown('f_member_contains', $_member_contains, $member_contains); $form['_member_contains_type'] = $this->registry->output->formDropdown('f_member_contains_type', $_member_contains_type, $member_contains_type); $form['_member_contains_text'] = $this->registry->output->formSimpleInput('f_member_contains_text', $member_contains_text, 15); $form['_member_type'] = $this->registry->output->formDropdown('f_member_type', $_member_type, $member_type); $form['_banned_type'] = $this->registry->output->formDropdown('f_banned_type', $_banned_type, $banned_type); $form['_spam_type'] = $this->registry->output->formDropdown('f_spam_type', $_spam_type, $spam_type); $form['_order_by'] = $this->registry->output->formDropdown('order_by', $_order_by, preg_replace("#.*\\.(.*)\$#", "\\1", $order_by)); $form['_order_direction'] = $this->registry->output->formDropdown('order_direction', $_order_direction, $order_direction); $form['_search_type'] = $this->registry->output->formDropdown('f_search_type', $_search_type, $search_type); $form['_post_count'] = $this->registry->output->formSimpleInput('f_post_count', $post_count, 10); $form['_post_count_type'] = $this->registry->output->formDropdown('f_post_count_type', $_post_count_types, $post_count_type); $form['_date_reg_from'] = $this->registry->output->formSimpleInput('f_date_reg_from', $date_reg_from, 10); $form['_date_reg_to'] = $this->registry->output->formSimpleInput('f_date_reg_to', $date_reg_to, 10); $form['_date_post_from'] = $this->registry->output->formSimpleInput('f_date_post_from', $date_post_from, 10); $form['_date_post_to'] = $this->registry->output->formSimpleInput('f_date_post_to', $date_post_to, 10); $form['_date_active_from'] = $this->registry->output->formSimpleInput('f_date_active_from', $date_active_from, 10); $form['_date_active_to'] = $this->registry->output->formSimpleInput('f_date_active_to', $date_active_to, 10); $form['_primary_group'] = $this->registry->output->formDropdown('f_primary_group', $_primary_group, $primary_group); $form['_secondary_group'] = $this->registry->output->formDropdown('f_secondary_group', $_secondary_group, $secondary_group); //----------------------------------------- // Set custom field data for cookie //----------------------------------------- $custom_field_data_imploded = array(); foreach ($custom_field_data as $k => $v) { if (strpos($k, 'field_') === 0) { $custom_field_data_imploded[] = substr($k, 6) . '==' . $v; } } $custom_field_data_imploded = implode('||', $custom_field_data_imploded); //----------------------------------------- // Store the cooookie //----------------------------------------- if (!$this->request['_nosave']) { $_cookie = array('c_member_type' => $member_type, 'c_banned_type' => $banned_type, 'c_spam_type' => $spam_type, 'c_member_contains' => $member_contains, 'c_member_contains_type' => $member_contains_type, 'c_member_contains_text' => $member_contains_text, 'c_order_by' => preg_replace("#.*\\.(.*)\$#", "\\1", $__order_by), 'c_order_direction' => $__order_direction, 'c_post_count' => $post_count, 'c_post_count_type' => $post_count_type, 'c_date_reg_from' => $date_reg_from, 'c_date_reg_to' => $date_reg_to, 'c_date_post_from' => $date_post_from, 'c_date_post_to' => $date_post_to, 'c_date_active_from' => $date_active_from, 'c_date_active_to' => $date_active_to, 'c_primary_group' => $primary_group, 'c_secondary_group' => $secondary_group, 'c_custom_fields' => $custom_field_data_imploded); ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', $_cookie); } //----------------------------------------- // Create filter boxes //----------------------------------------- $this->registry->output->html .= $this->html->member_list_context_menu_filters($form, $fields, $filters_preset); //----------------------------------------- // Return data //----------------------------------------- $_return = array('custom_fields' => ''); if (is_array($fields->out_fields) and count($fields->out_fields)) { foreach ($fields->out_fields as $id => $data) { $_return['custom_fields'][$id] = $fields->in_fields[$id]; } } foreach (array_keys($form) as $_key) { $__key = substr($_key, 1); $_return[$__key] = ${$__key}; } return $_return; }
/** * Form to edit a member * * @access private * @return void Outputs error screen * @todo [Future] Determine what items should be editable and allow moderators to edit them * @todo [Future] Show avatar and profile picture previews? */ private function _editMember() { $member = $this->_checkAndGetMember(); if (IPSText::getTextClass('editor')->method == 'rte') { $editable['signature'] = IPSText::getTextClass('bbcode')->convertForRTE($member['signature']); } else { $editable['signature'] = IPSText::getTextClass('bbcode')->preEditParse($member['signature']); } if (IPSText::getTextClass('editor')->method == 'rte') { $editable['aboutme'] = IPSText::getTextClass('bbcode')->convertForRTE($member['pp_about_me']); } else { $editable['aboutme'] = IPSText::getTextClass('bbcode')->preEditParse($member['pp_about_me']); } $editable['member_id'] = $member['member_id']; $editable['members_display_name'] = $member['members_display_name']; $editable['title'] = $member['title']; $editable['pp_status'] = $member['pp_status']; //----------------------------------------- // Profile fields //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $fields = new customProfileFields(); $fields->member_data = $member; $fields->initData('edit'); $fields->parseToEdit(); $editable['signature'] = IPSText::getTextClass('editor')->showEditor($editable['signature'], 'Post'); $editable['aboutme'] = IPSText::getTextClass('editor')->showEditor($editable['aboutme'], 'aboutme'); //----------------------------------------- // Show? //----------------------------------------- $this->output .= $this->registry->getClass('output')->getTemplate('mod')->editUserForm($editable, $fields); $this->registry->getClass('output')->setTitle($this->lang->words['cp_em_title']); $this->registry->getClass('output')->addNavigation($this->lang->words['cp_vp_title'], "showuser={$member['member_id']}", $member['members_seo_name'], 'showuser'); $this->registry->getClass('output')->addNavigation($this->lang->words['cp_em_title'], ''); }