diff options
| author | Fbenas <philbeansburton@gmail.com> | 2015-12-05 17:27:54 +0000 | 
|---|---|---|
| committer | Fbenas <philbeansburton@gmail.com> | 2015-12-05 17:27:54 +0000 | 
| commit | b70aeacf036a6604f6b233576ca68152557189e4 (patch) | |
| tree | 5967b0b717a974c9733195cc7b854cd8082b3cb9 /search.php | |
Add files to allow search of blaupload.\n WIP.
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 | 
