[2] | 1 | <?php |
---|
[5509] | 2 | /*************************************************************************** |
---|
| 3 | * Expresso Livre * |
---|
| 4 | * http://www.expressolivre.org * |
---|
| 5 | * -------------------------------------------- * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 7 | * under the terms of the GNU General Public License as published by the * |
---|
| 8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 9 | * option) any later version. * |
---|
| 10 | \**************************************************************************/ |
---|
| 11 | |
---|
[4416] | 12 | /* |
---|
| 13 | * Requieres |
---|
| 14 | */ |
---|
| 15 | require_once '../../header.session.inc.php'; |
---|
[5316] | 16 | require_once dirname(__FILE__).'/class.attachment.inc.php'; |
---|
[4416] | 17 | //------------------------// |
---|
[1040] | 18 | |
---|
[4416] | 19 | /* |
---|
| 20 | * Get variables |
---|
| 21 | */ |
---|
| 22 | $fileType = $_GET['file_type']; |
---|
| 23 | $msgFolder = $_GET['msg_folder']; |
---|
| 24 | $msgNumber = $_GET['msg_num']; |
---|
| 25 | $part = $_GET['msg_part']; |
---|
| 26 | //-------------------------------------// |
---|
[2] | 27 | |
---|
[178] | 28 | |
---|
[4416] | 29 | /* |
---|
| 30 | * Main |
---|
| 31 | */ |
---|
| 32 | $attachmentObj = new attachment(); |
---|
| 33 | $attachmentObj->setStructureFromMail($msgFolder, $msgNumber); |
---|
| 34 | $fileContent = $attachmentObj->getAttachment($part); |
---|
| 35 | $pic = @imagecreatefromstring($fileContent); |
---|
| 36 | if($pic !== FALSE) |
---|
| 37 | { |
---|
| 38 | header("Content-Type: ".$fileType); |
---|
| 39 | header("Content-Disposition: inline"); |
---|
| 40 | $width = imagesx($pic); |
---|
| 41 | $height = imagesy($pic); |
---|
| 42 | $twidth = 160; # width of the thumb 160 pixel |
---|
| 43 | $theight = $twidth * $height / $width; # calculate height |
---|
| 44 | $theight = $theight < 1 ? 1 : $theight; |
---|
| 45 | $thumb = imagecreatetruecolor ($twidth, $theight); |
---|
| 46 | imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb |
---|
| 47 | imagejpeg($thumb,"",75); # Thumbnail as JPEG |
---|
| 48 | } |
---|
| 49 | //------------------------------------------// |
---|
[1037] | 50 | ?> |
---|