jabberName = $handle['jabberName']; $this->serverLdap = $handle['serverLdap']; $this->contextLdap = $handle['contextLdap']; $this->userDn = $handle['user']; $this->passwd = $handle['password']; $this->refer = true; $this->version3 = true; } private final function ldapConnect() { if(!function_exists('ldap_connect')) return False; if(!$this->conn = ldap_connect($this->serverLdap)) return False; if( $this->version3 ) if( !ldap_set_option($this->conn,LDAP_OPT_PROTOCOL_VERSION,3) ) $this->version = false; ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $this->refer); // Bind as Admin if($this->userDn && $this->passwd && !ldap_bind($this->conn, $this->userDn, $this->passwd)) return False; // Bind as Anonymous if(!$this->userDn && !$this->passwd && !@ldap_bind($this->conn)) return False; } private final function ldapConnectExternal($pHostJabber) { require_once('confLDAPExternal.php'); $handle = unserialize(base64_decode($LDAP_EXTERNAL)); foreach($handle as $itens) if(trim($pHostJabber) == $itens['jabberName']) { $this->jabberName = $itens['jabberName']; $this->serverLdap = $itens['serverLdap']; $this->contextLdap = $itens['contextLdap']; $this->userDn = $itens['user']; $this->passwd = $itens['password']; } $this->refer = true; $this->version3 = true; $this->ldapConnect(); } public final function getNameOrganization($pJid, $pCharset) { $uid = substr($pJid, 0, strpos($pJid,"@")); if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 ))) { $this->ldapConnect(); if( $this->conn ) { $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; $justthese = array("uid","cn","dn"); $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); $entry = ldap_get_entries($this->conn,$search); $cn = $entry[0]['cn'][0]; $ou = explode("dc=", $entry[0]['dn']); $ou = explode("ou=",$ou[0]); $ou = array_pop($ou); $dn = strtoupper(substr($ou,0,strlen($ou)-1)); $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); } } else { $this->ldapConnectExternal(substr($pJid, strpos($pJid, "@") + 1 )); if( $this->conn ) { $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; $justthese = array("uid","cn","dn"); $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); $entry = ldap_get_entries($this->conn,$search); $cn = $entry[0]['cn'][0]; $ou = explode("dc=", $entry[0]['dn']); $ou = explode("ou=",$ou[0]); $ou = array_pop($ou); $dn = strtoupper(substr($ou,0,strlen($ou)-1)); $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); } } if( $pCharset === "1" ) return $return; else return mb_convert_encoding($return, "ISO-8859-1", "UTF-8"); $return = utf8_encode("Nome : Não Identificado ;Organização : Não Identificado"); if( $pCharset === 1 ) return $return; else return mb_convert_encoding($return, "ISO-8859-1", "UTF-8"); } public final function getPhotoLdap($pJid) { $uid = substr($pJid, 0, strpos($pJid,"@")); if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 ))) { $this->ldapConnect(); if( $this->conn ) { $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; $justthese = array("uid","jpegPhoto"); $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); $entry1 = ldap_get_entries($this->conn,$search); $entry = ldap_first_entry( $this->conn, $search ); if( $entry1['count'] > 0 ) { $i = 0; $photo = ""; $return_photo = ""; $photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto'); if ($photo) $return_photo = $photo[0]; return $return_photo; } } } else { $jabberName = substr($pJid, strpos($pJid, "@") + 1 ); if( strpos($jabberName, "/") ) $jabberName = substr($jabberName, 0, strpos($jabberName, "/")); $this->ldapConnectExternal($jabberName); if( $this->conn ) { $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; $justthese = array("uid","jpegPhoto"); $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); $entry1 = ldap_get_entries($this->conn,$search); $entry = ldap_first_entry( $this->conn, $search ); if( $entry1['count'] > 0 ) { $i = 0; $photo = ""; $return_photo = ""; $photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto'); if ($photo) $return_photo = $photo[0]; return $return_photo; } } } return false; } public final function getPhotoSession($pUid, $pOu) { $uid = $pUid; if( strpos($pUid, "@") ) $uid = substr($pUid, 0, strpos($pUid, "@")); if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) ) { $photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]); header("Content-Type: image/jpeg"); $width = imagesx($photo); $height = imagesy($photo); $twidth = 60; $theight = 80; $small_photo = imagecreatetruecolor ($twidth, $theight); imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height); imagejpeg($small_photo,'',100); unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]); return; } } } if(trim($_REQUEST['javaPhoto']) != "" ) { $obj = new webService(); $jid = $_REQUEST['javaPhoto']; $photo = $obj->getPhotoLdap($jid); $photoWidth = 70; $photoHeight = 90; $newImage = imagecreatetruecolor($photoWidth,$photoHeight); if( $photo ) { $photo = imagecreatefromstring($photo); imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); } else { $photo = @imagecreatefrompng("../templates/default/images/photo.png"); imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); } ob_start(); imagepng($newImage); $imagePhoto = ob_get_contents(); imagedestroy($newImage); ob_end_clean(); printf("%s",base64_encode($imagePhoto)); } if(trim($_POST['jid']) != "") { $jid = trim($_POST['jid']); $charset = trim($_POST['charset']); $obj = new webService(); printf("%s",$obj->getNameOrganization($jid, $charset)); } if(trim($_REQUEST['phpPhoto']) != "") { $obj = new webservice(); $ou = $_REQUEST['phpOu']; $jid = $_REQUEST['phpPhoto']; $obj->getPhotoSession($jid, $ou); } ?>