diff options
author | Craig Andrews <candrews@integralblue.com> | 2009-07-07 15:55:10 -0400 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2009-07-07 15:55:10 -0400 |
commit | 5f72423523c0d95800460cd3342461d3c72eafa1 (patch) | |
tree | 740fde7d48263c754a20d560e043ca7e538f1d8c | |
parent | a9c83b064f38a2a1c431710c20eef611057711e8 (diff) |
File classes does not use the $FILES array directly, as users of this class aren't necessarily from the web
-rw-r--r-- | actions/newnotice.php | 2 | ||||
-rw-r--r-- | classes/File.php | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php index 5f44a32a9..e254eac49 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -135,7 +135,7 @@ class NewnoticeAction extends Action function isRespectsQuota($user) { $file = new File; - $ret = $file->isRespectsQuota($user); + $ret = $file->isRespectsQuota($user,$_FILES['attach']['size']); if (true === $ret) return true; $this->clientError($ret); } diff --git a/classes/File.php b/classes/File.php index 5dd7cd865..533cc6e71 100644 --- a/classes/File.php +++ b/classes/File.php @@ -122,17 +122,17 @@ class File extends Memcached_DataObject return $x; } - function isRespectsQuota($user) { - if ($_FILES['attach']['size'] > common_config('attachments', 'file_quota')) { + function isRespectsQuota($user,$fileSize) { + if ($fileSize > common_config('attachments', 'file_quota')) { return sprintf(_('No file may be larger than %d bytes ' . 'and the file you sent was %d bytes. Try to upload a smaller version.'), - common_config('attachments', 'file_quota'), $_FILES['attach']['size']); + common_config('attachments', 'file_quota'), $fileSize); } $query = "select sum(size) as total from file join file_to_post on file_to_post.file_id = file.id join notice on file_to_post.post_id = notice.id where profile_id = {$user->id} and file.url like '%/notice/%/file'"; $this->query($query); $this->fetch(); - $total = $this->total + $_FILES['attach']['size']; + $total = $this->total + $fileSize; if ($total > common_config('attachments', 'user_quota')) { return sprintf(_('A file this large would exceed your user quota of %d bytes.'), common_config('attachments', 'user_quota')); } @@ -140,7 +140,7 @@ class File extends Memcached_DataObject $query .= ' month(modified) = month(now()) and year(modified) = year(now())'; $this->query($query); $this->fetch(); - $total = $this->total + $_FILES['attach']['size']; + $total = $this->total + $fileSize; if ($total > common_config('attachments', 'monthly_quota')) { return sprintf(_('A file this large would exceed your monthly quota of %d bytes.'), common_config('attachments', 'monthly_quota')); } |