예제 #1
0
        jQuery("a.reportme").click(function(e) {
            e.preventDefault;
            var commentID = jQuery(this).attr("commentid");
            var action = "reportme";
            
            jQuery.get("' . get_bloginfo('url') . '/?"+action+"="+commentID, function(data) {
                if(data.updated) {
                    jQuery("#comment-"+commentID).addClass("reported");
                    jQuery("#report_"+commentID).remove();
                }
            });
            return false;
        });
    });
    </script>
    ';
}
/**
 * "report comment" functionality - insert reported comment id into separate wp table
 *
 * @param int $user_id
 * @param int $comment_id
 */
function report_comment($user_id, $comment_id)
{
    global $table_prefix, $wpdb;
    $table_name = $table_prefix . 'reported_comments';
    $sql = 'INSERT into ' . $table_name . ' (user_id, comment_id) VALUES ("' . $user_id . '", "' . $comment_id . '") ON DUPLICATE KEY UPDATE comment_id="' . $comment_id . '"';
    $wpdb->query($sql);
    header("content-type: text/json");
    echo json_encode(array('updated' => '1'));
예제 #2
0
<?php

require "../includes/config.php";
if (!isset($_POST["report_comm_id"])) {
    apologize("Comment not specified.");
}
session_start();
if (report_comment($_POST["report_comm_id"], $_POST["report_comm_reason"]) === false) {
    apologize("Something went wrong.");
}
redirect("post.php?soc=" . $_GET["soc"] . "&pid=" . $_GET["pid"]);