diff options
| author | Phil Burton <phil@d3r.com> | 2015-12-10 15:32:18 +0000 | 
|---|---|---|
| committer | Phil Burton <phil@d3r.com> | 2015-12-10 15:32:18 +0000 | 
| commit | ebc68bf73205c0f821e6a0c70218112b4a2b288a (patch) | |
| tree | 09b1b965eeb84f2fd43838bc87e793b60ebf095f /search.php | |
| parent | 2eac02632ec2b7b6241e92423a3fdbda3baaafda (diff) | |
Switch to use plain text url
Diffstat (limited to 'search.php')
| -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);          }      }  | 
