summaryrefslogtreecommitdiff
path: root/static/classes/UploadedFile.class.php
blob: 102d6d952be812a8876f6e1ee013d7fae877a54d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

class UploadedFile {
	/* Public attributes */
	public $name;
	public $mime;
	public $size;
	public $tempfile;
	public $error;

	/* Cached checksums */
	private $sha1;
	private $crc32;

	/**
	 * Generates the SHA1 or returns the cached SHA1 hash for the file.
	 *
	 * @return string
	 */
	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.
	 *
	 * @return string
	 */
	public function get_crc32 () {
		if (!$this->crc32)
			$this->crc32 = hash_file('crc32b', $this->tempfile);

		return $this->crc32;
	}
}
?>