Herman |
06-28-2002 11:58 PM |
Ok for SWF! Here it is.. I haven't completely put a lot of thought into this code b/c I was busy today, but it will do the job.
I designed this addition to be completely independant of the IMG sig control hack.. This hack addition will only affect swf's, so if you don't care about IMG and want swfs controled, only install this, however, you can install them both, and it wll control both.
find:
Code:
// check max images
if ($maximages!=0) {
add ABOVE
Code:
$signature = preg_replace("/(\[)(swf)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/swf\])/seiU", "\swf_size_check('\\5','\\7')", $signature);
find at the very end of the file:
add ABOVE:
Code:
function swf_size_check($image, $h_w) {
global $maxsigheight, $maxsigwidth;
//parse_all img tags
$image_xy=@getimagesize($image);
if ($image_xy==NULL)
{
return "Image not found";
}
else {
//ok, here we need to see if the user specified a size(i believe the swf will
//default to default size if no height width is specified, so lets get the
//dimensions of the swf..
$im_width=$image_xy[0];
$im_height=$image_xy[1];
//ok, did the user specify a height? lets see...
unset($params);
$params=explode(" ", $h_w);
foreach($params AS $param)
{
if (preg_match("/(height)(=)(['\"]?)([^\"']*)(\\3)/siU", $param))
{
$im_height=preg_replace("/(height)(=)(['\"]?)([^\"']*)(\\3)/seiU", "\intval('\\4')", $param);
}
if (preg_match("/(width)(=)(['\"]?)([^\"']*)(\\3)/siU", $param))
{
$im_width=preg_replace("/(width)(=)(['\"]?)([^\"']*)(\\3)/seiU", "\intval('\\4')", $param);
}
}
if ($im_width > $maxsigwidth)
{
return "Sorry, swf size exceeds maximum width of ".$maxsigwidth.".";
}
if ($im_height > $maxsigheight)
{
return "Sorry, swf size exceeds maximum height of ".$maxsigheight.".";
}
}
return "[swf=".$image."]" . $h_w . "[/swf]";
}
Keep in mind, that this is NOT fully tested, but I wrote it b/c of requests.
|