summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2006-12-25 08:53:57 +0100
committerAndrew Dolgov <[email protected]>2006-12-25 08:53:57 +0100
commitbe832a1a56afd70a6281d65b58fb11def9f0257b (patch)
tree52cb6970de5c6eb2c568bb586b4da7ff40124a6c /functions.php
parent8fd2dc95ba734a8d44d03c01ca1922aff0d5da2a (diff)
drop BACKEND_RSS_TYPE from update_rss_feed, support detection of dc:subject as tags in Atom feeds
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php177
1 files changed, 98 insertions, 79 deletions
diff --git a/functions.php b/functions.php
index 527a34d05..e4400cad4 100644
--- a/functions.php
+++ b/functions.php
@@ -488,91 +488,98 @@
foreach ($iterator as $item) {
- if (RSS_BACKEND_TYPE == "magpie") {
-
- $entry_guid = $item["id"];
-
- if (!$entry_guid) $entry_guid = $item["guid"];
- if (!$entry_guid) $entry_guid = $item["link"];
- if (!$entry_guid) $entry_guid = make_guid_from_title($item["title"]);
-
- if (!$entry_guid) continue;
-
- $entry_timestamp = "";
+ $entry_guid = $item["id"];
- $rss_2_date = $item['pubdate'];
- $rss_1_date = $item['dc']['date'];
- $atom_date = $item['issued'];
- if (!$atom_date) $atom_date = $item['updated'];
+ if (!$entry_guid) $entry_guid = $item["guid"];
+ if (!$entry_guid) $entry_guid = $item["link"];
+ if (!$entry_guid) $entry_guid = make_guid_from_title($item["title"]);
+
+ if (!$entry_guid) continue;
+
+ $entry_timestamp = "";
+
+ $rss_2_date = $item['pubdate'];
+ $rss_1_date = $item['dc']['date'];
+ $atom_date = $item['issued'];
+ if (!$atom_date) $atom_date = $item['updated'];
+
+ if ($atom_date != "") $entry_timestamp = parse_w3cdtf($atom_date);
+ if ($rss_1_date != "") $entry_timestamp = parse_w3cdtf($rss_1_date);
+ if ($rss_2_date != "") $entry_timestamp = strtotime($rss_2_date);
- if ($atom_date != "") $entry_timestamp = parse_w3cdtf($atom_date);
- if ($rss_1_date != "") $entry_timestamp = parse_w3cdtf($rss_1_date);
- if ($rss_2_date != "") $entry_timestamp = strtotime($rss_2_date);
-
- if ($entry_timestamp == "") {
- $entry_timestamp = time();
- $no_orig_date = 'true';
- } else {
- $no_orig_date = 'false';
- }
-
- $entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
-
- $entry_title = trim(strip_tags($item["title"]));
-
- // strange Magpie workaround
- $entry_link = $item["link_"];
- if (!$entry_link) $entry_link = $item["link"];
-
- if (!$entry_title) continue;
+ if ($entry_timestamp == "") {
+ $entry_timestamp = time();
+ $no_orig_date = 'true';
+ } else {
+ $no_orig_date = 'false';
+ }
+
+ $entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
+
+ $entry_title = trim(strip_tags($item["title"]));
+
+ // strange Magpie workaround
+ $entry_link = $item["link_"];
+ if (!$entry_link) $entry_link = $item["link"];
+
+ if (!$entry_title) continue;
# if (!$entry_link) continue;
- $entry_link = strip_tags($entry_link);
+ $entry_link = strip_tags($entry_link);
- $entry_content = $item["content:escaped"];
-
- if (!$entry_content) $entry_content = $item["content:encoded"];
- if (!$entry_content) $entry_content = $item["content"];
- if (!$entry_content) $entry_content = $item["atom_content"];
- if (!$entry_content) $entry_content = $item["summary"];
- if (!$entry_content) $entry_content = $item["description"];
-
- // if (!$entry_content) continue;
-
- // WTF
- if (is_array($entry_content)) {
- $entry_content = $entry_content["encoded"];
- if (!$entry_content) $entry_content = $entry_content["escaped"];
- }
-
- // print_r($item);
- // print_r(htmlspecialchars($entry_content));
- // print "<br>";
-
- $entry_content_unescaped = $entry_content;
- $content_hash = "SHA1:" . sha1(strip_tags($entry_content));
-
- $entry_comments = strip_tags($item["comments"]);
+ $entry_content = $item["content:escaped"];
- $entry_author = db_escape_string(strip_tags($item['dc']['creator']));
+ if (!$entry_content) $entry_content = $item["content:encoded"];
+ if (!$entry_content) $entry_content = $item["content"];
+ if (!$entry_content) $entry_content = $item["atom_content"];
+ if (!$entry_content) $entry_content = $item["summary"];
+ if (!$entry_content) $entry_content = $item["description"];
- if (!$entry_author) {
- $entry_author = db_escape_string(strip_tags($item['author']));
- }
+// if (!$entry_content) continue;
- $entry_guid = db_escape_string(strip_tags($entry_guid));
-
- $result = db_query($link, "SELECT id FROM ttrss_entries
- WHERE guid = '$entry_guid'");
-
- $entry_content = db_escape_string($entry_content);
- $entry_title = db_escape_string($entry_title);
- $entry_link = db_escape_string($entry_link);
- $entry_comments = db_escape_string($entry_comments);
-
- $num_comments = db_escape_string($item["slash"]["comments"]);
-
- if (!$num_comments) $num_comments = 0;
+ // WTF
+ if (is_array($entry_content)) {
+ $entry_content = $entry_content["encoded"];
+ if (!$entry_content) $entry_content = $entry_content["escaped"];
+ }
+
+// print_r($item);
+// print_r(htmlspecialchars($entry_content));
+// print "<br>";
+
+ $entry_content_unescaped = $entry_content;
+ $content_hash = "SHA1:" . sha1(strip_tags($entry_content));
+
+ $entry_comments = strip_tags($item["comments"]);
+
+ $entry_author = db_escape_string(strip_tags($item['dc']['creator']));
+
+ if (!$entry_author) {
+ $entry_author = db_escape_string(strip_tags($item['author']));
+ }
+
+ $entry_guid = db_escape_string(strip_tags($entry_guid));
+
+ $result = db_query($link, "SELECT id FROM ttrss_entries
+ WHERE guid = '$entry_guid'");
+
+ $entry_content = db_escape_string($entry_content);
+ $entry_title = db_escape_string($entry_title);
+ $entry_link = db_escape_string($entry_link);
+ $entry_comments = db_escape_string($entry_comments);
+
+ $num_comments = db_escape_string($item["slash"]["comments"]);
+
+ if (!$num_comments) $num_comments = 0;
+
+ $dc_subject = $item['dc']['subject'];
+
+ $subject_tags = false;
+
+ if (is_array($dc_subject)) {
+ $subject_tags = $dc_subject;
+ } else if ($dc_subject) {
+ $subject_tags = array($dc_subject);
}
# sanitize content
@@ -761,8 +768,16 @@
$manual_tags = trim_array(split(",", $filter_param));
- foreach ($manual_tags as $tag) {
- if (!preg_match("/^[0-9]*$/", $tag) && $tag != '') {
+ foreach ($manual_tags as $tag) {
+ if (tag_is_valid($tag)) {
+ array_push($entry_tags, $tag);
+ }
+ }
+ }
+
+ if ($subject_tags) {
+ foreach ($subject_tags as $tag) {
+ if (tag_is_valid($tag)) {
array_push($entry_tags, $tag);
}
}
@@ -3112,4 +3127,8 @@
return $tmp;
}
+ function tag_is_valid($tag) {
+ return ($tag !='' && !preg_match("/^[0-9]*$/", $tag));
+ }
+
?>