vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=235)
-   -   Miscellaneous Hacks - Prevent APNG for users that are not allowed to have GIF images (https://vborg.vbsupport.ru/showthread.php?t=201227)

BartS 01-09-2009 10:00 PM

Prevent APNG for users that are not allowed to have GIF images
 
1 Attachment(s)
This is a very small plugin.

We don't allow users to have GIF images. But users, clever as they are, started using APNG images instead (Animated Portable Network Graphics) which vBulletin sees as regular PNG images. Even though it only works on a couple of browsers (unsupported browsers only see the first frame), we found it created allot of confusion (other users wondering why they couldn't upload animated avatars, while other had them).

This is a small plugin that will prevent users from uploading APNG images. It's so small it isn't even worth to be made into a product. It only rejects the image if the user is not allowed to upload animated images.

I only tested it on vBulletin 3.8, but I'm pretty sure this works on most versions.

Please note: this will only prevent new APNG avatars from being uploaded.

I got the detection part from: http://foone.org/apng/.

I hope a few of you can use this :).

Installation
Go to your Administration Panel then:

1. Go to the 'Plugins & Products' menu
2. 'Add New plugin'
3. Values:

Product: vBulletin
Hook location: upload_accept
Title: Prevent APNG for users that are not allowed to have GIF images
Execution Order: 5 (doesn't really matter)
Plugin PHP Code:

PHP Code:

if(isset($this->allowanimation) AND $this->allowanimation === false)
{
    
$img_bytes = @file_get_contents($this->upload['location']);

    if(
$img_bytes
    {
        if(
strpos(substr($img_bytes0strpos($img_bytes'IDAT')), 'acTL') !== false)
        {
            
$this->set_error('upload_invalid_animatedgif');
            eval(
standard_error($this->fetch_error()));
        }
    }


Plugin is Active: yes

4. Click 'Save'

pappocapo 10-02-2009 11:38 PM

Nice mod, thanks


All times are GMT. The time now is 09:15 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.03372 seconds
  • Memory Usage 1,722KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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