Ejemplo n.º 1
0
function SendSaveAsFileHeaderIfNeeded() {
	if (headers_sent()) {
		return false;
	}
	global $phpThumb;
	$downloadfilename = phpthumb_functions::SanitizeFilename(@$_GET['sia'] ? $_GET['sia'] : (@$_GET['down'] ? $_GET['down'] : 'phpThumb_generated_thumbnail'.(@$_GET['f'] ? $_GET['f'] : 'jpg')));
	if (@$downloadfilename) {
		$phpThumb->DebugMessage('SendSaveAsFileHeaderIfNeeded() sending header: Content-Disposition: '.(@$_GET['down'] ? 'attachment' : 'inline').'; filename="'.$downloadfilename.'"', __FILE__, __LINE__);
		header('Content-Disposition: '.(@$_GET['down'] ? 'attachment' : 'inline').'; filename="'.$downloadfilename.'"');
	}
	return true;
}
Ejemplo n.º 2
0
 function OutputThumbnail()
 {
     $this->purgeTempFiles();
     if (!$this->useRawIMoutput && !is_resource($this->gdimg_output)) {
         $this->DebugMessage('OutputThumbnail() failed because !is_resource($this->gdimg_output)', __FILE__, __LINE__);
         return false;
     }
     if (headers_sent()) {
         return $this->ErrorImage('OutputThumbnail() failed - headers already sent');
         exit;
     }
     $downloadfilename = phpthumb_functions::SanitizeFilename(is_string($this->sia) ? $this->sia : ($this->down ? $this->down : 'phpThumb_generated_thumbnail' . '.' . $this->thumbnailFormat));
     $this->DebugMessage('Content-Disposition header filename set to "' . $downloadfilename . '"', __FILE__, __LINE__);
     if ($downloadfilename) {
         header('Content-Disposition: ' . ($this->down ? 'attachment' : 'inline') . '; filename="' . $downloadfilename . '"');
     } else {
         $this->DebugMessage('failed to send Content-Disposition header because $downloadfilename is empty', __FILE__, __LINE__);
     }
     if ($this->useRawIMoutput) {
         header('Content-Type: ' . phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
         echo $this->IMresizedData;
     } else {
         $this->DebugMessage('ImageInterlace($this->gdimg_output, ' . intval($this->config_output_interlace) . ')', __FILE__, __LINE__);
         ImageInterlace($this->gdimg_output, intval($this->config_output_interlace));
         switch ($this->thumbnailFormat) {
             case 'jpeg':
                 header('Content-Type: ' . phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
                 $ImageOutFunction = 'image' . $this->thumbnailFormat;
                 @$ImageOutFunction($this->gdimg_output, '', $this->thumbnailQuality);
                 break;
             case 'png':
             case 'gif':
                 header('Content-Type: ' . phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
                 $ImageOutFunction = 'image' . $this->thumbnailFormat;
                 @$ImageOutFunction($this->gdimg_output);
                 break;
             case 'bmp':
                 if (!@(include_once dirname(__FILE__) . '/phpthumb.bmp.php')) {
                     $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.bmp.php" which is required for BMP format output', __FILE__, __LINE__);
                     return false;
                 }
                 $phpthumb_bmp = new phpthumb_bmp();
                 if (is_object($phpthumb_bmp)) {
                     $bmp_data = $phpthumb_bmp->GD2BMPstring($this->gdimg_output);
                     unset($phpthumb_bmp);
                     if (!$bmp_data) {
                         $this->DebugMessage('$phpthumb_bmp->GD2BMPstring() failed', __FILE__, __LINE__);
                         return false;
                     }
                     header('Content-Type: ' . phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
                     echo $bmp_data;
                 } else {
                     $this->DebugMessage('new phpthumb_bmp() failed', __FILE__, __LINE__);
                     return false;
                 }
                 break;
             case 'ico':
                 if (!@(include_once dirname(__FILE__) . '/phpthumb.ico.php')) {
                     $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.ico.php" which is required for ICO format output', __FILE__, __LINE__);
                     return false;
                 }
                 $phpthumb_ico = new phpthumb_ico();
                 if (is_object($phpthumb_ico)) {
                     $arrayOfOutputImages = array($this->gdimg_output);
                     $ico_data = $phpthumb_ico->GD2ICOstring($arrayOfOutputImages);
                     unset($phpthumb_ico);
                     if (!$ico_data) {
                         $this->DebugMessage('$phpthumb_ico->GD2ICOstring() failed', __FILE__, __LINE__);
                         return false;
                     }
                     header('Content-Type: ' . phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
                     echo $ico_data;
                 } else {
                     $this->DebugMessage('new phpthumb_ico() failed', __FILE__, __LINE__);
                     return false;
                 }
                 break;
             default:
                 $this->DebugMessage('OutputThumbnail failed because $this->thumbnailFormat "' . $this->thumbnailFormat . '" is not valid', __FILE__, __LINE__);
                 return false;
                 break;
         }
     }
     return true;
 }