Advertisement
SgtLegend

RSS Feed

Apr 19th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. /*=======================================================================
  4.  Nuke-Evolution Xtreme: Enhanced PHP-Nuke Web Portal System
  5.  =======================================================================*/
  6.  
  7. if (!defined('MODULE_FILE')) {
  8.     die('You can\'t access this file directly...');
  9. }
  10.  
  11.  
  12. //
  13. // Set the RSS feed values
  14. //
  15. $url   = 'http://www.guildwars2.com/en/rss.xml';
  16. $feed  = '';
  17. $limit = 10;
  18. $count = 0;
  19.  
  20.  
  21. include_once(NUKE_BASE_DIR . 'header.php');
  22.  
  23. OpenTable();
  24.    
  25.     // Open the RSS feed
  26.     if (($rss = simplexml_load_file($url)) !== false) {
  27.         // Get the feed items
  28.         $items = $rss->channel->item;
  29.  
  30.         if (sizeof($items > 0)) {
  31.             foreach ($items as $item) {
  32.                 if ($count === $limit) {
  33.                     continue;
  34.                 }
  35.                
  36.                 $feed .= '<h3><a href="' . $item->link . '">' . $item->title . '</a></h3>';
  37.                 $feed .= '<span class="gensmall">( ' . $item->pubDate . ' )</span>';
  38.                 $feed .= '<p>' . $item->description . '</p>';
  39.  
  40.                 // Increment the total count
  41.                 $count++;
  42.             }
  43.         }
  44.     } else {
  45.         $feed = '<div style="text-align: center;">Unable to connect to the RSS feed!</div>';
  46.     }
  47.  
  48.     echo $feed;
  49.  
  50. CloseTable();
  51.  
  52. include_once(NUKE_BASE_DIR . 'footer.php');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement