image_error("Could not retrieve the requested screenshot.", "HTTP/1.1 500 Internal Server Error");
        exit;
    }
    // Output the MIME header
    $imageExtension = array_search($query->fields['screenshot_format'], $config['screenshot_imageTypes']);
    // This should never happen, but we test for it regardless
    if ($imageExtension === false) {
        image_error("Invalid Image", "HTTP/1.1 404 OK");
    }
    // Headers
    header("Content-Type: " . $query->fields['screenshot_format']);
    header("Content-disposition: inline; filename=" . $_GET['report_id'] . "." . $imageExtension);
    // Output the image
    echo $query->fields['screenshot_data'];
} else {
    image_error("You are not authorized to view this resource.", "HTTP/1.1 401 Authorization Required");
}
function image_error($str, $header)
{
    // If a header is set, make sure to show it
    if ($header != null) {
        header($header);
    }
    if (!function_exists('imagecreate') || !function_exists('imagestring')) {
        print $str;
        exit;
    }
    $height = 200;
    $width = 700;
    $im = imagecreate($width, $height);
    $bg = imagecolorallocate($im, 255, 255, 255);
     list($item) = $items;
     $item_type_id = $item->getVar('item_type_id', 'n');
     $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
     $item_type =& $item_type_handler->get($item_type_id);
     if (is_null($item_type)) {
         image_error(500);
     }
     $viewphp = $item_type->getVar('viewphp', 'n');
     if (empty($viewphp)) {
         image_error(500);
     }
     include_once XOOPS_ROOT_PATH . '/modules/' . $itemtype['viewphp'];
     $fname_dllimit = "{$name}GetAttachmentDownloadLimitOption";
     if (function_exists($fname_dllimit) && $fname_dllimit($item_id) == 1) {
         /* require to confirm file download */
         image_error(403);
     }
 }
 $strip_mime_types = explode(';', $mime_type);
 $strip_mime_type = trim($strip_mime_types[0]);
 $show_mime_types = array('image/jpeg', 'image/png', 'image/gif', 'text/plain');
 if (in_array($strip_mime_type, $show_mime_types)) {
     // acceptable to show directly in the browser
     header("Content-Type: {$mime_type}");
     header("Content-Length: {$file_size}");
     readfile($file_path);
     exit;
 } else {
     // download file
     $download =& xoonips_getutility('download');
     if (!$download->check_pathinfo($file_name)) {