source: branches/2.2/expressoMail1_2/inc/show_thumbs.php @ 3018

Revision 3018, 1.5 KB checked in by amuller, 14 years ago (diff)

Ticket #1135 - Aplicando alterações do branches 2.0 no branches 2.2

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2
3        require_once '../../header.session.inc.php';
4        $username = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
5        $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
6        $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
7        $imap_port      = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
8        if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes')
9        {
10                $imap_options = '/tls/novalidate-cert';
11        }
12        else
13        {
14                $imap_options = '/notls/novalidate-cert';
15        }
16
17        $file_type = $_GET['file_type'];
18        $msg_num = $_GET['msg_num'];
19        $msg_part = $_GET['msg_part'];
20        $msg_folder = $_GET['msg_folder'];
21        $msg_folder = mb_convert_encoding($msg_folder,"UTF7-IMAP", mb_detect_encoding($msg_folder, "UTF-8, ISO-8859-1", true));
22        $mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);
23
24        $image_mail = imap_fetchbody($mb, $msg_num, $msg_part, FT_UID);
25        $image = imap_base64($image_mail);
26        $pic = @imagecreatefromstring ($image);
27        if($pic !== FALSE) {
28                header("Content-Type: ".$file_type);
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?>
Note: See TracBrowser for help on using the repository browser.