CJ - Twitch Posted March 20, 2010 Posted March 20, 2010 This is my little bit of code and i'm trying to make it allow image tags... $message = stripslashes(strip_tags($message, ' ')); Any ideas? Quote
Djkanna Posted March 20, 2010 Posted March 20, 2010 <?php // Add to your whitelist $whitelist = array ( ); // Then use your whitelist within Strip_tags() ;) $message = strip_tags($message, $whitelist); ?> Quote
CJ - Twitch Posted March 20, 2010 Author Posted March 20, 2010 Thank you DJK but woud should the img tag be? <img src />? Quote
Djkanna Posted March 20, 2010 Posted March 20, 2010 Just <img> I would think <?php $whitelist = array ( ' ', '<img>', '[i]', ' ', ); Quote
CJ - Twitch Posted March 20, 2010 Author Posted March 20, 2010 So it would be this... $whiteist = array (' ', '<img>', '[i]', ' ', '[b]', '<u>'); $message = stripslashes(strip_tags($message, $whiteist)); Quote
Djkanna Posted March 20, 2010 Posted March 20, 2010 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; ?> Quote
CJ - Twitch Posted March 20, 2010 Author Posted March 20, 2010 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/public_html/jailshout.php on line 10 Line 10 $whiteist " <img>[i] <u>"; Quote
CJ - Twitch Posted March 20, 2010 Author Posted March 20, 2010 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.. Quote
Magictallguy Posted March 20, 2010 Posted March 20, 2010 $whitelist = "the tags here"; You were missing the = Quote
a_bertrand Posted March 22, 2010 Posted March 22, 2010 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. Quote
seanybob Posted March 22, 2010 Posted March 22, 2010 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.