db->QueryObject("SELECT LOGIN,AUTHTYPE FROM OOPS_USERS WHERE ID = '".$UID."'"); $AUTH = $USER->AUTHTYPE; $USR = $USER->LOGIN; if(!$USER) { $USR = $UID; $AUTH = USER_AUTH_LDAP; } function Calculate($src) { global $CALC; if(empty($CALC)) return $src; $WW = 70; $HH = 70; $W = imagesx($src); $H = imagesy($src); $delta = $W / $H; $NW = $WW; $NH = @intval($NW / $delta); if($NH > $HH) { $resize = $NH / $HH; $NW = $NW / $resize; $NH = $HH; } $dst = imagecreatetruecolor($NW,$NH); imagecopyresized($dst,$src,0,0,0,0,$NW,$NH,$W,$H); $black = imagecolorallocate($dst,0,0,0); $white = imagecolorallocate($dst,255,255,255); $W = imagesx($dst); $H = imagesy($dst); imagerectangle($dst,0,0,$W-1,$H-1,$black); imagerectangle($dst,1,1,$W-2,$H-2,$white); return $dst; } switch($AUTH) { case USER_AUTH_LDAP: if(file_exists("./foto/cache/".$USR.".jpg")) { $src = ImageCreateFromJPEG("./foto/cache/".$USR.".jpg"); $dst = Calculate($src); ImageJPEG($dst); } else { $ldap_con=@ldap_connect($LDAP_SRV); if(!$ldap_con) { OOPSCrash(3001,array("LDAP Server" => $LDAP_SRV)); } ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldap_con, LDAP_OPT_REFERRALS, 0); $ldap_bind=@ldap_bind($ldap_con,$LDAP_RDN,$LDAP_PASS); if(!$ldap_bind) { OOPSCrash(3002,array("LDAP RDN" => $LDAP_RDN)); } $justthese = array("dn", "thumbnailphoto"); $search_result=@ldap_search($ldap_con,"DC=billing,DC=ru", "(&(objectCategory=Person)(objectClass=user)(sAMAccountName=".$USR."))", $justthese); $info = @ldap_first_entry($ldap_con, $search_result); $pic = @ldap_get_values_len($ldap_con,$info,"thumbnailphoto"); if ($pic) { $img = ImageCreateFromString($pic[0]); ImageJPEG($img,"./foto/cache/".$USR.".jpg"); $dst = Calculate($img); ImageJPEG($dst); } else { $src = ImageCreateFromGIF("./i/nobody.gif"); $dst = Calculate($src); ImageJPEG($dst); } ldap_close($ldap_con); } break; case USER_AUTH_STANDART: if(file_exists("./foto/cache/".$UID.".jpg")) { $src = ImageCreateFromJPEG("./foto/cache/".$UID.".jpg"); $dst = Calculate($src); ImageJPEG($dst); } else { $src = ImageCreateFromGIF("./i/nobody.gif"); $dst = Calculate($src); ImageJPEG($dst); } break; } OOPSExit(); ?>