diff options
Diffstat (limited to 'search.php')
-rw-r--r-- | search.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/search.php b/search.php new file mode 100644 index 0000000..8d027a0 --- /dev/null +++ b/search.php @@ -0,0 +1,40 @@ +<?php + + $config = false; +try { + if (!is_readable("config.ini")) { + throw new Exception('File config.ini does not exist'); + } + if (!$config = parse_ini_file("config.ini")) { + throw new Exception('Could not parse ini file'); + } + + // hash the password + $hash = hash("sha256", $config['password']); + $curl = curl_init($config["url"]. "?format=json"); + curl_setopt($curl, CURLOPT_HTTPHEADER, array("Cookie: password=$hash")); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $output = json_decode(curl_exec($curl)); + curl_close($curl); + + + $search = "abel"; + + // Really slow search + $results = []; + foreach ($output as $upload) { + if (strpos($upload->filename, $search) !== false) { + $results[] = $config["url"] . "/" . $upload->filename; + } + } + + // Return results + if (empty($results)) { + echo "No results found\n"; + } else { + var_dump($results);die(); + } + +} catch (Exception $e) { + var_dump($e->getMessage());die(); +}
\ No newline at end of file |