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. ;)


All times are GMT. The time now is 01:41 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.01052 seconds
  • Memory Usage 1,748KB
  • 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
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete