Mam problem z skryptem rss get.. ³adnie wy¶wietla wiadomo¶ci ale linki ¼le wy¶wietla bo wy¶wietla:
http://wiadomosci.onet.pl/17839451111item.html
zamiast
http://wiadomosci.onet.pl/1783945,11,1,1,item.html
Przecinki gubi
zobaczcie tak wy¶wietla: Czytnik
Skrypt:
index.php
<? $url = "http://wiadomosci.onet.pl/2,kategoria.rss"; $displayname = "Slashdot /."; include "rss_get.php"; ?>
rss_get.php
<?php #========================== # The following line declares how long to wait before reloading the RSS feed. # Keep in mind, many sites discourage people from pulling its feed more often th
an 30 minutes. # For example, Slashdot.org may ban your server if it tries to load the rss feed
too often. # You may change the below line. #========================== $minutes = 30; //How often to update the image. 0 indicates that image updates every time it is c
alled (heavy strain on bandwidth & server) #========================== # The next line is what directory to dump the htm files generated by this script
. # It should be relative to the location of this script, and it *MUST* have a tra
iling slash if it's a seperate dir. # If you want the files to be dumped in the same dir as this script, set it to "" # You may change the next line #========================== $filename = "rss/"; #========================== # The next 4 lines are default settings for the script to use, if they are not s
et prior to including this script # You may change the next 4 lines. #========================== $default_url = "http://www.aarondunlap.com/rss.php?mode=hl"; //URL for the RSS/XML feed you're subscribing to. $default_displayname = "|| aarondunlap.com ||"; //Title to appear before headlines. Should be feed-specific $default_number = 5; //How many headlines to display. If you set it higher than the ammount of headline
s, it will stop there $default_target = "_self"; //Target for headline links. Options: "_self" and "_blank" #========================== # The settings below are for advanced headline truncation. # $default_trunc is how many characters to cut off at, # the default is FALSE, which wont truncate # at all. # You may use $trunc when calling this script # to define the truncation for specific feeds # $default_delim is what character to cut off the headline at # for example, if your headlines contain useless # data at the end, like "(via Reuters)", setting # the delimiter to "(" will stop that from showing. # You may use $delim when calling this script # to define the truncation for specific feeds #=========================== $default_trunc = FALSE; $default_delim = FALSE; #XXXXXXXXXXXXXXXXXXXXXXXXXX # Everything below is functional code. # You should not change it unless you know what you're doing, # and even if you do know what you're doing, are you sure you're # awake enough to do it? Maybe take a nap, rethink things, try again. #XXXXXXXXXXXXXXXXXXXXXXXXXX $version = 1.5; //If these variables aren't declared already, use defaults. //In-URL definitions. Cannot be used for including, but it works great for testing. $basefile = $filename; $versionfile = $filename."updatelog.htm"; //File for update attempt log #========================== # Check the modify time of the htm file for this feed, and see if it's too new to reload the feed. # If the file is too new, it loads the htm file. This stops the script from cons
tantly pulling the feed. #========================== include $filename; echo "<br><i><span class=\"updated\">Updated $time minutes ago.</span></i>"; //Include "minutes ago" after output. #========================== # If we're down here, it means that the feed needs to be reloaded. #========================== } #========================== # Feed parsing #========================== $tag = "item "; $rssData = chop($rssData); // Strip any whitespace from the end of the string $rssData = ereg_replace("[r,\n]", "", $rssData); //Clear line breaks $rssData = strstr($rssData,"<item>"); //Remove everything before <item>. #========================== # Strip specific tags and their content from the feed, to lighten the strain on
the processor. # Currently, only the <description></description> tags are stripped, we don't need them and sometimes # they are REALLY long, getting rid of them now makes it easier to parse later. #========================== $tags_and_content_to_strip = Array("description"); foreach ($tags_and_content_to_strip as $tag) { $rssData = preg_replace("/<" . $tag . ">(.|s)*?</" . $tag . ">/","",$rssData); } $rssData = str_replace("<item>","", $rssData); //Remove <item> itself $rssData = urldecode($rssData); //Replace any silly %20-type characters with their readable replacement. $rssData = str_replace(strstr("</channel>",$rssData),"",$rssData); $rssArray = explode("</item>",$rssData); //Creates an Array from all the headlines $title = array(); $link = array(); #========================== # This loop creates an array for links and another for titles. #========================== $x = 0; while($x < $number) { $link[$x] = strstr($rssArray[$x],"<link>"); //Remove everything before <link> $link[$x] = ereg_replace("<link>","",$link[$x]); $link[$x] = str_replace(strstr($link[$x],"</link>"),"",$link[$x]); $link[$x] = trim($link[$x]); $title[$x] = strstr($rssArray[$x],"<title>"); $title[$x] = ereg_replace("<title>","",$title[$x]); // Remove the leading <title> tags from the selected headline $title[$x] = str_replace(strstr($title[$x],"</title>"),"",$title[$x]); // Remove </title> and anything after it $title[$x] = trim($title[$x]); if ($trunc != FALSE) { $title[$x] = str_replace(substr($title[$x],$trunc),"",$title[$x]); } if ($delim != FALSE) { $title[$x] = str_replace(strstr($title[$x],$delim),"",$title[$x]); } if ($title[$x] == "") { $number = $x; break; } //If there are no more headlines, reset $number to the max. $x++; } #========================== # Writing the file #========================== $fp = fopen($filename, "w+"); $x=0; fwrite($fp,"<b><span class=\"displayname\">$displayname</span></b> \n"); //Write the displayname to the file while ($x < $number) { //This loop writes each line individualy. fwrite($fp,"<br>\n-<a class=\"headlinellink\" target=\"$target\" href=\"$link[$x]\">$title[$x]</a>"); $x++; } fclose($fp); include $filename; echo "<br><i><span class=\"updated\">Live.</span></i>"; } else { #========================== # Error handling: # (rss url given is unreadable) #========================== echo "<b>Could not connect to $url. </b>"; } ?>
Proszê o pomoc