Blob Blame History Raw
--- bin/quotaimg.php.orig	2008-09-12 11:48:23.000000000 -0500
+++ bin/quotaimg.php	2008-12-16 11:21:30.000000000 -0600
@@ -4 +4 @@
- | program/bin/quotaimg.php                                              |
+ | bin/quotaimg.php                                                      |
@@ -7 +7 @@
- | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
+ | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
@@ -17 +17 @@
- $Id: $
+ $Id$
@@ -21,4 +21,4 @@
-$used   = ((isset($_GET['u']) && !empty($_GET['u'])) || $_GET['u']=='0')?(int)$_GET['u']:'??';
-$quota  = ((isset($_GET['q']) && !empty($_GET['q'])) || $_GET['q']=='0')?(int)$_GET['q']:'??';
-$width  = empty($_GET['w']) ? 100 : (int)$_GET['w'];
-$height = empty($_GET['h']) ? 14 : (int)$_GET['h'];
+$used   = isset($_GET['u']) ? intval($_GET['u']) : '??';
+$quota  = isset($_GET['q']) ? intval($_GET['q']) : '??';
+$width  = empty($_GET['w']) ? 100 : min(300, intval($_GET['w']));
+$height = empty($_GET['h']) ? 14  : min(50,  intval($_GET['h']));
@@ -99 +99 @@
-    }
+	}
@@ -101,2 +101 @@
-	if (strpos($used, '?') !== false || strpos($total, '?') !== false
-        && $used != 0) {
+	if (strpos($used, '?') !== false || strpos($total, '?') !== false && $used != 0) {
@@ -104 +103 @@
-    }
+	}
@@ -156 +155 @@
-		    // if($quota >= $limit['low'])
+			// if($quota >= $limit['low'])
@@ -166 +165 @@
-        // Print percent in black
+		// Print percent in black
@@ -171,5 +170,5 @@
-    
-    // @todo is harcoding GMT necessary?
-	header('Expires: ' . gmdate('D, d M Y H:i:s', mktime()+86400) . ' GMT');
-	header('Cache-Control: ');
-	header('Pragma: ');
+
+	// cache for 1 hour
+	$maxage = 3600;
+	header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$maxage). ' GMT');
+	header('Cache-Control: max-age=' . $maxage);
@@ -181 +180,7 @@
-genQuota($used, $quota, $width, $height);
+if ($width > 1 && $height > 1) {
+	genQuota($used, $quota, $width, $height);  
+}
+else {
+	header("HTTP/1.0 404 Not Found");
+}
+
@@ -183 +188 @@
-?>
\ No newline at end of file
+?>