diff options
-rw-r--r-- | includes/common.php | 6 | ||||
-rw-r--r-- | includes/news.php | 53 | ||||
-rw-r--r-- | index.php | 2 |
3 files changed, 57 insertions, 4 deletions
diff --git a/includes/common.php b/includes/common.php index 085a566..ae189b9 100644 --- a/includes/common.php +++ b/includes/common.php @@ -9,8 +9,8 @@ function placeHeader($page_title) { echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n"; ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>The Mana World</title> @@ -55,7 +55,7 @@ function placeHeader($page_title) <div class="section"> <ul> <!-- No newlines after list items because IE 6 can't handle that properly --> - <li><a href="index.php">News</a></li><li><a href="about.php">About</a></li><li><a href="downloads.php">Downloads</a></li><li><a href="http://wiki.themanaworld.org/">Wiki</a></li><li><a href="http://forums.themanaworld.org/">Forum</a></li><li><a href="http://mantis.themanaworld.org/">Bug tracker</a></li><li><a href="links.php">Links</a></li></ul> + <li><a href="index.php">News</a></li><li><a href="about.php">About</a></li><li><a href="downloads.php">Downloads</a></li><li><a href="http://wiki.themanaworld.org/">Wiki</a></li><li><a href="http://forums.themanaworld.org/">Forums</a></li><li><a href="http://mantis.themanaworld.org/">Bug tracker</a></li><li><a href="links.php">Links</a></li></ul> </div> </div> </div> diff --git a/includes/news.php b/includes/news.php new file mode 100644 index 0000000..52ad91e --- /dev/null +++ b/includes/news.php @@ -0,0 +1,53 @@ +<?php +// WARNING: +// This code uses the "DOM XML" extension, which is only available with PHP 4. +// Be sure to update it to use the "XML", "DOM" or "XMLReader" extensions when +// SF upgrades to PHP 5. + +$feedurl = "http://sourceforge.net/export/rss2_projnews.php?group_id=106790&rss_fulltext=1"; + +if (!$dom = domxml_open_file($feedurl)) { + echo "Error while fetching news feed.\n"; + exit; +} + +$root = $dom->document_element(); +$rootchilds = $root->child_nodes(); + +foreach ($rootchilds as $rootchild) +{ + if ($rootchild->tagname == "channel") + { + $channelchilds = $rootchild->child_nodes(); + + foreach ($channelchilds as $channelchild) + { + if ($channelchild->tagname == "item") + { + $itemchilds = $channelchild->child_nodes(); + $newsdata = array(); + + foreach ($itemchilds as $itemchild) + { + if (strlen($itemchild->tagname) > 0) + { + $newsdata[$itemchild->tagname] = + $itemchild->get_content(); + } + } + + print_news_item($newsdata); + } + } + } +} + +function print_news_item($newsdata) +{ + echo '<div class="news">'; + echo '<div class="news_date">' . $newsdata['pubDate'] . '</div>'; + echo '<h3>' . $newsdata['title'] . '</h3>'; + echo '<div class="news_body"><p>' . $newsdata['description'] . '</p></div>'; + echo '</div>'; +} +?> @@ -11,7 +11,7 @@ <?php $number = 6; - include('cutenews/show_news.php'); + include('includes/news.php'); placeFooter(); ?> |