/** * Hands the user a yummy cookie. * The cookie holds the md5 hash of the user password */ function setUserCookie($user, $hash) { $rs = rss_query('select value_ from ' . getTable('config') . "where key_ = 'rss.config.autologout'", false, true); if (rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR) && rss_num_rows($rs) > 0) { list($als) = rss_fetch_row($rs); $al = $als == 'true'; } else { $al = false; } $t = $al ? 0 : time() + COOKIE_LIFESPAN; setcookie(RSS_USER_COOKIE, $user . '|' . $hash, $t, getPath()); }
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'); }
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(); } }
/** * 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++; } }
} } } elseif ($vfid) { $sql = "select c.id, m.tid 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'"; // $vfid can be numeric (t.id) or alphabetic (t.tag) if (is_numeric($vfid)) { $sql .= "and t.id = {$vfid}"; } else { $sql .= "and t.tag like '{$vfid}'"; } $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE . ") "; if (hidePrivate()) { $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") "; } $res = rss_query($sql); if (rss_num_rows($res) > 0) { $cids = array(); while (list($cid__, $vfid__) = rss_fetch_row($res)) { $cids[] = $cid__; $vfid = $vfid__; } } } elseif ($cid) { if (hidePrivate()) { $sql = "select id from " . getTable('channels') . " where id={$cid} "; $sql .= " and not(mode & " . RSS_MODE_PRIVATE_STATE . ") "; list($cid) = rss_fetch_row(rss_query($sql)); } } } elseif (array_key_exists('y', $_REQUEST) && $_REQUEST['y'] != "" && is_numeric($_REQUEST['y']) && array_key_exists('m', $_REQUEST) && $_REQUEST['m'] != "" && is_numeric($_REQUEST['m']) && array_key_exists('d', $_REQUEST) && $_REQUEST['d'] != "" && is_numeric($_REQUEST['d'])) { $y = (int) sanitize($_REQUEST['y'], RSS_SANITIZER_NUMERIC);
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'); } }