PDA

View Full Version : Deny the usage of animated avatars


iblis
09-02-2004, 12:21 PM
Could you guys try the following code, and report back bugs if there are any?
This snipplet detects if an avatar is animated (or any other .gif)


function isAnimated($filename)
{
$fp = fopen($filename, "rb");
$whole = fread($fp, filesize($filename));
$i = -1;
while($i = strpos($whole, 0x2C, $i+1))
{
if(strpos($whole, 0x00, $i-1) == $i-1)
$c++;
}
if($c > 1)
return true;
return false;
}

tehste
09-02-2004, 12:55 PM
do php if statements work without brackets and without telling an if to end?

function isAnimated($filename)
{
$fp = fopen($filename, "rb");
$whole = fread($fp, filesize($filename));
$i = -1;
while($i = strpos($whole, 0x2C, $i+1))
{
if(strpos($whole, 0x00, $i-1) == $i-1) {
$c++;
}
}
if($c > 1) {
return true;
} else {
return false;
}
}

iblis
09-02-2004, 01:15 PM
Yes they do.
If you do not enclose the content in brackets, it assumes the next line is to be executed if the statement returns true - else it ignores it

tehste
09-02-2004, 09:30 PM
Yes they do.
If you do not enclose the content in brackets, it assumes the next line is to be executed if the statement returns true - else it ignores it
you learn something new everyday :)