Reputation: 3223
One of the PHP/MySQL sites I administer is a Social Network and I've noticed that spammers will send a lot of similarly-looking messages to several other users.
Due to the number of messages sent by the same user account and the similarities in those messages sent, it seems like it should be relatively easy to identify users that are spamming other users in this way, but I just don't know how to do that in PHP/MySQL. The messages are stored in the DB as type TEXT
.
How can I identify these spammers so I can get rid of them automatically when they start sending too many similarly-looking messages?
Edit:
The Spam messages are normally at least a paragraph of text, so we could safely ignore messages with less than 100 characters and automatically let those through.
Upvotes: 3
Views: 438
Reputation: 1753
Now, a human being can determine which of these senders are acceptable and which are spammers. A human being that can see everyone's messages, even more so. But you don't want to be reading every message!
First, you'll need to have a message flag or status so that a message can be added to the database, yet not appear in the recipient's inbox because spam is suspected.
Second, you'll need to have a user flag or status so that a user can be prevented from sending more messages, because spam is suspected.
I believe the best approach is:
words
and unique links in links
.First-Pass Spam Scoring
Second-Pass Spam Scoring
Human Moderation
It should also be possible to use much of the above structure to moderate messages for inappropriate content.
Upvotes: 1
Reputation: 3760
Spam messages will have link inside, so You can filter out those without link.
And You should try to prevent first, so if one user starts sending many messages in short time to many users probably it will be spam.
You can do it by having some kind of counter in session, You would increment it with each message send to new user and if it is over 20 per hour (I just made up this number to make it efficient You will need some tests) he may be spamming and start asking him for captcha or block his chat for 15 minutes, report him to admin to check manually
Upvotes: 3
Reputation: 210
You can search for messages looking like the one they are posting now by using the following method.
SELECT * FROM `messages`
WHERE MATCH (`messages`.`content`) against ($message)
&& `messages`.`user` = $user
That would select messages which are matching some of the content from the current user.
Hope it helps.
Upvotes: 1