Back to vBulletin 3.0 Add-Ons

Block animated avatars
Mod Version: 1.00, by nso

This modification is in the archives.
vB Version: 3.0.7 Rating: (0 vote - 0 average) Installs: 3
Released: 22 Feb 2005 Last Update: Never Downloads: 2
Not Supported  

On my forums we try to enhance the reading experience, and do not allow our members to use animated avatars. One of my members have written the following hack for my forums, and I got his permission to post it here on vbulletin.org.

What this hack does is to prevent your users from uploading an animated image. It does this by checking if the image contains more than one frame. It is not retroactive, and your current avatars will remain as is.

Hope you will enjoy this.

Changes:
1 New Phrase
1 File to edit (profile.php)

Installtime: 45 sec

In profile.php, find:
Code:
// ####################### SET PHP ENVIRONMENT ###########################
Above that, add:
Code:
// Block Animated Avatars Hack - by Scha at freakforum.nu
// start
function isAnimated($filename, $isurl = 0)
{
        $fp = fopen($filename, "rb");
        if(!$fp)
                return false;
        if($isurl)
                $whole = fread($fp, remote_filesize($filename));
        else
                $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;
}
// end
// Block Animated Avatars Hack - by Scha at freakforum.nu

In profile.php, find:
Code:
                if ($avatarid == 0)
                {
                        // begin custom avatar code
                      require_once('./includes/functions_upload.php');
                      require_once('./includes/functions_file.php');
REPLACE that with:
Code:
// Block Animated Avatars Hack - by Scha at freakforum.nu   
//start
                require_once('./includes/functions_upload.php');
                require_once('./includes/functions_file.php');
                if(isset($_FILES['upload']) && strtolower(substr($_FILES['upload']['name'], -3)) == 'gif' )    
                        if (isAnimated($_FILES['upload']['tmp_name']))
                                eval(print_standard_error('error_avataranimated'));
                if ( strlen($_POST['avatarurl']) && strtolower(substr($_POST['avatarurl'], -3)) == 'gif' )
                        if(isAnimated($_POST['avatarurl'], 1 && strtolower(substr($_POST['avatarurl'], -3)) == 'gif'))
                                eval(print_standard_error('error_avataranimated'));
// end
// Block Animated Avatars Hack - by Scha at freakforum.nu   
                if ($avatarid == 0)
                {
                        // begin custom avatar code


Add phrase 'avataranimated' under the category 'Front-End Error Messages' with the following content
Code:
We do not allow the usage of animated avatars on our forums. Please consider uploading a static image instead.

Done.

Please leave a comment if there is something you are wondering about, or if you encounter a bug.

Download

No files for download.


vblts.ru supports vBulletin®, 2022-2024