diff --git a/index.php b/index.php index 369e4ddde..83326ca70 100644 --- a/index.php +++ b/index.php @@ -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 diff --git a/resources/DirectoryLister.php b/resources/DirectoryLister.php index 90759b3e9..3e327efe0 100644 --- a/resources/DirectoryLister.php +++ b/resources/DirectoryLister.php @@ -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) { @@ -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; }