Changeset 2019 in subversion


Ignore:
Timestamp:
Oct 27, 2008 1:49:05 PM (5 years ago)
Author:
thomasb
Message:

Also check for negative image size + set caching headers for 1 hour

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/bin/quotaimg.php

    r2012 r2019  
    9797        if (ereg("^[^0-9?]*$", $used) || ereg("^[^0-9?]*$", $total)) { 
    9898                return false;  
    99     } 
     99        } 
    100100 
    101         if (strpos($used, '?') !== false || strpos($total, '?') !== false 
    102         && $used != 0) { 
     101        if (strpos($used, '?') !== false || strpos($total, '?') !== false && $used != 0) { 
    103102                $unknown = true;  
    104     } 
     103        } 
    105104 
    106105        $im = imagecreate($width, $height); 
     
    154153                        $fill = imagecolorallocate($im, $r, $g, $b); 
    155154                } else { 
    156                     // if($quota >= $limit['low']) 
     155                        // if($quota >= $limit['low']) 
    157156                        list($r, $g, $b) = explode(',', $color['fill']['low']); 
    158157                        $fill = imagecolorallocate($im, $r, $g, $b); 
     
    164163                $string = $quota . '%'; 
    165164                $mid    = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1; 
    166         // Print percent in black 
     165                // Print percent in black 
    167166                imagestring($im, $font, $mid, $padding, $string, $text);  
    168167        } 
    169168 
    170169        header('Content-Type: image/gif'); 
    171      
    172     // @todo is harcoding GMT necessary? 
    173         header('Expires: ' . gmdate('D, d M Y H:i:s', mktime()+86400) . ' GMT'); 
    174         header('Cache-Control: '); 
    175         header('Pragma: '); 
     170 
     171        // cache for 1 hour 
     172        $maxage = 3600; 
     173        header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$maxage). ' GMT'); 
     174        header('Cache-Control: max-age=' . $maxage); 
    176175         
    177176        imagegif($im); 
     
    179178} 
    180179 
    181 genQuota($used, $quota, $width, $height); 
     180if ($width > 1 && $height > 1) { 
     181        genQuota($used, $quota, $width, $height);   
     182} 
     183else { 
     184        header("HTTP/1.0 404 Not Found"); 
     185} 
     186 
    182187exit; 
    183188?> 
Note: See TracChangeset for help on using the changeset viewer.