Пример #1
0
function rss_query($query, $dieOnError = true, $preventRecursion = false)
{
    $pf = defined('PROFILING_DB') && PROFILING_DB && function_exists('_pf');
    if ($pf) {
        list($usec, $sec) = explode(" ", microtime());
    }
    $rs = $GLOBALS['rss_db']->rss_query($query, $dieOnError, $preventRecursion);
    if ($pf) {
        list($usec2, $sec2) = explode(" ", microtime());
        _pf("Query took " . ($sec2 - $sec + ($usec2 - $usec)) . " seconds:\n\t\t\t" . preg_replace('/\'[a-z0-9]+\'/i', '\'[removed]\'', $query));
    }
    return $rs;
}
Пример #2
0
 function _populateProperties()
 {
     _pf('Populating properties');
     $this->_properties = array();
     $qry = "select fk_ref_object_id, proptype, property, value from " . getTable('properties');
     $rs = rss_query($qry);
     while (list($ref_obj, $ptype, $prop, $pval) = rss_fetch_row($rs)) {
         if (!isset($this->_properties[$ptype])) {
             $this->_properties[$ptype] = array();
         }
         if (!isset($this->_properties[$ptype][$ref_obj])) {
             $this->_properties[$ptype][$ref_obj] = array();
         }
         $val = @unserialize($pval);
         $this->_properties[$ptype][$ref_obj][] = array('ref_obj' => $ref_obj, 'property' => $prop, 'value' => $val);
     }
     _pf('Done: populating properties');
 }
Пример #3
0
 function render()
 {
     _pf('FeedList->render() ...');
     include $GLOBALS['rss']->getTemplateFile("feeds.php");
     _pf('done');
 }
Пример #4
0
/**
 * Performs callbacks for the given hook,
 * based on the plugins registered functions
 */
function rss_plugin_hook($hook, $data, $plugin_filename = null)
{
    $hooks =& __getHooksArray();
    foreach ($hooks as $this_plugin_name => $filehooks) {
        if (!isset($plugin_filename) || $this_plugin_name == $plugin_filename) {
            if (array_key_exists($hook, $filehooks)) {
                foreach ($filehooks[$hook] as $fnct) {
                    if (function_exists($fnct)) {
                        _pf("calling plugin func {$fnct} in '{$this_plugin_name}' for {$hook} ...");
                        $data = call_user_func($fnct, $data);
                        _pf("done");
                    }
                }
            }
        }
    }
    return $data;
}
Пример #5
0
function readItems($limit)
{
    _pf('read items');
    /*
       $hiddenIds = getHiddenChannelIds();
    if (count($hiddenIds)) {
    	$sqlWhereHidden = " and c.id not in (" . implode(',',$hiddenIds) . ") ";
    } else {
    	$sqlWhereHidden = "";
    }
    */
    $readItems = new PaginatedItemList();
    $readItems->setRenderOptions(IL_TITLE_NO_ESCAPE);
    if (getConfig('rss.config.feedgrouping')) {
        if ($limit <= 0) {
            return;
        }
        $sql = "select " . " c.id" . " from " . getTable("channels") . " c " . " inner join " . getTable("folders") . " f on f.id = c.parent ";
        // $sql .= $sqlWhereHidden;
        $sql .= " where not(c.mode & " . RSS_MODE_DELETED_STATE . ") ";
        if (getConfig('rss.config.absoluteordering')) {
            $sql .= " order by f.position asc, c.position asc";
        } else {
            $sql .= " order by f.name asc, c.title asc";
        }
        $res1 = rss_query($sql);
        while ($readItems->itemCount < $limit && (list($cid) = rss_fetch_row($res1))) {
            $sqlWhere = " not(i.unread & " . RSS_MODE_UNREAD_STATE . ") and i.cid= {$cid}";
            $sqlWhere .= " and i.pubdate <= now() ";
            $readItems->populate($sqlWhere, "", 0, 2, ITEM_SORT_HINT_READ);
            //what if we have less than 2 items.
        }
    } else {
        if ($limit <= 0) {
            return;
        }
        $sqlWhere = " not(i.unread & " . RSS_MODE_UNREAD_STATE . ")  ";
        $sqlWhere .= " and i.pubdate <= now() ";
        //	$sqlWhere .= $sqlWhereHidden;
        $readItems->populate($sqlWhere, "", 0, $limit, ITEM_SORT_HINT_READ);
        $readItems->setRenderOptions(IL_NO_COLLAPSE | IL_TITLE_NO_ESCAPE);
    }
    $readItems->setTitle(__('Recent items'));
    $GLOBALS['rss']->appendContentObject($readItems);
    _pf('end read items');
}
Пример #6
0
 function preRender()
 {
     _pf('Header preRender()');
     if (!($this->options & HDR_NO_CACHECONTROL) && getConfig('rss.output.cachecontrol')) {
         $etag = getETag();
         $hdrs = rss_getallheaders();
         if (array_key_exists('If-None-Match', $hdrs) && $hdrs['If-None-Match'] == $etag) {
             header("HTTP/1.1 304 Not Modified");
             flush();
             exit;
         } else {
             header('Last-Modified: ' . gmstrftime("%a, %d %b %Y %T %Z", getLastModif()));
             header("ETag: {$etag}");
         }
     }
     if (count($this->extraHeaders)) {
         foreach ($this->extraHeaders as $hdr) {
             header($hdr);
         }
     }
     rss_plugin_hook('rss.plugins.bodystart', null);
 }
Пример #7
0
 function render()
 {
     _pf("ItemList -> render()");
     if ($this->readCount + $this->unreadCount == 0 && $this->beforeList == "") {
         return;
     }
     $this->rss->currentItemList = $this;
     rss_plugin_hook('rss.plugins.items.beforeitems', null);
     include $this->rss->getTemplateFile($this->_template);
     _pf("done: ItemList -> render()");
     rss_plugin_hook('rss.plugins.items.afteritems', null);
 }
Пример #8
0
    function getShownUnreadIds()
    {
        $ret = array();
        foreach ($this->mainObject as $o) {
            if (isset($o->unreadIids)) {
                $ret = array_merge($ret, $o->unreadIids);
            }
        }
        return $ret;
    }
}
$GLOBALS['rss'] = new RSS();
_pf('Parsing class wrappers:');
rss_require('cls/wrappers/errors.php');
_pf(" ...errors.php");
rss_require('cls/wrappers/feed.php');
_pf(" ...feed.php");
rss_require('cls/wrappers/feeds.php');
_pf(" ...feeds.php");
rss_require('cls/wrappers/header.php');
_pf(" ...header.php");
rss_require('cls/wrappers/nav.php');
_pf(" ...nav.php");
rss_require('cls/wrappers/item.php');
_pf(" ...item.php");
rss_require('cls/wrappers/itemlist.php');
_pf(" ...itemlist.php");
rss_require('cls/wrappers/misc.php');
_pf(" ...misc.php");
_pf('Parsed classes');
Пример #9
0
 function populate()
 {
     ////// actual feeds ///////
     $this->folders = array();
     _pf('CatList->populate() ...');
     $sql = "select " . " c.id, c.title, c.url, c.siteurl, t.tag, c.parent, c.icon, c.descr, c.mode, t.id " . " from " . getTable('channels') . " c " . " inner join " . getTable('metatag') . " m on m.fid = c.id " . " inner join " . getTable('tag') . " t on t.id = m.tid " . " where m.ttype = 'channel' ";
     if (hidePrivate()) {
         $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") ";
     }
     $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE . ") ";
     $sql .= " order by t.tag asc";
     if (!getConfig("rss.config.absoluteordering")) {
         $sql .= ", c.title asc";
     }
     $res = rss_query($sql);
     $this->taggedFeedCnt = rss_num_rows($res);
     // get # of unread items for each feed
     $ucres = rss_query("select cid, count(*) from " . getTable("item") . " where unread & " . RSS_MODE_UNREAD_STATE . " and not(unread & " . RSS_MODE_DELETED_STATE . ") group by cid");
     $uc = array();
     while (list($uccid, $ucuc) = rss_fetch_row($ucres)) {
         $uc[$uccid] = $ucuc;
     }
     while (list($cid, $ctitle, $curl, $csiteurl, $fname, $cparent, $cico, $cdescr, $cmode, $tid) = rss_fetch_row($res)) {
         $unread = 0;
         if (isset($uc[$cid])) {
             $unread = $uc[$cid];
         }
         $f = new FeedListItem($cid, $ctitle, $curl, $csiteurl, $fname, $cparent, $cico, $cdescr, $cmode, $unread);
         if (!array_key_exists($tid, $this->folders)) {
             $this->folders[$tid] = new CatFolder($fname, $tid, $this);
             $this->tagCnt++;
         }
         $this->folders[$tid]->feeds[] = $f;
         $this->folders[$tid]->isCollapsed = in_array($tid, $this->collapsed_ids) && $tid > 0;
         _pf('done');
     }
 }
Пример #10
0
    rss_require(RSS_THEME_DIR . "/{$theme}/intl/{$lang}.php");
} elseif ($lang != "en" && file_exists(RSS_THEME_DIR . "/{$theme}/intl/en.php")) {
    rss_require(RSS_THEME_DIR . "/{$theme}/intl/en.php");
}
//
if (file_exists(getThemePath(GREGARIUS_HOME) . "overrides.php")) {
    rss_require(getThemePath('') . "overrides.php");
}
/*
// Load the right locale
if (defined('OVERRIDE_LOCALE')) {
    setlocale(LC_TIME,constant("OVERRIDE_LOCALE"));
}
elseif (isset($_SERVER["WINDIR"]) && defined("LOCALE_WINDOWS")) {
    setlocale(LC_TIME,constant("LOCALE_WINDOWS"));
}
elseif (defined("LOCALE_LINUX")) {
    setlocale(LC_TIME,constant("LOCALE_LINUX"));
}
else {
    //last chance, we try to guess it
    $mylocale=strtolower(getConfig('rss.output.lang'));
    $mylocale.="_".strtoupper($mylocale);
    if (!setlocale(LC_TIME,$mylocale)) {
        // very last resort: try to load the system locale
        setlocale(LC_TIME,"");
    }
}
*/
_pf('done');