1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * Expresso - Expresso Messenger * |
---|
4 | * - Alexandre Correia / Rodrigo Souza * |
---|
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 | class WebService |
---|
13 | { |
---|
14 | function __construct() |
---|
15 | { |
---|
16 | require_once("../../header.session.inc.php"); |
---|
17 | } |
---|
18 | |
---|
19 | public final function getPhoto($pUid) |
---|
20 | { |
---|
21 | require_once("class.LdapIM.inc.php"); |
---|
22 | |
---|
23 | $ldap = new LdapIM(); |
---|
24 | |
---|
25 | $uid = $pUid; |
---|
26 | if( strpos($pUid, "/") ) |
---|
27 | $uid = substr($pUid, 0, strpos($pUid, "/")); |
---|
28 | |
---|
29 | $photo = $ldap->getPhotoUser($uid ); |
---|
30 | |
---|
31 | if( $photo ) |
---|
32 | $photo = imagecreatefromstring($photo); |
---|
33 | else |
---|
34 | $photo = imagecreatefrompng("../templates/default/images/photo.png"); |
---|
35 | |
---|
36 | header("Content-Type: image/jpeg"); |
---|
37 | $width = imagesx($photo); |
---|
38 | $height = imagesy($photo); |
---|
39 | $twidth = 60; |
---|
40 | $theight = 80; |
---|
41 | $small_photo = imagecreatetruecolor ($twidth, $theight); |
---|
42 | imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); |
---|
43 | imagejpeg($small_photo,'',100); |
---|
44 | |
---|
45 | return; |
---|
46 | } |
---|
47 | |
---|
48 | public final function getPhotoSession($pUid, $pOu) |
---|
49 | { |
---|
50 | $uid = $pUid; |
---|
51 | if( strpos($pUid, "@") ) |
---|
52 | $uid = substr($pUid, 0, strpos($pUid, "@")); |
---|
53 | |
---|
54 | if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) ) |
---|
55 | { |
---|
56 | $photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]); |
---|
57 | |
---|
58 | header("Content-Type: image/jpeg"); |
---|
59 | $width = imagesx($photo); |
---|
60 | $height = imagesy($photo); |
---|
61 | $twidth = 60; |
---|
62 | $theight = 80; |
---|
63 | $small_photo = imagecreatetruecolor ($twidth, $theight); |
---|
64 | imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); |
---|
65 | imagejpeg($small_photo,'',100); |
---|
66 | |
---|
67 | unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]); |
---|
68 | |
---|
69 | return; |
---|
70 | } |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | // Photo in Session |
---|
75 | if(trim($_REQUEST['photo_session']) != "") |
---|
76 | { |
---|
77 | $obj = new WebService(); |
---|
78 | $ou = $_REQUEST['ou']; |
---|
79 | $jid = $_REQUEST['photo_session']; |
---|
80 | |
---|
81 | $obj->getPhotoSession($jid, $ou); |
---|
82 | } |
---|
83 | |
---|
84 | // Photo Ldap |
---|
85 | if(trim($_REQUEST['photo_ldap'])) |
---|
86 | { |
---|
87 | $obj = new WebService(); |
---|
88 | $jid = $_REQUEST['photo_ldap']; |
---|
89 | $obj->getPhoto($jid); |
---|
90 | } |
---|
91 | |
---|
92 | ?> |
---|