Exemple #1
0
function buildRssFeedCache($rssurl)
{
    $snoopy = new Snoopy();
    $cnt = 0;
    foreach ($rssurl as $url) {
        if ($snoopy->fetch($url)) {
            $rssdata = $snoopy->results;
            $rss2parser = new XoopsXmlRss2Parser($rssdata);
            if (false != $rss2parser->parse()) {
                $_items = $rss2parser->getItems();
                $count = count($_items);
                for ($i = 0; $i < $count; $i++) {
                    $_items[$i]['title'] = XoopsLocale::convert_encoding($_items[$i]['title'], XoopsLocale::getCharset(), 'UTF-8');
                    $_items[$i]['description'] = XoopsLocale::convert_encoding($_items[$i]['description'], XoopsLocale::getCharset(), 'UTF-8');
                    $items[(string) strtotime($_items[$i]['pubdate']) . "-" . (string) ++$cnt] = $_items[$i];
                }
            } else {
                echo $rss2parser->getErrors();
            }
        }
    }
    krsort($items);
    return $items;
}
Exemple #2
0
 }
 $rssfile = 'adminnews-' . xoops_getConfigOption('language');
 xoops_load('XoopsCache');
 $items = array();
 if (!($items = XoopsCache::read($rssfile))) {
     require_once $GLOBALS['xoops']->path('class/snoopy.php');
     include_once $GLOBALS['xoops']->path('class/xml/rss/xmlrss2parser.php');
     xoops_load('XoopsLocal');
     $snoopy = new Snoopy();
     $cnt = 0;
     foreach ($rssurl as $url) {
         if ($snoopy->fetch($url)) {
             $rssdata = $snoopy->results;
             $rss2parser = new XoopsXmlRss2Parser($rssdata);
             if (false != $rss2parser->parse()) {
                 $_items = $rss2parser->getItems();
                 $count = count($_items);
                 for ($i = 0; $i < $count; $i++) {
                     $_items[$i]['title'] = XoopsLocal::convert_encoding($_items[$i]['title'], _CHARSET, 'UTF-8');
                     $_items[$i]['description'] = XoopsLocal::convert_encoding($_items[$i]['description'], _CHARSET, 'UTF-8');
                     $items[strval(strtotime($_items[$i]['pubdate'])) . "-" . strval(++$cnt)] = $_items[$i];
                 }
             } else {
                 echo $rss2parser->getErrors();
             }
         }
     }
     krsort($items);
     XoopsCache::write($rssfile, $items, 86400);
 }
 if ($items != '') {
Exemple #3
0
         fclose($fp);
     }
 } else {
     if (false !== ($fp = fopen($rssfile, 'r'))) {
         while (!feof($fp)) {
             $rssdata .= fgets($fp, 4096);
         }
         fclose($fp);
     }
 }
 if ($rssdata != '') {
     include_once XOOPS_ROOT_PATH . '/class/xml/rss/xmlrss2parser.php';
     $rss2parser = new XoopsXmlRss2Parser($rssdata);
     if (false != $rss2parser->parse()) {
         echo '<table class="outer" width="100%">';
         $items =& $rss2parser->getItems();
         $count = count($items);
         $myts =& MyTextSanitizer::getInstance();
         for ($i = 0; $i < $count; $i++) {
             echo '<tr class="head"><td><a href="' . htmlspecialchars($items[$i]['link']) . '" target="_blank">';
             echo htmlspecialchars(XoopsLocal::convert_encoding($items[$i]['title'], _CHARSET, "UTF-8")) . '</a> (' . formatTimestamp(htmlspecialchars($items[$i]['pubdate'])) . ')</td></tr>';
             if ($items[$i]['description'] != "") {
                 echo '<tr><td class="odd">' . XoopsLocal::convert_encoding($items[$i]['description'], _CHARSET, "UTF-8");
                 if ($items[$i]['guid'] != "") {
                     echo '&nbsp;&nbsp;<a href="' . htmlspecialchars($items[$i]['guid']) . '" target="_blank">' . _MORE . '</a>';
                 }
                 echo '</td></tr>';
             } elseif ($items[$i]['guid'] != "") {
                 echo '<tr><td class="even" valign="top"></td><td colspan="2" class="odd"><a href="' . htmlspecialchars($items[$i]['guid']) . '" target="_blank">' . _MORE . '</a></td></tr>';
             }
         }