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

Revision 37, 1.7 KB checked in by niltonneto, 17 years ago (diff)

Vide arquivo change_log.txt

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