Jump to content


Photo

Word Filter arrays...


  • Please log in to reply
27 replies to this topic

#21 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 June 2006 - 04:06 PM

$mail = $_POST['email'];
	$name = $_POST['name'];
	$arti = $_POST['artist'];
	$song = $_POST['song'];

include("dPanel/db.php");
	$db = mysql_connect("localhost", $login, $pwd);
	mysql_select_db("zroxxco_dpanel"); 

	function filterWords($w1, $w2, $w3, $w4)
			{
  			$sql = mysql_query("SELECT * FROM filter");
  			$words = array();
  			$replace = array();
  			while ($x = mysql_fetch_array($sql))
  			  {
    			  $words[] = $x['badword'];
    			  $replace[] = $x['replace'];
  			  }
	
	$return['1'] = str_replace($words, $replace, $w1);
	$return['2'] = str_replace($words, $replace, $w2);
	$return['3'] = str_replace($words, $replace, $w3);
	$return['4'] = str_replace($words, $replace, $w4);
	
             return $return;
}

$clean=filterWords($name, $mail, $arti, $song);
$name=$clean['1'];
$mail=$clean['2'];
$arti=$clean['3'];
$song=$clean['4'];

That's how I'd do it.
The only thing I dont understand is why you do this cleaning on the email... I mean, if someone calls himself this way, that's his problem =/

Orio.
Think you're smarty?

(Gone until 20 to November)

#22 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 30 June 2006 - 04:20 PM

The only thing I dont understand is why you do this cleaning on the email... I mean, if someone calls himself this way, that's his problem =/


What do you mean? & that didn't work either :S.

I was trying to do a song requesting form, and trying to make sure there is no foul language used, I tried to check the fields before they where saved to the database but it doesn't seem to work :[

#23 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 June 2006 - 04:27 PM

Are there two cols called "badword" and "replace" in your filter table?

Orio.
Think you're smarty?

(Gone until 20 to November)

#24 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 30 June 2006 - 04:29 PM

yes.


#25 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 June 2006 - 04:38 PM

Try changing the while in the function to:

 
$i=0;
while($x = mysql_fetch_array($sql))
{
$words[$i] = $x['badword'];
$replace[$i] = $x['replace'];
$i++;
};
 

Orio.
Think you're smarty?

(Gone until 20 to November)

#26 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 30 June 2006 - 04:44 PM

I've decided not to have it now just use the filter in the comments. which the one up would do :]

Thanks for helping anyway

#27 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 02 July 2006 - 12:14 PM

UPDATE:

I found out what my mistake was, I was using:

'".$_POST['field']."'

Instead of $name, $arti etc. So actualyl it was my mistake Lol =]

#28 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 July 2006 - 01:07 PM

now also email the user and tell them off lol............

and also send a copy to your self telly you of the bad words and user syaing it.....................


know in a diffrent database field stick the user name date time ip in there
and ban them with there id if they continue to speak badly on the website..........


good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users