diff --git a/pages/index/0.php b/pages/index/0.php index e7356c7..a2c2e5a 100644 --- a/pages/index/0.php +++ b/pages/index/0.php @@ -29,61 +29,47 @@
".date("Y-m-d", $row['TS'])." - ".$row['short']."
\n"; - if($row['story'] != "") - echo "\n"; - } - if(mysql_num_rows(mysql_query("select * from `news`")) > 2) - echo ""; -*/ - $rss = ""; - $open = $items = 0; - $fp = @fopen("/www/pages/index/feed.rss", "r"); - if($fp) - { - echo ''._('Latest News').'
'; - - - while(!feof($fp)) - $rss .= trim(fgets($fp, 4096)); - fclose($fp); - $rss = str_replace("><", ">\n<", $rss); - $lines = explode("\n", $rss); - foreach($lines as $line) - { - $line = trim($line); - - if($line != "".str_replace("&#", "", recode_string("UTF8..html", str_replace("&", "", trim(substr($line, 13, -14)))))."
\n"; - if(substr($line, 0, 6) == "") - echo "\n"; + printf("%s
\n\n",_('Latest News')); + + $xml = "/www/pages/index/feed.rss"; // FIXME: use relative path to allow operation with different document root + $dom = new DOMDocument(); + $dom->preserveWhiteSpace = false; + $dom->Load($xml); + + $xpath = new DOMXPath($dom); //Create an XPath query + + $query = "//channel/item"; + $items = $xpath->query($query); + + $count = 0; + foreach($items as $id => $item) { + $query = "./title"; + $nodeList = $xpath->query($query, $item); + $title = recode_string("UTF8..html" , $nodeList->item(0)->nodeValue); + + $query = "./link"; + $nodeList = $xpath->query($query, $item); + $link = htmlspecialchars($nodeList->item(0)->nodeValue); + + $query = "./description"; + $nodeList = $xpath->query($query, $item); + $description = recode_string("UTF8..html" , $nodeList->item(0)->nodeValue); + + printf("%s
\n", $description); + printf("[ %s ]
\n\n", $link,_("Full Story")); + + $title = ''; + $description = ''; + $link = ''; + + $count++; + if ($count >= 3) { + break; } } ?> + [ =_('More News Items')?> ]