Advertisement
Guest User

_ck_

a guest
Mar 24th, 2009
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Validator for bbPress
  4. Plugin URI:  http://reviewtrip.com/blog/stop-forum-spam-api-plugin-for-bbpress
  5. Description:  API for http://www.stopforumspam.com/ on bbPress
  6. Version: 0.1.0
  7. Author: pnd (http://nanp-info.com)
  8. Author URI: http://reviewtrip.com/
  9. */
  10.  
  11. add_action( 'bb_init', 'validator_registration',11);   // registration
  12.  
  13. function validator_registration() {
  14. if (!empty($_POST) && isset($_POST["Submit"])) {    // check this first to save cpu cycles on the next check
  15.     $location=false; $resource=array($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_FILENAME'], $_SERVER['SCRIPT_NAME']);
  16.     foreach ($resource as $name ) {if (false!==strpos($name, '.php')) {$location=bb_find_filename($name);}}
  17.     if ($location!="register.php") {return;}  //  only display on register.php and hide on profile page
  18.         if(!validate('ip',$_SERVER['REMOTE_ADDR']) || !validate('username',$_POST["user_login"]) || !validate('email',$_POST["user_email"])) {
  19.             bb_send_headers();
  20.             bb_get_header();
  21.             echo "<p align='center'><font size='+1'>".
  22.             __("Humans only please").". ".__("If you are not a bot").", <br />
  23.             ".__("please go back and try again").".
  24.             </font></p><br />";
  25.             bb_get_footer();
  26.             exit;
  27.         }
  28.     }
  29. }
  30.  
  31. function validate($type,$data) {
  32.     $data=urlencode(substr(strip_tags(stripslashes($data)),0,50));
  33.     $url = "http://www.stopforumspam.com/api?".$type."=".$data;
  34.     // $content=file_get_contents($url);    // if you don't have curl, try this instead
  35.     $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1);    curl_setopt($ch, CURLOPT_RETURNTRANSFER , TRUE); $content = curl_exec($ch); curl_close($ch);
  36.     preg_match("/<appears>(.*?)<\/appears>/si", $content, $tmp);
  37.     return ($tmp[1] == "yes") ? true : false;
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement