summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Burton <phil@d3r.com>2015-12-10 15:32:18 +0000
committerPhil Burton <phil@d3r.com>2015-12-10 15:32:18 +0000
commitebc68bf73205c0f821e6a0c70218112b4a2b288a (patch)
tree09b1b965eeb84f2fd43838bc87e793b60ebf095f
parent2eac02632ec2b7b6241e92423a3fdbda3baaafda (diff)
Switch to use plain text url
-rw-r--r--search.php16
1 files changed, 8 insertions, 8 deletions
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 <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);
}
}