source: trunk/expressoMail1_2/inc/show_user_photo.php @ 1036

Revision 1036, 2.2 KB checked in by amuller, 15 years ago (diff)

Ticket #559 - Atualização de segurança

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        $GLOBALS['phpgw_info']['flags'] = array(
3                'currentapp' => 'expressoMail1_2',
4                'nonavbar'   => true,
5                'noheader'   => true
6        );
7
8        require_once $_SERVER[ 'DOCUMENT_ROOT' ] . '/header.inc.php';
9        function ldapRebind($ldap_connection, $ldap_url)
10        {
11                @ldap_bind($ldap_connection, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);
12        }
13
14        if ($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] == '')
15                exit;
16       
17        $mail = $_GET['mail'];
18       
19        if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$", $mail))
20                exit;
21       
22        $ldap_host      = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host'];
23        $ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
24       
25        $ldap_conn=ldap_connect($ldap_host);
26        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
27        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1);
28        ldap_set_rebind_proc($ldap_conn, ldapRebind);
29       
30        $r=ldap_bind($ldap_conn, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);
31       
32        if (!$r)
33        {
34                echo 'Sem BIND: ' . ldap_error ( $ldap_conn );
35                exit;
36        }
37
38        $justthese = array("jpegPhoto");
39        $filter="(mail=$mail)";
40        $search=ldap_search($ldap_conn, $ldap_context, $filter, $justthese);
41
42        $entry = ldap_first_entry($ldap_conn, $search);
43        $contact = ldap_get_attributes($ldap_conn, $entry);
44       
45        if($contact['jpegPhoto'])
46        {
47                $contact['jpegPhoto'] = ldap_get_values_len ($ldap_conn, $entry, "jpegPhoto");
48                $image = imagecreatefromstring ($contact['jpegPhoto'][0]);
49        }
50        else
51        {
52                $loadFile = "../templates/default/images/photo.png";
53                $image = imagecreatefrompng($loadFile);
54        }
55       
56        header("Content-Type: image/jpeg");
57       
58        $pic = $image;
59        if ($pic)
60        {
61                $width = imagesx($pic);
62                $height = imagesy($pic);
63                $twidth = 60; # width of the thumb 160 pixel
64                $theight = $twidth * $height / $width; # calculate height
65                $thumb = imagecreatetruecolor ($twidth, $theight);
66                imagecopyresampled($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb
67                imagejpeg($thumb,"",80); # Thumbnail as JPEG
68        }
69                                                                                                                   
70        ldap_close($ldap_conn);
71?>
Note: See TracBrowser for help on using the repository browser.