开发者

Reporting spam or abuse

How would you allow users in sites such as a forum/blog comments .etc mark content as spam or abusive? I know you can use services such as a开发者_运维问答skimet and create Bayesian spam filter classes, but what would be the best way to implement a system that allows users to report content?

Would you add an extra field to the item table called spam and/or flagged and how would you differentiate betweeen the two? Basically how would you set up such a system, what would be the database structure?

Is there something that does this already in php?


Database

You'd want to keep detailed track of who flagged each post, but you'd also probably want to allow multiple people to flag a post as well. If one person flags a post, their judgment could be questionable, but if 20 people flag it, you immediately know there's an issue.

I'd create a table that looks something like this:

flag_seq | post_id | flagger_username |       timestamp     |       user_notes      | active
============================================================================================
       1 |    1431 |          joebob1 | 2010-01-25 13:41:12 | it's spam             | TRUE
       2 |    1431 |      i_hate_spam | 2010-01-25 14:01:23 | You know I hate spam. | TRUE
       3 |    2283 |          joebob1 | 2010-01-24 08:09:57 | vulgar language       | TRUE

Keeping track of each flag individually will allow you to do some more advanced things from a administration or moderation level.

  • You can keep track of who's flagging stuff (in case someone is abusing that feature i.e. joebob1 doesn't like *i_hate_spam* so they keep flagging their posts as offensive).
  • You can do a quick count by doing SELECT COUNT(*) FROM flag_table WHERE post_id = '1431'.
  • You can remove certain flags individually by targeting the flag_seq of the flagged post.
  • Give the user the ability to include their own comments so you know exactly what and why they're reporting this. You could opt to give them predefined options in a <select> box as well.
  • Setting an active flag, you never delete your flags even after they've been dealt with. This is useful for taking stats on flagged posts. You can use this information to justify more moderation staff or justify a time commitment to researching new methods of fighting spam, etc.

Flag this post

Once you have your database set up, you would simply need to put a "Flag this post" link somewhere on each post. Link this to a form that submits to your newly created database. Be sure to sanitize your data properly before inserting it into your database using mysql_real_escape_string or pg_escape_string or by using prepared statements.

Moderation

You can do a handful of different things once a post is flagged.

  • You could write a cron that will check the amount of flags on each post and take certain actions at certain thresholds.
  • You could write a moderation page that lists all active flags with different ways to handle them. (e.g. Delete the post, edit the post, ban the poster, all of the above, etc.)


If you would want to implement this yourself from sratch, you should create a table named reports.

This table will have these fields:

  • report_id
  • post_id
  • reason
  • datetime

I think thats pretty much it.


I dont know if there is something built in php. You can surely use an extra field in the table.. Say you have a table post something like

id title contents date ... flags

each time some user flags the post as abusive or something, you can simply increment the counter in flags. And if that counter reaches a threshold (keep it low as 3 to 5) depending on how you want to be. If it crosses over the threshold just delete the post or whatever action you want to take!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜