config->granularity != 'YYYY-MM-DDThh:mm:ssZ') { return 'invalid_granularity'; } else { $time = strtotime("$date UTC"); return ($time != -1) ? $time : 'invalid'; } } else { return 'invalid'; } } /** * Clean input variables. * @param $data mixed request parameter(s) * @return mixed cleaned request parameter(s) */ function prepInput(&$data) { if (!is_array($data)) { $data = urldecode($data); } else { foreach ($data as $k => $v) { if (is_array($data[$k])) { OAIUtils::prepInput($data[$k]); } else { $data[$k] = urldecode($v); } } } return $data; } /** * Prepare variables for output. * Data is assumed to be UTF-8 encoded (FIXME?) * @param $data mixed output parameter(s) * @return mixed cleaned output parameter(s) */ function prepOutput(&$data) { if (!is_array($data)) { $data = htmlspecialchars($data); } else { foreach ($data as $k => $v) { if (is_array($data[$k])) { $this->prepOutput($data[$k]); } else { // FIXME FIXME FIXME $data[$k] = htmlspecialchars($v); } } } return $data; } /** * Parses string $string into an associate array $array. * Acts like parse_str($string, $array) except duplicate * variable names in $string are converted to an array. * @param $duplicate string input data string * @param $array array of parsed parameters */ function parseStr($string, &$array) { $pairs = explode('&', $string); foreach ($pairs as $p) { $vars = explode('=', $p); if (!empty($vars[0]) && isset($vars[1])) { $key = $vars[0]; $value = join('=', array_splice($vars, 1)); if (!isset($array[$key])) { $array[$key] = $value; } else if (is_array($array[$key])) { array_push($array[$key], $value); } else { $array[$key] = array($array[$key], $value); } } } } } ?>