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