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