diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/php/components/SafeActiveFileUpload.php | 4 | ||||
-rw-r--r-- | app/php/components/SafeFileUpload.php | 33 | ||||
-rw-r--r-- | app/php/components/SafeFileUploadMethods.php | 32 |
3 files changed, 37 insertions, 32 deletions
diff --git a/app/php/components/SafeActiveFileUpload.php b/app/php/components/SafeActiveFileUpload.php index 9b8e2a8..0c3335c 100644 --- a/app/php/components/SafeActiveFileUpload.php +++ b/app/php/components/SafeActiveFileUpload.php @@ -1,11 +1,11 @@ <?php Prado::using('System.Web.UI.ActiveControls.TActiveFileUpload'); -Prado::using('Application.components.SafeFileUpload'); +Prado::using('Application.components.SafeFileUploadMethods'); class SafeActiveFileUpload extends TActiveFileUpload { - use MimeTypeCheckForFileUpload; + use SafeFileUploadMethods; } diff --git a/app/php/components/SafeFileUpload.php b/app/php/components/SafeFileUpload.php index ea65d22..dcc81a0 100644 --- a/app/php/components/SafeFileUpload.php +++ b/app/php/components/SafeFileUpload.php @@ -1,37 +1,10 @@ <?php -class SafeFileUpload extends TFileUpload { - - use MimeTypeCheckForFileUpload; - -} - -trait MimeTypeCheckForFileUpload { +Prado::using('Application.components.SafeFileUploadMethods'); - protected $_isSecure = TRUE; - - public function getIsSecure() { - return $this->_isSecure; - } - - public function setIsSecure($bool) { - $this->_isSecure = $bool; - } - - public function getFileType() { - if ($this->getIsSecure()) { - $fileInfo = new finfo(FILEINFO_MIME_TYPE); - return $fileInfo->file($this->getLocalName()); - } - return parent::getFileType(); - } +class SafeFileUpload extends TFileUpload { - public function getFileSize() { - if ($this->getIsSecure()) { - return filesize($this->getLocalName()); - } - return parent::getFileSize(); - } + use SafeFileUploadMethods; } diff --git a/app/php/components/SafeFileUploadMethods.php b/app/php/components/SafeFileUploadMethods.php new file mode 100644 index 0000000..bdb2af6 --- /dev/null +++ b/app/php/components/SafeFileUploadMethods.php @@ -0,0 +1,32 @@ +<?php + +trait SafeFileUploadMethods { + + protected $_isSecure = TRUE; + + public function getIsSecure() { + return $this->_isSecure; + } + + public function setIsSecure($bool) { + $this->_isSecure = $bool; + } + + public function getFileType() { + if ($this->getIsSecure()) { + $fileInfo = new finfo(FILEINFO_MIME_TYPE); + return $fileInfo->file($this->getLocalName()); + } + return parent::getFileType(); + } + + public function getFileSize() { + if ($this->getIsSecure()) { + return filesize($this->getLocalName()); + } + return parent::getFileSize(); + } + +} + +?> |