diff options
-rw-r--r-- | search.php | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -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 <phil@pgburton.com> */ -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); } } |