本文整理汇总了PHP中catchup_feed函数的典型用法代码示例。如果您正苦于以下问题:PHP catchup_feed函数的具体用法?PHP catchup_feed怎么用?PHP catchup_feed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了catchup_feed函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catchupFeed
function catchupFeed()
{
$feed_id = $this->dbh->escape_string($_REQUEST["feed_id"]);
$is_cat = $this->dbh->escape_string($_REQUEST["is_cat"]);
catchup_feed($feed_id, $is_cat);
$this->wrap(self::STATUS_OK, array("status" => "OK"));
}
示例2: catchupFeed
function catchupFeed()
{
$feed_id = db_escape_string($_REQUEST['feed_id']);
$is_cat = db_escape_string($_REQUEST['is_cat']) == "true";
$max_id = (int) db_escape_string($_REQUEST['max_id']);
catchup_feed($this->link, $feed_id, $is_cat, false, $max_id);
print json_encode(array("message" => "UPDATE_COUNTERS"));
}
示例3: format_headlines_list
private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, $override_order = false, $include_children = false)
{
$disable_cache = false;
$reply = array();
$timing_info = getmicrotime();
$topmost_article_ids = array();
if (!$offset) {
$offset = 0;
}
if ($method == "undefined") {
$method = "";
}
$method_split = explode(":", $method);
if ($method == "ForceUpdate" && $feed && is_numeric($feed) > 0) {
include "rssfuncs.php";
update_rss_feed($this->link, $feed, true);
}
if ($method_split[0] == "MarkAllReadGR") {
catchup_feed($this->link, $method_split[1], false);
}
// FIXME: might break tag display?
if (is_numeric($feed) && $feed > 0 && !$cat_view) {
$result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE id = '{$feed}' LIMIT 1");
if (db_num_rows($result) == 0) {
$reply['content'] = "<div align='center'>" . __('Feed not found.') . "</div>";
}
}
if (is_numeric($feed) && $feed > 0) {
$result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds\r\n\t\t\t\tWHERE id = '{$feed}' AND owner_uid = " . $_SESSION["uid"]);
if (db_num_rows($result) == 1) {
$rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
} else {
$rtl_content = false;
}
if ($rtl_content) {
$rtl_tag = "dir=\"RTL\"";
} else {
$rtl_tag = "";
}
} else {
$rtl_tag = "";
$rtl_content = false;
}
@($search = db_escape_string($_REQUEST["query"]));
if ($search) {
$disable_cache = true;
}
@($search_mode = db_escape_string($_REQUEST["search_mode"]));
@($match_on = db_escape_string($_REQUEST["match_on"]));
if (!$match_on) {
$match_on = "both";
}
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("H0", $timing_info);
}
// error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
if ($search_mode == '' && $method != '') {
$search_mode = $method;
}
// error_log("search_mode: " . $search_mode);
$qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order, $offset, 0, false, 0, $include_children);
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("H1", $timing_info);
}
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$vgroup_last_feed = $vgr_last_feed;
// if (!$offset) {
if (db_num_rows($result) > 0) {
$reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, $feed, $cat_view, $search, $match_on, $search_mode, $view_mode, $last_error);
}
// }
$headlines_count = db_num_rows($result);
if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
$button_plugins = array();
foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
$pclass = trim("button_{$p}");
if (class_exists($pclass)) {
$plugin = new $pclass($link);
array_push($button_plugins, $plugin);
}
}
}
if (db_num_rows($result) > 0) {
$lnum = $offset;
$num_unread = 0;
$cur_feed_title = '';
$fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("PS", $timing_info);
}
while ($line = db_fetch_assoc($result)) {
$class = $lnum % 2 ? "even" : "odd";
$id = $line["id"];
$feed_id = $line["feed_id"];
$label_cache = $line["label_cache"];
$labels = false;
if ($label_cache) {
//.........这里部分代码省略.........
示例4: outputHeadlinesList
function outputHeadlinesList($link, $feed, $subop, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, $override_order = false)
{
$disable_cache = false;
$timing_info = getmicrotime();
$topmost_article_ids = array();
if (!$offset) {
$offset = 0;
}
if ($subop == "undefined") {
$subop = "";
}
$subop_split = split(":", $subop);
if ($subop == "CatchupSelected") {
$ids = split(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]);
catchupArticlesById($link, $ids, $cmode);
}
if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
update_generic_feed($link, $feed, $cat_view, true);
}
if ($subop == "MarkAllRead") {
catchup_feed($link, $feed, $cat_view);
if (get_pref($link, 'ON_CATCHUP_SHOW_NEXT_FEED')) {
if ($next_unread_feed) {
$feed = $next_unread_feed;
}
}
}
if ($subop_split[0] == "MarkAllReadGR") {
catchup_feed($link, $subop_split[1], false);
}
if ($feed_id > 0) {
$result = db_query($link, "SELECT id FROM ttrss_feeds WHERE id = '{$feed}' LIMIT 1");
if (db_num_rows($result) == 0) {
print "<div align='center'>" . __('Feed not found.') . "</div>";
return;
}
}
if (preg_match("/^-?[0-9][0-9]*\$/", $feed) != false) {
$result = db_query($link, "SELECT rtl_content FROM ttrss_feeds\n\t\t\t\tWHERE id = '{$feed}' AND owner_uid = " . $_SESSION["uid"]);
if (db_num_rows($result) == 1) {
$rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
} else {
$rtl_content = false;
}
if ($rtl_content) {
$rtl_tag = "dir=\"RTL\"";
} else {
$rtl_tag = "";
}
} else {
$rtl_tag = "";
$rtl_content = false;
}
$script_dt_add = get_script_dt_add();
/// START /////////////////////////////////////////////////////////////////////////////////
$search = db_escape_string($_REQUEST["query"]);
if ($search) {
$disable_cache = true;
}
$search_mode = db_escape_string($_REQUEST["search_mode"]);
$match_on = db_escape_string($_REQUEST["match_on"]);
if (!$match_on) {
$match_on = "both";
}
$real_offset = $offset * $limit;
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("H0", $timing_info);
}
$qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order, $real_offset);
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("H1", $timing_info);
}
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$vgroup_last_feed = $vgr_last_feed;
if ($feed == -2) {
$feed_site_url = article_publish_url($link);
}
/// STOP //////////////////////////////////////////////////////////////////////////////////
if (!$offset) {
print "<div id=\"headlinesContainer\" {$rtl_tag}>";
if (!$result) {
print "<div align='center'>" . __("Could not display feed (query failed). Please check label match syntax or local configuration.") . "</div>";
return;
}
print_headline_subtoolbar($link, $feed_site_url, $feed_title, $feed, $cat_view, $search, $match_on, $search_mode);
print "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">";
}
$headlines_count = db_num_rows($result);
if (db_num_rows($result) > 0) {
# print "\{$offset}";
if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) {
print "<table class=\"headlinesList\" id=\"headlinesList\" \n\t\t\t\t\tcellspacing=\"0\">";
}
$lnum = $limit * $offset;
error_reporting(DEFAULT_ERROR_LEVEL);
$num_unread = 0;
//.........这里部分代码省略.........
示例5: format_headlines_list
private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, $override_order = false, $include_children = false)
{
if (isset($_REQUEST["DevForceUpdate"])) {
header("Content-Type: text/plain; charset=utf-8");
}
$disable_cache = false;
$reply = array();
$rgba_cache = array();
$timing_info = microtime(true);
$topmost_article_ids = array();
if (!$offset) {
$offset = 0;
}
if ($method == "undefined") {
$method = "";
}
$method_split = explode(":", $method);
if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
// Update the feed if required with some basic flood control
$result = $this->dbh->query("SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
if ($this->dbh->num_rows($result) != 0) {
$last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated"));
$cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
include "rssfuncs.php";
update_rss_feed($feed, true, true);
} else {
$this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'\n\t\t\t\t\t\t\tWHERE id = '{$feed}'");
}
}
}
if ($method_split[0] == "MarkAllReadGR") {
catchup_feed($method_split[1], false);
}
// FIXME: might break tag display?
if (is_numeric($feed) && $feed > 0 && !$cat_view) {
$result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE id = '{$feed}' LIMIT 1");
if ($this->dbh->num_rows($result) == 0) {
$reply['content'] = "<div align='center'>" . __('Feed not found.') . "</div>";
}
}
@($search = $this->dbh->escape_string($_REQUEST["query"]));
if ($search) {
$disable_cache = true;
}
@($search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]));
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("H0", $timing_info);
}
// error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
if ($search_mode == '' && $method != '') {
$search_mode = $method;
}
// error_log("search_mode: " . $search_mode);
if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
$handler = PluginHost::getInstance()->get_feed_handler(PluginHost::feed_to_pfeed_id($feed));
// function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
if ($handler) {
$options = array("limit" => $limit, "view_mode" => $view_mode, "cat_view" => $cat_view, "search" => $search, "search_mode" => $search_mode, "override_order" => $override_order, "offset" => $offset, "owner_uid" => $_SESSION["uid"], "filter" => false, "since_id" => 0, "include_children" => $include_children);
$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $options);
}
} else {
$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order, $offset, 0, false, 0, $include_children);
}
$vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("H1", $timing_info);
}
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? make_local_datetime($qfh_ret[4], false) : __("Never");
$highlight_words = $qfh_ret[5];
$vgroup_last_feed = $vgr_last_feed;
$reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, $feed, $cat_view, $search, $search_mode, $view_mode, $last_error, $last_updated);
$headlines_count = $this->dbh->num_rows($result);
/* if (get_pref('COMBINED_DISPLAY_MODE')) {
$button_plugins = array();
foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
$pclass = "button_" . trim($p);
if (class_exists($pclass)) {
$plugin = new $pclass();
array_push($button_plugins, $plugin);
}
}
} */
if ($offset == 0) {
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
$reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
}
}
if ($this->dbh->num_rows($result) > 0) {
$lnum = $offset;
$num_unread = 0;
$cur_feed_title = '';
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("PS", $timing_info);
}
//.........这里部分代码省略.........
示例6: update_rss_feed
//.........这里部分代码省略.........
}
}
if ($debug_enabled) {
_debug("update_rss_feed: article enclosures:");
print_r($enclosures);
}
db_query($link, "BEGIN");
foreach ($enclosures as $enc) {
$enc_url = db_escape_string($enc[0]);
$enc_type = db_escape_string($enc[1]);
$enc_dur = db_escape_string($enc[2]);
$result = db_query($link, "SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
if (db_num_rows($result) == 0) {
db_query($link, "INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '', '{$enc_dur}', '{$entry_ref_id}')");
}
}
db_query($link, "COMMIT");
// check for manual tags (we have to do it here since they're loaded from filters)
foreach ($article_filters as $f) {
if ($f["type"] == "tag") {
$manual_tags = trim_array(explode(",", $f["param"]));
foreach ($manual_tags as $tag) {
if (tag_is_valid($tag)) {
array_push($entry_tags, $tag);
}
}
}
}
// Skip boring tags
$boring_tags = trim_array(explode(",", mb_strtolower(get_pref($link, 'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
$filtered_tags = array();
$tags_to_cache = array();
if ($entry_tags && is_array($entry_tags)) {
foreach ($entry_tags as $tag) {
if (array_search($tag, $boring_tags) === false) {
array_push($filtered_tags, $tag);
}
}
}
$filtered_tags = array_unique($filtered_tags);
if ($debug_enabled) {
_debug("update_rss_feed: filtered article tags:");
print_r($filtered_tags);
}
// Save article tags in the database
if (count($filtered_tags) > 0) {
db_query($link, "BEGIN");
foreach ($filtered_tags as $tag) {
$tag = sanitize_tag($tag);
$tag = db_escape_string($tag);
if (!tag_is_valid($tag)) {
continue;
}
$result = db_query($link, "SELECT id FROM ttrss_tags\n\t\t\t\t\t\t\tWHERE tag_name = '{$tag}' AND post_int_id = '{$entry_int_id}' AND\n\t\t\t\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
if ($result && db_num_rows($result) == 0) {
db_query($link, "INSERT INTO ttrss_tags\n\t\t\t\t\t\t\t\t\t(owner_uid,tag_name,post_int_id)\n\t\t\t\t\t\t\t\t\tVALUES ('{$owner_uid}','{$tag}', '{$entry_int_id}')");
}
array_push($tags_to_cache, $tag);
}
/* update the cache */
$tags_to_cache = array_unique($tags_to_cache);
$tags_str = db_escape_string(join(",", $tags_to_cache));
db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET tag_cache = '{$tags_str}' WHERE ref_id = '{$entry_ref_id}'\n\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
db_query($link, "COMMIT");
}
if ($debug_enabled) {
_debug("update_rss_feed: article processed");
}
}
if (!$last_updated) {
if ($debug_enabled) {
_debug("update_rss_feed: new feed, catching it up...");
}
catchup_feed($link, $feed, false, $owner_uid);
}
if ($debug_enabled) {
_debug("purging feed...");
}
purge_feed($link, $feed, 0, $debug_enabled);
db_query($link, "UPDATE ttrss_feeds\n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
// db_query($link, "COMMIT");
} else {
if ($use_simplepie) {
$error_msg = mb_substr($rss->error(), 0, 250);
} else {
$error_msg = mb_substr(magpie_error(), 0, 250);
}
if ($debug_enabled) {
_debug("update_rss_feed: error fetching feed: {$error_msg}");
}
$error_msg = db_escape_string($error_msg);
db_query($link, "UPDATE ttrss_feeds SET last_error = '{$error_msg}',\n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
}
if ($use_simplepie) {
unset($rss);
}
if ($debug_enabled) {
_debug("update_rss_feed: done");
}
}
示例7: catchupFeed
function catchupFeed()
{
$feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
$is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
$mode = $this->dbh->escape_string($_REQUEST['mode']);
catchup_feed($feed_id, $is_cat, false, false, $mode);
print json_encode(array("message" => "UPDATE_COUNTERS"));
}
示例8: render_headlines
function render_headlines($link)
{
$feed = db_escape_string($_GET["id"]);
$limit = db_escape_string($_GET["limit"]);
$view_mode = db_escape_string($_GET["viewmode"]);
$cat_view = db_escape_string($_GET["cat"]);
$subop = $_GET["subop"];
$catchup_op = $_GET["catchup_op"];
if (!$view_mode) {
if ($_SESSION["mobile:viewmode"]) {
$view_mode = $_SESSION["mobile:viewmode"];
} else {
$view_mode = "adaptive";
}
}
$_SESSION["mobile:viewmode"] = $view_mode;
if (!$limit) {
$limit = 30;
}
if (!$feed) {
$feed = 0;
}
if (preg_match("/^-?[0-9][0-9]*\$/", $feed) != false) {
$result = db_query($link, "SELECT rtl_content FROM ttrss_feeds\n\t\t\t\tWHERE id = '{$feed}' AND owner_uid = " . $_SESSION["uid"]);
if (db_num_rows($result) == 1) {
$rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
} else {
$rtl_content = false;
}
if ($rtl_content) {
$rtl_tag = "dir=\"RTL\"";
} else {
$rtl_tag = "";
}
} else {
$rtl_content = false;
$rtl_tag = "";
}
print "<div id=\"headlines\" {$rtl_tag}>";
if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
update_generic_feed($link, $feed, $cat_view, true);
}
if ($subop == "MarkAllRead" || $catchup_op == "feed") {
catchup_feed($link, $feed, $cat_view);
}
if ($catchup_op == "selection") {
if (is_array($_GET["sel_ids"])) {
$ids_to_mark = array_keys($_GET["sel_ids"]);
if ($ids_to_mark) {
foreach ($ids_to_mark as $id) {
db_query($link, "UPDATE ttrss_user_entries SET \n\t\t\t\t\t\t\tunread = false,last_read = NOW()\n\t\t\t\t\t\t\tWHERE ref_id = '{$id}' AND owner_uid = " . $_SESSION["uid"]);
}
}
}
}
if ($subop == "MarkPageRead" || $catchup_op == "page") {
$ids_to_mark = $_SESSION["last_page_ids.{$feed}"];
if ($ids_to_mark) {
foreach ($ids_to_mark as $id) {
db_query($link, "UPDATE ttrss_user_entries SET \n\t\t\t\t\t\tunread = false,last_read = NOW()\n\t\t\t\t\t\tWHERE ref_id = '{$id}' AND owner_uid = " . $_SESSION["uid"]);
}
}
}
/// START /////////////////////////////////////////////////////////////////////////////////
$search = db_escape_string($_GET["query"]);
$search_mode = db_escape_string($_GET["search_mode"]);
$match_on = db_escape_string($_GET["match_on"]);
if (!$match_on) {
$match_on = "both";
}
$real_offset = $offset * $limit;
if ($_GET["debug"]) {
$timing_info = print_checkpoint("H0", $timing_info);
}
$qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, false, $real_offset);
if ($_GET["debug"]) {
$timing_info = print_checkpoint("H1", $timing_info);
}
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
/// STOP //////////////////////////////////////////////////////////////////////////////////
if (!$result) {
print "<div align='center'>" . __("Could not display feed (query failed). Please check label match syntax or local configuration.") . "</div>";
return;
}
print "<div id=\"heading\">";
# if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) {
# print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">";
# }
print "{$feed_title} <span id=\"headingAddon\">(";
print "<a href=\"index.php\">" . __("Back") . "</a>, ";
print "<a href=\"index.php?go=sform&aid={$feed}&ic={$cat_view}\">" . __("Search") . "</a>, ";
print "<a href=\"index.php?go=vf&id={$feed}&subop=ForceUpdate\">" . __("Update") . "</a>";
# print "Mark as read: ";
# print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAsRead\">Page</a>, ";
# print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a>";
print ")</span>";
print " " . __('View:');
//.........这里部分代码省略.........
示例9: update_rss_feed
//.........这里部分代码省略.........
db_query($link, "BEGIN");
foreach ($enclosures as $enc) {
$enc_url = db_escape_string($enc[0]);
$enc_type = db_escape_string($enc[1]);
$enc_dur = db_escape_string($enc[2]);
$result = db_query($link, "SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
if (db_num_rows($result) == 0) {
db_query($link, "INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '', '{$enc_dur}', '{$entry_ref_id}')");
}
}
db_query($link, "COMMIT");
// check for manual tags (we have to do it here since they're loaded from filters)
foreach ($article_filters as $f) {
if ($f["type"] == "tag") {
$manual_tags = trim_array(explode(",", $f["param"]));
foreach ($manual_tags as $tag) {
if (tag_is_valid($tag)) {
array_push($entry_tags, $tag);
}
}
}
}
// Skip boring tags
$boring_tags = trim_array(explode(",", mb_strtolower(get_pref($link, 'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
$filtered_tags = array();
$tags_to_cache = array();
if ($entry_tags && is_array($entry_tags)) {
foreach ($entry_tags as $tag) {
if (array_search($tag, $boring_tags) === false) {
array_push($filtered_tags, $tag);
}
}
}
$filtered_tags = array_unique($filtered_tags);
if ($debug_enabled) {
_debug("update_rss_feed: filtered article tags:");
print_r($filtered_tags);
}
// Save article tags in the database
if (count($filtered_tags) > 0) {
db_query($link, "BEGIN");
foreach ($filtered_tags as $tag) {
$tag = sanitize_tag($tag);
$tag = db_escape_string($tag);
if (!tag_is_valid($tag)) {
continue;
}
$result = db_query($link, "SELECT id FROM ttrss_tags\n\t\t\t\t\t\t\tWHERE tag_name = '{$tag}' AND post_int_id = '{$entry_int_id}' AND\n\t\t\t\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
if ($result && db_num_rows($result) == 0) {
db_query($link, "INSERT INTO ttrss_tags\n\t\t\t\t\t\t\t\t\t(owner_uid,tag_name,post_int_id)\n\t\t\t\t\t\t\t\t\tVALUES ('{$owner_uid}','{$tag}', '{$entry_int_id}')");
}
array_push($tags_to_cache, $tag);
}
/* update the cache */
$tags_to_cache = array_unique($tags_to_cache);
$tags_str = db_escape_string(join(",", $tags_to_cache));
db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET tag_cache = '{$tags_str}' WHERE ref_id = '{$entry_ref_id}'\n\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
db_query($link, "COMMIT");
}
if (get_pref($link, "AUTO_ASSIGN_LABELS", $owner_uid, false)) {
if ($debug_enabled) {
_debug("update_rss_feed: auto-assigning labels...");
}
foreach ($labels as $label) {
$caption = $label["caption"];
if (preg_match("/\\b{$caption}\\b/i", "{$tags_str} " . strip_tags($entry_content) . " {$entry_title}")) {
if (!labels_contains_caption($article_labels, $caption)) {
label_add_article($link, $entry_ref_id, $caption, $owner_uid);
}
}
}
}
if ($debug_enabled) {
_debug("update_rss_feed: article processed");
}
}
if (!$last_updated) {
if ($debug_enabled) {
_debug("update_rss_feed: new feed, catching it up...");
}
catchup_feed($link, $feed, false, $owner_uid);
}
if ($debug_enabled) {
_debug("purging feed...");
}
purge_feed($link, $feed, 0, $debug_enabled);
db_query($link, "UPDATE ttrss_feeds\n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
// db_query($link, "COMMIT");
} else {
$error_msg = db_escape_string(mb_substr($rss->error(), 0, 245));
if ($debug_enabled) {
_debug("update_rss_feed: error fetching feed: {$error_msg}");
}
db_query($link, "UPDATE ttrss_feeds SET last_error = '{$error_msg}',\n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
}
unset($rss);
if ($debug_enabled) {
_debug("update_rss_feed: done");
}
}
示例10: api_wrap_reply
}
print api_wrap_reply(API_STATUS_OK, $seq, $articles);
break;
case "getConfig":
$config = array("icons_dir" => ICONS_DIR, "icons_url" => ICONS_URL);
$config["daemon_is_running"] = file_is_locked("update_daemon.lock");
$result = db_query($link, "SELECT COUNT(*) AS cf FROM\n\t\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = db_fetch_result($result, 0, "cf");
$config["num_feeds"] = (int) $num_feeds;
print api_wrap_reply(API_STATUS_OK, $seq, $config);
break;
case "updateFeed":
$feed_id = db_escape_string($_REQUEST["feed_id"]);
update_rss_feed($link, $feed_id, true);
print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));
break;
case "catchupFeed":
$feed_id = db_escape_string($_REQUEST["feed_id"]);
$is_cat = db_escape_string($_REQUEST["is_cat"]);
catchup_feed($link, $feed_id, $is_cat);
print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));
break;
case "getPref":
$pref_name = db_escape_string($_REQUEST["pref_name"]);
print api_wrap_reply(API_STATUS_OK, $seq, array("value" => get_pref($link, $pref_name)));
break;
default:
print api_wrap_reply(API_STATUS_ERR, $seq, array("error" => 'UNKNOWN_METHOD'));
break;
}
db_close($link);