jak mo¿na przerobiæ ten skrypt, aby wszystkie wiadomo¶ci zapisywa³ do pliku tekstowego wg. wzoru:
id<!>tytul<!>opis<!>pelnyopis
oto skrypt:
<?php /************************************************************ RSS Fetch 0.4.1 RSS Feed Reader Author: Drew Phillips www.neoprogrammers.com Copyright 2005 Drew Phillips This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ************************************************************/ class rss_parser { var $update_interval = 60; /* How often to fetch the rss file A cached version will be used between updates */ var $data_directory = "/home/neoprog/www/rss"; /* Where to store the rss data from the feeds Note: an absolute path is better than a relative path here unless you plan on keeping the script to display the feeds in the same folder as this file and the feeds. */ /* NO NEED TO EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING */ var $rss_url; var $num_to_show; var $do_update; var $content; var $feed_title; var $feed_link; var $feed_description; var $my_html; function rss_parser($url, $numtoshow = 10, $html = "", $update = 0) { $this->rss_url = $url; $this->num_to_show = $numtoshow; $this->do_update = $update; $this->content = $this->fetch_feed(); $this->parse_feed(); $this->show(); } /* string */ function fetch_feed() { $filename = $url_parts['host'] . str_replace("/", ",", $url_parts['path']) . "_" . @$url_parts['query']; $update = 1; } } else { $create= 1; } if($create == 1 || ($this->do_update == TRUE && $update == 1)) { if (!$fp) { return; } ."Host: " . $url_parts['host'] . "r\n" ."User-Agent: Drew's RSS Reader 0.1r\n" ."Connection: Closer\nr\n"); } if(!$output) { return $rss_data; } else { } } //update } /* void */ function parse_feed() { $this->feed_title = @$title[1]; $this->feed_link = @$link[1]; $this->feed_description = @$description[1]; } preg_match_all("/(?:<([w:]*)[^>]*>(?:<![CDATA[)?(.*?)(?:]]>)?</1>)+?/si", preg_replace("/<item[^>]*>/", "", $items[0][$i]), $elements); $elements[1][$j] = str_replace(":", "__", $elements[1][$j]); //regex fix for items with : like dc:date } } } /* void */ function show() { if($this->my_html == "") { $this->show_html(); } else { $this->show_user_html(); } } function show_html() { for($i = 0; $i < $show; ++$i) { echo "- <a href=\"{$this->rss[$i]['link']}\" target=\"_new\">{$this->rss[$i]['title']}</a><br />\n"; } } function show_user_html() { for($i = 0; $i < $show; ++$i) { } } } // end class ?>