Skip to content

Commit

Permalink
Tweaked getFileHash() function to return php array.
Browse files Browse the repository at this point in the history
  • Loading branch information
PHLAK committed May 8, 2013
1 parent d55e8be commit 2bef8ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 8 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@

// Return file hash
if (isset($_GET['hash'])) {
die($lister->getFileHash($_GET['hash']));

// Get file hash array and JSON encode it
$hashes = $lister->getFileHash($_GET['hash']);
$data = json_encode($hashes);

// Return the data
die($data);

}

// Initialize the directory array
Expand Down
9 changes: 3 additions & 6 deletions resources/DirectoryLister.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ public function getSystemMessages() {


/**
* Returns a JSON encoded array of file hash values
* Returns array of file hash values
*
* @param string $path Path to file
* @return string JSON encoded array of file hashes
* @return string Array of file hashes
* @access public
*/
public function getFileHash($filePath) {
Expand Down Expand Up @@ -238,11 +238,8 @@ public function getFileHash($filePath) {
$hashArray['sha1'] = hash_file('sha1', $filePath);
$hashArray['sha256'] = hash_file('sha256', $filePath);

// JSON encode hash array
$data = json_encode($hashArray);

// Return the data
return $data;
return $hashArray;

}

Expand Down

0 comments on commit 2bef8ba

Please sign in to comment.