summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-04-25 11:40:28 +0200
committeremkael <emkael@tlen.pl>2016-04-25 11:40:28 +0200
commit050c6cfd0e75249ae7b7dad3f8ec6eed6be50102 (patch)
treedb6076f9edeccf9c2a867e87a42ff6f756f1603c
parentdd5aaa4db1e8758652586aa82f21bf631ce20bcc (diff)
* separating safer file upload trait to its own file
-rw-r--r--app/php/components/SafeActiveFileUpload.php4
-rw-r--r--app/php/components/SafeFileUpload.php33
-rw-r--r--app/php/components/SafeFileUploadMethods.php32
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();
+ }
+
+}
+
+?>