forked from uup-dump/api
Added search of builds in local database
This commit is contained in:
parent
6dc23e6737
commit
77de8b3efc
30
listid.php
30
listid.php
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright 2017 UUP dump API authors
|
||||
Copyright 2018 UUP dump API authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -17,7 +17,7 @@ limitations under the License.
|
||||
|
||||
require_once dirname(__FILE__).'/shared/main.php';
|
||||
|
||||
function uupListIds() {
|
||||
function uupListIds($search = null) {
|
||||
uupApiPrintBrand();
|
||||
|
||||
if(!file_exists('fileinfo')) return array('error' => 'NO_FILEINFO_DIR');
|
||||
@ -100,6 +100,32 @@ function uupListIds() {
|
||||
if(!$success) consoleLogger('Failed to update database cache.');
|
||||
}
|
||||
|
||||
if($search) {
|
||||
$searchSafe = preg_quote($search, '/');
|
||||
if(preg_match('/^".*"$/', $searchSafe)) {
|
||||
$searchSafe = preg_replace('/^"|"$/', '', $searchSafe);
|
||||
} else {
|
||||
$searchSafe = str_replace(' ', '.*', $searchSafe);
|
||||
}
|
||||
|
||||
foreach($builds as $key => $val) {
|
||||
$buildString[$key] = $val['title'].' '.$val['build'].' '.$val['arch'];
|
||||
}
|
||||
|
||||
$remove = preg_grep('/.*'.$searchSafe.'.*/i', $buildString, PREG_GREP_INVERT);
|
||||
$removeKeys = array_keys($remove);
|
||||
|
||||
foreach($removeKeys as $value) {
|
||||
unset($builds[$value]);
|
||||
}
|
||||
|
||||
if(empty($builds)) {
|
||||
return array('error' => 'SEARCH_NO_RESULTS');
|
||||
}
|
||||
|
||||
unset($remove, $removeKeys, $buildString);
|
||||
}
|
||||
|
||||
return array(
|
||||
'apiVersion' => uupApiVersion(),
|
||||
'builds' => $builds,
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright 2017 UUP dump API authors
|
||||
Copyright 2018 UUP dump API authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -16,7 +16,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
function uupApiVersion() {
|
||||
return '1.9.1';
|
||||
return '1.10.0';
|
||||
}
|
||||
|
||||
function uupApiPrintBrand() {
|
||||
|
Loading…
Reference in New Issue
Block a user