Ejemplo n.º 1
0
 /**
  * Detect and retrieve the IPv4 address
  */
 public static function get_ip()
 {
     if (is_null(self::$_ip)) {
         self::$_ip = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "0.0.0.0";
     }
     return self::$_ip;
 }
Ejemplo n.º 2
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;
     }
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 public function temp()
 {
     $this->_spampress->analyze("project_honeypot");
 }
Ejemplo n.º 5
0
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/**
 * SpamPress requires PHP 5.3+
 */
if (version_compare(PHP_VERSION, "5.3", "lt")) {
    if (!function_exists("spampress_version_notice")) {
        function spampress_version_notice()
        {
            $msg = sprintf('<div class="wrap"><div class="error"><p><strong><em>%s</em></strong></p></div></div>', __("SpamPress requires a PHP version of 5.3 or greater.", "spampress"));
            echo $msg;
        }
    }
    add_action("admin_notices", "spampress_version_notice");
    return;
}
/**
 * Bootstrap SpamPress
 */
require_once "constants.php";
require_once "inc/spampress.php";
$spampress = spampress::single();
$spampress->bootstrap();