diff options
-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++; } |