Beispiel #1
0
 public function analyze(array $data = array())
 {
     require_once SPAMPRESS_DIR . "inc/akismet.fuspam.php";
     $content = isset($data["content"]) ? $data["content"] : "";
     $email = isset($data["email"]) ? $data["email"] : "";
     $name = isset($data["name"]) ? $data["name"] : "";
     if (empty($content)) {
         // nothing to check, so pass
         return SPAMPRESS_RESULT_PASS;
     }
     $comment = array("blog" => home_url(), "user_ip" => spampress::get_ip(), "user_agent" => $_SERVER["HTTP_USER_AGENT"], "comment_author" => $name, "comment_author_email" => $email, "comment_content" => $content);
     $result = fuspam($comment, "check-spam", $this->_spampress->settings->akismet_key);
     if ($result == "true") {
         return SPAMPRESS_RESULT_FAIL;
     } else {
         return SPAMPRESS_RESULT_PASS;
     }
 }
 /**
  * Lookup an IP address against the Project Honeypot HTTPBLacklist 
  * @param string $ip Defaults to the requesting client IP address when this argument is empty. 
  * @return int One of the SPAMPRESS_RESULT_NOT_FOUND, SPAMPRESS_RESULT_ERROR or the lookup result array (as defined by spampress_analyze_project_honeypot::parse_result()).
  */
 public function lookup($ip = "")
 {
     if (empty($ip)) {
         $ip = spampress::get_ip();
     }
     $reverse_ip = implode(".", array_reverse(explode(".", $ip)));
     $host = sprintf("%s.%s.dnsbl.httpbl.org", $this->_spampress->settings->httpbl_key, $reverse_ip);
     $lookup = gethostbyname($host);
     if ($lookup !== $host) {
         // Parse result state from lookup
         $result = $this->parse_result($lookup);
         if (empty($result)) {
             // Some other error during the HTTPBL request
             return SPAMPRESS_RESULT_ERROR;
         } else {
             // Return the result array
             return $result;
         }
     }
     // The IP address was not found in the lookup.
     // This means either a) The IP is not in the database or b) The API key is somehow invalid.
     return SPAMPRESS_RESULT_NOT_FOUND;
 }