Welcome, Guest!!
follow us on... rss

Author Topic: WordPress and the Subscribe2 plugin  (Read 3738 times)

Mike

  • Administrator
  • Sr. Member
  • *****
  • Posts: 300
    • View Profile
WordPress and the Subscribe2 plugin
« on: September 09, 2011, 06:08:46 AM »
This is code sent in by "Piotr" for use with WordPress and the Subscribe2 plugin.

To implement bot trapping I have used your sample code.

I was working on 6.2 version of the plugin, but I'm sure all changes can be made to any version of it.
If anybody want to modify Subscribe2 plugin like I did, subscribe2.php file need to be modify:

function is_bot() must be placed anywhere in the file (I've placed it under is_barred() function, here is code, I deleted most of the comments as you guys knows your code:)

Code: [Select]
function is_bot($XMAIL='', $XIP='') {
                 /////////////////// START CONFIGURATION
////////////////////////
                 // use diagnostic output? ('1' to use, '0' to suppress)
                 // (normally set to '0')
                 $diag = '0';
                 ////////////////////////
                 // init vars
                 $diag='';
                 $data='';
                 $botdata='';
                 $APIKEY='';
                 $USEXML='';
                 $multi_test='';
                 $ch='';
                 $botdata='';
                 $XNAME='';
                 ////////////////////////
                 // your optional API key (don't have one? get one here: http://botscout.com/
                 $APIKEY = '';
                 ////////////////////////
                 // use XML output responses?
                 // '1' to use XML, '0' to use standard responses
                 $USEXML = '0';
                 /////////////////// END CONFIGURATION
////////////////////////

                 // make the url compliant with urlencode()
                 $XMAIL = urlencode($XMAIL);

                 // for this example we'll use the MULTI test
                 $test_string = "http://botscout.com/test/?multi&mail=$XMAIL&ip=$XIP";

                 // are using an API key? If so, append it.
                 if($APIKEY != ''){
                  $test_string = "$test_string&key=$APIKEY";
                 }

                  // are using XML responses? If so, append the XML format key.
                  if($USEXML == '1'){
                     $test_string = "$test_string&format=xml";
                  }

                  ////////////////////////
                  if($diag=='1'){print "Test String: $test_string";}
                  ////////////////////////


                $ch = curl_init($test_string);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $returned_data = curl_exec($ch);
                curl_close($ch);

                  if($diag=='1'){
                print "RETURNED DATA: $returned_data";
                // sanity check
                if($returned_data==''){ print 'Error: No return data from API query.'; exit; }
                  }

                  $botdata = explode('|', $returned_data);

                  if(substr($returned_data, 0,1) == '!'){
                print "Error: $returned_data";
                exit;
                 }

                 if($botdata[3] > 0 || $botdata[5] > 0){
                //print $data;
                if($diag=='1'){
                print "Bot signature found.";
                print "Type of test was: $botdata[1]";
                print "The {$botdata[2]} was found {$botdata[3]} times, the {$botdata[4]} was found {$botdata[5]} times";
                }

                        return true;
                } else {
                        return false;
                }

} //end is_bot()
Most important thing is to get email address and ip when calling a function
and to return true or false after checking that data.

2nd thing is to modify shortcode() function (3112 line of my file).

You have to search for this (3149-3151 lines of my file):

} elseif ( $this->is_barred($_POST['email']) ) {
 $this->s2form = $this->form . $this->barred_domain;
} else {

and change it to this:

} elseif ( $this->is_barred($_POST['email']) ) {
$this->s2form = $this->form . $this->barred_domain;
 } elseif ( $this->is_bot($_POST['email'], $_POST['ip']) ) {
$this->s2form = $this->form . $this->barred_domain;
 } else {

So now it works just like for barred_domain. If anybody wan't to show
something else, this could be modified, but for me this is fine.

That's it, I hope this will help people like me having problems with bots
and Subscribe2 plugin.
Please don't PM me for assistance- post your questions in the forum where others can see them.