25 #require_once 'Zend/Validate/Abstract.php'; 48 self::DOES_NOT_MATCH =>
"File '%value%' does not match the given hashes",
49 self::NOT_DETECTED =>
"A hash could not be evaluated for the given file",
50 self::NOT_FOUND =>
"File '%value%' is not readable or does not exist" 73 #require_once 'Zend/Validate/Exception.php'; 77 if (1 < func_num_args()) {
78 $options[
'algorithm'] = func_get_arg(1);
120 #require_once 'Zend/Validate/Exception.php'; 124 $known = hash_algos();
125 if (!isset(
$options[
'algorithm'])) {
126 $algorithm =
'crc32';
132 if (!in_array($algorithm, $known)) {
133 #require_once 'Zend/Validate/Exception.php'; 138 $this->_hash[
$value] = $algorithm;
156 #require_once 'Zend/Loader.php'; 158 return $this->
_throw($file, self::NOT_FOUND);
161 $algos = array_unique(array_values($this->_hash));
162 $hashes = array_unique(array_keys($this->_hash));
163 foreach ($algos as $algorithm) {
164 $filehash = hash_file($algorithm,
$value);
165 if ($filehash ===
false) {
166 return $this->
_throw($file, self::NOT_DETECTED);
169 foreach($hashes as $hash) {
170 if ($filehash === $hash) {
176 return $this->
_throw($file, self::DOES_NOT_MATCH);
186 protected function _throw($file, $errorType)
188 if ($file !==
null) {
189 $this->_value = $file[
'name'];
192 $this->
_error($errorType);
elseif(isset( $params[ 'redirect_parent']))
_error($messageKey, $value=null)
static isReadable($filename)
isValid($value, $file=null)
_throw($file, $errorType)