[Phplib-commit] CVS: php-lib/php ct_ldap.inc,1.5,1.6
Brought to you by:
nhruby,
richardarcher
From: Richard A. <ric...@us...> - 2001-08-27 10:16:43
|
Update of /cvsroot/phplib/php-lib/php In directory usw-pr-cvs1:/tmp/cvs-serv8035 Modified Files: ct_ldap.inc Log Message: Commit changes from Dimitry Gashinsky. This is completely untested -- bug reports and patches welcome. Dimitry wrote: I noticed that ct_ldap.inc container class was broken. I fixed it and it works on my machine with horde and imp. Index: ct_ldap.inc =================================================================== RCS file: /cvsroot/phplib/php-lib/php/ct_ldap.inc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ct_ldap.inc 2000/04/13 13:28:45 1.5 --- ct_ldap.inc 2001/08/27 10:16:39 1.6 *************** *** 1,4 **** <? - ## NOTE: THESE FILES WILL MOVE! ## ## Copyright (c) 1999 Sascha Schumann <sa...@sc...> --- 1,3 ---- *************** *** 15,20 **** var $ldap_host = "localhost"; var $ldap_port = 389; ! var $basedn = "dc=your-domain, dc=com"; ! var $rootdn = "cn=root, dc=your-domain, dc=com"; var $rootpw = "secret"; var $objclass = "phplibdata"; --- 14,19 ---- var $ldap_host = "localhost"; var $ldap_port = 389; ! var $basedn = "dc=comapny, dc=com"; ! var $rootdn = "cn=root, dc=comapny, dc=com"; var $rootpw = "secret"; var $objclass = "phplibdata"; *************** *** 39,73 **** } function ac_store($id, $name, $str) { ! $dn = "cn=$id_$name, ".$this->basedn; $entry = array( ! "cn" => "$id_$name", "str" => $str, ! "objectclass" => $this->objclass ); if(!@ldap_modify($this->ds, $dn, $entry)) { if(!ldap_add($this->ds, $dn, $entry)) { ! $this->ac_halt("LDAP add failed"); } } } function ac_delete($id, $name) { ! ldap_delete($this->ds, "cn=$id_$name, ".$this->basedn); } function ac_get_value($id, $name) { ! $sr = ldap_search($this->ds, $this->basedn, "cn=$id_$name"); ! $inf = ldap_get_entries($this->ds, $sr); ! $str = $inf[0]["str"][0]; ldap_free_result($sr); return $str; } ! function ac_release_lock($name, $sid) { } ! function ac_get_lock($name, $sid) { } --- 38,90 ---- } + function ac_gc($gc_time, $name) { + $timeout =time(); + $ldapdate =date("YmdHis", $timeout - ($gc_time * 60)); + $sr =ldap_search($this->ds, $this->basedn, "(&(cn=*_$name)(modifytimestamp<=$ldapdate))"); + $inf =ldap_get_entries($this->ds, $sr); + for ($i=0; $i<$inf["count"];$i++) { + ldap_delete($this->ds, $inf[$i]["dn"]); + } + ldap_free_result($sr); + } + function ac_store($id, $name, $str) { ! $ret = true; ! $ldapdate =date("YmdHis", time()); ! $dn = "cn=${id}_$name, ".$this->basedn; $entry = array( ! "cn" => "${id}_$name", "str" => $str, ! "objectclass" => $this->objclass, ! "modifytimestamp" => $ldapdate ); if(!@ldap_modify($this->ds, $dn, $entry)) { if(!ldap_add($this->ds, $dn, $entry)) { ! $ret =false; } } + return $ret; } function ac_delete($id, $name) { ! ldap_delete($this->ds, "cn=${id}_$name, ".$this->basedn); } function ac_get_value($id, $name) { ! $str =""; ! $sr =ldap_search($this->ds, $this->basedn, "cn=${id}_$name"); ! $inf =ldap_get_entries($this->ds, $sr); ! if ($inf["count"] > 0 && $inf[0]["str"]["count"] > 0) { ! $str =$inf[0]["str"][0]; ! } ldap_free_result($sr); return $str; } ! function ac_release_lock() { } ! function ac_get_lock() { } |