Beispiel #1
0
function SpamHam($id, $type)
{
    global $wpdb;
    $table_name = $wpdb->prefix . "dmsguestbook";
    $selectspam = $wpdb->get_results("SELECT * FROM {$table_name} WHERE id = '" . sprintf("%d", $id) . "'");
    $num_rows_spam = $wpdb->num_rows;
    include_once "../wp-content/plugins/dmsguestbook/microakismet/class.microakismet.inc.php";
    $url = get_bloginfo('wpurl');
    foreach ($selectspam as $result) {
        // The array of data we need
        $vars = array();
        $vars["user_ip"] = $result->ip;
        $vars["comment_content"] = $result->message;
        $vars["comment_author"] = $result->name;
        $vars["comment_author_url"] = $result->url;
        $vars["comment_author_email"] = $result->email;
        $vars["comment_type"] = "comment";
        $CheckAkismet = CheckAkismet();
        // ... Add vars as before ...
        $akismet = new MicroAkismet($CheckAkismet, $url, "{$url}/1.0");
        if ($type == "spam" && $CheckAkismet != "") {
            $akismet->spam($vars);
        }
        if ($type == "ham" && $CheckAkismet != "") {
            $akismet->ham($vars);
        }
    }
}
function akismet($var_akismet_key, $nname, $gbemail, $newurl, $mmu, $errormsg)
{
    $url = get_bloginfo('wpurl');
    $phpvers = explode(".", phpversion());
    if ($phpvers[0] == 4) {
        include_once 'microakismet/func.microakismet.inc.php';
    }
    if ($phpvers[0] >= 5) {
        include_once "microakismet/class.microakismet.inc.php";
    }
    // The array of data we need
    $vars = array();
    $vars["user_ip"] = $_SERVER["REMOTE_ADDR"];
    $vars["user_agent"] = $_SERVER["HTTP_USER_AGENT"];
    $vars["reerrer"] = $_SERVER["HTTP_REFERER"];
    $vars["comment_content"] = $mmu;
    $vars["comment_author"] = $nname;
    $vars["comment_author_url"] = $newurl;
    $vars["comment_author_email"] = $gbemail;
    $vars["permalink"] = get_permalink($var_page_id);
    $vars["comment_type"] = "comment";
    /* php 4 */
    if ($phpvers[0] == 4) {
        if (akismet_check($vars)) {
            //echo "Spam detected!";
            //echo $errormsg;
            return 1;
        } else {
            return 0;
        }
    }
    /* php 5 & 6 */
    if ($phpvers[0] >= 5) {
        $akismet = new MicroAkismet("{$var_akismet_key}", $vars["permalink"], "{$url}/1.0");
        if ($akismet->check($vars)) {
            //echo "Spam detected!";
            //echo $errormsg;
            return 1;
        } else {
            return 0;
        }
    }
}
Beispiel #3
0
$website = addslashes($_POST['website']);
$comment = addslashes(strip_tags($_POST['comment'], '<a>'));
$post_id = $_POST['post_id'];
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
// Now check if the comment is spam with Akismet
$vars = array();
// Mandatory fields of information
$vars["user_ip"] = $ip;
$vars["user_agent"] = $user_agent;
// The body of the message to check, the name of the person who
// posted it, and their email address
$vars["comment_content"] = $comment;
$vars["comment_author"] = $name;
$vars["comment_author_email"] = $email;
$akismet = new MicroAkismet("{$akismet_key}", "{$tld}", "{$tUrl}");
// Check if it's spam
if ($akismet->check($vars)) {
    //it's a spam
    $sql = "insert into `{$tprefix}" . "_comments` ( `post_id` , `name` , `email` , `website`,`comment`,`ip` ,`user_agent`, `status`  ) values ('{$post_id}','{$name}','{$email}','{$website}','{$comment}','{$ip}','{$user_agent}','U')";
    //echo $sql;
} else {
    // it's not a spam
    $sql = "insert into `{$tprefix}" . "_comments` ( `post_id` , `name` , `email` , `website`,`comment`,`ip` ,`user_agent`, `status`  ) values ('{$post_id}','{$name}','{$email}','{$website}','{$comment}','{$ip}','{$user_agent}','P')";
    //echo $sql;
}
/*insert the comment into the comments table if all verification passed
 statuses :  	U unpublished
				P published
				D deleted
				A awaiting moderation