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

Revision 5509, 2.7 KB checked in by gustavo, 12 years ago (diff)

Ticket #2488 - Adicionar cabecalho de licenca em arquivos que nao o possuem

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