21         $result = explode(
',', $uri->path, 2);
 
   28             $metas = explode(
';', $metadata);
 
   29             while(!empty($metas)) {
 
   30                 $cur = array_shift($metas);
 
   31                 if ($cur == 
'base64') {
 
   35                 if (substr($cur, 0, 8) == 
'charset=') {
 
   38                     if ($charset !== null) 
continue; 
 
   39                     $charset = substr($cur, 8); 
 
   41                     if ($content_type !== null) 
continue; 
 
   48         if ($content_type !== null && empty($this->allowed_types[$content_type])) {
 
   51         if ($charset !== null) {
 
   57             $raw_data = base64_decode(
$data);
 
   63         $file = tempnam(
"/tmp", 
"");
 
   64         file_put_contents(
$file, $raw_data);
 
   65         if (function_exists(
'exif_imagetype')) {
 
   66             $image_code = exif_imagetype(
$file);
 
   67         } elseif (function_exists(
'getimagesize')) {
 
   68             set_error_handler(array($this, 
'muteErrorHandler'));
 
   69             $info = getimagesize(
$file);
 
   70             restore_error_handler();
 
   71             if ($info == 
false) 
return false;
 
   72             $image_code = $info[2];
 
   74             trigger_error(
"could not find exif_imagetype or getimagesize functions", E_USER_ERROR);
 
   76         $real_content_type = image_type_to_mime_type($image_code);
 
   77         if ($real_content_type != $content_type) {
 
   80             if (empty($this->allowed_types[$real_content_type])) 
return false;
 
   81             $content_type = $real_content_type;
 
   84         $uri->userinfo = null;
 
   87         $uri->fragment = null;
 
   89         $uri->path = 
"$content_type;base64," . base64_encode($raw_data);