cvs: php-master-web /scripts rss_parser

From: Date: Sun, 11 Feb 2007 23:27:32 +0000
Subject: cvs: php-master-web /scripts rss_parser
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-34248@lists.php.net to get a copy of this message
bjori Sun Feb 11 23:27:32 2007 UTC Modified files: /php-master-web/scripts rss_parser Log: Link to the entry on php.net[/conferences] http://cvs.php.net/viewvc.cgi/php-master-web/scripts/rss_parser?r1=1.16&r2=1.17&diff_format=u Index: php-master-web/scripts/rss_parser diff -u php-master-web/scripts/rss_parser:1.16 php-master-web/scripts/rss_parser:1.17 --- php-master-web/scripts/rss_parser:1.16 Thu Feb 8 22:36:06 2007 +++ php-master-web/scripts/rss_parser Sun Feb 11 23:27:32 2007 @@ -18,9 +18,11 @@ } // Try to find a link in the text with any the used linking methods -function scanLinks($text) { +function scanLinks($text, $rootLink) { - if (preg_match('/<\?php\s+print_link\s*\("([^"]+)",\s*"[^"]+"\);\s*\?>/', $text, $matches)) { + if (preg_match('/<a\s+name="([^"]*)">/', $text, $matches)) { + $link = "#" .$matches[1]; + } elseif (preg_match('/<\?php\s+print_link\s*\("([^"]+)",\s*"[^"]+"\);\s*\?>/', $text, $matches)) { $link = $matches[1]; } elseif (preg_match('/<\?php\s+print_link\s*\(\'([^\']+)\',\s*\'[^\']+\'\);\s*\?>/', $text, $matches)) { $link = $matches[1]; @@ -32,7 +34,8 @@ // Make sure it is a full URL if (!preg_match('/^http:/', $link)) { - $link = ($link{0} != '/') ? "http://www.php.net/$link" : "http://www.php.net$link"; + $rootLink = rtrim($rootLink, "/"); + $link = ($link{0} != '/') ? "$rootLink/$link" : "$rootLink$link"; } return $link; @@ -62,7 +65,7 @@ } // Parse the index file searching for news item information -function ParseNews ($index_page = "") { +function ParseNews ($index_page = "", $aboutLink) { // Remove commented items $index_page = preg_replace("/<!--[\w\W]*?-->/", "", $index_page); @@ -137,7 +140,7 @@ foreach ($headlines as $num => $headline) { // The first link found is THE link for the news item - $headlines[$num]['link'] = scanLinks($headline['text']); + $headlines[$num]['link'] = scanLinks($headline['text'], $aboutLink); // And the text needs to be cleaned up $headlines[$num]['text'] = ProcessText($headline['text']); @@ -192,7 +195,7 @@ $homepage = getData("$root/index.php"); // This returns a data structure containing all the news items found -$hlines = ParseNews($homepage); +$hlines = ParseNews($homepage, $aboutLink); // Start with an empty RSS string $RSS = '';

« previous php.mirrors (#34248) next »