I'm trying to stop users from doing something like this:
Code:
[ I M G ]http://www.mysitename.com/logout.php [/imge]
or stuff like;
Code:
[I M G ]http://www.hacker.com/freehacks[/imge]
(the bbcode is normal img [] tag, i just had to do the above because vb was showing it up blank)
I currently do this:
PHP Code:
function isImage($matches) {
$im = $matches['1'];
//Make sure $im is an image and not some script
if(script) {
$re= "bad code";
} else {
$re = "<img src='".$im."' style='border:0px;'>";
}
return $re;
}
function bbcode($text) {
$text = preg_replace_callback("'/\[img\](.*?)\[\/img\]/is'","isImage",$text);
}
So what I'm trying to do is find some kind of way to validate the input between the [img] tags. The isImage function should do this, I just have no clue on how to do it. I thought about getting the extention of the url, but then users can simple just change it .gif when really its a .php.
Is there something like
PHP Code:
if (list($width, $height, $type, $attr) = @getimagesize($im)) {
echo"is an image";
} else {
echo"error";
}
That doesn't work with URLs, just file uploads.
Any help on this would be greatly appriciated
Thanks!
Bookmarks