From eb36b4eb5526fca5ea05b635d828e290687b4ea3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 9 Sep 2005 05:52:36 +0100 Subject: start work on support for technorati tags, schema uses cascade deletes for pgsql --- functions.php | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index c032364d7..f4628a812 100644 --- a/functions.php +++ b/functions.php @@ -269,12 +269,47 @@ $result = db_query($link, $query); } } - } - if ($result) { - $result = db_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()"); + /* taaaags */ + // , // + + $entry_tags = null; + + preg_match_all("/([^>]+)<\/a>/i", $entry_content, + $entry_tags); + + $entry_tags = $entry_tags[1]; + + if (count($entry_tags) > 0) { + + $result = db_query($link, "SELECT id FROM ttrss_entries + WHERE guid = '$entry_guid'"); + + if (!$result || db_num_rows($result) != 1) { + return; + } + + $entry_id = db_fetch_result($result, 0, "id"); + + foreach ($entry_tags as $tag) { + $tag = db_escape_string(strtolower($tag)); + + $result = db_query($link, "SELECT id FROM ttrss_tags + WHERE tag_name = '$tag' AND post_id = '$entry_id' LIMIT 1"); + + if ($result && db_num_rows($result) == 0) { + +// print "tagging $entry_id as $tag
"; + + db_query($link, "INSERT INTO ttrss_tags (tag_name,post_id) + VALUES ('$tag', '$entry_id')"); + } + } + } } + db_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()"); + } db_query($link, "COMMIT"); -- cgit v1.2.3-54-g00ecf