A couple problems arose when signatures with images were allowed back in IPB, and one was the image size. Now that you have vB and that is able to be regulated (I think), it's time to solve the other problem: large file-size images, like long animated GIFs. It really reduces the quality of the forum when 95% of the loading time is spent loading the animated GIFs in your users' signatures, and it detracts from the purpose of actually reading things.

Of course, there's no use in presenting a problem without a layout of a solution:

- Solution -

The idea of this solution is, upon making a signature, the system checks the file size of every remote image and adds all sizes of all images in the signature before actually allowing the signature change to be validated. If it's over a certain value (I would highly suggest a filesize limit of 400-500 kb), then reject the signature change.

This, of course, isn't a perfect change, since the check only happens once. Users could potentially upload a low-file size image and pass the check, then replace the URL with a higher file-size image. This is pretty difficult to enforce without significant resources drained on part of the system, but fortunately the number of users doing this should be small enough in number that moderators are able to actively enforce it. After all, if a page does take too long to load, it's pretty easy to pick out the offender. It was just too difficult back in the day to enforce the whole "signature size" rule, and it really detracted from the real moderation job.

Here's some sample code cooked up:

The most logical place to put the resource check is with the regexp that replaces the IMG tags with HTML. Given an abstraction of $images, a PHP "array" of image URLs, we can write the following code:

PHP Code:
<?php
// original code from php.net ksobolewski at o2 dot pl
// modified by allen chen for multiple files
foreach ($images as $imageurl) {
    
$remoteFile $imageurl;
    
$ch curl_init($remoteFile);
    
curl_setopt($chCURLOPT_NOBODYtrue);
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt($chCURLOPT_HEADERtrue);
    
curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); //not necessary unless the file redirects (like the PHP example we're using here)
    
$data curl_exec($ch);
    
curl_close($ch);
    if (
$data === false) {
      
// We failed to retrieve any data - server isn't responding, URL is invalid, etc.
    
} else {
        
$contentLength 'unknown';
        
$status 'unknown';
        if (
preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
          
$status = (int)$matches[1];
        }
        if (
preg_match('/Content-Length: (\d+)/'$data$matches)) {
          
$contentLength = (int)$matches[1];
        }
    }
    
$total_size += $contentLength;
}

// utilize $total_size for checking for file size
// additional code below for the actual validation
?>