diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-02-22 23:44:53 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-02-22 23:44:53 +0000 |
commit | d00469cd05aa7351255f9c16b13ca5dc1cc879b5 (patch) | |
tree | f8b61f1c2682320cf7b02b6c77db1035b290819d /modules | |
parent | 0505e7b999d4700493d06de0aec810eb3b080a45 (diff) | |
download | brdo-d00469cd05aa7351255f9c16b13ca5dc1cc879b5.tar.gz brdo-d00469cd05aa7351255f9c16b13ca5dc1cc879b5.tar.bz2 |
- improved RDF backend class to support more backend formats
Diffstat (limited to 'modules')
-rw-r--r-- | modules/backend.class | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/modules/backend.class b/modules/backend.class index 2028c5d87..7cdaa328b 100644 --- a/modules/backend.class +++ b/modules/backend.class @@ -1,5 +1,4 @@ <? - class backend { // Channel properties: @@ -46,7 +45,7 @@ class backend { } } - function rdf2sql($timout = 10) { + function url2sql($timout = 10) { global $site_name; if ($this->file) { @@ -62,12 +61,10 @@ class backend { $fp = fsockopen($host, $port, &$errno, &$errstr, $timout); if ($fp) { - // Get data from URL: - fputs($fp, "GET $path HTTP/1.0\n"); - fputs($fp, "User-Agent: $site_name\n"); - fputs($fp, "Host: ". $host ."\n"); - fputs($fp, "Accept: */*\n\n"); + // Request data via URL: + fputs($fp, "GET $path HTTP/1.0\nUser-Agent: $site_name\nHost: $host\nAccept: */*\n\n"); + // Read data from socket: while(!feof($fp)) $data .= fgets($fp, 128); // print "<PRE>$data</PRE><HR>"; @@ -93,7 +90,7 @@ class backend { $title = ereg_replace(".*<title>", "", $item); $title = ereg_replace("</title>.*", "", $title); - // Count the number of stories: + // Increase the number of headlines: $number += 1; // Insert item in database: @@ -104,25 +101,13 @@ class backend { $result = db_query("UPDATE channel SET timestamp = '". time() ."' WHERE id = $this->id"); $this->timestamp = time(); } - else print "<HR>RDF parser: 404 error?<BR><BR><PRE>$data</PRE><HR>"; + else { + watchdog("error", "failed to retrieve headline data from $host: <PRE>$data</PRE>"); + } } } } - function rss2sql($timout = 10) { - print "backend->rss2sql : TODO<BR>"; - } - - function xml2sql($timout = 10) { - print "backend->xml2sql : TODO<BR>"; - } - - function url2sql($timout = 10) { - if (strstr($this->file, ".rdf")) $this->rdf2sql($timout); - if (strstr($this->file, ".rss")) $this->rss2sql($timout); - if (strstr($this->file, ".xml")) $this->xml2sql($timout); - } - function displayHeadlines($timout = 1800) { global $theme; |