예제 #1
0
파일: index.php 프로젝트: hinablue/TextCube
function defensio_make_to_ham($comment_TYPE, $comment_ID = 0)
{
    global $database;
    $table = $comment_TYPE == 'C' ? "Comments" : "Trackbacks";
    $blogid = getBlogId();
    $sql = "SELECT c.*, d.spaminess, d.signature FROM {$database['prefix']}{$table} c LEFT JOIN  {$database['prefix']}defensio d\n\t\tON c.blogid = d.blog_ID and c.id = d.comment_ID \n\t\tWHERE d.blog_ID = '{$blogid}' and d.comment_TYPE = '{$comment_TYPE}' and c.isFiltered = 0 and d.spaminess > 0";
    if ($comment_ID) {
        $sql .= " and c.id in ({$comment_ID})";
    }
    $r = POD::queryAll($sql);
    if (!$r || !count($r)) {
        return;
    }
    $hams = array();
    $comment_IDs = array();
    foreach ($r as $c) {
        array_push($hams, $c['signature']);
        array_push($comment_IDs, $c['id']);
    }
    // make spam to ham
    if (count($hams) > 0) {
        defensio_submit_ham(implode(',', $hams));
        $string_id = implode(',', $comment_IDs);
        $sql = "UPDATE {$database['prefix']}defensio SET spaminess = 0 WHERE blog_ID = '{$blogid}' and comment_TYPE = '{$comment_TYPE}' and comment_ID in ({$string_id})";
        POD::execute($sql);
        //
        //$sql = "UPDATE {$database['prefix']}{$table} SET isFiltered = 0 WHERE blogid = '$blogid' and id in ($string_id)";
        //POD::execute($sql);
    }
}
예제 #2
0
function defensio_submit_nonspam_comment($defensio_conf)
{
    //Function to report the comment is not spam
    //Loop thru the $_POST['moderate_commnts_boxes'] and keep marking each comment as spam to Defensio
    global $pixelpost_db_prefix;
    if (is_array($_POST['moderate_commnts_boxes'])) {
        $number_of_images = count($_POST['moderate_commnts_boxes']);
        $counter = 0;
        $counter_no_signature = 0;
        $signatures = null;
        foreach ($_POST['moderate_commnts_boxes'] as $cid) {
            $query = "SELECT `signature` FROM {$pixelpost_db_prefix}comments WHERE id = '" . (int) $cid . "'";
            $result = mysql_query($query);
            if (mysql_num_rows($result)) {
                $row = mysql_fetch_assoc($result);
                if ($row['signature'] != null) {
                    $counter = $counter + 1;
                    if ($counter != $number_of_images) {
                        $signatures .= $row['signature'] . ",";
                    } else {
                        $signatures .= $row['signature'];
                    }
                    //Since comment is not spam, let's mark it to publish
                    $query = "UPDATE {$pixelpost_db_prefix}comments SET publish = 'yes' WHERE id = '" . (int) $cid . "'";
                    mysql_query($query);
                } else {
                    // no signature was found
                    $counter_no_signature = $counter_no_signature + 1;
                }
            }
        }
        // construct the error message
        $GLOBALS['defensio_result_message'] = '<div class="jcaption confirm">';
        if ($signatures != null) {
            // we obviously have some signatures so submit them
            $r = defensio_submit_ham($defensio_conf, $signatures);
            $GLOBALS['defensio_result_message'] .= 'Reported ' . $counter . ' comments as HAM to Defensio.';
            if ($counter_no_signature > 0) {
                $GLOBALS['defensio_result_message'] .= 'However, ' . $counter_no_signature . 'comments could not be reported.';
            }
        } else {
            $GLOBALS['defensio_result_message'] .= 'Could not report ' . $counter_no_signature . ' comments as HAM to Defensio.';
        }
        $GLOBALS['defensio_result_message'] .= '</div>';
    } else {
        $GLOBALS['defensio_result_message'] = '<div class="jcaption confirm">You must select at least one comment.</div>';
    }
}