Skip to content

Commit

Permalink
Update DirectoryLister.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Toyo committed Sep 18, 2018
1 parent c1b799a commit ed30e74
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions resources/DirectoryLister.php
Expand Up @@ -362,56 +362,6 @@ function getFileSize($filePath) {

}


/**
* Returns array of file hash values
*
* @param string $filePath Path to file
* @return array Array of file hashes
* @access public
*/
public function getFileHash($filePath) {

// Placeholder array
$hashArray = array();

// Verify file path exists and is a directory
if (!file_exists($filePath)) {
return json_encode($hashArray);
}

// Prevent access to hidden files
if ($this->_isHidden($filePath)) {
return json_encode($hashArray);
}

// Prevent access to parent folders
if (strpos($filePath, '<') !== false || strpos($filePath, '>') !== false
|| strpos($filePath, '..') !== false || strpos($filePath, '/') === 0) {
return json_encode($hashArray);
}

// Prevent hashing if file is too big
if (filesize($filePath) > $this->_config['hash_size_limit']) {

// Notify user that file is too large
$hashArray['md5'] = '[ 文件大小超过阈值 ]';
$hashArray['sha1'] = '[ 文件大小超过阈值 ]';

} else {

// Generate file hashes
$hashArray['md5'] = hash_file('md5', $filePath);
$hashArray['sha1'] = hash_file('sha1', $filePath);

}

// Return the data
return $hashArray;

}


/**
* Set directory path variable
*
Expand Down

0 comments on commit ed30e74

Please sign in to comment.