Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Block animated avatars Details »»
Block animated avatars
Version: 1.00, by nso nso is offline
Developer Last Online: Aug 2021 Show Printable Version Email this Page

Version: 3.0.7 Rating:
Released: 02-21-2005 Last Update: Never Installs: 3
 
No support by the author.

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.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 04-01-2005, 04:22 PM
nso nso is offline
 
Join Date: Mar 2002
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #23  
Old 04-01-2005, 11:28 PM
trulylowcarb's Avatar
trulylowcarb trulylowcarb is offline
 
Join Date: Apr 2004
Location: Colorado
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #24  
Old 04-02-2005, 07:25 PM
TCM TCM is offline
 
Join Date: Dec 2004
Location: 3.6.8
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06340 seconds
  • Memory Usage 2,243KB
  • Queries Executed 20 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete