From 5ba6852f28301c6cca7d3e19914aea00e64f9c00 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 15 Jul 2001 09:29:22 +0000 Subject: - import.module: + small improvements to feed administration + added some additional error/watchdog message upon failure + improved the robustness of the parser routine; more feeds get parsed succesfully now. --- modules/aggregator/aggregator.module | 37 +++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'modules/aggregator/aggregator.module') diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index f43ebf4c6..447f84a43 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -127,7 +127,18 @@ function import_remove($feed) { function import_refresh($feed) { - // open socket: + /* + ** Check whether the feed is properly configured: + */ + + if (!ereg("^http://|ftp://", $feed[url])) { + watchdog("warning", "import: invalid or missing URL for '$feed[title]'"); + } + + /* + ** Grab the headlines: + */ + $url = parse_url($feed[url]); $fp = fsockopen($url[host], ($url[port] ? $url[port] : 80), $errno, $errstr, 15); @@ -148,43 +159,57 @@ function import_refresh($feed) { db_query("DELETE FROM item WHERE fid = '$feed[fid]' AND timestamp < ". (time() - $feed[uncache])); + /* + ** Remove unsupported tags or sub-elements: + */ + + $data = ereg_replace("", "", $data); + $data = ereg_replace("", "", $data); + /* ** Extract and process channel information: */ $channel = ereg_replace("", "", $data); - $channel = ereg_replace("", "", $channel); + eregi("(.*)", $channel, $title); eregi("(.*)", $channel, $link); eregi("(.*)", $channel, $description); db_query("UPDATE feed SET timestamp = '". time() ."', link = '". check_input($link[1]) ."', description = '". check_input($description[1]) ."' WHERE fid = '". $feed[fid] ."'"); + unset($title, $link, $description); + /* ** Extract and process individual items: */ eregi("", $data, $data); - // print "
". htmlentities($data[0]) ."
"; + // print "
". htmlentities($data[0]) ."
"; $items = array_reverse(explode("", $data[0])); foreach ($items as $item) { + unset($title, $link, $author, $description); + $t = eregi("(.*)", $item, $title); $l = eregi("(.*)", $item, $link); $a = eregi("(.*)", $item, $author); $d = eregi("(.*)", $item, $description); if ($l || $t || $a || $d) { - $title = strtr(strip_tags($title[1]), $tt); + $title = strip_tags(strtr($title[1], $tt)); $description = strtr($description[1], $tt); + + // print "
title = ". htmlentities($title) ."\n\ndescription = ". htmlentities($description) ."\n\nauthor = ". htmlentities($author[1]) ."

"; + import_save_item(array(fid => $feed[fid], title => $title, link => $link[1], author => $author[1], description => $description, attributes => $feed[attributes])); } } } else { - watchdog("error", "failed to syndicate from '$feed[title]'"); + watchdog("warning", "failed to syndicate from '$feed[title]'". ($errstr ? ": $errstr" : "")); } } @@ -390,6 +415,8 @@ function import_admin() { else print status(import_save_feed($edit)); // fall through: + print import_view(); + break; default: if ($type == "bundle") print import_view_bundle(); -- cgit v1.2.3