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

Revision 2360, 2.8 KB checked in by amuller, 14 years ago (diff)

Ticket #1008 - Adicionando informações sobre licenças

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2
3/***************************************************************************
4        * Expresso Livre                                                           *
5        * http://www.expressolivre.org                                             *
6        * --------------------------------------------                             *
7        *  This program is free software; you can redistribute it and/or modify it *
8        *  under the terms of the GNU General Public License as published by the   *
9        *  Free Software Foundation; either version 2 of the License, or (at your  *
10        *  option) any later version.                                              *
11        \**************************************************************************/
12
13        require_once '../../header.session.inc.php';
14
15
16        function ldapRebind($ldap_connection, $ldap_url)
17        {
18                @ldap_bind($ldap_connection, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);
19        }
20
21        if ($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] == '')
22                exit;
23       
24        $mail = $_GET['mail'];
25       
26        if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$", $mail))
27                exit;
28       
29        $ldap_host      = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host'];
30        $ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
31       
32        $ldap_conn=ldap_connect($ldap_host);
33        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
34        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1);
35        ldap_set_rebind_proc($ldap_conn, ldapRebind);
36       
37        $r=ldap_bind($ldap_conn, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);
38       
39        if (!$r)
40        {
41                echo 'Sem BIND: ' . ldap_error ( $ldap_conn );
42                exit;
43        }
44
45        $justthese = array("jpegPhoto");
46        $filter="(mail=$mail)";
47        $search=ldap_search($ldap_conn, $ldap_context, $filter, $justthese);
48
49        $entry = ldap_first_entry($ldap_conn, $search);
50        $contact = ldap_get_attributes($ldap_conn, $entry);
51       
52        if($contact['jpegPhoto'])
53        {
54                $contact['jpegPhoto'] = ldap_get_values_len ($ldap_conn, $entry, "jpegPhoto");
55                $image = imagecreatefromstring ($contact['jpegPhoto'][0]);
56        }
57        else
58        {
59                $loadFile = "../templates/default/images/photo.jpg";
60                $image = imagecreatefromjpeg($loadFile);
61        }
62       
63        header("Content-Type: image/jpeg");
64       
65        $pic = $image;
66        if ($pic)
67        {
68                $width = imagesx($pic);
69                $height = imagesy($pic);
70                $twidth = 60; # width of the thumb 160 pixel
71                $theight = $twidth * $height / $width; # calculate height
72                $thumb = imagecreatetruecolor ($twidth, $theight);
73                imagecopyresampled($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb
74                imagejpeg($thumb,"",80); # Thumbnail as JPEG
75        }
76                                                                                                                   
77        ldap_close($ldap_conn);
78?>
Note: See TracBrowser for help on using the repository browser.