diff options
author | Phil Burton <phil@d3r.com> | 2015-12-10 16:14:17 +0000 |
---|---|---|
committer | Phil Burton <phil@d3r.com> | 2015-12-10 16:14:17 +0000 |
commit | 2ddc79fe381529f81886c385622d5bff3e586236 (patch) | |
tree | caada216e2adc1144847c45ef2e3026b1103b83d | |
parent | ebc68bf73205c0f821e6a0c70218112b4a2b288a (diff) |
-rw-r--r-- | search.php | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -1,6 +1,6 @@ <?php -define("VERSION", "2.0.2"); +define("VERSION", "2.1.0"); /** * Load and parse the config file, setting any defaults here if non-required @@ -234,19 +234,12 @@ try { // Really slow search $results = []; - foreach ($content as $upload) { - $match = false; - foreach ($arguments["search"] as $arg) { - if (!is_null($arg) && stripos($upload, $arg) === false) { - $match = false; - break; - } - $match = true; - } - if ($match) { - $results[] = $config["url"] . "/" . rawurlencode($upload); - } + $regex = ""; + foreach ($arguments["search"] as $arg) { + $regex .= "(?=.*" . $arg . ")"; } + $content = preg_grep("/" . $regex . "/i", $content); + $results = $content; if (empty($results)) { output("No results found"); @@ -265,7 +258,7 @@ try { $i++; continue; } - $out[] = $i + 1 . ": " . $result; + $out[] = $i + 1 . ": " . $config["url"] . "/" . rawurlencode($result); $i++; } |