News and Announcements > General Discussion
Truble LDAP Address Book
(1/1)
daemon17:
uname -sr
--- Quote ---FreeBSD 7.0-RELEASE-p3
--- End quote ---
php -v
--- Quote ---PHP 5.2.6 (cli) (built: Sep 17 2008 10:02:00)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
--- End quote ---
There is a problem at address display in LDAP.
If record in LDAP contains symbols in the russian coding, at BASE64 java-script badly fulfils it. :rolleyes:
Symbols "+" and "/" in BASE64 are badly processed java-script.
Contact is found but the address is not displayed. :eek:
This patch solves some problems
--- Code: ------ rcube_ldap.php.ORIG 2008-09-10 19:02:37.000000000 +0300
+++ rcube_ldap.php 2008-09-11 16:51:03.000000000 +0300
@@ -17,6 +17,34 @@
$Id: rcube_ldap.php 1482 2008-06-06 09:42:31Z alec $
*/
+function write_to_debug ($string)
+{
+ //$file=fopen ("/tmp/roundcube.dbg","a");
+ //fwrite ($file, $string."\n");
+ //fclose($file);
+}
+
+
+function fixed_base64_encode ($string )
+{
+ $result = base64_encode($string);
+ $result = preg_replace("/\+/","_", $result);
+ $result = preg_replace("/\//","-", $result);
+ write_to_debug ($string."\t".$result);
+ return $result;
+}
+
+function fixed_base64_decode ($string)
+{
+ //return base64_decode( preg_replace("/_/","+",preg_replace("/~/","/",$string)));
+ $result = preg_replace("/_/","+",$string);
+ $result = preg_replace("/-/",'/',$result);
+ $result = base64_decode( $result);
+ write_to_debug ($string."\t".$result);
+ return $result;
+
+}
+
/**
@@ -408,13 +436,13 @@
$res = null;
if ($this->conn && $dn)
{
- $this->ldap_result = @ldap_read($this->conn, base64_decode($dn), "(objectclass=*)", array_values($this->fieldmap));
+ $this->ldap_result = @ldap_read($this->conn, fixed_base64_decode($dn), "(objectclass=*)", array_values($this->fieldmap));
$entry = @ldap_first_entry($this->conn, $this->ldap_result);
if ($entry && ($rec = ldap_get_attributes($this->conn, $entry)))
{
// Add in the dn for the entry.
- $rec["dn"] = base64_decode($dn);
+ $rec["dn"] = fixed_base64_decode($dn);
$res = $this->_ldap2result($rec);
$this->result = new rcube_result_set(1);
$this->result->add($res);
@@ -461,7 +489,7 @@
return false;
} // end if
- return base64_encode($dn);
+ return fixed_base64_encode($dn);
}
@@ -508,7 +536,7 @@
} // end foreach
// Update the entry as required.
- $dn = base64_decode($id);
+ $dn = fixed_base64_decode($id);
if (!empty($deletedata)) {
// Delete the fields.
$res = @ldap_mod_del($this->conn, $dn, $deletedata);
@@ -551,7 +579,7 @@
} // end if
foreach ($dns as $id) {
- $dn = base64_decode($id);
+ $dn = fixed_base64_decode($id);
// Delete the record.
$res = @ldap_delete($this->conn, $dn);
if ($res === FALSE) {
@@ -589,7 +617,7 @@
$out = array();
if ($rec['dn'])
- $out[$this->primary_key] = base64_encode($rec['dn']);
+ $out[$this->primary_key] = fixed_base64_encode($rec['dn']);
foreach ($this->fieldmap as $rf => $lf)
{
--- End code ---
Navigation
[0] Message Index
Go to full version