Reputation: 65
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 askimet 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?
Upvotes: 3
Views: 2628
Reputation: 22957
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.
SELECT COUNT(*) FROM flag_table WHERE post_id = '1431'
.flag_seq
of the flagged post.<select>
box as well.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.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.
You can do a handful of different things once a post is flagged.
Upvotes: 11
Reputation: 885
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!!
Upvotes: 0
Reputation: 1096
If you would want to implement this yourself from sratch, you should create a table named reports.
This table will have these fields:
I think thats pretty much it.
Upvotes: 0