diff options
-rw-r--r-- | app/php/components/FileUploadSecureFileSize.php | 18 | ||||
-rw-r--r-- | app/php/components/FileUploadSecureFileType.php | 19 | ||||
-rw-r--r-- | app/php/components/FileUploadSecureMethods.php | 16 | ||||
-rw-r--r-- | app/php/components/FileUploadSecureOption.php | 17 | ||||
-rw-r--r-- | app/php/components/SafeActiveFileUpload.php | 5 | ||||
-rw-r--r-- | app/php/components/SafeFileUpload.php | 4 | ||||
-rw-r--r-- | app/php/components/SafeFileUploadMethods.php | 32 |
7 files changed, 75 insertions, 36 deletions
diff --git a/app/php/components/FileUploadSecureFileSize.php b/app/php/components/FileUploadSecureFileSize.php new file mode 100644 index 0000000..1e60c9a --- /dev/null +++ b/app/php/components/FileUploadSecureFileSize.php @@ -0,0 +1,18 @@ +<?php + +Prado::using('Application.components.FileUploadSecureOption'); + +trait FileUploadSecureFileSize { + + use FileUploadSecureOption; + + public function getFileSize() { + if ($this->getIsSecure()) { + return filesize($this->getLocalName()); + } + return parent::getFileSize(); + } + +} + +?> diff --git a/app/php/components/FileUploadSecureFileType.php b/app/php/components/FileUploadSecureFileType.php new file mode 100644 index 0000000..ce16501 --- /dev/null +++ b/app/php/components/FileUploadSecureFileType.php @@ -0,0 +1,19 @@ +<?php + +Prado::using('Application.components.FileUploadSecureOption'); + +trait FileUploadSecureFileType { + + use FileUploadSecureOption; + + public function getFileType() { + if ($this->getIsSecure()) { + $fileInfo = new finfo(FILEINFO_MIME_TYPE); + return $fileInfo->file($this->getLocalName()); + } + return parent::getFileType(); + } + +} + +?> diff --git a/app/php/components/FileUploadSecureMethods.php b/app/php/components/FileUploadSecureMethods.php new file mode 100644 index 0000000..8a42240 --- /dev/null +++ b/app/php/components/FileUploadSecureMethods.php @@ -0,0 +1,16 @@ +<?php + +Prado::using('Application.components.FileUploadSecureOption'); +Prado::using('Application.components.FileUploadSecureFileSize'); +Prado::using('Application.components.FileUploadSecureFileType'); + +trait FileUploadSecureMethods { + use FileUploadSecureOption, FileUploadSecureFileSize, FileUploadSecureFileType { + FileUploadSecureOption::getIsSecure + insteadof FileUploadSecureFileType, FileUploadSecureFileSize; + FileUploadSecureOption::setIsSecure + insteadof FileUploadSecureFileType, FileUploadSecureFileSize; + } +} + +?> diff --git a/app/php/components/FileUploadSecureOption.php b/app/php/components/FileUploadSecureOption.php new file mode 100644 index 0000000..3550e21 --- /dev/null +++ b/app/php/components/FileUploadSecureOption.php @@ -0,0 +1,17 @@ +<?php + +trait FileUploadSecureOption { + + protected $_isSecure = TRUE; + + public function getIsSecure() { + return $this->_isSecure; + } + + public function setIsSecure($bool) { + $this->_isSecure = $bool; + } + +} + +?> diff --git a/app/php/components/SafeActiveFileUpload.php b/app/php/components/SafeActiveFileUpload.php index 0c3335c..69bffab 100644 --- a/app/php/components/SafeActiveFileUpload.php +++ b/app/php/components/SafeActiveFileUpload.php @@ -1,11 +1,12 @@ <?php Prado::using('System.Web.UI.ActiveControls.TActiveFileUpload'); -Prado::using('Application.components.SafeFileUploadMethods'); + +Prado::using('Application.components.FileUploadSecureMethods'); class SafeActiveFileUpload extends TActiveFileUpload { - use SafeFileUploadMethods; + use FileUploadSecureMethods; } diff --git a/app/php/components/SafeFileUpload.php b/app/php/components/SafeFileUpload.php index dcc81a0..a8cbcae 100644 --- a/app/php/components/SafeFileUpload.php +++ b/app/php/components/SafeFileUpload.php @@ -1,10 +1,10 @@ <?php -Prado::using('Application.components.SafeFileUploadMethods'); +Prado::using('Application.components.FileUploadSecureMethods'); class SafeFileUpload extends TFileUpload { - use SafeFileUploadMethods; + use FileUploadSecureMethods; } diff --git a/app/php/components/SafeFileUploadMethods.php b/app/php/components/SafeFileUploadMethods.php deleted file mode 100644 index bdb2af6..0000000 --- a/app/php/components/SafeFileUploadMethods.php +++ /dev/null @@ -1,32 +0,0 @@ -<?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(); - } - -} - -?> |