1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Stopping Registration at the door...

Discussion in 'XenForo Development Discussions' started by Jaxel, Jan 5, 2011.

  1. Jaxel

    Jaxel Well-Known Member

    So I wrote a StopForumSpam function on my XenUtiles release...
    Code:
    <?php
    
    class EWRutiles_ControllerPublic_Register extends XFCP_EWRutiles_ControllerPublic_Register
    {
    	public function actionRegister()
    	{
    		$response = parent::actionRegister();
    		$options = XenForo_Application::get('options');
    
    		$data = $this->_input->filter(array(
    			'username'   => XenForo_Input::STRING,
    			'email'      => XenForo_Input::STRING,
    		));
    		$data['ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false;
    
    		$errors = $this->getModelFromCache('EWRutiles_Model_ForumSpam')->checkDatabase($data, $count);
    
            if ($count >= $options->EWRutiles_forumspam_hound)
            {
                return $this->_getRegisterFormResponse($data, $errors);
            }
    
    		return $response;
    	}
    }
    Looks simple right? It checks against errors, and if the number of errors exceed the error requirement for the StopForumSpam check, it returns the errors back to the parent. This works. If the error requirement is met, it is properly displays the errors such as "Your username was found on the StopForumSpam database and has been rejected."

    However, the problem is that even though the error is presented to the user, it still registers their account. I just tested it on my forums by registering with known spammer usernames and emails; it did properly give me StopForumSpam errors, but as long as I filled in all the rest of the required information, it still registered my account and presented "Your account is currently awaiting confirmation." on top of the registration form.

    How do I fix this?
     
  2. ragtek

    ragtek Guest

    You're calling as first
    PHP:
    $response parent::actionRegister();
    so it's creating the users, and then you're making the check:D

    strange logic^^
     
  3. Jaxel

    Jaxel Well-Known Member

    Ah... well this OO stuff still confuses me sometimes.
     
  4. ragtek

    ragtek Guest

    hehe
     
  5. Jaxel

    Jaxel Well-Known Member

    Yeah, well before XenForo I have had ZERO experience with object oriented programming. I am learned in Perl, C++ and other procedural languages. And except for the DataWriters in VB4 (I wouldn't be surprised if the DW system was one of the few things Kier/Mike wrote before they left Jelsoft), everything there was procedural as well.

    Still, I don't think I'm doing so bad...
     
  6. ragtek

    ragtek Guest

Share This Page