diff options
Diffstat (limited to 'app/frontend/components')
-rw-r--r-- | app/frontend/components/FileUploadSecureFileSize.php | 18 | ||||
-rw-r--r-- | app/frontend/components/FileUploadSecureFileType.php | 19 | ||||
-rw-r--r-- | app/frontend/components/FileUploadSecureMethods.php | 16 | ||||
-rw-r--r-- | app/frontend/components/FileUploadSecureOption.php | 17 | ||||
-rw-r--r-- | app/frontend/components/SafeActiveFileUpload.php | 13 | ||||
-rw-r--r-- | app/frontend/components/SafeFileUpload.php | 11 |
6 files changed, 94 insertions, 0 deletions
diff --git a/app/frontend/components/FileUploadSecureFileSize.php b/app/frontend/components/FileUploadSecureFileSize.php new file mode 100644 index 0000000..1e60c9a --- /dev/null +++ b/app/frontend/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/frontend/components/FileUploadSecureFileType.php b/app/frontend/components/FileUploadSecureFileType.php new file mode 100644 index 0000000..ce16501 --- /dev/null +++ b/app/frontend/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/frontend/components/FileUploadSecureMethods.php b/app/frontend/components/FileUploadSecureMethods.php new file mode 100644 index 0000000..8a42240 --- /dev/null +++ b/app/frontend/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/frontend/components/FileUploadSecureOption.php b/app/frontend/components/FileUploadSecureOption.php new file mode 100644 index 0000000..3550e21 --- /dev/null +++ b/app/frontend/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/frontend/components/SafeActiveFileUpload.php b/app/frontend/components/SafeActiveFileUpload.php new file mode 100644 index 0000000..69bffab --- /dev/null +++ b/app/frontend/components/SafeActiveFileUpload.php @@ -0,0 +1,13 @@ +<?php + +Prado::using('System.Web.UI.ActiveControls.TActiveFileUpload'); + +Prado::using('Application.components.FileUploadSecureMethods'); + +class SafeActiveFileUpload extends TActiveFileUpload { + + use FileUploadSecureMethods; + +} + +?> diff --git a/app/frontend/components/SafeFileUpload.php b/app/frontend/components/SafeFileUpload.php new file mode 100644 index 0000000..a8cbcae --- /dev/null +++ b/app/frontend/components/SafeFileUpload.php @@ -0,0 +1,11 @@ +<?php + +Prado::using('Application.components.FileUploadSecureMethods'); + +class SafeFileUpload extends TFileUpload { + + use FileUploadSecureMethods; + +} + +?> |