From 9fbd8d993fd58791e4d33db5318ba1da8eb5f211 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Thu, 9 Jun 2016 15:19:08 +0200 Subject: fixed some minor things. --- modules-available/dozmod/api.inc.php | 61 +++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'modules-available/dozmod/api.inc.php') diff --git a/modules-available/dozmod/api.inc.php b/modules-available/dozmod/api.inc.php index cadd8943..6ff52c14 100644 --- a/modules-available/dozmod/api.inc.php +++ b/modules-available/dozmod/api.inc.php @@ -1,13 +1,13 @@ filter_var(strtolower(trim($_REQUEST['resource'])), FILTER_SANITIZE_STRING), - 'lecture' => filter_var(strtolower(trim($_REQUEST['lecture'])), FILTER_SANITIZE_STRING), - 'ip' => $ip]; +$resource = Request::get('resource', false, 'string'); +$lecture = Request::get('lecture', false, 'string'); +if ($resource === false) { + Util::traceError("you have to specify the 'resource' parameter"); +} +if ($lecture === false) { + Util::traceError("you have to specify the 'lecture' parameter"); +} /* lookup location id(s) */ -$location_ids = Location::getFromIp($request['ip']); +$location_ids = Location::getFromIp($ip); $location_ids = Location::getLocationRootChain($location_ids); /* lookup lecture uuids */ -$lectures = getLecturesForLocations(); +$lectures = getLecturesForLocations($location_ids); /* validate request -------------------------------------------- */ /* check resources */ -if (!in_array($request['resource'], $availableRessources)) { - Util::traceError("unknown resource: {$request['resource']}"); +if (!in_array($resource, $availableRessources)) { + Util::traceError("unknown resource: $resource"); } /* check that the user requests a lecture that he is allowed to have */ -if (!in_array($request['lecture'], $lectures)) { - Util::traceError("client is not allowed to access this lecture: ${request['lecture']}"); +if (!in_array($lecture, $lectures)) { + Util::traceError("client is not allowed to access this lecture: $lecture"); } -if ($request['resource'] === 'vmx') { - echo getVMX($request['lecture']); -} else if ($request['resource'] === 'test') { +if ($resource === 'vmx') { + echo getVMX($lecture); +} else if ($resource === 'test') { echo "Here's your special test data!"; } else { echo "I don't know how to give you that resource"; -- cgit v1.2.3-55-g7522