32 require_once dirname(dirname(__DIR__)) .
"/search-helper.php";
50 $searchType = $request->getHeaderLine(
"searchType");
51 $filename = $request->getHeaderLine(
"filename");
52 $tag = $request->getHeaderLine(
"tag");
53 $filesizeMin = $request->getHeaderLine(
"filesizemin");
54 $filesizeMax = $request->getHeaderLine(
"filesizemax");
55 $license = $request->getHeaderLine(
"license");
56 $copyright = $request->getHeaderLine(
"copyright");
59 if (empty($searchType)) {
60 $searchType =
"allfiles";
66 if (empty($filename) && empty($tag) && empty($filesizeMin) &&
67 empty($filesizeMax) && empty($license) && empty($copyright)) {
68 $returnVal =
new Info(400,
69 "Bad Request. At least one parameter, containing a value is required",
71 return $response->withJson($returnVal->getArray(), $returnVal->getCode());
77 if ((! empty($filesizeMin) && (! is_numeric($filesizeMin) || $filesizeMin < 0)) ||
78 (! empty($filesizeMax) && (! is_numeric($filesizeMax) || $filesizeMax < 0))) {
79 $returnVal =
new Info(400,
80 "Bad Request. filesizemin and filesizemax need to be positive integers!",
82 return $response->withJson($returnVal->getArray(), $returnVal->getCode());
86 $results = GetResults($item, $filename, $tag, 0,
87 $filesizeMin, $filesizeMax, $searchType, $license, $copyright,
88 $this->restHelper->getUploadDao(), $this->restHelper->getGroupId(),
89 $GLOBALS[
'PG_CONN'])[0];
93 for ($i = 0; $i <
sizeof($results); $i ++) {
94 $currentUpload = $this->dbHelper->getUploads(
95 $this->restHelper->getUserId(), $results[$i][
"upload_fk"])[0];
96 $uploadTreePk = $results[$i][
"uploadtree_pk"];
97 $filename = $this->dbHelper->getFilenameFromUploadTree($uploadTreePk);
98 $currentResult =
new SearchResult($currentUpload, $uploadTreePk, $filename);
99 $searchResults[] = $currentResult->getArray();
101 return $response->withJson($searchResults, 200);
Controller for Search model.
Base controller for REST calls.
Model to hold search results.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
performSearch($request, $response, $args)
Info model to contain general error and return values.