X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fabook_local_file.php;h=309a48f0ae6934234df246548142f4820515d096;hb=6872a6750379b6c17cf6a6dfec6150ade78f52a0;hp=a37368a73dee6924bd849191a366e97b4b013e91;hpb=1977ab5587905d225c6288141b82f7a6e3d29d02;p=squirrelmail.git diff --git a/functions/abook_local_file.php b/functions/abook_local_file.php index a37368a7..309a48f0 100644 --- a/functions/abook_local_file.php +++ b/functions/abook_local_file.php @@ -3,7 +3,7 @@ /** * abook_local_file.php * - * @copyright 1999-2010 The SquirrelMail Project Team + * @copyright 1999-2018 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -92,11 +92,11 @@ class abook_local_file extends addressbook_backend { /* ========================== Private ======================= */ /** - * Constructor + * Constructor (PHP5 style, required in some future version of PHP) * @param array $param backend options * @return bool */ - function abook_local_file($param) { + function __construct($param) { $this->sname = _("Personal Address Book"); $this->umask = Umask(); @@ -139,6 +139,15 @@ class abook_local_file extends addressbook_backend { } } + /** + * Constructor (PHP4 style, kept for compatibility reasons) + * @param array $param backend options + * @return bool + */ + function abook_local_file($param) { + return self::__construct($param); + } + /** * Open the addressbook file and store the file pointer. * Use $file as the file to open, or the class' own @@ -274,10 +283,9 @@ class abook_local_file extends addressbook_backend { if ($expr=='*' && ! $this->listing) return array(); - /* Make regexp from glob'ed expression - * May want to quote other special characters like (, ), -, [, ], etc. */ - $expr = str_replace('?', '.', $expr); - $expr = str_replace('*', '.*', $expr); + // Make regexp from glob'ed expression + $expr = preg_quote($expr); + $expr = str_replace(array('\\?', '\\*'), array('.', '.*'), $expr); $res = array(); if(!$this->open()) { @@ -295,13 +303,15 @@ class abook_local_file extends addressbook_backend { $oTemplate->display('footer.tpl'); die(); } else { - $line = join(' ', $row); /** * TODO: regexp search is supported only in local_file backend. * Do we check format of regexp or ignore errors? */ // errors on preg_match call are suppressed in order to prevent display of regexp compilation errors - if(@preg_match('/' . $expr . '/i', $line)) { + if (@preg_match('/' . $expr . '/i', $row[0]) // nickname + || @preg_match('/' . $expr . '/i', $row[1]) // firstname + || @preg_match('/' . $expr . '/i', $row[2]) // lastname + || @preg_match('/' . $expr . '/i', $row[3])) { // email array_push($res, array('nickname' => $row[0], 'name' => $this->fullname($row[1], $row[2]), 'firstname' => $row[1],