source: companies/serpro/expressoMail1_2/inc/show_user_photo.php @ 903

Revision 903, 2.0 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

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