Reply To: Daily Russian spam

Home Forums Quform PHP Daily Russian spam Reply To: Daily Russian spam

#29108
waubain
Participant

This may or may not apply to your situation. I also was getting a lot of spam. One common denominator of all the spam that I received is that it contained a URL link. Since my users would have no reason so submit a URL, I created a Validator that check the textarea for a URL and prevented the form from being submitted, and alerted the users of no URLs.

Since doing this, I have not gotten any spam submitted. I am not a programmer, but this code worked for me.


/**
 * Quform_Validator_URL
 *
 * Checks that the text block does not have a embedded URL
 *
 * @package Quform
 * @subpackage Validator
 * @copyright Copyright (c) 2009-2015 ThemeCatcher (http://www.themecatcher.net)
 */
class Quform_Validator_Url extends Quform_Validator_Abstract
{
    /**
     * Error message templates
     * @var array
     */
    protected $_messageTemplates = array(
        'empty' => 'URLs not allowed'
    );

    /**
     * Checks whether the given value is empty.
     *
     * @param $value The value to check
     * @return boolean True if valid false otherwise
     */
    public function isValid($value)
    {
        $valid = true;

          if (stristr($value, 'http')||stristr($value, 'www.') !== false) { 
            
            $this->addMessage($this->_messageTemplates['empty']);
            $valid = false;
        }
        return $valid;
    }
}
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy