vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Block animated avatars (https://vborg.vbsupport.ru/showthread.php?t=76832)

nso 02-21-2005 10:00 PM

Block animated avatars
 
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.

yoyoyoyo 02-22-2005 01:23 PM

very cool!

Polo 02-22-2005 02:46 PM

what is wrong with animated avatars??? :(

Well thanks for sharing anyways nso ;)

nso 02-22-2005 03:24 PM

Polo: On my forums we value the information it contains above the package it is delivered in. Animated avatars steales focus from the content, and it is more intensive on 64K'ers since it in essense contains several images in one.

Allan 02-22-2005 05:42 PM

Screenshot please ?

Polo 02-22-2005 06:32 PM

Quote:

Originally Posted by nso
Polo: On my forums we value the information it contains above the package it is delivered in. Animated avatars steales focus from the content, and it is more intensive on 64K'ers since it in essense contains several images in one.

yeah I know... i was just joking... i'm pretty sure that more than one person here at vbulletin.org will find your mod useful :)

Jolten 02-22-2005 07:47 PM

Nice.. but needs a usergroup conditional so certain usergroups can have animated avatars.

Bolas 02-22-2005 09:31 PM

Quote:

Originally Posted by Polo
what is wrong with animated avatars??? :(

Well thanks for sharing anyways nso ;)

From WCAG 1.0 (http://www.w3.org/TR/WAI-WEBCONTENT-...avoid-movement)

priority 2, WAI checkpoint 7.3 - "Do not create a blinking effect with animated gif images."

Some people with cognitive or visual disabilities are unable to read moving text quickly enough or at all. Movement can also cause such a distraction that the rest of the page becomes unreadable for people with cognitive disabilities. Screen readers are unable to read moving text. People with physical disabilities might not be able to move quickly or accurately enough to interact with moving objects.

nso 02-22-2005 10:10 PM

Quote:

Originally Posted by Allan
Screenshot please ?

I don't think that's really needed here. The only visual effect of this script is a standard formated error message with a custom phrase when someone tries to upload an animated avatar.

Boofo 02-23-2005 03:47 AM

Is there a way to make this so Admins can have animated avatars but not anyone else? Might be a nice way to add a perk for certain membergorups on a site. ;)

kevin_r1 02-24-2005 01:58 AM

Quote:

Originally Posted by nso
Polo: On my forums we value the information it contains above the package it is delivered in. Animated avatars steales focus from the content, and it is more intensive on 64K'ers since it in essense contains several images in one.

Then why do you allow avatars at all? Nice hack anyhow.

Jolten 02-24-2005 02:17 AM

FYI a 10k jpg takes up the same amount of space as a 10k animate gif.

nso 02-24-2005 06:32 AM

Sure, but a lot of forums allow crazyass filesize - mostly because the admins are too dumb to use the admcp :)
However the bandwidth has nothing to do with my descition to block animated avatars.

It is in my opinion, as earlier stated, screenspam which steales focus much more than a static 64x64 IMG (unless you do a goatse or something). My users love this rule, and there is never any complaints.

Polo 02-24-2005 12:36 PM

yeah... forums have different needs... every single forum is unique..

nso 03-10-2005 11:54 AM

Updated the second profile.php edit and I suggest that anyone using this script update their profile.php with the changes. Just delete the old code and add the new.

trulylowcarb 03-21-2005 03:29 AM

Thank you VERY MUCH for this mod!!

trulylowcarb 04-01-2005 12:56 PM

Note: having to uninstall this, as all avatar uploads stopped working. May have to do with the Geek Articles System 3.51 hack I installed afterwards? I will try installing it again and see what happens, but wanted to note this potential conflict.

nso 04-01-2005 03:32 PM

Please describe the actuall errors and/or errormessages you recieved and I might answer that for you.

Cheers.

nexialys 04-01-2005 03:35 PM

there is not a single link between the Geek articles system and this hack... btw, if your php server is older than 4.3, you may encounter the problem related to detecting image size and content...

trulylowcarb 04-01-2005 03:37 PM

No errors, or at least no error messages at all ... the avatars appeared to save normally (regular files, not animated ones) but were not displayed/changed.
One user did report receiving the no animated images error message when trying to upload a static gif, but I couldn't reproduce that error myself. Sorry I can't be of more help.
*My php version is 4.3.10*

I'm sure it's probably just a conflict with another hack ...

nso 04-01-2005 04:22 PM

Ah yes. That one.
The hack works by detecting a certain pattern in the file
PHP Code:

        while($i strpos($whole0x2C$i+1))
        {
                if(
strpos($whole0x00$i-1) == $i-1)
                
$c++;
        } 

This pattern may actually occur without there actually being a new frame. I only recently discovered this myself, and as far as I can see there is no foolproof way of doing this without the false positives.

Suggestion on this part would be highly appreciated. I know that you also could do a check for the string "NETSCAPE" in the header of the gif, but that won't suffice.
Does anyone know how an image processing application like, for example, Adobes Imagemagic (isn't that the right one?) seperate the frames?

trulylowcarb 04-01-2005 11:28 PM

Back to click install again ... the Geek helped me sort out whatever was causing the conflict, and this is working again for me. Guess I could have waited for my earlier feedback, but when I put things off, they never get done, so ...

Thanks again for this hack!

TCM 04-02-2005 07:25 PM

Seems like a nice hack. I prefer to just allow users the option to freeze them, however.


All times are GMT. The time now is 05:02 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01101 seconds
  • Memory Usage 1,775KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (23)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete