Search

Main Menu

Login
Username:

Password:

Remember me?
Anonymous

Lost Password?

Register now!

Samurize Forums -> php help


  Reply to this topicStart new topicStart Poll

> php help, any php experts around?
Spewed
Posted: Apr 6 2006, 12:44 PM
Quote Post
Our Blind Friend
*****



Group: Moderating Crew
Joined: Jan 12 2006
Posts: 1,555
Offline



I have a php gbook template (see attachment). How to add an action that defines a list of words, if the message that user try to send contain some of these words, the script don't allow the message to be sent?

It's enough, if the page just refresh after clicking submit, so I don't need a specific error page which tells the reason to user why the message didn't update. Why I need this is that I've got lots of poker, viagra etc. spam into my guestbook and I want to filter those messages into the deepest hell. smil3dbd4daabd491.gif

Thanks.

Attached File ( Number of downloads: 842 )
Attached File  index.php
PMEmail PosterMSN
Top
Spewed
Posted: Apr 9 2006, 10:28 AM
Quote Post
Our Blind Friend
*****



Group: Moderating Crew
Joined: Jan 12 2006
Posts: 1,555
Offline



Heyy, come on! smil43cc58de1e8cb.gif

Anyone have a glue or should I do some more googling here? smil3dbd4d6422f04.gif
PMEmail PosterMSN
Top
KMDonlon
  Posted: Apr 9 2006, 10:40 AM
Quote Post
The Weather Freak
*****



Group: Member
Joined: Feb 19 2004
Posts: 3,535
Offline



Don't look at me smil3dbd4ddd6835f.gif

Also, the word you are looking for is CLUE, not glue smil43e645b3e958a.gif


--------------------
PMEmail PosterICQAOLYahooMSN
Top
Spewed
Posted: Apr 9 2006, 12:08 PM
Quote Post
Our Blind Friend
*****



Group: Moderating Crew
Joined: Jan 12 2006
Posts: 1,555
Offline



Haha! smil43e645b3e958a.gif

Or maybe I need some glue here..? smil3dbd4e5e7563a.gif
PMEmail PosterMSN
Top
KMDonlon
  Posted: Apr 9 2006, 12:16 PM
Quote Post
The Weather Freak
*****



Group: Member
Joined: Feb 19 2004
Posts: 3,535
Offline



I suck at PHP, usually Adam has to come to my rescue with issues here on our site when it is PHP related...........

Some times I feel Sofa King We Todd Ed smil3dbd4e398ff7b.gif


--------------------
PMEmail PosterICQAOLYahooMSN
Top
Mythril
Posted: Apr 9 2006, 05:34 PM
Quote Post
Samurai
***



Group: Member
Joined: May 8 2004
Posts: 134
Offline



The easiest way I can think of doing this is to just define a list of words that you want to disable, then loop through that list and do a stripos() on the word and the input. Something like:
CODE

$bannedwords = Array("word1","word2","word3"); //etc

foreach ($bannedwords as $word)
   if (stripos($message, $word) !== false)
// Don't accept message!

Note that I haven't tested the code nor do I know if this is the best way, but unless your guestbook is quite frequently used, performance shouldn't be an issue anyway. I guess.

This post has been edited by Mythril on Apr 10 2006, 09:30 AM
PM
Top
Spewed
Posted: Apr 10 2006, 06:37 AM
Quote Post
Our Blind Friend
*****



Group: Moderating Crew
Joined: Jan 12 2006
Posts: 1,555
Offline



That could do the job, thanks! I'll test it when I get home.
PMEmail PosterMSN
Top
Spewed
Posted: Apr 10 2006, 02:31 PM
Quote Post
Our Blind Friend
*****



Group: Moderating Crew
Joined: Jan 12 2006
Posts: 1,555
Offline



Damn, can't figure it out where to add that foreach thing in the code. Could you do that for me Mythril? smil3dbd4e29bbcc7.gif
PMEmail PosterMSN
Top
Mythril
Posted: Apr 21 2006, 02:53 AM
Quote Post
Samurai
***



Group: Member
Joined: May 8 2004
Posts: 134
Offline



Ups, sorry, I've been on vacation, and adding in the fact that "Show new messages" hasn't worked in a while, I totally missed your message.

Anyway, I've been looking more closely at the script, and I found that there is actually already a "bad words" list! It's on line 40 of the script. However, it seems like it just replaces the words with stars when they are shown!

If you still want bad words messages to be completely blocked, you should add something similar to the code I gave on line 442 of the script. I added some example code in your script. If it doesn't work, you may need to change the line:
CODE
if (stripos($msg, $word) !== false)

to
CODE
if (preg_match("/$word/", $msg) == 1)

because stripos is only supported in PHP5. stripos should be faster though, which is why I used that in the script first.

Attached File ( Number of downloads: 519 )
Attached File  fixed.php
PM
Top
Spewed
Posted: Apr 21 2006, 02:50 PM
Quote Post
Our Blind Friend
*****



Group: Moderating Crew
Joined: Jan 12 2006
Posts: 1,555
Offline



Actually got it working already. The publisher of the script had updated a $bannedwords function in it. Hope you didn't spend too much time to solve it. smil3dbd4e29bbcc7.gif

I should have comment that before to this thread but I forgot. Thanks anyway! smil3dbd4d6422f04.gif
PMEmail PosterMSN
Top
Mythril
Posted: Apr 21 2006, 02:55 PM
Quote Post
Samurai
***



Group: Member
Joined: May 8 2004
Posts: 134
Offline



Heh, it's ok, glad you got it working. I don't think I spent too much time on it. Probably. smil3dbd4ddd6835f.gif
PM
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Come On, Get Samurized!