From ed4760018fe8a60ab89e4bab58fde04faa4ccd0e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 27 Nov 2008 10:13:29 +0000 Subject: Minor fix: improve import from Netscape files (now takes description into account) git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@177 b3834d28-1941-0410-a4f8-b48e95affb8f --- services/bookmark2tagservice.php | 2 +- services/bookmarkservice.php | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'services') diff --git a/services/bookmark2tagservice.php b/services/bookmark2tagservice.php index 26a05c1..347df9c 100644 --- a/services/bookmark2tagservice.php +++ b/services/bookmark2tagservice.php @@ -42,7 +42,7 @@ class Bookmark2TagService { } //clean tags from strange characters - $tags = str_replace(array('"', '\''), "_", $tags); + $tags = str_replace(array('"', '\'', '/'), "_", $tags); $tags_count = is_array($tags)?count($tags):0; diff --git a/services/bookmarkservice.php b/services/bookmarkservice.php index 4c3cbca..ee7e169 100644 --- a/services/bookmarkservice.php +++ b/services/bookmarkservice.php @@ -92,10 +92,7 @@ class BookmarkService { return; } - // If address doesn't contain ":", add "http://" as the default protocol - if (strpos($address, ':') === false) { - $address = 'http://'. $address; - } + $address = $this->normalize($address); $crit = array ('bHash' => md5($address)); if (isset ($uid)) { @@ -117,13 +114,7 @@ class BookmarkService { $sId = $userservice->getCurrentUserId(); } - // If bookmark address doesn't contain ":", add "http://" to the start as a default protocol - if (strpos($address, ':') === false) { - $address = 'http://'. $address; - } - if (substr($address, -1) == '/') { - $address = substr($address, 0, count($address)-2); - } + $address = $this->normalize($address); // Get the client's IP address and the date; note that the date is in GMT. if (getenv('HTTP_CLIENT_IP')) @@ -462,6 +453,20 @@ class BookmarkService { } return $this->db->sql_fetchfield(0, 0) - 1; } + + function normalize($address) { + // If bookmark address doesn't contain ":", add "http://" to the start as a default protocol + if (strpos($address, ':') === false) { + $address = 'http://'. $address; + } + + // Delete final / + if (substr($address, -1) == '/') { + $address = substr($address, 0, count($address)-2); + } + + return $address; + } function deleteAll() { $query = 'TRUNCATE TABLE `'. $this->getTableName() .'`'; -- cgit v1.2.3