From ebc68bf73205c0f821e6a0c70218112b4a2b288a Mon Sep 17 00:00:00 2001 From: Phil Burton Date: Thu, 10 Dec 2015 15:32:18 +0000 Subject: Switch to use plain text url --- search.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index fa990ed..aa19f90 100644 --- a/search.php +++ b/search.php @@ -45,26 +45,26 @@ function getConfig() } /** - * Use curl to find get the json file for a url + * Use curl to find get the plain text file for a url * Using the sha256 hashed password if it's been set in the config * * @param string[] $config * @return StdClass[] * @author Phil Burton */ -function getJsonFromUrl($config) +function getResultsFromUrl($config) { - $curl = curl_init($config["url"] . "?format=json"); + $curl = curl_init($config["url"] . "?format=plain"); if (isset($config["hash"])) { curl_setopt($curl, CURLOPT_HTTPHEADER, array("Cookie: password=" . $config["hash"])); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - $output = json_decode(curl_exec($curl)); + $output = explode("\n", curl_exec($curl)); curl_close($curl); if (!isset($output)) { throw new Exception( - "Could not retrive JSON from http server `" + "Could not retrive results from http server `" . $config["url"] . "?format=json` using password=" . (isset($config["hash"]) ? "true" : "false"), @@ -224,7 +224,7 @@ function getFormattedArguments($config) *********************************/ try { $config = getConfig(); - $content = getJsonFromUrl($config); + $content = getResultsFromUrl($config); $arguments = getFormattedArguments($config); // parse the arguments @@ -237,14 +237,14 @@ try { foreach ($content as $upload) { $match = false; foreach ($arguments["search"] as $arg) { - if (!is_null($arg) && stripos($upload->filename, $arg) === false) { + if (!is_null($arg) && stripos($upload, $arg) === false) { $match = false; break; } $match = true; } if ($match) { - $results[] = $config["url"] . "/" . rawurlencode($upload->filename); + $results[] = $config["url"] . "/" . rawurlencode($upload); } } -- cgit v1.2.3