Add option to search builds using regex

This commit is contained in:
whatever127 2019-12-06 01:15:03 +01:00
parent 8b0b157b5e
commit 8bceb8aac3
7 changed files with 18 additions and 8 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* /*
Copyright 2019 UUP dump API authors Copyright 2019 whatever127
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -142,11 +142,22 @@ function uupListIds($search = null, $sortByDate = 0) {
} }
if($search) { if($search) {
$searchSafe = preg_quote($search, '/'); if(!preg_match('/^regex:/', $search)) {
if(preg_match('/^".*"$/', $searchSafe)) { $searchSafe = preg_quote($search, '/');
$searchSafe = preg_replace('/^"|"$/', '', $searchSafe);
if(preg_match('/^".*"$/', $searchSafe)) {
$searchSafe = preg_replace('/^"|"$/', '', $searchSafe);
} else {
$searchSafe = str_replace(' ', '.*', $searchSafe);
}
} else { } else {
$searchSafe = str_replace(' ', '.*', $searchSafe); $searchSafe = preg_replace('/^regex:/', '', $search);
}
//I really hope that this will not backfire at me
@preg_match("/$searchSafe/", "");
if(preg_last_error()) {
return array('error' => 'SEARCH_NO_RESULTS');
} }
foreach($builds as $key => $val) { foreach($builds as $key => $val) {
@ -172,4 +183,3 @@ function uupListIds($search = null, $sortByDate = 0) {
'builds' => $builds, 'builds' => $builds,
); );
} }
?>

View File

@ -16,7 +16,7 @@ limitations under the License.
*/ */
function uupApiVersion() { function uupApiVersion() {
return '1.27.3'; return '1.28.0';
} }
require_once dirname(__FILE__).'/auths.php'; require_once dirname(__FILE__).'/auths.php';

File diff suppressed because one or more lines are too long