handle = unserialize(base64_decode($CONF_SERVER)); $this->host = $this->handle['host']; $this->context = $this->handle['context']; $this->dn = $this->handle['dn']; $this->passwd = $this->handle['passwd']; $this->refer = false; $this->version3 = true; } private final function ldap_rebind($ldap_connection, $ldap_url) { @ldap_bind($ldap_connection, $this->user_referral, $this->password_referral); } private final function ldapConnect() { if(!function_exists('ldap_connect')) { printf("Erro : Ldap Não suportado %s
" , $this->host); return False; } if(!$this->conn = ldap_connect($this->host)) { printf("Erro: não pode conectar no servidor ldap %s!
", $this->host); 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); // verifica refer if( $this->refer ) { $this->user_referral = $this->dn; $this->password_referral = $this->passwd; @ldap_set_rebind_proc($this->conn, $this->ldap_rebind); } // bind as admin if($this->dn && $this->passwd && !ldap_bind($this->conn, $this->dn, $this->passwd)){ echo "
ExpressoLivre indisponível no momento
"; return False; } // bind as anonymous if(!$this->dn && !$this->passwd && !@ldap_bind($this->conn)) { echo "
ExpressoLivre indisponível no momento
"; return False; } } public final function getPhotoLdap($uid) { $this->ldapConnect(); if( $this->conn ) { $filter = "(&(phpgwaccounttype=u)(uid=".$uid."))"; $justthese = array("uid","phpgwAccountVisible","jpegPhoto"); $search = ldap_search($this->conn,$this->context,$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 = ""; if ( $entry1[$i]['phpgwaccountvisible'][0] != '-1' ) { $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) { if(isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid])) { $photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid]); 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'][$pUid]); return; } } } if(trim($_REQUEST['uid']) != "") { $uid = trim($_REQUEST['uid']); $a = new ldapPhoto(); if( strpos($uid,"@")) { $uid = substr($uid, 0, strpos($uid,"@")); $photo = $a->getPhotoLdap($uid); $photoWidth = 70; $photoHeight = 90; $newImage = imagecreatetruecolor($photoWidth,$photoHeight); if($photo) { $photo = imagecreatefromstring($photo); $trans = imagecolortransparent($photo); imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); imagepng($newImage); imagedestroy($newImage); } else { $photo = @imagecreatefrompng("../templates/default/images/photo.png"); $trans = imagecolortransparent($photo); imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo)); imagepng($newImage); imagedestroy($newImage); } } else { $a->getPhotoSession($uid); } } ?>