function getVirtualFeeds($msg) { global $link; $error_code = 0; $login_o = $msg->getParam(0); $pass_o = $msg->getParam(1); $login = $login_o->scalarval(); $pass = $pass_o->scalarval(); $user_id = authenticate_user($link, $login, $pass); $counters_ret = array(); if (authenticate_user($link, $login, $pass)) { $counters = getLabelCounters($link, true); foreach (array_keys($counters) as $id) { $line_struct = new xmlrpcval(array("id" => new xmlrpcval($id, "int"), "title" => new xmlrpcval($counters[$id]["description"]), "unread" => new xmlrpcval($counters[$id]["counter"], "int")), "struct"); array_push($counters_ret, $line_struct); } $reply = new xmlrpcval($counters_ret, "array"); } else { $reply_msg = "Login failed."; $error_code = 1; } if ($error_code != 0) { return new xmlrpcresp(0, $error_code, $reply_msg); } else { return new xmlrpcresp($reply); } }
static function api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested = false) { $feeds = array(); /* Labels */ if ($cat_id == -4 || $cat_id == -2) { $counters = getLabelCounters(true); foreach (array_values($counters) as $cv) { $unread = $cv["counter"]; if ($unread || !$unread_only) { $row = array("id" => (int) $cv["id"], "title" => $cv["description"], "unread" => $cv["counter"], "cat_id" => -2); array_push($feeds, $row); } } } /* Virtual feeds */ if ($cat_id == -4 || $cat_id == -1) { foreach (array(-1, -2, -3, -4, -6, 0) as $i) { $unread = getFeedUnread($i); if ($unread || !$unread_only) { $title = getFeedTitle($i); $row = array("id" => $i, "title" => $title, "unread" => $unread, "cat_id" => -1); array_push($feeds, $row); } } } /* Child cats */ if ($include_nested && $cat_id) { $result = db_query("SELECT\n\t\t\t\t\tid, title FROM ttrss_feed_categories\n\t\t\t\t\tWHERE parent_cat = '{$cat_id}' AND owner_uid = " . $_SESSION["uid"] . " ORDER BY id, title"); while ($line = db_fetch_assoc($result)) { $unread = getFeedUnread($line["id"], true) + getCategoryChildrenUnread($line["id"]); if ($unread || !$unread_only) { $row = array("id" => (int) $line["id"], "title" => $line["title"], "unread" => $unread, "is_cat" => true); array_push($feeds, $row); } } } /* Real feeds */ if ($limit) { $limit_qpart = "LIMIT {$limit} OFFSET {$offset}"; } else { $limit_qpart = ""; } if ($cat_id == -4 || $cat_id == -3) { $result = db_query("SELECT\n\t\t\t\t\tid, feed_url, cat_id, title, order_id, " . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\t\tFROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY cat_id, title " . $limit_qpart); } else { if ($cat_id) { $cat_qpart = "cat_id = '{$cat_id}'"; } else { $cat_qpart = "cat_id IS NULL"; } $result = db_query("SELECT\n\t\t\t\t\tid, feed_url, cat_id, title, order_id, " . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\t\tFROM ttrss_feeds WHERE\n\t\t\t\t\t\t{$cat_qpart} AND owner_uid = " . $_SESSION["uid"] . " ORDER BY cat_id, title " . $limit_qpart); } while ($line = db_fetch_assoc($result)) { $unread = getFeedUnread($line["id"]); $has_icon = feed_has_icon($line['id']); if ($unread || !$unread_only) { $row = array("feed_url" => $line["feed_url"], "title" => $line["title"], "id" => (int) $line["id"], "unread" => (int) $unread, "has_icon" => $has_icon, "cat_id" => (int) $line["cat_id"], "last_updated" => (int) strtotime($line["last_updated"]), "order_id" => (int) $line["order_id"]); array_push($feeds, $row); } } return $feeds; }
function getAllCounters() { $data = getGlobalCounters(); $data = array_merge($data, getVirtCounters()); $data = array_merge($data, getLabelCounters()); $data = array_merge($data, getFeedCounters()); $data = array_merge($data, getCategoryCounters()); return $data; }
function getAllCounters($link) { $data = getGlobalCounters($link); $data = array_merge($data, getVirtCounters($link)); $data = array_merge($data, getLabelCounters($link)); $data = array_merge($data, getFeedCounters($link, $active_feed)); $data = array_merge($data, getCategoryCounters($link)); return $data; }
function getAllCounters($link, $omode = "flc", $active_feed = false) { if (!$omode) { $omode = "flc"; } getGlobalCounters($link); getVirtCounters($link); if (strchr($omode, "l")) { getLabelCounters($link); } if (strchr($omode, "f")) { getFeedCounters($link, $active_feed); } if (strchr($omode, "t")) { getTagCounters($link); } if (strchr($omode, "c")) { if (get_pref($link, 'ENABLE_FEED_CATS')) { getCategoryCounters($link); } } }
} else { $result = db_query($link, "SELECT \n\t\t\t\t\tid, feed_url, cat_id, title, " . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\t\tFROM ttrss_feeds WHERE \n\t\t\t\t\t\tcat_id = '{$cat_id}' AND owner_uid = " . $_SESSION["uid"] . "ORDER BY cat_id, title " . $limit_qpart); } $feeds = array(); while ($line = db_fetch_assoc($result)) { $unread = getFeedUnread($link, $line["id"]); $icon_path = "../" . ICONS_DIR . "/" . $line["id"] . ".ico"; $has_icon = file_exists($icon_path) && filesize($icon_path) > 0; if ($unread || !$unread_only) { $row = array("feed_url" => $line["feed_url"], "title" => $line["title"], "id" => (int) $line["id"], "unread" => (int) $unread, "has_icon" => $has_icon, "cat_id" => (int) $line["cat_id"], "last_updated" => strtotime($line["last_updated"])); array_push($feeds, $row); } } /* Labels */ if (!$cat_id || $cat_id == -2) { $counters = getLabelCounters($link, true); foreach (array_keys($counters) as $id) { $unread = $counters[$id]["counter"]; if ($unread || !$unread_only) { $row = array("id" => $id, "title" => $counters[$id]["description"], "unread" => $counters[$id]["counter"], "cat_id" => -2); array_push($feeds, $row); } } } /* Virtual feeds */ if (!$cat_id || $cat_id == -1) { foreach (array(-1, -2, -3, -4, 0) as $i) { $unread = getFeedUnread($link, $i); if ($unread || !$unread_only) { $title = getFeedTitle($link, $i); $row = array("id" => $i, "title" => $title, "unread" => $unread, "cat_id" => -1);