Sciagnalem sobie taki oto skrypcik(ze strony http://www.aarondunlap.com). Najbardziej mi odpowiadal swoja funkcjonalnoscia i jego dzialanie jest dla mnie zrozumiale winksmiley.jpg. Odrobinke go poprawilem(tak aby czytal tez nazwy kanalow). Niestety jest z nim pewien powazny problem sad.gif. Nie wiem dlaczego nie tworzy poprawnie linkow z kanalow typu Onet czyli takich w ktorych wystepuja przecinki w linkach. W linkach stworzonych przez ten skrypt ich brakuje.
Czy ktos moze mi powiedziec co jest nie tak z tym skryptem??
  1. <?php
  2. $minutes = 30; //How often to update the feed. 0 indicates that feed updates every time it is cal
    led (heavy strain on bandwidth & server)
  3. $filename = 'rssCache/';
  4.  
  5. $default_url = "http://www.aarondunlap.com/rss.php?mode=hl"; //URL for the RSS/XML feed you're subscribing to.
  6. $default_displayname = "|| aarondunlap.com ||"; //Title to appear before headlines. Should be feed-specific
  7. $default_number = 5; //How many headlines to display. If you set it higher than the ammount of headline
    s, it will stop there
  8. $default_target = _blank; //Target for headline links. Options: "_self" and "_blank"
  9.  
  10. $autoupdate = 0;
  11.  
  12. $default_trunc = FALSE;
  13. $default_delim = FALSE;
  14.  
  15. #XXXXXXXXXXXXXXXXXXXXXXXXXX
  16. # Everything below is functional code.
  17.  
  18. # You should not change it unless you know what you're doing,
  19. # and even if you do know what you're doing, are you sure you're
  20. # awake enough to do it? Maybe take a nap, rethink things, try again.
  21. #XXXXXXXXXXXXXXXXXXXXXXXXXX
  22.  
  23. $version = 1.482;
  24.  
  25. //If these variables aren't declared already, use defaults.
  26. if (!isset($url)) { $url = $default_url; }
  27. // if (!isset($displayname)) { $displayname = $default_displayname; }
  28. if (!isset($number)) { $number = $default_number; }
  29. if (!isset($target)) { $target = $default_target; }
  30. if (!isset($trunc)) { $trunc = $default_trunc; }
  31. if (!isset($delim)) { $delim = $default_delim; }
  32.  
  33.  
  34. //In-URL definitions. Cannot be used for including, but it works great for testing.
  35. if (isset($_GET['url'])) { $url = $_GET['url'];}
  36. if (isset($_GET['number'])) { $number = $_GET['number'];}
  37. if (isset($_GET['displayname'])) { $displayname = $_GET['displayname'];}
  38. if (isset($_GET['rssHeadline'])) { $rssHeadline = $_GET['rssHeadline'];}
  39. $basefile = $filename; 
  40. $versionfile = $filename."updatelog.htm"; //File for update attempt log
  41. $filename .= md5($url).".htm"; //Prepare filename for htm output
  42.  
  43.  
  44. #==========================
  45. # Check the modify time of the htm file for this feed, and see if it's too new to reload the feed.
  46. # If the file is too new, it loads the htm file. This stops the script from cons
    tantly pulling the feed.
  47. #==========================
  48.  
  49. if (($minutes > 0) && (is_file($filename)) && (((time()-filemtime($filename)) < ($minutes * 60)))) { 
  50. include $filename;
  51. $time = floor((time()-filemtime($filename)) / 60); //See how many "minutes ago" the file was made.
  52. //echo "<br><i><span class="updated">Updated $time minutes ago.</span></i>"; //Include "minutes ago" after output.
  53. echo "<br><i><span class="updated">Aktualizowane $time minut temu.</span></i>"; //Include "minutes ago" after output.
  54.  
  55. } elseif (@fopen($url,"r")) { //Makes sure the file can actually be accessed.
  56.  
  57. #==========================
  58. # If we're down here, it means that the feed needs to be reloaded.
  59. #==========================
  60.  
  61. $rssHandle = fopen($url,"r") ; // Open the rss file for reading 
  62.  
  63. while (!feof($rssHandle)) {
  64. $rssData .= fgets($rssHandle);
  65. }
  66.  
  67. $rssData1=$rssData;
  68. #==========================
  69. # Feed parsing dla nazwy
  70. #==========================
  71. $tag = "channel";
  72. $rssData1 = preg_replace("/<" . $tag . "(.|s)*?>/","<channel>",$rssData1);
  73. $rssData1 = chop($rssData1); // Strip any whitespace from the end of the string
  74. $rssData1 = ereg_replace("[r,n]", "", $rssData1); //Clear line breaks
  75. $rssData1 = strstr($rssData1,"<channel>"); //Remove everything before <item>.
  76.  
  77. #==========================
  78. # Wyciagamy nazwe kanalu
  79. #==========================
  80. $rssData1 = str_replace("<channel>","", $rssData1); //Remove <item> itself
  81. $rssData1 = str_replace("<title>","", $rssData1); //Remove <item> itself
  82. $rssData1 = urldecode($rssData1); //Replace any silly %20-type characters with their readable replacement.
  83. $rssData1 = str_replace(strstr($rssData1,"</title>"),"",$rssData1); // Remove </title> and anything after it
  84. $default_displayname = $rssData1;
  85.  
  86. //jak nie zostala zdefiniowana inna nazwa to podstawiamy nazwe kanalu
  87. if (!isset($displayname)) { $displayname = $default_displayname; }
  88.  
  89. #==========================
  90. # Feed parsing
  91. #==========================
  92. $tag = "item ";
  93. $rssData = preg_replace("/<" . $tag . "(.|s)*?>/","<item>",$rssData);
  94. $rssData = chop($rssData); // Strip any whitespace from the end of the string
  95. $rssData = ereg_replace("[r,n]", "", $rssData); //Clear line breaks
  96. $rssData = strstr($rssData,"<item>"); //Remove everything before <item>.
  97.  
  98. #==========================
  99. # Strip specific tags and their content from the feed, to lighten the strain on 
    the processor.
  100. # Currently, only the <description></description> tags are stripped, we don't need them and sometimes
  101. # they are REALLY long, getting rid of them now makes it easier to parse later.
  102. #==========================
  103. $tags_and_content_to_strip = Array("description");
  104.  
  105. foreach ($tags_and_content_to_strip as $tag) {
  106.  $rssData = preg_replace("/<" . $tag . ">(.|s)*?</" . $tag . ">/","",$rssData);
  107. }
  108.  
  109. $rssData = str_replace("<item>","", $rssData); //Remove <item> itself
  110. $rssData = urldecode($rssData); //Replace any silly %20-type characters with their readable replacement.
  111. $rssData = str_replace(strstr("</channel>",$rssData),"",$rssData);
  112. $rssArray = explode("</item>",$rssData); //Creates an Array from all the headlines
  113.  
  114. $title = array();
  115. $link = array();
  116.  
  117. #==========================
  118. # This loop creates an array for links and another for titles.
  119. #==========================
  120. $x = 0;
  121. while($x < $number) {
  122. $link[$x] = strstr($rssArray[$x],"<link>"); //Remove everything before <link>
  123. $link[$x] = ereg_replace("<link>","",$link[$x]); 
  124.  
  125.  $link[$x] = str_replace(strstr($link[$x],"</link>"),"",$link[$x]);
  126.  $link[$x] = trim($link[$x]);
  127.  
  128. $title[$x] = strstr($rssArray[$x],"<title>");
  129. $title[$x] = ereg_replace("<title>","",$title[$x]); // Remove the leading <title> tags from the selected headline
  130. $title[$x] = str_replace(strstr($title[$x],"</title>"),"",$title[$x]); // Remove </title> and anything after it
  131. $title[$x] = trim($title[$x]);
  132.  
  133. if ($trunc != FALSE) { $title[$x] = str_replace(substr($title[$x],$trunc),"",$title[$x]); }
  134. if ($delim != FALSE) { $title[$x] = str_replace(strstr($title[$x],$delim),"",$title[$x]); }
  135.  
  136. if ($title[$x] == "") { $number = $x; break; } //If there are no more headlines, reset $number to the max.
  137. $x++;
  138. }
  139.  
  140. #==========================
  141. # Writing the file
  142. #==========================
  143. $fp = fopen($filename, "w+"); 
  144. $x=0;
  145. fwrite($fp,"<b><span class="displayname">$displayname</span></b> n"); //Write the displayname to the file
  146.  
  147. while ($x < $number) { //This loop writes each line individualy.
  148. fwrite($fp,"<br>n-<a class="headlinellink" target="$target" href="$link[$x]">$title[$x]</a>");
  149. $x++;
  150. }
  151.  fclose($fp);
  152.  include $filename; //wyswietlenie kanalu
  153.  echo "<br><i><span class="updated">Live.</span></i>";
  154.  
  155.  } else { 
  156. # Error handling:
  157. echo "<b>Could not connect to $url. </b>"; 
  158.  
  159. }