コード例 #1
0
ファイル: dblclicktoread.php プロジェクト: jphpsf/gregarius
function __dblclickToRead_init_js($dummy)
{
    if (!hidePrivate()) {
        echo "\n<script type=\"text/javascript\">\n" . "<!--\n" . "__dbclickToRead_jsInit();\n" . "-->\n" . "</script>\n";
    }
    return $dummy;
}
コード例 #2
0
ファイル: searchform.php プロジェクト: jphpsf/gregarius
function rss_search_channels_combo($id)
{
    $ret = "\t\t<select name=\"{$id}\" id=\"{$id}\">\n" . "\t\t\t<option value=\"" . ALL_CHANNELS_ID . "\"" . (!array_key_exists(QUERY_CHANNEL, $_REQUEST) || $_REQUEST[QUERY_CHANNEL] == ALL_CHANNELS_ID ? " selected=\"selected\"" : "") . ">" . __('All') . "</option>\n";
    $sql = "select " . " c.id, c.title, f.name, f.id  " . " from " . getTable("channels") . " c " . " inner join " . getTable("folders") . " f " . "   on f.id = c.parent ";
    if (hidePrivate()) {
        $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") ";
    }
    $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE . ") ";
    $sql .= " order by " . (getConfig('rss.config.absoluteordering') ? "f.position asc, c.position asc" : "f.name asc, c.title asc");
    $res = rss_query($sql);
    $prev_parent = -1;
    while (list($id_, $title_, $parent_, $parent_id_) = rss_fetch_row($res)) {
        if ($prev_parent != $parent_id_) {
            if ($prev_parent > -1) {
                $ret .= "\t\t\t</optgroup>\n";
            }
            if ($parent_ == "") {
                $parent_ = __('Root');
            }
            $ret .= "\t\t\t<optgroup label=\"{$parent_} /\">\n";
            $prev_parent = $parent_id_;
        }
        if (strlen($title_) > 25) {
            $title_ = substr($title_, 0, 22) . "...";
        }
        $ret .= "\t\t\t\t<option value=\"{$id_}\"" . (array_key_exists(QUERY_CHANNEL, $_REQUEST) && $_REQUEST[QUERY_CHANNEL] == $id_ ? " selected=\"selected\"" : "") . ">{$title_}</option>\n";
    }
    if ($prev_parent != 0) {
        $ret .= "\t\t\t</optgroup>\n";
    }
    $ret .= "\t\t</select>\n";
    return $ret;
}
コード例 #3
0
ファイル: tags.php プロジェクト: abdallahchamas/haiti_tracker
function relatedTags($tags)
{
    /* related tags */
    $twhere = "";
    foreach ($tags as $tag) {
        $tag = rss_real_escape_string($tag);
        $twhere .= "t.tag='{$tag}' or ";
    }
    $twhere .= "1=0";
    $sql = "select fid,tid,m.tdate from " . getTable('metatag') . " m " . "inner join " . getTable('tag') . " t on t.id = m.tid  where m.ttype = 'item'" . " and ({$twhere})";
    //echo $sql;
    $res = rss_query($sql);
    $fids = array();
    $ctid = -1;
    while (list($fid, $tid) = rss_fetch_row($res)) {
        $fids[] = $fid;
        $tids[] = $tid;
    }
    $fids = array_unique($fids);
    $tids = array_unique($tids);
    $rtags = array();
    if (count($fids)) {
        $sql = "select t.tag, count(*) as cnt from " . getTable('metatag') . " m left join " . getTable('item') . " i on (m.fid=i.id) " . " inner join " . getTable('tag') . " t on (t.id = m.tid) " . " where m.fid in (" . implode(",", $fids) . ")" . " and t.id not in (" . implode(",", $tids) . ")";
        if (hidePrivate()) {
            $sql .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") ";
        }
        $sql .= " group by t.tag order by cnt desc";
        //echo $sql;
        $res = rss_query($sql);
        while (list($rtag, $cnt) = rss_fetch_row($res)) {
            $rtags[$rtag] = $cnt;
        }
    }
    return $rtags;
}
コード例 #4
0
ファイル: channels.php プロジェクト: jphpsf/gregarius
 function populate()
 {
     _pf('FeedList->populate() ...');
     $sql = "select " . " c.id, c.title, c.url, c.siteurl, f.name, c.parent, c.icon, c.descr, c.mode " . " from " . getTable("channels") . " c " . "inner join " . getTable("folders") . " f on f.id = c.parent";
     if (hidePrivate()) {
         $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") ";
     }
     $sql .= " and 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, c.title asc";
     }
     $res = rss_query($sql);
     $this->feedCount = rss_num_rows($res);
     $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) = rss_fetch_row($res)) {
         $ucc = 0;
         if (array_key_exists($cid, $uc)) {
             $ucc = $uc[$cid];
         }
         $f = new FeedListItem($cid, $ctitle, $curl, $csiteurl, $fname, $cparent, $cico, $cdescr, $cmode, $ucc);
         $f->isActiveFeed = $this->activeId && $cid == $this->activeId;
         if (!array_key_exists($cparent, $this->folders)) {
             $this->folders[$cparent] = new FeedFolder($fname, $cparent, $this);
         }
         //$this->folders[$cparent]->feeds[] = $f;
         if ($ucc != 0 || !getConfig('rss.output.minimalchannellist')) {
             $this->folders[$cparent]->feeds[] = $f;
         }
         $this->folders[$cparent]->isCollapsed = in_array($cparent, $this->collapsed_ids) && $cparent > 0;
     }
     _pf('done');
 }
コード例 #5
0
ファイル: opml.php プロジェクト: jphpsf/gregarius
/** OPML1.0 Specs: http://opml.scripting.com/spec                        */
// This is a pretty lame opml 1.1 generation routine, in that it is not
// recursive, but instead relies on the fact that we only have one level
// of folders.
// Output should be valid xml. (*fingers crossed*)
if (array_key_exists('act', $_REQUEST)) {
    $rs = rss_query("select fid,tag from " . getTable('tag') . " t " . "inner join " . getTable('metatag') . " mt on mt.tid = t.id " . " where ttype='channel'");
    $cats = array();
    while (list($cid, $tag) = rss_fetch_row($rs)) {
        if (!isset($cats[$cid])) {
            $cats[$cid] = array();
        }
        $cats[$cid][] = $tag;
    }
    $sql = "select " . " c.id, c.title, c.url, c.siteurl, d.name, c.parent, c.descr " . " from " . getTable("channels") . " c " . " inner join " . getTable("folders") . " d on d.id = c.parent " . " where not (c.mode & " . RSS_MODE_DELETED_STATE . ") ";
    if (hidePrivate()) {
        $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") ";
    }
    // note: should we export deprecated feeds?
    if (getConfig('rss.config.absoluteordering')) {
        $sql .= " order by d.position asc, c.position asc";
    } else {
        $sql .= " order by d.name asc, c.title asc";
    }
    $res = rss_query($sql);
    $dateRes = rss_query("select max(dateadded) from " . getTable("channels"));
    list($dateModif) = rss_fetch_row($dateRes);
    $dateLabel = date("r", strtotime($dateModif));
    header("Content-Type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"" . getConfig('rss.output.encoding') . "\"?>\n" . "<?xml-stylesheet type=\"text/xsl\" href=\"" . getPath() . "css/opml.xsl\"?>\n" . "<!-- Generated by " . _TITLE_ . " " . _VERSION_ . " -->\n" . "<opml version=\"2.0\">\n";
    echo "\t<head>\n" . "\t\t<title>" . _TITLE_ . " OPML Feed</title>\n" . "\t\t<dateModified>{$dateLabel}</dateModified>\n" . "\t</head>\n" . "\t<body>\n";
コード例 #6
0
ファイル: api.php プロジェクト: jphpsf/gregarius
function blGetItems($cid, $date, $markread)
{
    if (hidePrivate()) {
        header('HTTP/1.x 401 Not Authorized');
        exit;
    }
    if (!$cid) {
        header('HTTP/1.x 403 Forbidden');
        exit;
    }
    $sql = "select i.title as ititle, i.description as idescr, c.title as ctitle, " . " c.descr as cdescr, c.url as curl, i.author as iauth, i.url as iurl, " . " unix_timestamp(ifnull(i.pubdate, i.added)) as idate ,i.id as iid" . " from " . getTable('item') . " i " . " inner join " . getTable('channels') . " c " . "  on c.id = i.cid " . " where i.unread & " . RSS_MODE_UNREAD_STATE . " and c.id={$cid}";
    if ($date) {
        $sql .= " and ifnull(i.pubdate, i.added) > {$date} ";
    }
    $rs = rss_query($sql);
    if (rss_num_rows($rs) == 0) {
        header('HTTP/1.x 304 Not Modified');
        exit;
    }
    $ids = array();
    header('Content-Type: text/xml; charset=utf-8');
    $hdr = false;
    while ($row = rss_fetch_assoc($rs)) {
        if (!$hdr) {
            $hdr = true;
            echo "<" . "?xml version=\"1.0\"?" . ">\n" . "<rss version=\"2.0\"\n" . "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" . "xmlns:bloglines=\"http://www.bloglines.com/services/module\"\n" . "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" . "<channel>\n" . "\t<title>" . htmlspecialchars($row['ctitle']) . "</title>\n" . "\t<link>" . htmlspecialchars($row['curl']) . "</link>\n" . "\t<description>" . htmlspecialchars($row['cdescr']) . "</description>\n" . "\t<language>en-us</language>\n" . "\t<webMaster>support@bloglines.com</webMaster>\n";
        }
        $ids[] = $row['iid'];
        echo "\t<item>\n" . "\t\t<title>" . htmlspecialchars($row['ititle']) . "</title>\n" . "\t\t<dc:creator>" . htmlspecialchars($row['iauth']) . "</dc:creator>\n" . "\t\t<guid isPermaLink=\"true\">" . htmlspecialchars($row['iurl']) . "</guid>\n" . "\t\t<link>" . htmlspecialchars($row['iurl']) . "</link>\n" . "\t\t<description><![CDATA[" . $row['idescr'] . "]]></description>\n" . "\t\t<pubDate>" . date('D, j M Y H:i:s \\G\\M\\T', $row['idate']) . "</pubDate>\n" . "\t\t<bloglines:itemid>" . $row['iid'] . "</bloglines:itemid>\n" . "\t</item>\n";
    }
    echo "</channel>\n</rss>\n";
    if ($markread) {
        $sql = "update " . getTable('item') . " set unread = unread & " . SET_MODE_READ_STATE . " where id in (" . implode(',', $ids) . ")";
        rss_query($sql);
        rss_invalidate_cache();
    }
}
コード例 #7
0
function __stickyflag_BeforeTitle($id)
{
    $ret = "";
    $flags = rss_item_flags();
    if (!hidePrivate()) {
        $options = rss_plugins_get_option(STICKYFLAG_CONFIG_OPTIONS);
        if (null == $options) {
            return;
        }
        if ($options & STICKYFLAG_ENABLE_STICKY_SHORTCUT) {
            if ($flags & RSS_MODE_STICKY_STATE) {
                $ret .= "<a id='ms" . $id . "' href='#' onclick='_stickyflag_sticky(" . $id . ", " . $flags . "); return false;' title='Make Un-Sticky'>" . "<img id='sticky_img_" . $id . "' src='" . STICKYFLAG_ICON_STICKY . "' alt='S' /></a>&nbsp;";
            } else {
                $ret .= "<a id='ms" . $id . "' href='#' onclick='_stickyflag_sticky(" . $id . ", " . $flags . "); return false;' title='Make Sticky'>" . "<img id='sticky_img_" . $id . "' src='" . STICKYFLAG_ICON_NOSTICKY . "' alt='S' /></a>&nbsp;";
            }
        }
        if ($options & STICKYFLAG_ENABLE_FLAG_SHORTCUT) {
            if ($flags & RSS_MODE_FLAG_STATE) {
                $ret .= "<a id='mf" . $id . "' href='#' onclick='_stickyflag_flag(" . $id . ", " . $flags . "); return false;' title='Un-Flag Item'>" . "<img id='flag_img_" . $id . "' src='" . __stickyflag_GetFlagIcon() . "' alt='F' /></a>&nbsp;";
            } else {
                $ret .= "<a id='mf" . $id . "' href='#' onclick='_stickyflag_flag(" . $id . ", " . $flags . "); return false;' title='Flag Item'>" . "<img id='flag_img_" . $id . "' src='" . STICKYFLAG_ICON_NOFLAG . "' alt='F' /></a>&nbsp;";
            }
        }
        if (!empty($ret)) {
            print $ret;
        }
    }
    return $id;
}
コード例 #8
0
ファイル: markallread.php プロジェクト: jphpsf/gregarius
function __markallread_afteritems($in)
{
    $options = rss_plugins_get_option(MARKALLREAD_CONFIG_OPTIONS);
    if (hidePrivate() || !($options & MARKALLREAD_OPTION_BOTTOM_BUTTON)) {
        return $in;
    }
    if (defined('MARK_READ_FEED_FORM') || defined('MARK_READ_FOLDER_FORM') || defined('MARK_READ_VFOLDER_FORM')) {
        echo "<div style=\"text-align:right\">\n";
        __markallread_buttondisplay();
        echo "</div>\n";
    }
    return $in;
}
コード例 #9
0
ファイル: categories.php プロジェクト: jphpsf/gregarius
 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
ファイル: update.php プロジェクト: nerdling/gregarius
 function render()
 {
     $newIds = array();
     foreach ($this->chans as $chan) {
         list($cid, $url, $title) = $chan;
         $ret = update($cid);
         if (is_array($ret)) {
             list($error, $unreadIds) = $ret;
             $newIds = array_merge($newIds, $unreadIds);
         } else {
             $error = 0;
             $unreadIds = array();
         }
         $unread = count($unreadIds);
         list($label, $cls) = parent::magpieError($error);
         if ($cls != ERROR_NOERROR || $unread > 0) {
             echo "{$title} ...\t";
             flush();
             echo "\n{$label}, {$unread} " . __('New Items') . "\n\n";
             flush();
         }
     }
     if (!hidePrivate()) {
         parent::cleanUp($newIds);
     }
 }
コード例 #11
0
ファイル: feed.php プロジェクト: jphpsf/gregarius
/**
* This function will return an array for the previous, next and up
* navigation elements, based on the current location
*
* @return: array (
	('prev'|'next'|'up')* => array (
		 'y' => year of the prev,next,up item
		 'm' => month of the prev,next,up item
		 'd' => day of the prev,next,up item
		 'cnt' => count of the prev,next,up items for this date
		 'ts' => unix timestamp of the above 
		 'url' =>  precomputed uri for the link
		 'lbl' => precomupted label to be used in the links
	)
)
*/
function makeNav($cid, $iid, $y, $m, $d, $fid, $vfid, $cids)
{
    //echo "X-info: $cid,$iid,$y,$m,$d,$fid,$vfid,$cids";
    $currentView = null;
    $prev = $succ = $up = null;
    if (isset($_REQUEST['channel'])) {
        $escaped_title = rss_uri($_REQUEST['channel']);
        //preg_replace("/[^A-Za-z0-9\.]/","_",$_REQUEST['channel']);
    } else {
        $escaped_title = null;
    }
    // where are we anyway?
    if ($y > 0 && $m > 0 && $d > 0) {
        if ($iid != "") {
            $currentView = 'item';
        } else {
            $currentView = 'day';
        }
    } elseif ($y > 0 && $m > 0 && $d == 0) {
        $currentView = 'month';
    } elseif ($cids) {
        if ($fid) {
            $currentView = "folder";
        } elseif ($vfid) {
            $currentView = "cat";
        }
    } elseif ($cid) {
        $currentView = "feed";
    }
    if ($currentView) {
        switch ($currentView) {
            case 'month':
            case 'day':
                if ($currentView == 'day') {
                    $ts_p = mktime(23, 59, 59, $m, $d - 1, $y);
                    $ts_s = mktime(0, 0, 0, $m, $d, $y);
                } elseif ($currentView == 'month') {
                    $ts_p = mktime(0, 0, 0, $m + 1, 0, $y);
                    $ts_s = mktime(0, 0, 0, $m, 1, $y);
                }
                $sql_succ = " select " . " UNIX_TIMESTAMP( ifnull(i.pubdate, i.added)) as ts_, " . " year( ifnull(i.pubdate, i.added)) as y_, " . " month( ifnull(i.pubdate, i.added)) as m_, " . ($currentView == 'day' ? " dayofmonth( ifnull(i.pubdate, i.added)) as d_, " : "") . " count(*) as cnt_ " . " from " . getTable("item") . "i  where " . " UNIX_TIMESTAMP(ifnull(i.pubdate, i.added)) > {$ts_s} ";
                if ($cid) {
                    $sql_succ .= " and cid={$cid} ";
                }
                if (hidePrivate()) {
                    $sql_succ .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") ";
                }
                $sql_succ .= " group by y_,m_" . ($currentView == 'day' ? ",d_ " : "") . " order by ts_ asc limit 4";
                $sql_prev = " select " . " UNIX_TIMESTAMP( ifnull(i.pubdate, i.added)) as ts_, " . " year( ifnull(i.pubdate, i.added)) as y_, " . " month( ifnull(i.pubdate, i.added)) as m_, " . ($currentView == 'day' ? " dayofmonth( ifnull(i.pubdate, i.added)) as d_, " : "") . " count(*) as cnt_ " . " from " . getTable("item") . " i  where " . " UNIX_TIMESTAMP(ifnull(i.pubdate, i.added)) < {$ts_p} ";
                if ($cid) {
                    $sql_prev .= " and cid={$cid} ";
                }
                if (hidePrivate()) {
                    $sql_prev .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") ";
                }
                $sql_prev .= " group by y_,m_" . ($currentView == 'day' ? ",d_ " : "") . " order by ts_ desc limit 4";
                //echo "<!-- $sql_prev -->\n";
                $res_prev = rss_query($sql_prev);
                $res_succ = rss_query($sql_succ);
                $mCount = 12 * $y + $m;
                // next
                while ($succ == null && ($row = rss_fetch_assoc($res_succ))) {
                    if ($currentView == 'day') {
                        if (mktime(0, 0, 0, $row['m_'], $row['d_'], $row['y_']) > $ts_s) {
                            $succ = array('y' => $row['y_'], 'm' => $row['m_'], 'd' => $row['d_'], 'cnt' => $row['cnt_'], 'ts' => $row['ts_'], 'url' => makeArchiveUrl($row['ts_'], $escaped_title, $cid, $currentView == 'day'), 'lbl' => rss_locale_date('%B %e', $row['ts_']) . " (" . $row['cnt_'] . " " . ($row['cnt_'] > 1 ? __('items') : __('item')) . ")");
                        }
                    } elseif ($currentView == 'month') {
                        if ($row['m_'] + 12 * $row['y_'] > $mCount) {
                            $succ = array('y' => $row['y_'], 'm' => $row['m_'], 'cnt' => $row['cnt_'], 'ts' => $row['ts_'], 'url' => makeArchiveUrl($row['ts_'], $escaped_title, $cid, $currentView == 'day'), 'lbl' => rss_locale_date('%B %Y', $row['ts_']) . " (" . $row['cnt_'] . " " . ($row['cnt_'] > 1 ? __('items') : ITEM) . ")");
                        }
                    }
                }
                // prev
                while ($prev == null && ($row = rss_fetch_assoc($res_prev))) {
                    if ($currentView == 'day') {
                        if (mktime(0, 0, 0, $row['m_'], $row['d_'], $row['y_']) < $ts_p) {
                            $prev = array('y' => $row['y_'], 'm' => $row['m_'], 'd' => $row['d_'], 'cnt' => $row['cnt_'], 'ts' => $row['ts_'], 'url' => makeArchiveUrl($row['ts_'], $escaped_title, $cid, $currentView == 'day'), 'lbl' => rss_locale_date('%B %e', $row['ts_']) . " (" . $row['cnt_'] . " " . ($row['cnt_'] > 1 ? __('items') : __('item')) . ")");
                        }
                    } elseif ($currentView == 'month') {
                        if ($row['m_'] + 12 * $row['y_'] < $mCount) {
                            $prev = array('y' => $row['y_'], 'm' => $row['m_'], 'cnt' => $row['cnt_'], 'ts' => $row['ts_'], 'url' => makeArchiveUrl($row['ts_'], $escaped_title, $cid, $currentView == 'day'), 'lbl' => rss_locale_date('%B %Y', $row['ts_']) . " (" . $row['cnt_'] . " " . ($row['cnt_'] > 1 ? __('items') : __('item')) . ")");
                        }
                    }
                }
                // up
                if ($currentView == 'day') {
                    $ts = mktime(0, 0, 0, $m, 10, $y);
                    $up = array('y' => $y, 'm' => $m, 'url' => makeArchiveUrl($ts, $escaped_title, $cid, false), 'lbl' => rss_locale_date('%B %Y', $ts));
                } elseif ($currentView == 'month') {
                    $up = array('url' => getPath() . (getConfig('rss.output.usemodrewrite') ? $escaped_title : "feed.php?channel={$cid}"), 'lbl' => $escaped_title, 'lbl' => '');
                }
                break;
            case 'item':
                $sql = " select i.title, i.id, " . " UNIX_TIMESTAMP( ifnull(i.pubdate, i.added)) as ts_, " . " year( ifnull(i.pubdate, i.added)) as y_, " . " month( ifnull(i.pubdate, i.added)) as m_, " . " dayofmonth( ifnull(i.pubdate, i.added)) as d_ " . " from " . getTable("item") . " i " . " where i.cid = {$cid}  ";
                if (hidePrivate()) {
                    $sql .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") ";
                }
                if (getConfig('rss.config.datedesc.unread')) {
                    $sql .= " order by ts_ desc, i.id asc";
                } else {
                    $sql .= " order by ts_ asc, i.id asc";
                }
                $rs = rss_query($sql);
                $found = false;
                $stop = false;
                $prev__ = null;
                $fCounter = 0;
                while (!$stop && (list($title_, $iid_, $ts_, $y_, $m_, $d_) = rss_fetch_row($rs))) {
                    if ($iid_ == $iid) {
                        //this is the "current" item, get a hold on the previous one
                        $found = true;
                        if ($prev__) {
                            list($ptitle_, $piid_, $pts_, $py_, $pm_, $pd_) = $prev__;
                            $succ = array('y' => $py_, 'm' => $pm_, 'cnt' => 0, 'ts' => $pts_, 'url' => makeArchiveUrl($pts_, $escaped_title, $cid, true) . (getConfig('rss.output.usemodrewrite') ? rss_uri($ptitle_) : "&amp;iid={$piid_}"), 'lbl' => htmlentities($ptitle_, ENT_COMPAT, "UTF-8"));
                        }
                    }
                    if ($found) {
                        // okay, this is the next item, then.
                        $fCounter++;
                        if ($fCounter == 2) {
                            $prev = array('y' => $y_, 'm' => $m_, 'cnt' => 0, 'ts' => $ts_, 'url' => makeArchiveUrl($ts_, $escaped_title, $cid, true) . (getConfig('rss.output.usemodrewrite') ? rss_uri($title_) : "&amp;iid={$iid_}"), 'lbl' => htmlentities($title_, ENT_COMPAT, "UTF-8"));
                            $stop = true;
                        }
                    }
                    $prev__ = array($title_, $iid_, $ts_, $y_, $m_, $d_);
                }
                // up
                $ts = mktime(0, 0, 0, $m, $d, $y);
                $up = array('y' => $y, 'm' => $m, 'd' => $d, 'url' => makeArchiveUrl($ts, $escaped_title, $cid, true), 'lbl' => rss_locale_date('%B %e', $ts));
                break;
            case 'feed':
                $sql = "select " . " c.id, c.title " . " from " . getTable("channels") . " c " . " inner join " . getTable("folders") . " d " . "   on d.id = c.parent ";
                $sql .= " where not(c.mode & " . RSS_MODE_DELETED_STATE . ") ";
                if (hidePrivate()) {
                    $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") ";
                }
                if (getConfig('rss.config.absoluteordering')) {
                    $sql .= " order by d.position asc, c.position asc";
                } else {
                    $sql .= " order by d.name asc, c.title asc";
                }
                $res = rss_query($sql);
                $pcid = $ptitile = null;
                $cidname = array();
                $cids = array();
                while (list($cid_, $title_) = rss_fetch_row($res)) {
                    $cids[] = $cid_;
                    $cidname[] = array($cid_, $title_);
                }
                $key = array_search($cid, $cids);
                if ($key !== NULL && $key !== FALSE) {
                    //echo "$key " .count($cidname);
                    if ($key + 1 < count($cidname)) {
                        list($cid_, $title_) = $cidname[$key + 1];
                        $succ = array('url' => getPath() . (getConfig('rss.output.usemodrewrite') ? rss_uri($title_) . "/" : "feed.php?channel={$cid_}"), 'lbl' => htmlentities($title_, ENT_COMPAT, "UTF-8"));
                    }
                    if ($key > 0) {
                        list($cid_, $title_) = $cidname[$key - 1];
                        $prev = array('url' => getPath() . (getConfig('rss.output.usemodrewrite') ? rss_uri($title_) . "/" : "feed.php?channel={$cid_}"), 'lbl' => htmlentities($title_, ENT_COMPAT, "UTF-8"));
                    }
                }
                break;
            case 'cat':
                $res = rss_query(" select t.tag,t.id from  " . getTable('metatag') . " m " . "inner join " . getTable('tag') . "t on t.id = m.tid " . " where  m.ttype = 'channel' " . " order by t.tag asc");
                $pp = null;
                $nn = null;
                $found = false;
                $stop = false;
                while (!$stop && (list($tt_, $tid_) = rss_fetch_row($res))) {
                    if ($vfid == $tid_) {
                        $found = true;
                    }
                    if (!$found) {
                        $pp = array('id' => $tid_, 'title' => $tt_);
                    } elseif ($vfid != $tid_) {
                        $nn = array('id' => $tid_, 'title' => $tt_);
                        $stop = true;
                    }
                }
                if ($pp) {
                    $vftitle_ = $pp['title'];
                    $vfid_ = $pp['id'];
                    $prev = array('url' => getPath() . (getConfig('rss.output.usemodrewrite') ? rss_uri($vftitle_) . "/" : "feed.php?vfolder={$vfid_}"), 'lbl' => htmlentities($vftitle_, ENT_COMPAT, "UTF-8"));
                }
                if ($nn) {
                    $vftitle_ = $nn['title'];
                    $vfid_ = $nn['id'];
                    $succ = array('url' => getPath() . (getConfig('rss.output.usemodrewrite') ? rss_uri($vftitle_) . "/" : "feed.php?vfolder={$vfid_}"), 'lbl' => htmlentities($vftitle_, ENT_COMPAT, "UTF-8"));
                }
                break;
            case 'folder':
                $sql = "select  f.id, f.name, count(*) from " . getTable('channels') . " c " . "inner join " . getTable('folders') . " f on f.id = c.parent " . " where f.name != '' ";
                if (hidePrivate()) {
                    $sql .= " and not (c.mode & " . RSS_MODE_PRIVATE_STATE . ")";
                }
                $sql .= " group by f.id ";
                if (getConfig('rss.config.absoluteordering')) {
                    $sql .= " order by f.position asc, c.position asc";
                } else {
                    $sql .= " order by f.name, c.title asc";
                }
                $res = rss_query($sql);
                $pp = null;
                $nn = null;
                $found = false;
                $stop = false;
                while (!$stop && (list($fid_, $fn_, $fc_) = rss_fetch_row($res))) {
                    if ($fc_ == 0) {
                        continue;
                    }
                    if ($fid == $fid_) {
                        $found = true;
                    }
                    if (!$found) {
                        $pp = array('id' => $fid_, 'title' => $fn_);
                    } elseif ($fid != $fid_) {
                        $nn = array('id' => $fid_, 'title' => $fn_);
                        $stop = true;
                    }
                }
                if ($pp) {
                    $ftitle__ = $pp['title'];
                    $fid__ = $pp['id'];
                    $prev = array('url' => getPath() . (getConfig('rss.output.usemodrewrite') ? rss_uri($ftitle__) . "/" : "feed.php?folder={$fid__}"), 'lbl' => htmlentities($ftitle__, ENT_COMPAT, "UTF-8"));
                }
                if ($nn) {
                    $ftitle__ = $nn['title'];
                    $fid__ = $nn['id'];
                    $succ = array('url' => getPath() . (getConfig('rss.output.usemodrewrite') ? rss_uri($ftitle__) . "/" : "feed.php?folder={$fid__}"), 'lbl' => htmlentities($ftitle__, ENT_COMPAT, "UTF-8"));
                }
                break;
            default:
                //echo "current view: $currentView";
                break;
        }
        return array($prev, $succ, $up);
    }
    return null;
}
コード例 #12
0
ファイル: alltags.php プロジェクト: jphpsf/gregarius
 /**
  * Fills the instance data for this object: gets a hold 
  * of all tags defined in the system.
  */
 function populate()
 {
     // the all tags weighted list
     $sql = "select t.id, tag, count(*) as cnt from " . getTable('metatag');
     if ($this->type == 'channel') {
         $sql .= " left join " . getTable('channels') . " c on (fid=c.id) " . "inner join " . getTable('tag') . " t " . " on tid=t.id " . " where ttype = 'channel'";
     } else {
         $sql .= " left join " . getTable('item') . " i on (fid=i.id) " . "inner join " . getTable('tag') . " t " . " on tid=t.id " . " where ttype = 'item'";
     }
     // Don't count tags of private items
     if (hidePrivate()) {
         $sql .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") ";
     }
     $sql .= " and not (i.unread & " . RSS_MODE_DELETED_STATE . ") ";
     $sql .= " group by tid order by tag";
     $res = rss_query($sql);
     $max = 0;
     $min = 100000;
     $cntr = 0;
     while (list($tid, $tag, $cnt) = rss_fetch_row($res)) {
         $this->allTags[$tag] = $cnt;
         // list of unread items
         $cntUnread = 0;
         $sql = "select fid from " . getTable('metatag') . " where tid = {$tid}";
         $res2 = rss_query($sql);
         while (list($fid) = rss_fetch_row($res2)) {
             if ($this->type == 'channel') {
                 $cntUnread += getUnreadCount($fid, null);
             } else {
                 $sql = "select unread from " . getTable('item') . " where id = {$fid}" . " and (unread & " . RSS_MODE_UNREAD_STATE . ") ";
                 if (hidePrivate()) {
                     $sql .= " and not(unread & " . RSS_MODE_PRIVATE_STATE . ") ";
                 }
                 if (rss_num_rows(rss_query($sql))) {
                     $cntUnread++;
                 }
             }
         }
         $this->unreadItems[$tag] = $cntUnread;
         $cntr++;
     }
 }
コード例 #13
0
ファイル: search.php プロジェクト: jphpsf/gregarius
 function populate()
 {
     if (!$this->query) {
         return;
     }
     $this->matchMode = sanitize(!array_key_exists(QUERY_MATCH_MODE, $_REQUEST) ? QUERY_MATCH_AND : $_REQUEST[QUERY_MATCH_MODE], RSS_SANITIZER_CHARACTERS_EXT);
     $this->matchType = sanitize(!array_key_exists(QUERY_MATCH_TYPE, $_REQUEST) ? "" : $_REQUEST[QUERY_MATCH_TYPE], RSS_SANITIZER_CHARACTERS_EXT);
     $this->channelId = sanitize(array_key_exists(QUERY_CHANNEL, $_REQUEST) ? $_REQUEST[QUERY_CHANNEL] : ALL_CHANNELS_ID, RSS_SANITIZER_NUMERIC);
     if (!$this->resultsPerPage) {
         $this->resultsPerPage = sanitize(array_key_exists(QUERY_RESULTS, $_REQUEST) ? $_REQUEST[QUERY_RESULTS] : 15, RSS_SANITIZER_NUMERIC);
     }
     $this->currentPage = sanitize(array_key_exists(QUERY_CURRENT_PAGE, $_REQUEST) ? $_REQUEST[QUERY_CURRENT_PAGE] : 0, RSS_SANITIZER_NUMERIC);
     $this->startItem = $this->resultsPerPage * $this->currentPage;
     $this->endItem = $this->startItem + $this->resultsPerPage - 1;
     if ($this->resultsPerPage == INFINE_RESULTS) {
         $this->endItem = 99999999;
     }
     $this->orderBy = sanitize(array_key_exists(QUERY_ORDER_BY, $_REQUEST) ? $_REQUEST[QUERY_ORDER_BY] : QUERY_ORDER_BY_DATE, RSS_SANITIZER_CHARACTERS_EXT);
     $qWhere = "";
     $this->regMatch = "";
     $term = "";
     if ($this->matchMode == QUERY_MATCH_OR || $this->matchMode == QUERY_MATCH_AND) {
         $this->logicSep = $this->matchMode == QUERY_MATCH_OR ? "or" : "and";
         $this->searchTerms = explode(" ", $this->query);
         foreach ($this->searchTerms as $term) {
             $term = trim($term);
             if ($term != "") {
                 $qWhere .= "(i.description like '%{$term}%' or " . " i.title like '%{$term}%') " . $this->logicSep;
             }
             // this will be used later for the highliting regexp
             if ($this->regMatch != "") {
                 $this->regMatch .= "|";
             }
             $this->regMatch .= $term;
         }
         $qWhere .= $this->matchMode == QUERY_MATCH_OR ? " 1=0 " : " 1=1 ";
     } else {
         $this->logicSep = "";
         $this->searchTerms[0] = $this->query;
         $term = $this->query;
         $qWhere .= "(i.description like '%{$term}%' or " . " i.title like '%{$term}%') ";
         $this->regMatch = $this->query;
     }
     $qWhere = "(" . $qWhere . ") ";
     if ($this->channelId != ALL_CHANNELS_ID) {
         $qWhere .= " and c.id = " . $this->channelId . " ";
     }
     if (hidePrivate()) {
         $qWhere .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") ";
     }
     $qWhere .= " and not(i.unread & " . RSS_MODE_DELETED_STATE . ") ";
     if (array_key_exists(QUERY_MATCH_STATE, $_REQUEST) && QUERY_MATCH_READ == $_REQUEST[QUERY_MATCH_STATE]) {
         // Show only read items.
         $qWhere .= " and not (i.unread & " . RSS_MODE_UNREAD_STATE . ") ";
     } else {
         if (array_key_exists(QUERY_MATCH_STATE, $_REQUEST) && QUERY_MATCH_UNREAD == $_REQUEST[QUERY_MATCH_STATE]) {
             // Show only unread items.
             $qWhere .= " and (i.unread & " . RSS_MODE_UNREAD_STATE . ") ";
         }
     }
     if ($this->orderBy == QUERY_ORDER_BY_DATE) {
         $qOrder = "  ts desc";
     } else {
         if (getConfig('rss.config.absoluteordering')) {
             $qOrder = "  f.position asc, c.position asc";
         } else {
             $qOrder = "  f.name asc, c.title asc";
         }
     }
     $qOrder .= ", i.added desc";
     parent::populate($qWhere, $qOrder, 0, getConfig("rss.search.maxitems"), ITEM_SORT_HINT_MIXED, true);
     $this->filterItems();
     $this->nav();
 }
コード例 #14
0
 /**
  * Populates a an ItemList with items from the Database. Note that this methdo
  * can be invoked several times on the same ItemList object instance: upon each
  * call the new items will be aggregated to the existing ones.
  * 
  * @param sqlWhere specifies what should be fetched
  * @param sqlOrder (optional) specifies a different item ordering
  * @param sqlLimit (optional) specifies how many items should be fetched
  * @param includeDeprecated (optional) specifies if deprecated feeds should be fetched
  */
 function populate($sqlWhere, $sqlOrder = "", $startItem = 0, $itemCount = -1, $hint = ITEM_SORT_HINT_MIXED, $includeDeprecated = false)
 {
     _pf('ItemList::populate()');
     $this->_sqlActualWhat = " i.title,  c.title, c.id, i.unread, " . "i.url, i.enclosure, i.author, i.description, c.icon, " . " unix_timestamp(ifnull(i.pubdate,i.added)) as ts, " . " i.pubdate is not null as ispubdate, i.id " . " , null ";
     $this->_sqlActualFrom = getTable("item") . " i " . " inner join " . getTable("channels") . " c on (c.id = i.cid) " . " inner join " . getTable("folders") . " f on (f.id = c.parent) ";
     $this->_sqlActualWhere = (false == $includeDeprecated ? " not(c.mode & " . RSS_MODE_DELETED_STATE . ") and " : "") . " not(i.unread & " . RSS_MODE_DELETED_STATE . ") and ";
     if (hidePrivate()) {
         $this->_sqlActualWhere .= " not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") and ";
     }
     if ($this->_sqlActualWhere) {
         $this->_sqlActualWhere .= $sqlWhere . " and ";
     }
     $this->_sqlActualWhere .= " 1=1 ";
     /// Order by
     $sqlOrder = rss_plugin_hook("rss.plugins.items.order", $sqlOrder);
     if ($sqlOrder == "") {
         switch ($hint) {
             case ITEM_SORT_HINT_MIXED:
             case ITEM_SORT_HINT_READ:
                 $skey = 'read';
                 break;
             case ITEM_SORT_HINT_UNREAD:
             default:
                 $skey = 'unread';
                 break;
         }
         if (!getConfig('rss.config.feedgrouping')) {
             if (getConfig("rss.config.datedesc.{$skey}")) {
                 $this->_sqlActualOrder = " ts desc, f.position asc, c.position asc ";
             } else {
                 $this->_sqlActualOrder = " ts asc, f.position asc, c.position asc ";
             }
         } elseif (getConfig('rss.config.absoluteordering')) {
             $this->_sqlActualOrder = " f.position asc, c.position asc";
         } else {
             $this->_sqlActualOrder = " f.name asc, c.title asc";
         }
         if (getConfig("rss.config.datedesc.{$skey}")) {
             $this->_sqlActualOrder .= ", ts desc, i.id asc";
         } else {
             $this->_sqlActualOrder .= ", ts asc, i.id asc";
         }
     } else {
         $this->_sqlActualOrder = " {$sqlOrder} ";
     }
     if ($itemCount < 0 || $itemCount > RSS_DB_MAX_QUERY_RESULTS) {
         $itemCount = RSS_DB_MAX_QUERY_RESULTS;
     }
     $this->_sqlActualLimit = " {$startItem}, {$itemCount}";
     $sql = "select " . $this->_sqlActualWhat . " from " . $this->_sqlActualFrom . " where " . $this->_sqlActualWhere . " order by " . $this->_sqlActualOrder . " limit " . $this->_sqlActualLimit;
     //echo $sql;
     $this->iids = array();
     $res = $GLOBALS['rss_db']->rss_query($sql);
     $this->rowCount = $GLOBALS['rss_db']->rss_num_rows($res);
     $prevCid = -1;
     $curIdx = 0;
     $f = null;
     while (list($ititle_, $ctitle_, $cid_, $iunread_, $iurl_, $ienclosure_, $iauthor_, $idescr_, $cicon_, $its_, $iispubdate_, $iid_, $rrating_) = $GLOBALS['rss_db']->rss_fetch_row($res)) {
         // Built a new Item
         $i = new Item($iid_, $ititle_, $iurl_, $ienclosure_, $cid_, $iauthor_, $idescr_, $its_, $iispubdate_, $iunread_, $rrating_);
         // no dupes, please
         if (in_array($iid_, $this->iids)) {
             $this->rowCount--;
             continue;
         }
         // Allow for some item filtering before it is rendered
         if (($i = rss_plugin_hook('rss.plugins.items.beforerender', $i)) == null) {
             $this->rowCount--;
             continue;
         }
         // See if we have a channel for it
         if ($cid_ != $prevCid) {
             $f = new Feed($ctitle_, $cid_, $cicon_);
             $this->feeds[] = $f;
             $curIdx = count($this->feeds) - 1;
             $prevCid = $cid_;
         }
         $this->iidInCid[$iid_] = $curIdx;
         // Add it to the channel
         $this->iids[] = $iid_;
         $this->feeds[$curIdx]->addItem($i);
         // Some stats...
         $this->itemCount++;
         if ($iunread_ & RSS_MODE_UNREAD_STATE) {
             $this->unreadCount++;
             $this->unreadIids[] = $iid_;
         } else {
             $this->readCount++;
         }
     }
     // Tags!
     if (count($this->iids)) {
         // fetch the tags for the items;
         $sql = "select t.tag, m.fid, i.cid " . " from " . getTable('tag') . " t " . " inner join " . getTable('metatag') . " m " . "   on m.tid = t.id " . " inner join " . getTable('item') . " i " . "   on i.id = m.fid " . " where m.ttype = 'item' and m.fid in (" . implode(",", $this->iids) . ")";
         $res = $GLOBALS['rss_db']->rss_query($sql);
         while (list($tag_, $iid_, $cid_) = $GLOBALS['rss_db']->rss_fetch_row($res)) {
             if (array_key_exists($iid_, $this->iidInCid)) {
                 $idx = $this->iidInCid[$iid_];
                 while (list($key, $item) = each($this->feeds[$idx]->items)) {
                     if ($item->id == $iid_) {
                         $this->feeds[$idx]->items[$key]->tags[] = $tag_;
                         break;
                     }
                 }
                 reset($this->feeds[$idx]->items);
             }
             if (array_key_exists($tag_, $this->allTags)) {
                 $this->allTags[$tag_]++;
             } else {
                 $this->allTags[$tag_] = 1;
             }
         }
     }
     _pf('done: ItemList::populate()');
 }
コード例 #15
0
ファイル: util.php プロジェクト: abdallahchamas/haiti_tracker
function getUnreadCount($cid, $fid)
{
    static $_uccache = array();
    $key_ = "key {$cid} {$fid} key";
    if (isset($_uccache[$key_])) {
        return $_uccache[$key_];
    }
    $sql = "select count(*) from " . getTable("item") . "i " . "inner join " . getTable('channels') . " c on c.id = i.cid " . " where i.unread & " . RSS_MODE_UNREAD_STATE . " and not(i.unread & " . RSS_MODE_DELETED_STATE . ") " . " and not(c.mode & " . RSS_MODE_DELETED_STATE . ") ";
    if (hidePrivate()) {
        $sql .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ")";
    }
    if ($cid) {
        $sql .= " and c.id={$cid} ";
    } elseif ($fid) {
        $sql .= " and c.parent={$fid} ";
    }
    $res = rss_query($sql);
    list($_uccache[$key_]) = rss_fetch_row($res);
    return $_uccache[$key_];
}
コード例 #16
0
ファイル: item.php プロジェクト: abdallahchamas/haiti_tracker
function rss_item_rating()
{
    $iid = $GLOBALS['rss']->currentItem->id;
    $ret = "\n\t\t<ul class=\"rr\" id=\"rr{$iid}\">\n";
    for ($r = 1; $r <= 5; $r++) {
        $cls = $GLOBALS['rss']->currentItem->rating == $r ? " class=\"current\" " : "";
        $act = !hidePrivate() ? "_rt({$iid},{$r}); return false;" : "return false;";
        $ret .= "\t\t\t<li{$cls}><a href=\"#\" onclick=\"{$act}\" class=\"r{$r}\">{$r}</a></li>\n";
    }
    $ret .= "\t\t</ul>\n";
    return $ret;
}
コード例 #17
0
ファイル: item.php プロジェクト: jphpsf/gregarius
        echo rss_item_pl_url();
        ?>
">
		<img src="<?php 
        echo rss_theme_path();
        ?>
/media/mark_off.gif" alt="<?php 
        echo rss_item_pl_title();
        ?>
" />
	</a>
	<?php 
    }
    ?>
	<?php 
    if (!hidePrivate()) {
        ?>
	<a id="sa<?php 
        echo rss_item_id();
        ?>
" href="#" onclick="_es(<?php 
        echo rss_item_id();
        ?>
,<?php 
        echo rss_item_flags();
        ?>
,<?php 
        echo rss_item_cid();
        ?>
); return false;">
		<img src="<?php 
コード例 #18
0
ファイル: items.php プロジェクト: jphpsf/gregarius
 /**
  * Populates a an ItemList with items from the Database. Note that this methdo
  * can be invoked several times on the same ItemList object instance: upon each
  * call the new items will be aggregated to the existing ones.
  *
  * @param sqlWhere specifies what should be fetched
  * @param sqlOrder (optional) specifies a different item ordering
  * @param sqlLimit (optional) specifies how many items should be fetched
  * @param includeDeprecated (optional) specifies if deprecated feeds should be fetched
  */
 function populate($sqlWhere, $sqlOrder = "", $startItem = 0, $itemCount = -1, $hint = ITEM_SORT_HINT_MIXED, $includeDeprecated = false)
 {
     _pf('ItemList::populate()');
     /*$this -> _sqlActualWhat = " i.title,  c.title, c.id, i.unread, "
     			."i.url, i.enclosure, i.author, i.description, c.icon, "
     			." unix_timestamp(ifnull(i.pubdate,i.added)) as ts, "
     			." i.pubdate is not null as ispubdate, i.id "
     			." , null "
     			//.", r.rating  "
     			;
     		$this -> _sqlActualFrom = 	getTable("item") ." i "
     			//." left join " . getTable("rating") ." r on (i.id = r.iid) "
     			." inner join " . getTable("channels")." c on (c.id = i.cid) "
     			." inner join " . getTable("folders") ." f on (f.id = c.parent) ";
     
     		$this -> _sqlActualWhere = (false == $includeDeprecated ? " not(c.mode & ".RSS_MODE_DELETED_STATE.") and " : "")
     			." not(i.unread & ".RSS_MODE_DELETED_STATE.") and ";
     
     		if (hidePrivate()) {
     			$this -> _sqlActualWhere .= " not(i.unread & ".RSS_MODE_PRIVATE_STATE.") and ";
     		}
     
     		if ($this -> _sqlActualWhere) {
     			$this -> _sqlActualWhere .= $sqlWhere ." and ";
     		}
     		$this -> _sqlActualWhere .= " 1=1 ";*/
     // jphpsf: this JOIN query between items and channels and folders seesm to be a bottleneck
     // on my installation the query takes like 5 sec to run. By splitting the query in 2 parts
     // (1 to get the items followed by another 1 to get the channels, it runs in less than 500ms)
     $this->_sqlActualWhat = "title, unread, url, enclosure, author, description,\n\t\t\t\t\tunix_timestamp(ifnull(pubdate,added)) as ts,\n\t\t\t\t\tpubdate is not null as ispubdate, id, cid ";
     $this->_sqlActualFrom = getTable("item") . " i ";
     if ($sqlWhere !== '') {
         $this->_sqlActualWhere = $sqlWhere . " and unread=5 ";
     } else {
         $this->_sqlActualWhere = "unread=5";
     }
     // unread=5 => only unread items
     if (hidePrivate()) {
         $this->_sqlActualWhere .= " and not(i.unread & " . RSS_MODE_PRIVATE_STATE . ") ";
     }
     /// Order by
     $sqlOrder = rss_plugin_hook("rss.plugins.items.order", $sqlOrder);
     if ($sqlOrder == "") {
         switch ($hint) {
             case ITEM_SORT_HINT_MIXED:
             case ITEM_SORT_HINT_READ:
                 $skey = 'read';
                 break;
             case ITEM_SORT_HINT_UNREAD:
             default:
                 $skey = 'unread';
                 break;
         }
         if (!getConfig('rss.config.feedgrouping')) {
             if (getConfig("rss.config.datedesc.{$skey}")) {
                 //$this -> _sqlActualOrder = " ts desc, f.position asc, c.position asc ";
                 $this->_sqlActualOrder = " ts desc, cid ";
             } else {
                 //$this -> _sqlActualOrder = " ts asc, f.position asc, c.position asc ";
                 $this->_sqlActualOrder = " ts asc, cid ";
             }
         }
         /*elseif (getConfig('rss.config.absoluteordering')) {
         			$this -> _sqlActualOrder = " f.position asc, c.position asc";
         		} else {
         			$this -> _sqlActualOrder = " f.name asc, c.title asc";
         		}
         		if(getConfig("rss.config.datedesc.$skey")){
         			$this -> _sqlActualOrder  .= ", ts desc, i.id asc";
         		}else{
         			$this -> _sqlActualOrder  .= ", ts asc, i.id asc";
         		}*/
     } else {
         $this->_sqlActualOrder = " {$sqlOrder} ";
     }
     if ($itemCount < 0 || $itemCount > RSS_DB_MAX_QUERY_RESULTS) {
         $itemCount = RSS_DB_MAX_QUERY_RESULTS;
     }
     $this->_sqlActualLimit = " {$startItem}, {$itemCount}";
     $sql = "select " . $this->_sqlActualWhat . " from " . $this->_sqlActualFrom . " where " . $this->_sqlActualWhere . " order by " . $this->_sqlActualOrder . " limit " . $this->_sqlActualLimit;
     $this->iids = array();
     $res = $GLOBALS['rss_db']->rss_query($sql);
     $this->rowCount = $GLOBALS['rss_db']->rss_num_rows($res);
     // jphpsf: this is the 1st query to get all items
     // we grab the channel ids at the same time
     $items = array();
     $cids = array();
     $groupByFeeds = array();
     while ($row = $GLOBALS['rss_db']->rss_fetch_row($res)) {
         if (!isset($cids[$row[9]])) {
             $cids[$row[9]] = $row[9];
             $groupByFeeds[$row[9]] = array();
         }
         $groupByFeeds[$row[9]][] = $row;
     }
     foreach ($groupByFeeds as $cid => $row) {
         $items = array_merge($items, $row);
     }
     // this is the 2nd query to get all channels
     if (count($cids) > 0) {
         $res = $GLOBALS['rss_db']->rss_query('select c.title, c.id, c.icon from channels c where id IN (' . implode(',', $cids) . ')');
         $channels = array();
         while ($row = $GLOBALS['rss_db']->rss_fetch_row($res)) {
             $channels[$row[1]] = $row;
             // cid index
         }
     }
     $prevCid = -1;
     $curIdx = 0;
     $f = null;
     // jphpsf: loop on items array instead of executing old query
     //		while (list ($ititle_, $ctitle_, $cid_, $iunread_, $iurl_, $ienclosure_, $iauthor_, $idescr_, $cicon_, $its_, $iispubdate_, $iid_, $rrating_) = $GLOBALS['rss_db']->rss_fetch_row($res)) {
     foreach ($items as $item) {
         $ititle_ = $item[0];
         $iunread_ = $item[1];
         $iurl_ = $item[2];
         $ienclosure_ = $item[3];
         $iauthor_ = $item[4];
         $idescr_ = $item[5];
         $its_ = $item[6];
         $iispubdate_ = $item[7];
         $iid_ = $item[8];
         $cid_ = $item[9];
         $ctitle_ = $channels[$cid_][0];
         $cicon_ = $channels[$cid_][2];
         $rrating_ = FALSE;
         // Built a new Item
         $i = new Item($iid_, $ititle_, $iurl_, $ienclosure_, $cid_, $iauthor_, $idescr_, $its_, $iispubdate_, $iunread_, $rrating_);
         // no dupes, please
         if (in_array($iid_, $this->iids)) {
             $this->rowCount--;
             continue;
         }
         // Allow for some item filtering before it is rendered
         if (($i = rss_plugin_hook('rss.plugins.items.beforerender', $i)) == null) {
             $this->rowCount--;
             continue;
         }
         // See if we have a channel for it
         if ($cid_ != $prevCid) {
             $f = new Feed($ctitle_, $cid_, $cicon_);
             $this->feeds[] = $f;
             $curIdx = count($this->feeds) - 1;
             $prevCid = $cid_;
         }
         $this->iidInCid[$iid_] = $curIdx;
         // Add it to the channel
         $this->iids[] = $iid_;
         $this->feeds[$curIdx]->addItem($i);
         // Some stats...
         $this->itemCount++;
         if ($iunread_ & RSS_MODE_UNREAD_STATE) {
             $this->unreadCount++;
             $this->unreadIids[] = $iid_;
         } else {
             $this->readCount++;
         }
     }
     // Tags! - Don't use tag, let's comment
     /*if (count($this -> iids)) {
     			// fetch the tags for the items;
     			$sql = "select t.tag, m.fid, i.cid "
     			." from " . getTable('tag')." t "
     			." inner join " . getTable('metatag') . " m "
     			."   on m.tid = t.id "
     			." inner join " . getTable('item')." i "
     			."   on i.id = m.fid "
     			." where m.ttype = 'item' and m.fid in (".implode(",", $this -> iids).")";
     
     			$res = $GLOBALS['rss_db']->rss_query($sql);
     			while (list ($tag_, $iid_, $cid_) = $GLOBALS['rss_db']->rss_fetch_row($res)) {
     				if (array_key_exists($iid_, $this -> iidInCid)) {
     					$idx = $this->iidInCid[$iid_];
     					while (list($key, $item) = each($this ->feeds[$idx] -> items)) {
     						if ($item -> id == $iid_) {
     							$this ->feeds[$idx] -> items[$key] -> tags[] = $tag_;
     							break;
     						}
     					}
     					reset($this ->feeds[$idx] -> items);
     				}
     
     
     				if (array_key_exists($tag_,$this -> allTags)) {
     		    		$this -> allTags[ $tag_ ]++;
     				} else {
     		    		$this -> allTags[ $tag_ ]=1;
     				}
     			}
     		}*/
     _pf('done: ItemList::populate()');
 }
コード例 #19
0
ファイル: update.php プロジェクト: jphpsf/gregarius
 function cleanUp($newIds, $ignorePrivate = false)
 {
     if (!hidePrivate() || $ignorePrivate) {
         if (count($newIds) > 0 && getConfig('rss.config.markreadonupdate')) {
             rss_query("update " . getTable("item") . " set unread = unread & " . SET_MODE_READ_STATE . " where unread & " . RSS_MODE_UNREAD_STATE . " and id not in (" . implode(",", $newIds) . ")");
         }
     }
     setProperty('__meta__', 'meta.lastupdate', 'misc', time());
     if (count($newIds) > 0) {
         rss_invalidate_cache();
     }
     rss_plugin_hook('rss.plugins.updates.after', null);
 }