/** * Processes the registration form * * @return @e void */ public function registerProcessForm() { $this->_resetMember(); $form_errors = array(); $coppa = $this->request['coppa_user'] == 1 ? 1 : 0; $in_password = trim($this->request['PassWord']); $in_email = strtolower(trim($this->request['EmailAddress'])); /* Did we agree to the t&c? */ if (!$this->request['agree_tos']) { $form_errors['tos'] = array($this->lang->words['must_agree_to_terms']); } /* Custom profile field stuff */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields'); $custom_fields = new $classToLoad(); $custom_fields->initData('edit'); $custom_fields->parseToSave($_POST, 'register'); /* Check */ if ($custom_fields->error_messages) { $form_errors['general'] = $custom_fields->error_messages; } /* Check the email address */ if (!$in_email or strlen($in_email) < 6 or !IPSText::checkEmailAddress($in_email)) { $form_errors['email'][$this->lang->words['err_invalid_email']] = $this->lang->words['err_invalid_email']; } if (trim($this->request['PassWord_Check']) != $in_password or !$in_password) { $form_errors['password'][$this->lang->words['passwords_not_match']] = $this->lang->words['passwords_not_match']; } /* There's no reason for this - http://community.invisionpower.com/resources/bugs.html/_/ip-board/registrations-limit-passwords-to-32-characters-for-no-apparent-reason-r37770 elseif ( strlen( $in_password ) < 3 ) { $form_errors['password'][$this->lang->words['pass_too_short']] = $this->lang->words['pass_too_short']; } elseif ( strlen( $in_password ) > 32 ) { $form_errors['password'][$this->lang->words['pass_too_long']] = $this->lang->words['pass_too_long']; } */ /* Check the username */ $user_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'name'); $disp_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'members_display_name'); if (is_array($user_check['errors']) && count($user_check['errors'])) { foreach ($user_check['errors'] as $key => $error) { $form_errors['dname'][$error] = isset($this->lang->words[$error]) ? $this->lang->words[$error] : $error; } } /* this duplicates username error above */ /*if( is_array( $disp_check['errors'] ) && count( $disp_check['errors'] ) ) { foreach( $disp_check['errors'] as $key => $error ) { $form_errors['dname'][ $error ] = isset($this->lang->words[ $error ]) ? $this->lang->words[ $error ] : $error; } }*/ /* Is this email addy taken? */ if (IPSMember::checkByEmail($in_email) == TRUE) { $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken']; } /* Load handler... */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login'); $this->han_login = new $classToLoad($this->registry); $this->han_login->init(); $this->han_login->emailExistsCheck($in_email); if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'EMAIL_NOT_IN_USE') { $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken']; } /* Are they banned [EMAIL]? */ if (IPSMember::isBanned('email', $in_email) === TRUE) { $form_errors['email'][$this->lang->words['reg_error_email_ban']] = $this->lang->words['reg_error_email_ban']; } /* Check the CAPTCHA */ if ($this->settings['bot_antispam_type'] != 'none') { if ($this->registry->getClass('class_captcha')->validate() !== TRUE) { $form_errors['general'][$this->lang->words['err_reg_code']] = $this->lang->words['err_reg_code']; } } /* Check the Q and A */ $qanda = intval($this->request['qanda_id']); $pass = true; if ($qanda) { $pass = false; $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'question_and_answer', 'where' => 'qa_id=' . $qanda)); if ($data['qa_id']) { $answers = explode("\n", str_replace("\r", "", $data['qa_answers'])); if (count($answers)) { foreach ($answers as $answer) { $answer = trim($answer); if (IPSText::mbstrlen($answer) and mb_strtolower($answer) == mb_strtolower($this->request['qa_answer'])) { $pass = true; break; } } } } } else { //----------------------------------------- // Do we have any questions? //----------------------------------------- $data = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as questions', 'from' => 'question_and_answer')); if ($data['questions']) { $pass = false; } } if (!$pass) { $form_errors['general'][$this->lang->words['err_q_and_a']] = $this->lang->words['err_q_and_a']; } /* CHECK 2: Any errors ? */ if (count($form_errors)) { $this->registerForm($form_errors); return; } /* Build up the hashes */ $mem_group = $this->settings['member_group']; /* Are we asking the member or admin to preview? */ if ($this->settings['reg_auth_type']) { $mem_group = $this->settings['auth_group']; } else { if ($coppa == 1) { $mem_group = $this->settings['auth_group']; } } /* Create member */ $member = array('name' => $this->request['members_display_name'], 'password' => $in_password, 'members_display_name' => $this->request['members_display_name'], 'email' => $in_email, 'member_group_id' => $mem_group, 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->request['time_offset'], 'coppa_user' => $coppa, 'members_auto_dst' => intval($this->settings['time_dst_auto_correction']), 'allow_admin_mails' => intval($this->request['allow_admin_mail']), 'language' => $this->member->language_id); /* Spam Service */ $spamCode = 0; $_spamFlag = 0; if ($this->settings['spam_service_enabled']) { /* Query the service */ $spamCode = IPSMember::querySpamService($in_email); /* Action to perform */ $action = $this->settings['spam_service_action_' . $spamCode]; /* Perform Action */ switch ($action) { /* Proceed with registration */ case 1: break; /* Flag for admin approval */ /* Flag for admin approval */ case 2: $member['member_group_id'] = $this->settings['auth_group']; $this->settings['reg_auth_type'] = 'admin'; $_spamFlag = 1; break; /* Approve the account, but ban it */ /* Approve the account, but ban it */ case 3: $member['member_banned'] = 1; $member['bw_is_spammer'] = 1; $this->settings['reg_auth_type'] = ''; break; /* Deny registration */ /* Deny registration */ case 4: $this->registry->output->showError('spam_denied_account', '100x001', FALSE, '', 200); break; } } //----------------------------------------- // Create the account //----------------------------------------- $member = IPSMember::create(array('members' => $member, 'pfields_content' => $custom_fields->out_fields), FALSE, FALSE, FALSE); //----------------------------------------- // Login handler create account callback //----------------------------------------- $this->han_login->createAccount(array('member_id' => $member['member_id'], 'email' => $member['email'], 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $this->member->ip_address, 'username' => $member['members_display_name'], 'name' => $member['name'], 'members_display_name' => $member['members_display_name'])); //----------------------------------------- // We'll just ignore if this fails - it shouldn't hold up IPB anyways //----------------------------------------- /*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) ) { $this->registry->output->showError( 'han_login_create_failed', 2017, true ); }*/ //----------------------------------------- // Validation //----------------------------------------- $validate_key = md5(IPSMember::makePassword() . time()); $time = time(); if ($coppa != 1) { if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin' or $this->settings['reg_auth_type'] == 'admin_user') { //----------------------------------------- // We want to validate all reg's via email, // after email verificiation has taken place, // we restore their previous group and remove the validate_key //----------------------------------------- $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address'], 'spam_flag' => $_spamFlag)); if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin_user') { /* Send out the email. */ $message = array('THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=auto_validate&uid=" . urlencode($member['member_id']) . "&aid=" . urlencode($validate_key), 'publicNoSession', 'false'), 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=05", 'publicNoSession', 'false'), 'EMAIL' => $member['email'], 'ID' => $member['member_id'], 'CODE' => $validate_key); IPSText::getTextClass('email')->setPlainTextTemplate(IPSText::getTextClass('email')->getTemplate("reg_validate", $this->member->language_id)); IPSText::getTextClass('email')->buildPlainTextContent($message); IPSText::getTextClass('email')->buildHtmlContent($message); IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email'], $this->settings['board_name']); IPSText::getTextClass('email')->to = $member['email']; IPSText::getTextClass('email')->sendMail(); $this->output = $this->registry->output->getTemplate('register')->showAuthorize($member); } else { if ($this->settings['reg_auth_type'] == 'admin') { $this->output = $this->registry->output->getTemplate('register')->showPreview($member); } } /* Only send new registration email if the member wasn't banned */ if ($this->settings['new_reg_notify'] and !$member['member_banned']) { $date = $this->registry->class_localization->getDate(time(), 'LONG', 1); IPSText::getTextClass('email')->getTemplate('admin_newuser'); IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'LOG_IN_NAME' => $member['name'], 'EMAIL' => $member['email'], 'IP' => $member['ip_address'], 'DISPLAY_NAME' => $member['members_display_name'])); IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email1'], $this->settings['board_name']); IPSText::getTextClass('email')->to = $this->settings['email_in']; IPSText::getTextClass('email')->sendMail(); } $this->registry->output->setTitle($this->lang->words['reg_success'] . ' - ' . ipsRegistry::$settings['board_name']); $this->registry->output->addNavigation($this->lang->words['nav_reg'], ''); } else { /* We don't want to preview, or get them to validate via email. */ $stat_cache = $this->cache->getCache('stats'); if ($member['members_display_name'] and $member['member_id'] and !$this->caches['group_cache'][$member['member_group_id']]['g_hide_online_list']) { $stat_cache['last_mem_name'] = $member['members_display_name']; $stat_cache['last_mem_name_seo'] = IPSText::makeSeoTitle($member['members_display_name']); $stat_cache['last_mem_id'] = $member['member_id']; } $stat_cache['mem_count'] += 1; $this->cache->setCache('stats', $stat_cache, array('array' => 1)); /* Only send new registration email if the member wasn't banned */ if ($this->settings['new_reg_notify'] and !$member['member_banned']) { $date = $this->registry->class_localization->getDate(time(), 'LONG', 1); IPSText::getTextClass('email')->getTemplate('admin_newuser'); IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'LOG_IN_NAME' => $member['name'], 'EMAIL' => $member['email'], 'IP' => $member['ip_address'], 'DISPLAY_NAME' => $member['members_display_name'])); IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email1'], $this->settings['board_name']); IPSText::getTextClass('email')->to = $this->settings['email_in']; IPSText::getTextClass('email')->sendMail(); } IPSCookie::set('pass_hash', $member['member_login_key'], 1); IPSCookie::set('member_id', $member['member_id'], 1); //----------------------------------------- // Fix up session //----------------------------------------- $privacy = $member['g_hide_online_list'] || empty($this->settings['disable_anonymous']) && !empty($this->request['Privacy']) ? 1 : 0; # Update value for onCompleteAccount call $member['login_anonymous'] = $privacy . '&1'; $this->member->sessionClass()->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => $privacy)); IPSLib::runMemberSync('onCompleteAccount', $member); $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global§ion=login&do=autologin&fromreg=1'); } } else { /* This is a COPPA user, so lets tell them they registered OK and redirect to the form. */ $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address'])); $this->registry->output->redirectScreen($this->lang->words['cp_success'], $this->settings['base_url'] . 'app=core&module=global&section=register&do=12'); } }
/** * Processes the registration form * * @access public * @return void */ public function registerProcessForm() { $form_errors = array(); $coppa = $this->request['coppa_user'] == 1 ? 1 : 0; $in_password = trim($this->request['PassWord']); $in_email = strtolower(trim($this->request['EmailAddress'])); $_SFS_FOUND = FALSE; /* Check */ if ($this->settings['no_reg'] == 1) { $this->registry->output->showError('registration_disabled', 2016, true); } /* Custom profile field stuff */ require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $custom_fields = new customProfileFields(); $custom_fields->initData('edit'); $custom_fields->parseToSave($this->request, 'register'); /* Check */ if ($custom_fields->error_messages) { $form_errors['general'] = $custom_fields->error_messages; } /* Check the email address */ if (!$in_email or strlen($in_email) < 6 or !IPSText::checkEmailAddress($in_email)) { $form_errors['email'][$this->lang->words['err_invalid_email']] = $this->lang->words['err_invalid_email']; } if (trim($this->request['PassWord_Check']) != $in_password) { $form_errors['password'][$this->lang->words['passwords_not_match']] = $this->lang->words['passwords_not_match']; } /* Test email address */ $this->request['EmailAddress_two'] = strtolower(trim($this->request['EmailAddress_two'])); $this->request['EmailAddress'] = strtolower(trim($this->request['EmailAddress'])); if (!IPSText::checkEmailAddress($this->request['EmailAddress_two'])) { $form_errors['email'][$this->lang->words['reg_error_email_invalid']] = $this->lang->words['reg_error_email_invalid']; } else { if ($in_email and $this->request['EmailAddress_two'] != $in_email) { $form_errors['email'][$this->lang->words['reg_error_email_nm']] = $this->lang->words['reg_error_email_nm']; } } /* Need username? */ $uses_name = false; foreach ($this->cache->getCache('login_methods') as $method) { if ($method['login_user_id'] == 'username') { $uses_name = true; } } if (!$uses_name) { $_REQUEST['UserName'] = $_REQUEST['members_display_name']; $this->request['UserName'] = $this->request['members_display_name']; } /* Check the username */ $user_check = IPSMember::getFunction()->cleanAndCheckName($this->request['UserName'], array(), 'name'); if ($this->settings['auth_allow_dnames']) { $disp_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'members_display_name'); } if (is_array($user_check['errors']) && count($user_check['errors'])) { foreach ($user_check['errors'] as $key => $error) { $form_errors[$key][] = $error; } } if ($this->settings['auth_allow_dnames'] and is_array($disp_check['errors']) && count($disp_check['errors'])) { foreach ($disp_check['errors'] as $key => $error) { $form_errors[$key][] = $error; } } /* CHECK 1: Any errors (missing fields, etc)? */ if (count($form_errors)) { $this->registerForm($form_errors); return; } /* Is this email addy taken? */ if (IPSMember::checkByEmail($in_email) == TRUE) { $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken']; } /* Load handler... */ require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php'; $this->han_login = new han_login($this->registry); $this->han_login->init(); $this->han_login->emailExistsCheck($in_email); if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'EMAIL_NOT_IN_USE') { $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken']; } /* Are they banned [EMAIL]? */ if (IPSMember::isBanned('email', $in_email) === TRUE) { $form_errors['email'][$this->lang->words['reg_error_email_ban']] = $this->lang->words['reg_error_email_ban']; } /* Check the CAPTCHA */ if ($this->settings['bot_antispam']) { if ($this->registry->getClass('class_captcha')->validate() !== TRUE) { $form_errors['general'][$this->lang->words['err_reg_code']] = $this->lang->words['err_reg_code']; } } /* Check the Q and A */ if ($this->settings['registration_qanda']) { $qanda = intval($this->request['qanda_id']); $pass = false; if ($qanda) { $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'question_and_answer', 'where' => 'qa_id=' . $qanda)); if ($data['qa_id']) { $answers = explode("\n", str_replace("\r", "", $data['qa_answers'])); if (count($answers)) { foreach ($answers as $answer) { if (strtolower($answer) == strtolower($this->request['qa_answer'])) { $pass = true; break; } } } } } else { //----------------------------------------- // Do we have any questions? //----------------------------------------- $data = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as questions', 'from' => 'question_and_answer')); if (!$data['questions']) { $pass = true; } } if (!$pass) { $form_errors['general'][$this->lang->words['err_q_and_a']] = $this->lang->words['err_q_and_a']; } } /* CHECK 2: Any errors ? */ if (count($form_errors)) { $this->registerForm($form_errors); return; } /* Build up the hashes */ $mem_group = $this->settings['member_group']; /* Are we asking the member or admin to preview? */ if ($this->settings['reg_auth_type']) { $mem_group = $this->settings['auth_group']; } else { if ($coppa == 1) { $mem_group = $this->settings['auth_group']; } } /* Create member */ $member = array('name' => $this->request['UserName'], 'password' => $in_password, 'members_display_name' => $this->settings['auth_allow_dnames'] ? $this->request['members_display_name'] : $this->request['UserName'], 'email' => $in_email, 'member_group_id' => $mem_group, 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->request['time_offset'], 'coppa_user' => $coppa, 'members_auto_dst' => intval($this->request['dst']), 'allow_admin_mails' => intval($this->request['allow_admin_mail']), 'hide_email' => $this->request['allow_member_mail'] ? 0 : 1); /* Spam Service */ $spamCode = 0; if ($this->settings['spam_service_enabled'] && $this->settings['spam_service_api_key']) { /* Query the service */ $spamCode = IPSMember::querySpamService($in_email); /* Action to perform */ $action = $this->settings['spam_service_action_' . $spamCode]; /* Perform Action */ switch ($action) { /* Proceed with registraction */ case 1: break; /* Flag for admin approval */ /* Flag for admin approval */ case 2: $member['member_group_id'] = $this->settings['auth_group']; $this->settings['reg_auth_type'] = 'admin'; break; /* Approve the account, but ban it */ /* Approve the account, but ban it */ case 3: $member['member_banned'] = 1; $member['member_group_id'] = $this->settings['banned_group']; $this->settings['reg_auth_type'] = ''; break; } } //----------------------------------------- // Create the account //----------------------------------------- $member = IPSMember::create(array('members' => $member, 'pfields_content' => $this->request)); //----------------------------------------- // Login handler create account callback //----------------------------------------- $this->han_login->createAccount(array('email' => $member['email'], 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $this->member->ip_address, 'username' => $member['members_display_name'])); //----------------------------------------- // We'll just ignore if this fails - it shouldn't hold up IPB anyways //----------------------------------------- /*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) ) { $this->registry->output->showError( 'han_login_create_failed', 2017, true ); }*/ //----------------------------------------- // Validation //----------------------------------------- $validate_key = md5(IPSLib::makePassword() . time()); $time = time(); if ($coppa != 1) { if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin' or $this->settings['reg_auth_type'] == 'admin_user') { //----------------------------------------- // We want to validate all reg's via email, // after email verificiation has taken place, // we restore their previous group and remove the validate_key //----------------------------------------- $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address'])); if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin_user') { IPSText::getTextClass('email')->getTemplate("reg_validate"); IPSText::getTextClass('email')->buildMessage(array('THE_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=auto_validate&uid=" . urlencode($member['member_id']) . "&aid=" . urlencode($validate_key), 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=05", 'EMAIL' => $member['email'], 'ID' => $member['member_id'], 'CODE' => $validate_key)); IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email'] . $this->settings['board_name']; IPSText::getTextClass('email')->to = $member['email']; IPSText::getTextClass('email')->sendMail(); $this->output = $this->registry->output->getTemplate('register')->showAuthorize($member); } else { if ($this->settings['reg_auth_type'] == 'admin') { $this->output = $this->registry->output->getTemplate('register')->showPreview($member); } } if ($this->settings['new_reg_notify']) { $date = $this->registry->class_localization->getDate(time(), 'LONG', 1); IPSText::getTextClass('email')->getTemplate('admin_newuser'); IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'MEMBER_NAME' => $member['members_display_name'])); IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email1'] . $this->settings['board_name']; IPSText::getTextClass('email')->to = $this->settings['email_in']; IPSText::getTextClass('email')->sendMail(); } $this->registry->output->setTitle($this->lang->words['reg_success']); $this->registry->output->addNavigation($this->lang->words['nav_reg'], ''); } else { /* We don't want to preview, or get them to validate via email. */ $stat_cache = $this->caches['stats']; if ($member['members_display_name'] and $member['member_id']) { $stat_cache['last_mem_name'] = $member['members_display_name']; $stat_cache['last_mem_id'] = $member['member_id']; } $stat_cache['mem_count'] += 1; $this->cache->setCache('stats', $stat_cache, array('array' => 1, 'deletefirst' => 0)); if ($this->settings['new_reg_notify']) { $date = $this->registry->class_localization->getDate(time(), 'LONG', 1); IPSText::getTextClass('email')->getTemplate('admin_newuser'); IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'MEMBER_NAME' => $member['members_display_name'])); IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email1'] . $this->settings['board_name']; IPSText::getTextClass('email')->to = $this->settings['email_in']; IPSText::getTextClass('email')->sendMail(); } IPSCookie::set('pass_hash', $member['member_login_key'], 1); IPSCookie::set('member_id', $member['member_id'], 1); //----------------------------------------- // Fix up session //----------------------------------------- $privacy = $this->request['Privacy'] ? 1 : 0; if ($member['g_hide_online_list']) { $privacy = 1; } $this->member->sessionClass()->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => $privacy)); $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global§ion=login&do=autologin&fromreg=1'); } } else { /* This is a COPPA user, so lets tell them they registered OK and redirect to the form. */ $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address'])); $this->registry->output->redirectScreen($this->lang->words['cp_success'], $this->settings['base_url'] . 'app=core&module=global&section=register&do=12'); } }
/** * Toggle member spam [process] * * @access private * @return void [Outputs to screen] */ private function _memberToggleSpam() { /* INIT */ $toSave = array(); $this->request['member_id'] = intval($this->request['member_id']); if (!$this->request['member_id']) { $this->registry->output->showError($this->lang->words['m_specify'], 11228); } $member = IPSMember::load($this->request['member_id']); if (!$member['member_id']) { $this->registry->output->showError($this->lang->words['m_noid'], 11229); } //----------------------------------------- // Allowed to spam administrators? //----------------------------------------- if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_ban_admin')) { $this->registry->output->global_message = $this->lang->words['m_banadmin']; $this->_memberView(); return; } /* Load mod lib */ require IPSLib::getAppDir('forums') . '/sources/classes/moderate.php'; $this->modLibrary = new moderatorLibrary($this->registry); /* Spam or not ? */ if ($member['bw_is_spammer']) { $toSave['core']['bw_is_spammer'] = 0; $toSave['core']['restrict_post'] = 0; $toSave['core']['members_disable_pm'] = 0; /* Flag them as a spammer */ IPSMember::save($member['member_id'], $toSave); } else { $toSave['core']['bw_is_spammer'] = 1; /* What do to.. */ if ($this->settings['spm_option']) { switch ($this->settings['spm_option']) { case 'disable': $toSave['core']['restrict_post'] = 1; $toSave['core']['members_disable_pm'] = 2; break; case 'unapprove': $toSave['core']['restrict_post'] = 1; $toSave['core']['members_disable_pm'] = 2; /* Unapprove posts and topics */ $this->modLibrary->toggleApproveMemberContent($member['member_id'], FALSE, 'all', intval($this->settings['spm_post_days']) * 24); break; } } /* Send an email */ if ($this->settings['spm_notify'] and $this->settings['email_out'] != $this->memberData['email']) { IPSText::getTextClass('email')->getTemplate('possibleSpammer'); IPSText::getTextClass('email')->buildMessage(array('DATE' => $this->registry->class_localization->getDate($member['joined'], 'LONG', 1), 'MEMBER_NAME' => $member['members_display_name'], 'IP' => $member['ip_address'], 'EMAIL' => $member['email'], 'LINK' => $this->registry->getClass('output')->buildSEOUrl("showuser="******"{$this->form_code}&do=viewmember&member_id={$member['member_id']}", "redirect"); }
/** * Unmarks member(s) as spam * * @note Exceptions CAN bubble up, so you should still capture exceptions from calls to this method * @param array Array of member ids * @param bool Unmark posts additionally * @return string Confirmation message */ public function unmarkMembersAsSpam($ids, $unmarkPosts = false) { /* Load Member Data */ $members = IPSMember::load($ids); foreach ($ids as $i) { IPSMember::save($i, array('core' => array('bw_is_spammer' => 0, 'restrict_post' => 0, 'members_disable_pm' => 0))); if ($this->settings['spam_service_send_to_ips']) { IPSMember::querySpamService($members[$i]['email'], $members[$i]['ip_address'], 'notspam'); } $this->DB->update('validating', array('spam_flag' => 0), 'member_id=' . $i); } /* Reset last member */ IPSMember::resetLastRegisteredMember(); if ($unmarkPosts) { /* Toggle their content */ $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums'); $modLibrary = new $classToLoad($this->registry); foreach ($ids as $id) { $modLibrary->toggleApproveMemberContent($id, TRUE, 'all', intval($this->settings['spm_post_days']) * 24); /* Run member sync */ IPSLib::runMemberSync('onUnSetAsSpammer', array('member_id' => $id)); } } $message = sprintf($this->lang->words['t_memunspammed'], count($ids)); ipsRegistry::getClass('adminFunctions')->saveAdminLog($message); IPSMember::resetLastRegisteredMember(); return $message; }
/** * Manage validating members * * @access private * @return void [Outputs to screen] */ private function _manageValidating() { //----------------------------------------- // INIT //----------------------------------------- $ids = array(); //----------------------------------------- // GET checkboxes //----------------------------------------- foreach ($this->request as $k => $v) { if (preg_match("/^mid_(\\d+)\$/", $k, $match)) { if ($v) { $ids[] = $match[1]; } } } $ids = IPSLib::cleanIntArray($ids); //----------------------------------------- // Check //----------------------------------------- if (count($ids) < 1) { $this->registry->output->showError($this->lang->words['t_nomemsel'], 11247); } //----------------------------------------- // APPROVE //----------------------------------------- if ($this->request['type'] == 'approve') { IPSText::getTextClass('email')->getTemplate("complete_reg"); $approved = array(); //----------------------------------------- // Get members //----------------------------------------- $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => "m.member_id IN(" . implode(",", $ids) . ")", 'add_join' => array(array('select' => 'm.member_id, m.members_display_name, m.name, m.email, m.member_group_id', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left')))); $main = $this->DB->execute(); while ($row = $this->DB->fetch($main)) { $approved[] = $row['name']; //----------------------------------------- // Only approve if the user is validating //----------------------------------------- if ($row['member_group_id'] != $this->settings['auth_group']) { continue; } //----------------------------------------- // Don't approve if no real_group set //----------------------------------------- if (!$row['real_group']) { //$row['real_group'] = $this->settings['member_group']; continue; } //----------------------------------------- // We don't approve lost pass requests //----------------------------------------- if ($row['lost_pass'] == 1) { continue; } try { IPSMember::save($row['member_id'], array('core' => array('member_group_id' => $row['real_group']))); } catch (Exception $error) { $this->registry->output->showError($error->getMessage(), 11247); } IPSText::getTextClass('email')->buildMessage(array()); //----------------------------------------- // Using 'name' on purpose // @see http://forums./index.php?autocom=tracker&showissue=11564&view=findpost&p=45269 //----------------------------------------- IPSText::getTextClass('email')->subject = sprintf($this->lang->words['subject__complete_reg'], $row['name'], $this->settings['board_name']); IPSText::getTextClass('email')->to = $row['email']; IPSText::getTextClass('email')->sendMail(); IPSLib::runMemberSync('onGroupChange', $row['member_id'], $row['real_group']); } $this->DB->delete('validating', "member_id IN(" . implode(",", $ids) . ")"); ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_memregapp2'] . implode(", ", $approved)); //----------------------------------------- // Stats to Update? //----------------------------------------- $this->cache->rebuildCache('stats', 'global'); $this->registry->output->global_message = count($ids) . $this->lang->words['t_memregapp']; if ($this->request['_return']) { $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'app=members&module=members§ion=members&do=viewmember&member_id=' . $this->request['_return']); } $this->_viewQueue('validating'); return; } else { if ($this->request['type'] == 'resend') { $reset = array(); $cant = array(); $main_msgs = array(); //----------------------------------------- // Get members //----------------------------------------- $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => "m.member_id IN(" . implode(",", $ids) . ")", 'add_join' => array(array('select' => 'm.member_id, m.members_display_name, m.email, m.member_group_id', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left')))); $main = $this->DB->execute(); while ($row = $this->DB->fetch($main)) { if ($row['member_group_id'] != $this->settings['auth_group']) { continue; } if ($row['lost_pass']) { IPSText::getTextClass('email')->getTemplate("lost_pass"); IPSText::getTextClass('email')->buildMessage(array('NAME' => $row['members_display_name'], 'THE_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global§ion=lostpass&do=sendform&uid=" . $row['member_id'] . "&aid=" . $val['vid'], 'MAN_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global§ion=lostpass", 'EMAIL' => $row['email'], 'ID' => $row['member_id'], 'CODE' => $row['vid'], 'IP_ADDRESS' => $row['ip_address'])); IPSText::getTextClass('email')->subject = $this->lang->words['t_passwordrec'] . $this->settings['board_name']; IPSText::getTextClass('email')->to = $row['email']; IPSText::getTextClass('email')->sendMail(); } else { if ($row['new_reg']) { if ($row['user_verified']) { $cant[] = $row['members_display_name']; continue; } IPSText::getTextClass('email')->getTemplate("reg_validate"); IPSText::getTextClass('email')->buildMessage(array('THE_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global§ion=register&do=auto_validate&uid=" . $row['member_id'] . "&aid=" . $row['vid'], 'NAME' => $row['members_display_name'], 'MAN_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global§ion=register&do=05", 'EMAIL' => $row['email'], 'ID' => $row['member_id'], 'CODE' => $row['vid'])); IPSText::getTextClass('email')->subject = $this->lang->words['t_regat'] . $this->settings['board_name']; IPSText::getTextClass('email')->to = $row['email']; IPSText::getTextClass('email')->sendMail(); } else { if ($row['email_chg']) { IPSText::getTextClass('email')->getTemplate("newemail"); IPSText::getTextClass('email')->buildMessage(array('NAME' => $row['members_display_name'], 'THE_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global§ion=register&do=auto_validate&type=newemail&uid=" . $row['member_id'] . "&aid=" . $row['vid'], 'ID' => $row['member_id'], 'MAN_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global§ion=register&do=user_validate", 'CODE' => $row['vid'])); IPSText::getTextClass('email')->subject = $this->lang->words['t_emailchange'] . $this->settings['board_name']; IPSText::getTextClass('email')->to = $row['email']; IPSText::getTextClass('email')->sendMail(); } } } $resent[] = $row['members_display_name']; } if (count($resent)) { ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($resent) . $this->lang->words['tools_val_resent_log'] . implode(", ", $resent)); $main_msgs[] = count($resent) . $this->lang->words['t_vallog'] . implode(", ", $resent); } if (count($cant)) { $main_msgs[] = $this->lang->words['t_valcannot'] . implode(", ", $cant); } $this->registry->output->global_message = count($main_msgs) ? implode("<br />", $main_msgs) : ''; $this->_viewQueue('validating'); return; } else { if ($this->request['type'] == 'ban') { $this->DB->update('members', array('member_banned' => 1), "member_id IN(" . implode(",", $ids) . ")"); $this->DB->delete('validating', "member_id IN(" . implode(",", $ids) . ")"); ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_membanned']); $this->registry->output->global_message = count($ids) . $this->lang->words['t_membanned']; $this->_viewQueue('validating'); return; } else { if ($this->request['type'] == 'spam') { /* Grab members */ $members = IPSMember::load($ids); /* Load moderator's library */ require IPSLib::getAppDir('forums') . '/sources/classes/moderate.php'; $modLibrary = new moderatorLibrary($this->registry); /* Load custom fields class */ require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $fields = new customProfileFields(); /* Load language file */ $this->registry->getClass('class_localization')->loadLanguageFile(array('public_mod'), 'forums'); foreach ($members as $member_id => $member) { $toSave = array('core' => array('bw_is_spammer' => 1, 'member_group_id' => $this->settings['member_group'])); /* Protected group? */ if (strstr(',' . $this->settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) { continue; } /* What do to.. */ if ($this->settings['spm_option']) { switch ($this->settings['spm_option']) { case 'disable': $toSave['core']['restrict_post'] = 1; $toSave['core']['members_disable_pm'] = 2; break; case 'unapprove': $toSave['core']['restrict_post'] = 1; $toSave['core']['members_disable_pm'] = 2; /* Unapprove posts and topics */ $modLibrary->toggleApproveMemberContent($member_id, FALSE, 'all', intval($this->settings['spm_post_days']) * 24); break; case 'ban': /* Unapprove posts and topics */ $modLibrary->toggleApproveMemberContent($member_id, FALSE, 'all', intval($this->settings['spm_post_days']) * 24); $toSave = array('core' => array('member_banned' => 1, 'title' => '', 'bw_is_spammer' => 1), 'extendedProfile' => array('signature' => '', 'pp_bio_content' => '', 'pp_about_me' => '', 'pp_status' => '')); //----------------------------------------- // Avatar //----------------------------------------- $toSave['extendedProfile']['avatar_location'] = ""; $toSave['extendedProfile']['avatar_size'] = ""; try { IPSMember::getFunction()->removeAvatar($member['member_id']); } catch (Exception $e) { // Maybe should show an error or something } //----------------------------------------- // Photo //----------------------------------------- IPSMember::getFunction()->removeUploadedPhotos($member['member_id']); $toSave['extendedProfile'] = array_merge($toSave['extendedProfile'], array('pp_main_photo' => '', 'pp_main_width' => '', 'pp_main_height' => '', 'pp_thumb_photo' => '', 'pp_thumb_width' => '', 'pp_thumb_height' => '')); //----------------------------------------- // Profile fields //----------------------------------------- $fields->member_data = $member; $fields->initData('edit'); $fields->parseToSave(array()); if (count($fields->out_fields)) { $toSave['customFields'] = $fields->out_fields; } //----------------------------------------- // Update signature content cache //----------------------------------------- IPSContentCache::update($member['member_id'], 'sig', ''); break; } } /* Send an email */ if ($this->settings['spm_notify'] and $this->settings['email_out'] != $this->memberData['email']) { IPSText::getTextClass('email')->getTemplate('possibleSpammer'); IPSText::getTextClass('email')->buildMessage(array('DATE' => $this->registry->class_localization->getDate($member['joined'], 'LONG', 1), 'MEMBER_NAME' => $member['members_display_name'], 'IP' => $member['ip_address'], 'EMAIL' => $member['email'], 'LINK' => $this->registry->getClass('output')->buildSEOUrl("showuser="******"member_id IN(" . implode(",", $ids) . ")"); $this->registry->output->global_message = count($ids) . ' ' . $this->lang->words['t_setasspammers']; $this->_viewQueue('validating'); return; } } else { $denied = array(); $this->DB->build(array('select' => 'members_display_name', 'from' => 'members', 'where' => "member_id IN(" . implode(",", $ids) . ")")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $denied[] = $r['members_display_name']; } try { IPSMember::remove($ids); } catch (Exception $error) { $this->registry->output->showError($error->getMessage(), 11247); } ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_regdenied'] . implode(", ", $denied)); $this->registry->output->global_message = count($ids) . $this->lang->words['t_removedmem']; $this->_viewQueue('validating'); return; } } } } }
protected function _testApiConnection() { /* Test the connection */ $result = IPSMember::querySpamService('', '', '', 1); $this->registry->output->html .= $this->html->spamServiceTest($result); }
/** * Flag a user account as a spammer * * @access private * @return void Outputs error screen */ private function _setAsSpammer() { /* INIT */ $member_id = intval($this->request['member_id']); $toSave = array('core' => array('bw_is_spammer' => 1)); /* Load member */ $member = IPSMember::load($member_id); if (!$member['member_id']) { $this->_showError('moderate_no_permission', 10311900); } /* Check permissions */ $this->_genericPermissionCheck('bw_flag_spammers'); /* Protected group? */ if (strstr(',' . $this->settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) { $this->_showError('moderate_no_permission', 10311901); } /* What do to.. */ if ($this->settings['spm_option']) { switch ($this->settings['spm_option']) { case 'disable': $toSave['core']['restrict_post'] = 1; $toSave['core']['members_disable_pm'] = 2; break; case 'unapprove': $toSave['core']['restrict_post'] = 1; $toSave['core']['members_disable_pm'] = 2; /* Unapprove posts and topics */ $this->modLibrary->toggleApproveMemberContent($member_id, FALSE, 'all', intval($this->settings['spm_post_days']) * 24); break; case 'ban': /* Unapprove posts and topics */ $this->modLibrary->toggleApproveMemberContent($member_id, FALSE, 'all', intval($this->settings['spm_post_days']) * 24); $toSave = array('core' => array('member_banned' => 1, 'title' => '', 'bw_is_spammer' => 1), 'extendedProfile' => array('signature' => '', 'pp_bio_content' => '', 'pp_about_me' => '', 'pp_status' => '')); //----------------------------------------- // Avatar //----------------------------------------- $toSave['extendedProfile']['avatar_location'] = ""; $toSave['extendedProfile']['avatar_size'] = ""; try { IPSMember::getFunction()->removeAvatar($member['member_id']); } catch (Exception $e) { // Maybe should show an error or something } //----------------------------------------- // Photo //----------------------------------------- IPSMember::getFunction()->removeUploadedPhotos($member['member_id']); $toSave['extendedProfile'] = array_merge($toSave['extendedProfile'], array('pp_main_photo' => '', 'pp_main_width' => '', 'pp_main_height' => '', 'pp_thumb_photo' => '', 'pp_thumb_width' => '', 'pp_thumb_height' => '')); //----------------------------------------- // Profile fields //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php'; $fields = new customProfileFields(); $fields->member_data = $member; $fields->initData('edit'); $fields->parseToSave(array()); if (count($fields->out_fields)) { $toSave['customFields'] = $fields->out_fields; } //----------------------------------------- // Update signature content cache //----------------------------------------- IPSContentCache::update($member['member_id'], 'sig', ''); break; } } /* Send an email */ if ($this->settings['spm_notify'] and $this->settings['email_out'] != $this->memberData['email']) { IPSText::getTextClass('email')->getTemplate('possibleSpammer'); IPSText::getTextClass('email')->buildMessage(array('DATE' => $this->registry->class_localization->getDate($member['joined'], 'LONG', 1), 'MEMBER_NAME' => $member['members_display_name'], 'IP' => $member['ip_address'], 'EMAIL' => $member['email'], 'LINK' => $this->registry->getClass('output')->buildSEOUrl("showuser="******"showtopic=" . $this->topic['tid'] . "&st=" . intval($this->request['st']), $this->topic['title_seo']); } else { $this->registry->output->redirectScreen($this->lang->words['flag_spam_done'], $this->settings['base_url'] . "showuser=" . $member['member_id'], $member['members_seo_name']); } }