Jump to content
MakeWebGames

Recommended Posts

Posted

Forget the array();

<?php
// Add to your whitelist
$whitelist = "
<img>

[i]";
// Then use your whitelist within Strip_tags() ;)
$message = "[img=http://domain.tld/image.png] 
Some Text [i]WooP[/i]

Hello</p>";
$message = strip_tags($message, $whitelist);
echo $message;
?>
Posted

Here is the code...

 

<?
if(isset($_POST['Submit']))
{
?><table width="100%" border="0" cellspacing="1" bordercolor="#000000" bgcolor="#333333">
 <tr>
   <td width="432"><?

$dataf = "jailshouts.txt";
$name = $ir['username'];
$whiteist "
<img>[i]

<u>";
$codes = array(':)', ':D', ':O');
$images = array('[img=images/smile/smile.gif]', '[img=images/smile/biggrin.gif]', '[img=images/smile/wow.gif]');
$message = str_replace($codes, $images, $_POST['message']);

$fo=fopen("$dataf","r");
$stuff=file_get_contents("$dataf");
fclose($fo);

$message = strip_tags($message, $whiteist);
$comfile = file($dataf);

if ($message != "")
{
  $file = fopen("$dataf","w");
  $stuff2 = "<table width='90%'  border='0' align='center' cellspacing='1'>
    <tr>
      <td><font color=black>[i]$name[/i]:  [b]$message[/b]</font></td>
    </tr>
  </table>";
  $stuff3=$stuff2.$stuff;
  $write = fwrite($file,"$stuff3");
  fclose($file);

}
?></td>
 </tr>
</table><? } ?>


<table width="100%" border="0" cellspacing="1" bordercolor="#000000">
 <tr>
   <td width="432"><form name="guestbook" action="" method="post">



         <input name="message" type="text" id="message"><input type="submit" name="Submit" value="Shout">
       </p>
   </form></td>
 </tr>
</table>




<table width="100%" border="-" cellpadding="0" cellspacing="1">
 <tr>
   <td class="style3">[i][b]<font color=black>Shouts</font>[/b][/i]::</td>
 </tr>
 <tr>
   <td><? include("jailshouts.txt"); ?></td>
 </tr>
</table>

 

I am trying to add smilies to seanybobs jail chat and prevent meta refresh/meta redirect tags...

The smilies work fine untill i prevent the meta tags and then they don't..

Posted

Either you use strip_tags to remove ALL, or you should not use it at all. Why? Because strip tags will keep all parameters of your allowed tags, which means, an imagine can be displayed as a link (via JS / CSS) or have effect with on mouse over and more. It's really not safe. If you need to be on the safe side, I can help you with, but please DO NOT use strip_tags for that purpose.

Posted

I HIGHLY recommend that if you use that jailshout, you set parse the user input through some BBCODE engine or an html purifier.

It was a free mod for a reason - it had the barebones that works, but no security.

Search these forums for topics related to BBCODE, or google html purifier - either should do the trick.

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...