/** * Checks the argument list from the POST/GET query. * * Checks if the required arguments are present, and no invalid extra * arguments are present. All valid arguments must be in either the * required or optional array. * * @param array requiredArgs Array of required argument names. * @param array optionalArgs Array of optional, but valid argument names. */ private function checkArguments($requiredArgs = array(), $optionalArgs = array()) { $requiredArgs[] = 'verb'; /* Checks (essentially), if there are more arguments in the query string than in PHP's returned array, if so there were duplicate arguments, which is not allowed. */ if ($_SERVER['REQUEST_METHOD'] == 'GET' && urldecode($_SERVER['QUERY_STRING']) != urldecode(http_build_query($this->query))) { $this->throwError(self::OAI_ERR_BAD_ARGUMENT, "Duplicate arguments in request."); } $keys = array_keys($this->query); foreach (array_diff($requiredArgs, $keys) as $arg) { $this->throwError(self::OAI_ERR_BAD_ARGUMENT, "Missing required argument {$arg}."); } foreach (array_diff($keys, $requiredArgs, $optionalArgs) as $arg) { $this->throwError(self::OAI_ERR_BAD_ARGUMENT, "Unknown argument {$arg}."); } $from = $this->_getParam('from'); $until = $this->_getParam('until'); $fromGran = OaiPmhRepository_Date::getGranularity($from); $untilGran = OaiPmhRepository_Date::getGranularity($until); if ($from && !$fromGran) { $this->throwError(self::OAI_ERR_BAD_ARGUMENT, "Invalid date/time argument."); } if ($until && !$untilGran) { $this->throwError(self::OAI_ERR_BAD_ARGUMENT, "Invalid date/time argument."); } if ($from && $until && $fromGran != $untilGran) { $this->throwError(self::OAI_ERR_BAD_ARGUMENT, "Date/time arguments of differing granularity."); } $metadataPrefix = $this->_getParam('metadataPrefix'); if ($metadataPrefix && !array_key_exists($metadataPrefix, $this->metadataFormats)) { $this->throwError(self::OAI_ERR_CANNOT_DISSEMINATE_FORMAT); } }