addressbook.class.php
changeset 7 47446e75ceea
parent 6 48ffdc97f54b
--- a/addressbook.class.php	Wed Oct 26 00:37:13 2011 +0200
+++ b/addressbook.class.php	Wed Oct 26 00:56:32 2011 +0200
@@ -18,8 +18,7 @@
 
     function __construct($file) {
 	@mkdir(dirname($file));
-	@$this->fh = fopen($file, "a+b");
-	if (!$this->fh) throw new Address_Book_Exception("Can't open address book.");
+	$this->fh = fopen($file, "a+b");
 	flock($this->fh, LOCK_EX);
 	$stat = fstat($this->fh);
 	if ($stat['size'] == 0) {
@@ -61,7 +60,9 @@
     function search_entries($pattern) {
 	$pattern = trim($pattern);
 	if (empty($pattern)) return;
-	$pattern = preg_replace('/\//', '\/', $pattern);
+	//$pattern = preg_replace('/\//', '\/', $pattern);
+	if (preg_match('/\//', $pattern))
+	    throw new Address_Book_Exception("Pattern must not contain '/'");
 	fseek($this->fh, 0, SEEK_SET);
 	$entries = array();
 	while ($line = stream_get_line($this->fh, 0, self::RS)) {