summaryrefslogtreecommitdiff
path: root/static/classes/UploadedFile.class.php
diff options
context:
space:
mode:
authorPeter Lejeck <peter.lejeck@gmail.com>2013-10-31 13:01:18 +0100
committerPeter Lejeck <peter.lejeck@gmail.com>2013-10-31 13:01:18 +0100
commitafc3e0f15e6c4e69d17fd5a84253a436a4fba4fc (patch)
tree196fcab3f38edf81a00b9b95b4bc64c0a9ee2713 /static/classes/UploadedFile.class.php
parent3cb3570707b13e5e2ae3097a7e872d6c798f7db8 (diff)
Move upload.php into static dir, and do hardcore refactoring
Diffstat (limited to 'static/classes/UploadedFile.class.php')
-rw-r--r--static/classes/UploadedFile.class.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/static/classes/UploadedFile.class.php b/static/classes/UploadedFile.class.php
new file mode 100644
index 0000000..5b7ba9b
--- /dev/null
+++ b/static/classes/UploadedFile.class.php
@@ -0,0 +1,32 @@
+<?php
+
+class UploadedFile {
+ /* Public attributes */
+ public $name;
+ public $mime;
+ public $tempfile;
+ public $error;
+ public $size;
+
+ /* Cached checksums */
+ private $sha1;
+ private $crc32;
+
+ /**
+ * Generates the SHA1 or returns the cached SHA1 hash for the file.
+ */
+ public function get_sha1 () {
+ if (! $this->sha1) $this->sha1 = sha1_file($this->tempfile);
+
+ return $this->sha1;
+ }
+ /**
+ * Generates the CRC32 or returns the cached CRC32 hash for the file.
+ */
+ public function get_crc32 () {
+ if (! $this->crc32) $this->crc32 = hash_file('crc32b', $this->tempfile);
+
+ return $this->crc32;
+ }
+}
+?>