Jump to content
MakeWebGames

Recommended Posts

Posted

Sorry to keep bothering you guys :( but anybody know how i can add a way for curse words to be replaced or blocked by my shoutbox.php ? dont know if it will help but here is the code to my shoutbox

 

<?php
session_start();
include "globals.php";
?>
<style>
body {
background-color: black;
  scrollbar-base-color: white
  scrollbar-arrow-color: #000000;
  scrollbar-DarkShadow-Color: #000000;
  bgbackground: black;
  bgcolor: black;  }
a:visited,a:active,a:hover,a:link { color:white;text-decoration: none; }
table,tr,td { font-size: 11.1; }
img { border:none; }
.button
{
font-family:helvetica, arial, geneva, sans-serif;
font-size:12;
color:#000000;
background-color: white;
}

input,textarea,dropdown{
font-family:helvetica, arial, geneva, sans-serif;
font-size:12;
color:#000000;
background-color: white;
border: 1px solid;
}

textarea,.submit input{
font-family:helvetica, arial, geneva, sans-serif;font-size:12;color:#000000;
}
textarea { font-family:helvetica, arial, geneva, sans-serif;font-size:11;color: #000000; }
a:hover { color: blue;text-decoration: blink; text-decoration: underline; background: none; }
</style>

<center>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">-> <b>Refresh Shout Box</b> <-</a>
<?php
if($ir['user_level']>1)
{
echo"<br><a href='?action=banlist'>-> <b>Ban List</b> <-</a>";
}
?>
<br><a href='?action=shoutbox'></a>
</center>
<?php
if($ir['banshout']==1)
{
echo"You cannot access the shout box while being banned.";
exit;
}
if($_GET['action']==del)
{
if($ir['user_level']>1)
{
$id=$_GET['id'];
$db->query("DELETE FROM shoutbox WHERE id='{$id}'") or die(mysql_error());
echo"";
}
else
{
echo"";
}
}
if($_GET['action']==shoutbox)
{
global $ir,$c,$userid,$h;
echo "Your Shoutbox is now ";
if($ir['shoutbox']==1)
{
echo "hidden";
$db->query("UPDATE users SET shoutbox=0 WHERE userid=$userid",$c);
}
exit;
}
if($_GET['action']==ban)
{
if($ir['user_level']>1)
{
$id=$_GET['id'];
$db->query("UPDATE users SET banshout=1 WHERE userid='{$id}'") or die(mysql_error());
echo"";
}
else
{
echo"";
}
}
if($_GET['action']==banlist)
{
echo"<table border=1 width=50%><th>User</th><th>Actions</th><tr>";
$d=$db->query("SELECT * FROM users WHERE banshout=1") or die(mysql_error());
while($t=$db->fetch_row($d))
{
echo"<td>{$t['username']}</td><td><a href='?action=unban&id={$t['userid']}'>Unban</td><tr>";
}
echo"</table>";
exit;
}
if($_GET['action']==unban)
{
if($ir['user_level']>1)
{
$id=$_GET['id'];
$db->query("UPDATE users SET banshout=0 WHERE userid='{$id}'") or die(mysql_error());
echo"";
}
else
{
echo"";
}
}
if ($_GET['action']=='1') {
$newmsg = strip_tags($_POST['msg'],"");
$string = "$newmsg";

$new_string = str_replace($replace, $search, $string);

$new_string = str_replace($search, $replace, $string);
print "</form>";

if ($_POST['msg']) {
               $starter = "<font color=white>{$ir['username']}</font>";
                if ($ir['userid']==1) {
		$starter = "<font color=red>{$ir['username']}</font>";
              }
                if ($ir['title']=='Captain') {
		$starter = "<font color=blue>{$ir['username']}</font>";
              }
                if ($ir['title']=='Lieutenant') {
		$starter = "<font color=orange>{$ir['username']}</font>";
              }
                if ($ir['race']=='Hollow') {
		$starter = "<font color=black>{$ir['username']}</font>";
              }
                if ($ir['race']=='Visored') {
		$starter = "<font color=teal>{$ir['username']}</font>";
              }
                if ($ir['race']=='Arrancar') {
		$starter = "<font color=purple>{$ir['username']}</font>";
              }
$id=$ir['userid'];
$db->query("INSERT INTO shoutbox VALUES ('', unix_timestamp(),'<a href=user.php?ID=$id target=_blank>$starter</a>','$userid', '$new_string')");
}
}


$bk = $db->query("select * from shoutbox order by id desc limit 15");
while ($chat = $db->fetch_row($bk))
{
$time=date('g:i a',$chat['time']);
print "</center>";
if($ir['user_level']>1){echo"<a href='?action=del&id={$chat['id']}'><font color=red>[D]</font></a><a href='?action=ban&id={$chat[userid]}'><font color=lime>[b]</font></a>";}echo"<font color=990099>[$time]</font></b><b>$chat[user]</b></font></font></font></font></a></a></a></a></a><font color=red>:</font> <font color=white>$chat[chat]</font><br>";
}
?>
<center>
<form method=post action=shoutbox.php?action=1>
<font color=white>Enter Message:</font> <input type=text name=msg size=20><br />
</form>
</center>
</body>
Posted

You also gotta stay one step ahead of them as well and make sure they dont bypass the check by using non case sensitive. I forgot what its called and im pretty dure you can do it so maybe someone here can shed some light on it but say you want to filter "badword" I may be able to do BADWORD or Badword and it may pass the check since I used capitolization.

Again I may be wrong but maybe look into it.

Posted

I use this to filter words, or game links on my site.. It was made for the GRPG engine,

 

function ReplaceWords($str, $bad_words, $replace_str){
   if (!is_array($bad_words)){ $bad_words = explode(',', $bad_words); }
   for ($x=0; $x < count($bad_words); $x++){
       $fix = isset($bad_words[$x]) ? $bad_words[$x] : '';
       $_replace_str = $replace_str;
       if (strlen($replace_str)==1){ 
           $_replace_str = str_pad($_replace_str, strlen($fix), $replace_str);
       }
       $str = preg_replace('/'.$fix.'/i', $_replace_str, $str);
   }
   return $str;
}

 

$banned_sites = array('your', 'filter', 'words', 'here''');
   $replacement_text = "banned-site";

   $row['msgtext'] = ReplaceWords($row['msgtext'], $banned_sites, $replacement_text);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...