~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to functions/abook_ldap_server.php

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst, Jeroen van Wolffelaar, Thijs Kinkhorst
  • Date: 2005-08-15 21:06:00 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050815210600-qxvat452exjqg64j
Tags: 2:1.4.5-2
[ Jeroen van Wolffelaar ]
* Restore squirrelmail-configure manpage, accidently dropped in -1
* Use debhelper compat level 4

[ Thijs Kinkhorst ]
* Drop obsolete symlink for attachment dir.
* Do not ship upstream README, which contains hardly any information
  relevant to Debian. Extend README.Debian a bit. Thanks W. Borgert.
* Add years to copyright statement.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *
8
8
 * Address book backend for LDAP server
9
9
 *
10
 
 * @version $Id: abook_ldap_server.php,v 1.18.2.5 2004/12/27 15:03:42 kink Exp $
 
10
 * @version $Id: abook_ldap_server.php,v 1.18.2.7 2005/06/22 14:23:10 tokul Exp $
11
11
 * @package squirrelmail
12
12
 * @subpackage addressbook
13
13
 */
231
231
        }
232
232
    }
233
233
 
 
234
    /**
 
235
     * Sanitizes ldap search strings.
 
236
     * See rfc2254
 
237
     * @link http://www.faqs.org/rfcs/rfc2254.html
 
238
     * @since 1.5.1 and 1.4.5
 
239
     * @param string $string
 
240
     * @return string sanitized string
 
241
     */
 
242
    function ldapspecialchars($string) {
 
243
        $sanitized=array('\\' => '\5c',
 
244
                         '*' => '\2a',
 
245
                         '(' => '\28',
 
246
                         ')' => '\29',
 
247
                         "\x00" => '\00');
 
248
 
 
249
        return str_replace(array_keys($sanitized),array_values($sanitized),$string);
 
250
    }
234
251
 
235
252
    /* ========================== Public ======================== */
236
253
 
240
257
     * @return array search results
241
258
     */
242
259
    function search($expr) {
243
 
 
244
260
        /* To be replaced by advanded search expression parsing */
245
261
        if(is_array($expr)) return false;
246
262
 
247
263
        /* Encode the expression */
248
264
        $expr = $this->charset_encode($expr);
249
 
        if(strstr($expr, '*') === false) {
250
 
            $expr = "*$expr*";
 
265
 
 
266
        /*
 
267
         * allow use of one asterisk in search. 
 
268
         * Don't allow any ldap special chars if search is different
 
269
         */
 
270
        if($expr!='*') {
 
271
            $expr = '*' . $this->ldapspecialchars($expr) . '*';
 
272
            /* Undo sanitizing of * symbol */
 
273
            $expr = str_replace('\2a','*',$expr);
251
274
        }
252
275
        $expression = "cn=$expr";
253
276