note 104348 deleted from function.ldap-search by danbrown

From: Date: Fri, 10 Jun 2011 15:28:45 +0000
Subject: note 104348 deleted from function.ldap-search by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180420@lists.php.net to get a copy of this message
Note Submitter: DaveRandom ---- Building on ldap_escape() from douglass_davis at earthlink dot net: - This code is more succinct - Moved the backslash escape to the start of the queue, so it doesn't escape backslashes that are added by escaping other characters - This version is around 3 times faster (on Windows 2K3 R2 at least) This still does not cope with nested filters, but is quick and useful on systems where PEAR is not available/not practical. <?php function ldap_escape ($s, $d = FALSE) { return str_replace(($d) ? array('\\',',','=','+','<','>',';','"','#') : array('\\','*','(',')',chr(0)), ($d) ? array('\\5c','\\2c','\\3d','\\2b','\\3c','\\3e','\\3b','\\22','\\23') : array('\\5c','\\2a','\\28','\\29','\\00'), $s); } ?>

« previous php.notes (#180420) next »