summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2010-11-03 20:07:32 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2010-11-03 20:07:32 +1100
commit8849f5a2db1d041df556d069bb0b530aee11294e (patch)
tree5dbad2fee94f195f82fa1eb93ba1b13fe61b87c1
parent690f206a63967805c1d61806683947ac6f2a2175 (diff)
Maximum image dimensions
-rw-r--r--inc/config.php6
-rw-r--r--post.php5
2 files changed, 10 insertions, 1 deletions
diff --git a/inc/config.php b/inc/config.php
index b2bfa3fe..86d36feb 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -40,7 +40,8 @@
define('ERROR_NOMOVE', 'The server failed to handle your upload.');
define('ERROR_FILEEXT', 'Unsupported image format.');
define('ERR_INVALIDIMG','Invalid image.');
- define('ERR_FILSIZE','The file was too large.');
+ define('ERR_FILSIZE', 'The file was too large.');
+ define('ERR_MAXSIZE', 'The file was too big.');
// For resizing, max values
define('THUMB_WIDTH', 200);
@@ -48,6 +49,9 @@
// Maximum image upload size in bytes
define('MAX_FILESIZE', 1048576); // 10MB
+ // Maximum image dimensions
+ define('MAX_WIDTH', 1000);
+ define('MAX_HEIGHT', MAX_WIDTH);
define('DIR_IMG', 'src/');
define('DIR_THUMB', 'thumb/');
diff --git a/post.php b/post.php
index 23eb0453..22aba6af 100644
--- a/post.php
+++ b/post.php
@@ -121,6 +121,11 @@
error(ERR_INVALIDIMG);
}
+ if($post['width'] > MAX_WIDTH || $post['height'] > MAX_HEIGHT) {
+ unlink($post['file']);
+ error(ERR_MAXSIZE);
+ }
+
$post['filesize'] = filesize($post['file']);
$thumb = resize($post['extension'], $post['file'], $post['thumb'], THUMB_WIDTH, THUMB_HEIGHT);
$post['thumbwidth'] = $thumb['width'];