/**
 * defensio_submit_spam_comment()
 * 
 * @param mixed $defensio_conf
 * @return
 */
function defensio_submit_spam_comment($defensio_conf)
{
    //Function to report the comment as spam which Defensio marked as not spam
    //Loop thru the $_POST['moderate_commnts_boxes'] and keep marking each comment as spam to Defensio
    global $pixelpost_db_prefix, $defensio;
    $defensio = new Defensio($defensio_conf['key']);
    if (is_array($_POST['moderate_commnts_boxes'])) {
        $number_of_images = count($_POST['moderate_commnts_boxes']);
        $counter = 0;
        $counter_fail = 0;
        $counter_no_signature = 0;
        $signatures = array();
        foreach ($_POST['moderate_commnts_boxes'] as $cid) {
            $query = "SELECT * FROM {$pixelpost_db_prefix}comments WHERE id = '" . (int) $cid . "'";
            $defensio_result = mysql_query($query) or die(mysql_error());
            if (mysql_num_rows($defensio_result)) {
                $row = mysql_fetch_assoc($defensio_result);
                if ($row['signature'] != null) {
                    $put_result = $defensio->putDocument($row['signature'], array('allow' => 'false'));
                    if ($put_result[0] == 200) {
                        $counter = $counter + 1;
                        //Since comment is spam, let's mark it as marked by defensio
                        $query = "UPDATE {$pixelpost_db_prefix}comments SET publish = 'dfn' WHERE id = '" . (int) $cid . "'";
                        mysql_query($query);
                    } else {
                        $counter_fail = $counter_fail + 1;
                    }
                } else {
                    // no signature was found. With the addition of code in the frontpage addon
                    // this situation should almost never happen. However, if it does we'll send
                    // the comment to Defensio again.
                    $counter_no_signature = $counter_no_signature + 1;
                    $document = array('client' => 'Pixelpost Defensio Addon | ' . $addon_version . ' | Schonhose | schonhose@pixelpost.org', 'content' => $row['message'], 'platform' => 'pixelpost', 'type' => 'comment', 'async' => 'true', 'async-callback' => $defensio_conf['blog'] . 'addons/_defensio2.0/lib/callback.php?id=' . md5($defensio_conf['key']), 'author-email' => $row['email'], 'author-ip' => $row['ip'], 'author-logged-in' => 'false', 'author-name' => $row['name'], 'parent-document-date' => defensio_get_datetime_post($row['parent_id']), 'parent-document-permalink' => $defensio_conf['blog'] . "index.php?showimage=" . $row['parent_id'], 'referrer' => $_SERVER['HTTP_REFERER'], 'author-url' => $row['url']);
                    $post_result = $defensio->postDocument($document);
                    defensio_process_comment_pixelpost($post_result, true, (int) $cid);
                }
            }
        }
        // construct the error message
        $GLOBALS['defensio_result_message'] = '<div class="jcaption confirm">';
        if ($counter > 0) {
            $GLOBALS['defensio_result_message'] .= 'Reported ' . $counter . ' comments as SPAM 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_fail . ' comments as SPAM to Defensio.';
        }
        $GLOBALS['defensio_result_message'] .= '</div>';
    } else {
        $GLOBALS['defensio_result_message'] = '<div class="jcaption confirm">You must select at least one comment.</div>';
    }
}