--- a/class.Address_Book_File.php Wed Oct 26 20:56:15 2011 +0200
+++ b/class.Address_Book_File.php Wed Oct 26 21:44:35 2011 +0200
@@ -1,5 +1,5 @@
<?
-require "interface.Address_Book.php";
+require_once "interface.Address_Book.php";
class Address_Book_File implements Address_Book {
const RS = "\n";
@@ -37,21 +37,21 @@
$new = array();
foreach($fields as $key) {
if (!isset($entry[$key])) return;
- $new[$key] = $entry[$key];
- trim($new[$key]);
- preg_replace('/['.self::RS.self::FS.' ]+/', ' ', $new[$key]);
+ $new[$key] = trim($entry[$key]);
+ $new[$key] = preg_replace('/['.self::RS.self::FS.' ]+/', ' ', $new[$key]);
if (empty($new[$key])) return;
}
flock($this->fh, LOCK_EX);
fputs($this->fh, join(self::FS, $new) . self::RS);
flock($this->fh, LOCK_UN);
- header("Location: $_SERVER[PHP_SELF]?action=add");
- exit;
}
public function search_entries($pattern) {
+ $pattern = trim($pattern);
+ if (empty($pattern)) return array();
fseek($this->fh, 0, SEEK_SET);
+ $pattern = preg_replace('|/|', '\/', $pattern);
$entries = array();
while ($line = stream_get_line($this->fh, 0, self::RS)) {
if ($line === FALSE) break;