TPU: Detect and Block Spam Registrations

TPU: Detect and Block Spam Registrations 1.6.6

No permission to download
i've got this php socket error for new registrations. anyone know what this is?

Action: Moderated - TPUDetectSpamReg checking: Kingstonian,, 2.99.55.135, AS detected: ASN13285, OPALTELECOM-AS TalkTalk Communications Limited, GB, Hostname detected: host-2-99-55-135.as13285.net, PHP function socket_create() not available, you need the PHP socket extension for open port detection to work, Country detected: XX, +1. Email local part exceeds 15 chars: chessingtonpete, Total score: +1
Generated By: Kingstonian, Today at 8:16 AM, Content: user (803)
Request State
array(4) {
["url"] => string(44) "http://www.dressedwell.net/register/register"
["referrer"] => string(44) "http://www.dressedwell.net/register/register"
["_GET"] => array(0) {
}
["_POST"] => array(19) {
["username"] => string(0) ""
["d3ec51e6ac8b3a9131fbdadd1f43f7a5"] => string(11) "Kingstonian"
["c5994e152041d41c4849b6b0a8aa512e"] => string(23) ""
["password"] => string(8) "********"
["817ee452f567b8b26c72e4e22b5b3f15"] => string(0) ""
["11c5e7c7daeeacdbb3050dbb9c272715"] => string(4) "male"
["dob_month"] => string(1) "2"
["dob_day"] => string(1) "2"
["dob_year"] => string(4) "1972"
["55a247aa6fd2dab534dca144ff5e1a25"] => array(1) {
["zjm5otnmmdu3mzc3mjnjmw"] => string(0) ""
}
["custom_fields_shown"] => array(1) {
[0] => string(22) "zjm5otnmmdu3mzc3mjnjmw"
}
["906ec3b2ab54544e4060204b79df5055"] => string(13) "Europe/London"
["slidercaptcha_validate_time"] => string(10) "1488892553"
["slidercaptcha_validate_hash"] => string(40) "1b3fb500fdde07ae1761e62d8af373b607a2ea35"
["slidercaptcha_loaded"] => string(4) "true"
["slidercaptcha_fallback"] => string(8) "Noscript"
["agree"] => string(1) "1"
["_xfToken"] => string(8) "********"
["reg_key"] => string(32) "f3993f05737723c3ac44b6bf0cbec485"
}
}
 
Getting this error when someone tries to register. I'm using @Xon's version mentioned here: https://xenforo.com/community/threa...spam-registrations.70418/page-15#post-1135829

Code:
Server Error Log
Error Info
ErrorException: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address - library/TPUDetectSpamReg/Hostname.php:11
Generated By: Unknown Account, 1 minute ago
Stack Trace
#0 [internal function]: XenForo_Application::handlePhpError(2, 'gethostbyaddr()...', '/home/dir/publ...', 11, Array)
#1 /home/dir/public_html/library/TPUDetectSpamReg/Hostname.php(11): gethostbyaddr('')
#2 [internal function]: TPUDetectSpamReg_Hostname::getRegSpamScore(Array, Array, '1', '0', Object(TPUDetectSpamReg_ModelSpamPrevention))
#3 /home/dir/public_html/library/XenForo/CodeEvent.php(90): call_user_func_array(Array, Array)
#4 /home/dir/public_html/library/TPUDetectSpamReg/ModelSpamPrevention.php(67): XenForo_CodeEvent::fire('tpu_detect_spam...', Array)
#5 /home/dir/public_html/library/XenForo/ControllerPublic/Register.php(1426): TPUDetectSpamReg_ModelSpamPrevention->allowRegistration(Array, Object(Zend_Controller_Request_Http))
#6 /home/dir/public_html/library/XenForo/ControllerPublic/Register.php(401): XenForo_ControllerPublic_Register->_runSpamCheck(Object(LiveUpdate_DataWriter_User), Array)
#7 /home/dir/public_html/library/UserEss/ControllerPublic/Register.php(68): XenForo_ControllerPublic_Register->actionRegister()
#8 /home/dir/public_html/library/XenForo/FrontController.php(351): UserEss_ControllerPublic_Register->actionRegister()
#9 /home/dir/public_html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#10 /home/dir/public_html/index.php(13): XenForo_FrontController->run()
#11 {main}
Request State
array(3) {
  ["url"] => string(51) "https://www.domain.com/register/register"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(17) {
    ["username"] => string(0) ""
    ["e534e17d4a011e59507d2df6e4f7c843"] => string(13) "username02"
    ["f7aa788fabeb0373d4273209adfe6dc5"] => string(0) ""
    ["8cce925065c9b8376c72c985d9fd3b7f"] => string(27) "username@domain.com"
    ["33c00a49f9cf231d7f5a8c561e3bc2f3"] => string(0) ""
    ["dob_month"] => string(1) "0"
    ["dob_day"] => string(0) ""
    ["dob_year"] => string(0) ""
    ["location"] => string(7) "Home"
    ["859fbac9bd0c699961e8d696d478b249"] => array(3) {
      ["UserSource"] => string(0) ""
      ["Secret_Word"] => string(4) "Twinky"
      ["vxnlclnvdxjjzq"] => string(0) ""
    }
    ["custom_fields_shown"] => array(3) {
      [0] => string(10) "UserSource"
      [1] => string(11) "Secret_Word"
      [2] => string(14) "vxnlclnvdxjjzq"
    }
    ["a02acda79b6a4ff807f328998fed8f4e"] => string(19) "America/Los_Angeles"
    ["captcha_question_answer"] => string(6) "None"
    ["captcha_question_hash"] => string(40) "a704d9fef4d7879575aa0d9cf457afb3831e5fbd"
    ["agree"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
    ["reg_key"] => string(32) "8377936d2adfeaf362960146f0437c3a"
  }
}
 
php isn't getting the remote IP ($_SERVER['REMOTE_ADDR']) set correctly by your webserver. It shouldn't error like that however.
 
That's why I asked... I could not find where it was addressed... just ignore me if it bothers you.
 
I still get a country code of XX, so for me it's an ongoing issue.
Ahh... okay... so now it's 14 months ongoing. Hmmm.

So I looked at the plugins code. XX is not a bug.

PHP:
static function getIPCountry($ip)
    {
        if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_COUNTRY_EDITION))
        {
            try
            {
                try
                {
                    return geoip_country_code_by_name($ip);
                } catch(Exception $e) {}
            } catch(ErrorException $e) {}
        }

        try
        {
            $country=json_decode(file_get_contents('http://ip-api.com/json/'.$ip));
            if (isset($country) && isset($country->countryCode) && $country->countryCode!='')
                return $country->countryCode;
        } catch(Exception $e) {}

        try
        {
            $country=trim(file_get_contents("http://api.hostip.info/country.php?ip=".$ip));
            if ($country!='XX')
                return $country;
        } catch(Exception $e) {}

        return 'XX';
    }

We have 3 attempts to get a result. First calling PHP's geoip_country_code_by_name which will only work if the server supports it. Some crappy shared host probably wont have this.

So it provides 2 external service providers that can get a result instead. Now the second one "api.hostip.info/country.php" no longer exists. Relying on this will return XX. However the first provider ip-api.com does exist still. But that is assuming your hosting doesn't stop you from trying to contact it.

@Xon care to make sure ip-api.com is still returning a result that works with this code?

As far as you @Sonnie goes. You can either try the addon or at least try some test code to see if the first method works on your server. If it does then the rest doesn't concern you. If it doesn't work well you still only lack the Country scoring ability, the rest of it works fine unless well I need to look at other bugs.
 
Thanks... I appreciate the thorough explanation.

Would this add-on and this other one work together... or both not needed: https://xenforo.com/community/resou...ollection-anti-spam-complete-collection.1469/

I wouldn't run them together. Too many of the same things covered. Doesn't mean you can't. I only ever used his FBHP add-on. But the full suite may be a good alternative. He is a good developer and on top of things. I've stuck with this as it works for us for now.
 
  • Like
Reactions: Xon
Top Bottom