/** returns type on success, false on failure */ public static function isAcceptable($content_type) { $ok_type = false; try { list($type, $subtype) = Dase_Media::parseMimeType($content_type); } catch (Exception $e) { return false; } foreach (Dase_Media::getAcceptedTypes() as $t) { list($acceptedType, $acceptedSubtype) = explode('/', $t); if ($acceptedType == '*' || $acceptedType == $type) { if ($acceptedSubtype == '*' || $acceptedSubtype == $subtype) { $ok_type = $type . "/" . $subtype; } } } return $ok_type; }
public function getContentType() { if (isset($_SERVER['CONTENT_TYPE'])) { $header = $_SERVER['CONTENT_TYPE']; } if (isset($_SERVER['HTTP_CONTENT_TYPE'])) { $header = $_SERVER['HTTP_CONTENT_TYPE']; } if (isset($header)) { list($type, $subtype, $params) = Dase_Media::parseMimeType($header); if (isset($params['type'])) { return $type . '/' . $subtype . ';type=' . $params['type']; } else { return $type . '/' . $subtype; } } }