[2] | 1 | <?php |
---|
[4416] | 2 | /* |
---|
| 3 | * Requieres |
---|
| 4 | */ |
---|
| 5 | require_once '../../header.session.inc.php'; |
---|
[5316] | 6 | require_once dirname(__FILE__).'/class.attachment.inc.php'; |
---|
[4416] | 7 | //------------------------// |
---|
[1040] | 8 | |
---|
[4416] | 9 | /* |
---|
| 10 | * Get variables |
---|
| 11 | */ |
---|
| 12 | $fileType = $_GET['file_type']; |
---|
| 13 | $msgFolder = $_GET['msg_folder']; |
---|
| 14 | $msgNumber = $_GET['msg_num']; |
---|
| 15 | $part = $_GET['msg_part']; |
---|
| 16 | //-------------------------------------// |
---|
[2] | 17 | |
---|
[178] | 18 | |
---|
[4416] | 19 | /* |
---|
| 20 | * Main |
---|
| 21 | */ |
---|
| 22 | $attachmentObj = new attachment(); |
---|
| 23 | $attachmentObj->setStructureFromMail($msgFolder, $msgNumber); |
---|
| 24 | $fileContent = $attachmentObj->getAttachment($part); |
---|
| 25 | $pic = @imagecreatefromstring($fileContent); |
---|
| 26 | if($pic !== FALSE) |
---|
| 27 | { |
---|
| 28 | header("Content-Type: ".$fileType); |
---|
| 29 | header("Content-Disposition: inline"); |
---|
| 30 | $width = imagesx($pic); |
---|
| 31 | $height = imagesy($pic); |
---|
| 32 | $twidth = 160; # width of the thumb 160 pixel |
---|
| 33 | $theight = $twidth * $height / $width; # calculate height |
---|
| 34 | $theight = $theight < 1 ? 1 : $theight; |
---|
| 35 | $thumb = imagecreatetruecolor ($twidth, $theight); |
---|
| 36 | imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb |
---|
| 37 | imagejpeg($thumb,"",75); # Thumbnail as JPEG |
---|
| 38 | } |
---|
| 39 | //------------------------------------------// |
---|
[1037] | 40 | ?> |
---|