mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 13:59:29 +00:00
Check query lenght
This commit is contained in:
parent
c5f26e661f
commit
cbfc390c1a
@ -19,6 +19,11 @@ class searchController
|
|||||||
//Check if the query was specified with the request
|
//Check if the query was specified with the request
|
||||||
if(!isset($_POST['query']))
|
if(!isset($_POST['query']))
|
||||||
Rest_fatal_error(400, "Please specify search terms");
|
Rest_fatal_error(400, "Please specify search terms");
|
||||||
|
$query = $_POST['query'];
|
||||||
|
|
||||||
|
//Check the query
|
||||||
|
if(strlen($query) < 1)
|
||||||
|
Rest_fatal_error(401, "Empty requests not allowed !");
|
||||||
|
|
||||||
//Check for search limit
|
//Check for search limit
|
||||||
$searchLimit = (isset($_POST['searchLimit']) ? toInt($_POST['searchLimit']) : 5);
|
$searchLimit = (isset($_POST['searchLimit']) ? toInt($_POST['searchLimit']) : 5);
|
||||||
@ -28,7 +33,7 @@ class searchController
|
|||||||
Rest_fatal_error(401, "Invalid search limit !");
|
Rest_fatal_error(401, "Invalid search limit !");
|
||||||
|
|
||||||
//Perform research on the database and return results
|
//Perform research on the database and return results
|
||||||
$results = CS::get()->components->search->search_user($_POST['query'], $searchLimit);
|
$results = CS::get()->components->search->search_user($query, $searchLimit);
|
||||||
if($results === false)
|
if($results === false)
|
||||||
Rest_fatal_error(500, "An error occured while trying to perform a research in user list !");
|
Rest_fatal_error(500, "An error occured while trying to perform a research in user list !");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user