fuel/fuel/core/classes/request/driver.php
protected function mime_in_header($mime, $accept_header)
	{
		// make sure we have input
		if (empty($mime) or empty($accept_header))
		{
			// no header or no mime to check
			return true;
		}

		// process the accept header and get a list of accepted mimes
		$accept_mimes = array();
		$accept_header = explode(',', $accept_header);
		foreach ($accept_header as $accept_def)
		{
			$accept_def = explode(';', $accept_def);
			$accept_def = trim($accept_def[0]);
			if ( ! in_array($accept_def, $accept_mimes))
			{
				$accept_mimes[] = $accept_def;
			}
		}

		// match on generic mime type
		if (in_array('*/*', $accept_mimes))
		{
			return true;
		}

		// match on full mime type
		if (in_array($mime, $accept_mimes))
		{
			return true;
		}

		// match on generic mime type
		$mime = substr($mime, 0, strpos($mime, '/')).'/*';
		if (in_array($mime, $accept_mimes))
		{
			return true;
		}

		// no match
		return false;
	}
protected function mime_in_header($mime, $accept_header)
	{
		// make sure we have input
		if (empty($mime) or empty($accept_header))
		{
			// no header or no mime to check
			return true;
		}

		// process the accept header and get a list of accepted mimes
		$accept_mimes = array();
		$accept_header = explode(',', $accept_header);
		foreach ($accept_header as $accept_def)
		{
			$accept_def = explode(';', $accept_def);
			$accept_def = trim($accept_def[0]);
			if ( ! in_array($accept_def, $accept_mimes))
			{
				$accept_mimes[] = $accept_def;
			}
		}

		// match on generic mime type
		if (in_array('*/*', $accept_mimes))
		{
			return true;
		}

		// match on full mime type
		if (in_array($mime, $accept_mimes))
		{
			return true;
		}

		// match on generic mime type
		$mime = substr($mime, 0, strpos($mime, '/')).'/*';
		if (in_array($mime, $accept_mimes))
		{
			return true;
		}

		// no match
		return false;
	}
protected function mime_in_header ( $ mime , $ accept_header ) { // make sure we have input if ( empty ( $ mime ) or empty ( $ accept_header ) ) { // no header or no mime to check return true ; } // process the accept header and get a list of accepted mimes $ accept_mimes = array ( ) ; $ accept_header = explode ( ',' , $ accept_header ) ; foreach ( $ accept_header as $ accept_def ) { $ accept_def = explode ( ';' , $ accept_def ) ; $ accept_def = trim ( $ accept_def [ 0 ] ) ; if ( ! in_array ( $ accept_def , $ accept_mimes ) ) { $ accept_mimes [ ] = $ accept_def ; } } // match on generic mime type if ( in_array ( '*/*' , $ accept_mimes ) ) { return true ; } // match on full mime type if ( in_array ( $ mime , $ accept_mimes ) ) { return true ; } // match on generic mime type $ mime = substr ( $ mime , 0 , strpos ( $ mime , '/' ) ) . '/*' ; if ( in_array ( $ mime , $ accept_mimes ) ) { return true ; } // no match return false ; }
Validate if a given mime type is accepted according to an accept header

@param  string  $mime
@param  string  $accept_header
@return bool
Validate if a given mime type is accepted according to an accept header