本文整理汇总了PHP中sql_bool_to_bool函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_bool_to_bool函数的具体用法?PHP sql_bool_to_bool怎么用?PHP sql_bool_to_bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_bool_to_bool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trainArticle
function trainArticle()
{
$article_id = (int) $_REQUEST["article_id"];
$train_up = sql_bool_to_bool($_REQUEST["train_up"]);
//$category = $train_up ? "GOOD" : "UGLY";
$dst_category = "UGLY";
$nbs = new NaiveBayesianStorage($_SESSION["uid"]);
$nb = new NaiveBayesian($nbs);
$result = $this->dbh->query("SELECT score, guid, title, content FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id AND id = " . $article_id . " AND owner_uid = " . $_SESSION["uid"]);
if ($this->dbh->num_rows($result) != 0) {
$guid = $this->dbh->fetch_result($result, 0, "guid");
$title = $this->dbh->fetch_result($result, 0, "title");
$content = mb_substr(mb_strtolower($title . " " . strip_tags($this->dbh->fetch_result($result, 0, "content"))), 0, $this->max_document_length);
$score = $this->dbh->fetch_result($result, 0, "score");
$this->dbh->query("BEGIN");
$ref = $nbs->getReference($guid, false);
if (isset($ref['category_id'])) {
$current_category = $nbs->getCategoryById($ref['category_id']);
} else {
$current_category = "UGLY";
}
// set score to fixed value for now
if ($train_up) {
switch ($current_category) {
case "UGLY":
$dst_category = "GOOD";
$score = $this->score_modifier;
break;
case "BAD":
$dst_category = "UGLY";
$score = 0;
break;
case "GOOD":
$dst_category = "GOOD";
break;
}
} else {
switch ($current_category) {
case "UGLY":
$dst_category = "BAD";
$score = -$this->score_modifier;
break;
case "BAD":
$dst_category = "BAD";
break;
case "GOOD":
$dst_category = "UGLY";
$score = 0;
break;
}
}
$nb->untrain($guid, $content);
$nb->train($guid, $nbs->getCategoryByName($dst_category), $content);
$this->dbh->query("UPDATE ttrss_user_entries SET score = '{$score}' WHERE ref_id = {$article_id} AND owner_uid = " . $_SESSION["uid"]);
$nb->updateProbabilities();
$this->dbh->query("COMMIT");
}
print "{$article_id} :: {$dst_category} :: {$score}";
}
示例2: digestgetcontents
function digestgetcontents()
{
$article_id = db_escape_string($_REQUEST['article_id']);
$result = db_query($this->link, "SELECT content,title,link,marked,published\n\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\tWHERE id = '{$article_id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
$content = sanitize($this->link, db_fetch_result($result, 0, "content"));
$title = strip_tags(db_fetch_result($result, 0, "title"));
$article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
$marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
$published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
print json_encode(array("article" => array("id" => $article_id, "url" => $article_url, "tags" => get_article_tags($this->link, $article_id), "marked" => $marked, "published" => $published, "title" => $title, "content" => $content)));
}
示例3: authenticate
function authenticate($login, $password)
{
$pwd_hash1 = encrypt_password($password);
$pwd_hash2 = encrypt_password($password, $login);
$login = db_escape_string($login);
$otp = db_escape_string($_REQUEST["otp"]);
if (get_schema_version($this->link) > 96) {
if (!defined('AUTH_DISABLE_OTP') || !AUTH_DISABLE_OTP) {
$result = db_query($this->link, "SELECT otp_enabled,salt FROM ttrss_users WHERE\n\t\t\t\t\tlogin = '{$login}'");
if (db_num_rows($result) > 0) {
require_once "lib/otphp/vendor/base32.php";
require_once "lib/otphp/lib/otp.php";
require_once "lib/otphp/lib/totp.php";
$base32 = new Base32();
$otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
$secret = $base32->encode(sha1(db_fetch_result($result, 0, "salt")));
$topt = new \OTPHP\TOTP($secret);
$otp_check = $topt->now();
if ($otp_enabled) {
if ($otp) {
if ($otp != $otp_check) {
return false;
}
} else {
$return = urlencode($_REQUEST["return"]);
?>
<html>
<head><title>Tiny Tiny RSS</title></head>
<body>
<form action="public.php?return=<?php
echo $return;
?>
"
method="POST">
<input type="hidden" name="op" value="login">
<input type="hidden" name="login" value="<?php
echo htmlspecialchars($login);
?>
">
<input type="hidden" name="password" value="<?php
echo htmlspecialchars($password);
?>
">
<label><?php
echo __("Please enter your one time password:");
?>
</label>
<input type="password" size="6" name="otp"/>
<input type="submit" value="Continue"/>
</form>
<script type="text/javascript">
document.forms[0].otp.focus();
</script>
<?php
exit;
}
}
}
}
}
if (get_schema_version($this->link) > 87) {
$result = db_query($this->link, "SELECT salt FROM ttrss_users WHERE\n\t\t\t\tlogin = '{$login}'");
if (db_num_rows($result) != 1) {
return false;
}
$salt = db_fetch_result($result, 0, "salt");
if ($salt == "") {
$query = "SELECT id\n\t FROM ttrss_users WHERE\n\t\t\t\t\tlogin = '{$login}' AND (pwd_hash = '{$pwd_hash1}' OR\n\t\t\t\t\tpwd_hash = '{$pwd_hash2}')";
// verify and upgrade password to new salt base
$result = db_query($this->link, $query);
if (db_num_rows($result) == 1) {
// upgrade password to MODE2
$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
$pwd_hash = encrypt_password($password, $salt, true);
db_query($this->link, "UPDATE ttrss_users SET\n\t\t\t\t\t\tpwd_hash = '{$pwd_hash}', salt = '{$salt}' WHERE login = '{$login}'");
$query = "SELECT id\n\t\t FROM ttrss_users WHERE\n\t\t\t\t\t\tlogin = '{$login}' AND pwd_hash = '{$pwd_hash}'";
} else {
return false;
}
} else {
$pwd_hash = encrypt_password($password, $salt, true);
$query = "SELECT id\n\t\t FROM ttrss_users WHERE\n\t\t\t\t\tlogin = '{$login}' AND pwd_hash = '{$pwd_hash}'";
}
} else {
$query = "SELECT id\n\t FROM ttrss_users WHERE\n\t\t\t\tlogin = '{$login}' AND (pwd_hash = '{$pwd_hash1}' OR\n\t\t\t\t\tpwd_hash = '{$pwd_hash2}')";
}
$result = db_query($this->link, $query);
if (db_num_rows($result) == 1) {
return db_fetch_result($result, 0, "id");
}
return false;
}
示例4: editfeed
function editfeed()
{
global $purge_intervals;
global $update_intervals;
print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
<div dojoType="dijit.layout.ContentPane" title="' . __('General') . '">';
$feed_id = $this->dbh->escape_string($_REQUEST["id"]);
$result = $this->dbh->query("SELECT * FROM ttrss_feeds WHERE id = '{$feed_id}' AND\n\t\t\t\towner_uid = " . $_SESSION["uid"]);
$auth_pass_encrypted = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "auth_pass_encrypted"));
$title = htmlspecialchars($this->dbh->fetch_result($result, 0, "title"));
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$feed_id}\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
print "<div class=\"dlgSecCont\">";
/* Title */
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Feed Title") . "\"\n\t\t\tstyle=\"font-size : 16px; width: 20em\" name=\"title\" value=\"{$title}\">";
/* Feed URL */
$feed_url = $this->dbh->fetch_result($result, 0, "feed_url");
$feed_url = htmlspecialchars($this->dbh->fetch_result($result, 0, "feed_url"));
print "<hr/>";
print __('URL:') . " ";
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Feed URL") . "\"\n\t\t\tregExp='^(http|https)://.*' style=\"width : 20em\"\n\t\t\tname=\"feed_url\" value=\"{$feed_url}\">";
$last_error = $this->dbh->fetch_result($result, 0, "last_error");
if ($last_error) {
print " <img src=\"images/error.png\" alt=\"(error)\"\n\t\t\t\tstyle=\"vertical-align : middle\"\n\t\t\t\ttitle=\"" . htmlspecialchars($last_error) . "\">";
}
/* Category */
if (get_pref('ENABLE_FEED_CATS')) {
$cat_id = $this->dbh->fetch_result($result, 0, "cat_id");
print "<hr/>";
print __('Place in category:') . " ";
print_feed_cat_select("cat_id", $cat_id, 'dojoType="dijit.form.Select"');
}
/* FTS Stemming Language */
if (DB_TYPE == "pgsql") {
$feed_language = $this->dbh->fetch_result($result, 0, "feed_language");
print "<hr/>";
print __('Language:') . " ";
print_select("feed_language", $feed_language, $this::$feed_languages, 'dojoType="dijit.form.Select"');
}
print "</div>";
print "<div class=\"dlgSec\">" . __("Update") . "</div>";
print "<div class=\"dlgSecCont\">";
/* Update Interval */
$update_interval = $this->dbh->fetch_result($result, 0, "update_interval");
print_select_hash("update_interval", $update_interval, $update_intervals, 'dojoType="dijit.form.Select"');
/* Purge intl */
$purge_interval = $this->dbh->fetch_result($result, 0, "purge_interval");
print "<hr/>";
print __('Article purging:') . " ";
print_select_hash("purge_interval", $purge_interval, $purge_intervals, 'dojoType="dijit.form.Select" ' . (FORCE_ARTICLE_PURGE == 0 ? "" : 'disabled="1"'));
print "</div>";
print "<div class=\"dlgSec\">" . __("Authentication") . "</div>";
print "<div class=\"dlgSecCont\">";
$auth_login = htmlspecialchars($this->dbh->fetch_result($result, 0, "auth_login"));
print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\"\n\t\t\tplaceHolder=\"" . __("Login") . "\"\n\t\t\tname=\"auth_login\" value=\"{$auth_login}\"><hr/>";
$auth_pass = $this->dbh->fetch_result($result, 0, "auth_pass");
if ($auth_pass_encrypted) {
require_once "crypt.php";
$auth_pass = decrypt_string($auth_pass);
}
$auth_pass = htmlspecialchars($auth_pass);
print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"\n\t\t\tplaceHolder=\"" . __("Password") . "\"\n\t\t\tvalue=\"{$auth_pass}\">";
print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedEditDlg_login\" position=\"below\">\n\t\t\t" . __('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.') . "\n\t\t\t</div>";
print "</div>";
print '</div><div dojoType="dijit.layout.ContentPane" title="' . __('Options') . '">';
//print "<div class=\"dlgSec\">".__("Options")."</div>";
print "<div class=\"dlgSecSimple\">";
$private = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "private"));
if ($private) {
$checked = "checked=\"1\"";
} else {
$checked = "";
}
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\"\n\t\t\t{$checked}> <label for=\"private\">" . __('Hide from Popular feeds') . "</label>";
$include_in_digest = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "include_in_digest"));
if ($include_in_digest) {
$checked = "checked=\"1\"";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"\n\t\t\tname=\"include_in_digest\"\n\t\t\t{$checked}> <label for=\"include_in_digest\">" . __('Include in e-mail digest') . "</label>";
$always_display_enclosures = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "always_display_enclosures"));
if ($always_display_enclosures) {
$checked = "checked";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"\n\t\t\tname=\"always_display_enclosures\"\n\t\t\t{$checked}> <label for=\"always_display_enclosures\">" . __('Always display image attachments') . "</label>";
$hide_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "hide_images"));
if ($hide_images) {
$checked = "checked=\"1\"";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"hide_images\"\n\t\tname=\"hide_images\"\n\t\t\t{$checked}> <label for=\"hide_images\">" . __('Do not embed images') . "</label>";
$cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
if ($cache_images) {
$checked = "checked=\"1\"";
//.........这里部分代码省略.........
示例5: getFeedTree
function getFeedTree()
{
$include_empty = sql_bool_to_bool($_REQUEST['include_empty']);
$pf = new Pref_Feeds($_REQUEST);
$_REQUEST['mode'] = 2;
$_REQUEST['force_show_empty'] = $include_empty;
if ($pf) {
$data = $pf->makefeedtree();
$this->wrap(self::STATUS_OK, array("categories" => $data));
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'UNABLE_TO_INSTANTIATE_OBJECT'));
}
}
示例6: add
function add()
{
$savemode = db_escape_string($_REQUEST["savemode"]);
$regexp = db_escape_string(trim($_REQUEST["reg_exp"]));
$filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
$feed_id = db_escape_string($_REQUEST["feed_id"]);
$cat_id = db_escape_string($_REQUEST["cat_id"]);
$action_id = db_escape_string($_REQUEST["action_id"]);
$action_param = db_escape_string($_REQUEST["action_param"]);
$action_param_label = db_escape_string($_REQUEST["action_param_label"]);
$inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
$cat_filter = checkbox_to_sql_bool(db_escape_string($_REQUEST["cat_filter"]));
# for the time being, no other filters use params anyway...
$filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
if (!$regexp) {
return;
}
if (!$feed_id) {
$feed_id = 'NULL';
} else {
$feed_id = sprintf("'%s'", db_escape_string($feed_id));
}
if (!$cat_id) {
$cat_id = 'NULL';
} else {
$cat_id = sprintf("'%d'", db_escape_string($cat_id));
}
/* When processing 'assign label' filters, action_param_label dropbox
* overrides action_param */
if ($action_id == 7) {
$action_param = $action_param_label;
}
if ($action_id == 6) {
$action_param = (int) str_replace("+", "", $action_param);
}
if ($savemode != "test") {
$result = db_query($this->link, "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,\n\t\t\t\t\taction_id, action_param, inverse, filter_param, cat_id, cat_filter)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$regexp}', '{$filter_type}','" . $_SESSION["uid"] . "',\n\t\t\t\t\t{$feed_id}, '{$action_id}', '{$action_param}', {$inverse},\n\t\t\t\t\t'{$filter_param}', {$cat_id}, {$cat_filter})");
if (db_affected_rows($this->link, $result) != 0) {
print T_sprintf("Created filter <b>%s</b>", htmlspecialchars($regexp));
}
} else {
$this->filter_test($filter_type, $regexp, $action_id, $action_param, $filter_param, sql_bool_to_bool($inverse), (int) $_REQUEST["feed_id"], (int) $_REQUEST['cat_id'], sql_bool_to_bool($cat_filter));
print "<div align='center'>";
print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return dijit.byId('filterTestDlg').hide()\">" . __('Close this window') . "</button>";
print "</div>";
}
}
示例7: 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) {
//.........这里部分代码省略.........
示例8: editfeed
function editfeed()
{
global $purge_intervals;
global $update_intervals;
global $update_methods;
$feed_id = db_escape_string($_REQUEST["id"]);
$result = db_query($this->link, "SELECT * FROM ttrss_feeds WHERE id = '{$feed_id}' AND\n\t\t\t\towner_uid = " . $_SESSION["uid"]);
$title = htmlspecialchars(db_fetch_result($result, 0, "title"));
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$feed_id}\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
print "<div class=\"dlgSecCont\">";
/* Title */
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Feed Title") . "\"\n\t\t\tstyle=\"font-size : 16px; width: 20em\" name=\"title\" value=\"{$title}\">";
/* Feed URL */
$feed_url = db_fetch_result($result, 0, "feed_url");
$feed_url = htmlspecialchars(db_fetch_result($result, 0, "feed_url"));
print "<hr/>";
print __('URL:') . " ";
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Feed URL") . "\"\n\t\t\tregExp='^(http|https)://.*' style=\"width : 20em\"\n\t\t\tname=\"feed_url\" value=\"{$feed_url}\">";
$last_error = db_fetch_result($result, 0, "last_error");
if ($last_error) {
print " <span title=\"" . htmlspecialchars($last_error) . "\"\n\t\t\t\tclass=\"feed_error\">(error)</span>";
}
/* Category */
if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
$cat_id = db_fetch_result($result, 0, "cat_id");
print "<hr/>";
print __('Place in category:') . " ";
print_feed_cat_select($this->link, "cat_id", $cat_id, 'dojoType="dijit.form.Select"');
}
print "</div>";
print "<div class=\"dlgSec\">" . __("Update") . "</div>";
print "<div class=\"dlgSecCont\">";
/* Update Interval */
$update_interval = db_fetch_result($result, 0, "update_interval");
print_select_hash("update_interval", $update_interval, $update_intervals, 'dojoType="dijit.form.Select"');
/* Update method */
$update_method = db_fetch_result($result, 0, "update_method", 'dojoType="dijit.form.Select"');
print " " . __('using') . " ";
print_select_hash("update_method", $update_method, $update_methods, 'dojoType="dijit.form.Select"');
$purge_interval = db_fetch_result($result, 0, "purge_interval");
/* Purge intl */
print "<hr/>";
print __('Article purging:') . " ";
print_select_hash("purge_interval", $purge_interval, $purge_intervals, 'dojoType="dijit.form.Select" ' . (FORCE_ARTICLE_PURGE == 0 ? "" : 'disabled="1"'));
print "</div>";
print "<div class=\"dlgSec\">" . __("Authentication") . "</div>";
print "<div class=\"dlgSecCont\">";
$auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\"\n\t\t\tplaceHolder=\"" . __("Login") . "\"\n\t\t\tname=\"auth_login\" value=\"{$auth_login}\"><hr/>";
$auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"\n\t\t\tplaceHolder=\"" . __("Password") . "\"\n\t\t\tvalue=\"{$auth_pass}\">";
print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedEditDlg_login\" position=\"below\">\n\t\t\t" . __('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.') . "\n\t\t\t</div>";
print "</div>";
print "<div class=\"dlgSec\">" . __("Options") . "</div>";
print "<div class=\"dlgSecCont\">";
$private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
if ($private) {
$checked = "checked=\"1\"";
} else {
$checked = "";
}
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\"\n\t\t\t{$checked}> <label for=\"private\">" . __('Hide from Popular feeds') . "</label>";
$rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
if ($rtl_content) {
$checked = "checked=\"1\"";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"\n\t\t\t{$checked}> <label for=\"rtl_content\">" . __('Right-to-left content') . "</label>";
$include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
if ($include_in_digest) {
$checked = "checked=\"1\"";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"\n\t\t\tname=\"include_in_digest\"\n\t\t\t{$checked}> <label for=\"include_in_digest\">" . __('Include in e-mail digest') . "</label>";
$always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
if ($always_display_enclosures) {
$checked = "checked";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"\n\t\t\tname=\"always_display_enclosures\"\n\t\t\t{$checked}> <label for=\"always_display_enclosures\">" . __('Always display image attachments') . "</label>";
$cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
if ($cache_images) {
$checked = "checked=\"1\"";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\"\n\t\tname=\"cache_images\"\n\t\t\t{$checked}> <label for=\"cache_images\">" . __('Cache images locally') . "</label>";
$mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
if ($mark_unread_on_update) {
$checked = "checked";
} else {
$checked = "";
}
print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\"\n\t\t\tname=\"mark_unread_on_update\"\n\t\t\t{$checked}> <label for=\"mark_unread_on_update\">" . __('Mark updated articles as unread') . "</label>";
//.........这里部分代码省略.........
示例9: otpqrcode
function otpqrcode()
{
require_once "lib/otphp/vendor/base32.php";
require_once "lib/otphp/lib/otp.php";
require_once "lib/otphp/lib/totp.php";
require_once "lib/phpqrcode/phpqrcode.php";
$result = $this->dbh->query("SELECT login,salt,otp_enabled\n\t\t\tFROM ttrss_users\n\t\t\tWHERE id = " . $_SESSION["uid"]);
$base32 = new Base32();
$login = $this->dbh->fetch_result($result, 0, "login");
$otp_enabled = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "otp_enabled"));
if (!$otp_enabled) {
$secret = $base32->encode(sha1($this->dbh->fetch_result($result, 0, "salt")));
print QRcode::png("otpauth://totp/" . urlencode($login) . "?secret={$secret}&issuer=" . urlencode("Tiny Tiny RSS"));
}
}
示例10: render_article
function render_article($link, $id, $feed_id, $cat_id, $is_cat)
{
$query = "SELECT title,link,content,feed_id,comments,int_id,\n\t\t\tmarked,unread,published,\n\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,16) as updated,\n\t\t\tauthor\n\t\t\tFROM ttrss_entries,ttrss_user_entries\n\t\t\tWHERE\tid = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION["uid"];
$result = db_query($link, $query);
if (db_num_rows($result) != 0) {
$line = db_fetch_assoc($result);
$tmp_result = db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\tSET unread = false,last_read = NOW()\n\t\t\t\tWHERE ref_id = '{$id}'\n\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
$updated_fmt = make_local_datetime($link, $line['updated'], false);
$title = $line["title"];
$article_link = $line["link"];
if (!$is_cat) {
$feed_title = getFeedTitle($link, $feed_id);
} else {
$feed_title = getCategoryTitle($link, $feed_id);
}
print "<div class=\"panel\" id=\"article-{$id}\" title=\"{$title}\"\n\t\t\t\tselected=\"true\"\n\t\t\t\tmyBackLabel='{$feed_title}' myBackHref='feed.php?id={$feed_id}&cat={$cat_id}&is_cat={$is_cat}'>";
if ($line['feed_id'] != $feed_id) {
$real_feed_title = getFeedTitle($link, $line['feed_id']);
$real_feed_id = $line['feed_id'];
$feed_link = "(<a href=\"feed.php?id={$real_feed_id}\">{$real_feed_title}</a>)";
}
// print "<fieldset>";
print "<div style='float : right'>({$updated_fmt})</div>";
print "<h2><a target='_blank' href='{$article_link}'>{$title}</a> {$feed_link}</h2>";
print "<hr>";
/* print "<div class=\"row\">";
print "<label id='title'><a target='_blank' href='$article_link'>$title</a></label>";
print "</div>"; */
$is_starred = sql_bool_to_bool($line["marked"]) ? "true" : "false";
$is_published = sql_bool_to_bool($line["published"]) ? "true" : "false";
//print "<div class=\"row\">";
//print "<label id='updated'>Updated:</label>";
//print "<input type='text' enabled='false' name='updated' disabled value='$updated_fmt'/>";
//print "</div>";
// print "</fieldset>";
$content = sanitize($link, $line["content"]);
$content = preg_replace("/href=/i", "target=\"_blank\" href=", $content);
if (!mobile_get_pref($link, "SHOW_IMAGES")) {
$content = preg_replace('/<img[^>]+>/is', '', $content);
}
print "<p>{$content}</p>";
print "<div class='nav'>\n <label>Navigation</label>\n <div class='button left' onclick='goPrev({$id}, {$feed_id}, this)'>Prev</div>\n <div class='button right' onclick='goNext({$id}, {$feed_id}, this)'>Next</div>\n </div>";
print "<fieldset>";
print "<div class=\"row\">\n\t <label>Starred</label>\n\t <div class=\"toggle\" onclick=\"toggleMarked({$id}, this)\" toggled=\"{$is_starred}\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>\n\t </div>";
print "<div class=\"row\">\n\t <label>Published</label>\n\t <div class=\"toggle\" onclick=\"togglePublished({$id}, this)\" toggled=\"{$is_published}\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>\n\t </div>";
print "<div class=\"row\">\n\t <label>Unread</label>\n\t <div class=\"toggle\" onclick=\"toggleUnread({$id}, this)\" toggled=\"{$is_unread}\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>\n\t </div>";
print "</fieldset>";
print "</div>";
}
}
示例11: update_rss_feed
function update_rss_feed($link, $feed, $ignore_daemon = false, $no_cache = false, $override_url = false)
{
require_once "lib/simplepie/simplepie.inc";
require_once "lib/magpierss/rss_fetch.inc";
require_once 'lib/magpierss/rss_utils.inc';
$debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
if (!$_REQUEST["daemon"] && !$ignore_daemon) {
return false;
}
if ($debug_enabled) {
_debug("update_rss_feed: start");
}
if (!$ignore_daemon) {
if (DB_TYPE == "pgsql") {
$updstart_thresh_qpart = "(ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '120 seconds')";
} else {
$updstart_thresh_qpart = "(ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 120 SECOND))";
}
$result = db_query($link, "SELECT id,update_interval,auth_login,\n\t\t\t\tauth_pass,cache_images,update_method,last_updated\n\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}' AND {$updstart_thresh_qpart}");
} else {
$result = db_query($link, "SELECT id,update_interval,auth_login,\n\t\t\t\tfeed_url,auth_pass,cache_images,update_method,last_updated,\n\t\t\t\tmark_unread_on_update, owner_uid, update_on_checksum_change,\n\t\t\t\tpubsub_state\n\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
}
if (db_num_rows($result) == 0) {
if ($debug_enabled) {
_debug("update_rss_feed: feed {$feed} NOT FOUND/SKIPPED");
}
return false;
}
$update_method = db_fetch_result($result, 0, "update_method");
$last_updated = db_fetch_result($result, 0, "last_updated");
$owner_uid = db_fetch_result($result, 0, "owner_uid");
$mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
$update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change"));
$pubsub_state = db_fetch_result($result, 0, "pubsub_state");
db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW()\n\t\t\tWHERE id = '{$feed}'");
$auth_login = db_fetch_result($result, 0, "auth_login");
$auth_pass = db_fetch_result($result, 0, "auth_pass");
if ($update_method == 0) {
$update_method = DEFAULT_UPDATE_METHOD + 1;
}
// 1 - Magpie
// 2 - SimplePie
// 3 - Twitter OAuth
if ($update_method == 2) {
$use_simplepie = true;
} else {
$use_simplepie = false;
}
if ($debug_enabled) {
_debug("update method: {$update_method} (feed setting: {$update_method}) (use simplepie: {$use_simplepie})\n");
}
if ($update_method == 1) {
$auth_login = urlencode($auth_login);
$auth_pass = urlencode($auth_pass);
}
$cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
$fetch_url = db_fetch_result($result, 0, "feed_url");
$feed = db_escape_string($feed);
if ($auth_login && $auth_pass) {
$url_parts = array();
preg_match("/(^[^:]*):\\/\\/(.*)/", $fetch_url, $url_parts);
if ($url_parts[1] && $url_parts[2]) {
$fetch_url = $url_parts[1] . "://{$auth_login}:{$auth_pass}@" . $url_parts[2];
}
}
if ($override_url) {
$fetch_url = $override_url;
}
if ($debug_enabled) {
_debug("update_rss_feed: fetching [{$fetch_url}]...");
}
// Ignore cache if new feed or manual update.
$cache_age = is_null($last_updated) || $last_updated == '1970-01-01 00:00:00' ? -1 : get_feed_update_interval($link, $feed) * 60;
if ($update_method == 3) {
$rss = fetch_twitter_rss($link, $fetch_url, $owner_uid);
} else {
if ($update_method == 1) {
define('MAGPIE_CACHE_AGE', $cache_age);
define('MAGPIE_CACHE_ON', !$no_cache);
define('MAGPIE_FETCH_TIME_OUT', 60);
define('MAGPIE_CACHE_DIR', CACHE_DIR . "/magpie");
$rss = @fetch_rss($fetch_url);
} else {
$simplepie_cache_dir = CACHE_DIR . "/simplepie";
if (!is_dir($simplepie_cache_dir)) {
mkdir($simplepie_cache_dir);
}
$rss = new SimplePie();
$rss->set_useragent(SELF_USER_AGENT);
# $rss->set_timeout(10);
$rss->set_feed_url($fetch_url);
$rss->set_output_encoding('UTF-8');
//$rss->force_feed(true);
if ($debug_enabled) {
_debug("feed update interval (sec): " . get_feed_update_interval($link, $feed) * 60);
}
$rss->enable_cache(!$no_cache);
if (!$no_cache) {
$rss->set_cache_location($simplepie_cache_dir);
$rss->set_cache_duration($cache_age);
//.........这里部分代码省略.........
示例12: getFilterName
private function getFilterName($id)
{
$result = $this->dbh->query("SELECT title,match_any_rule,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions\n\t\t\t\tFROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r\n\t\t\t\t\tON (r.filter_id = f.id)\n\t\t\t\t\t\tLEFT JOIN ttrss_filters2_actions AS a\n\t\t\t\t\t\t\tON (a.filter_id = f.id) WHERE f.id = '{$id}' GROUP BY f.title, f.match_any_rule");
$title = $this->dbh->fetch_result($result, 0, "title");
$num_rules = $this->dbh->fetch_result($result, 0, "num_rules");
$num_actions = $this->dbh->fetch_result($result, 0, "num_actions");
$match_any_rule = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "match_any_rule"));
if (!$title) {
$title = __("[No caption]");
}
$title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", $num_rules), $title, $num_rules);
$result = $this->dbh->query("SELECT * FROM ttrss_filters2_actions WHERE filter_id = '{$id}' ORDER BY id LIMIT 1");
$actions = "";
if ($this->dbh->num_rows($result) > 0) {
$line = $this->dbh->fetch_assoc($result);
$actions = $this->getActionName($line);
$num_actions -= 1;
}
if ($match_any_rule) {
$title .= " (" . __("matches any rule") . ")";
}
if ($num_actions > 0) {
$actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", $num_actions), $actions, $num_actions);
}
return array($title, $actions);
}
示例13: perform_data_import
function perform_data_import($filename, $owner_uid)
{
$num_imported = 0;
$num_processed = 0;
$num_feeds_created = 0;
libxml_disable_entity_loader(false);
$doc = @DOMDocument::load($filename);
if (!$doc) {
$contents = file_get_contents($filename);
if ($contents) {
$data = @gzuncompress($contents);
}
if (!$data) {
$data = @gzdecode($contents);
}
if ($data) {
$doc = DOMDocument::loadXML($data);
}
}
libxml_disable_entity_loader(true);
if ($doc) {
$xpath = new DOMXpath($doc);
$container = $doc->firstChild;
if ($container && $container->hasAttribute('schema-version')) {
$schema_version = $container->getAttribute('schema-version');
if ($schema_version != SCHEMA_VERSION) {
print "<p>" . __("Could not import: incorrect schema version.") . "</p>";
return;
}
} else {
print "<p>" . __("Could not import: unrecognized document format.") . "</p>";
return;
}
$articles = $xpath->query("//article");
foreach ($articles as $article_node) {
if ($article_node->childNodes) {
$ref_id = 0;
$article = array();
foreach ($article_node->childNodes as $child) {
if ($child->nodeName != 'label_cache') {
$article[$child->nodeName] = db_escape_string($child->nodeValue);
} else {
$article[$child->nodeName] = $child->nodeValue;
}
}
//print_r($article);
if ($article['guid']) {
++$num_processed;
//db_query("BEGIN");
//print 'GUID:' . $article['guid'] . "\n";
$result = db_query("SELECT id FROM ttrss_entries\n\t\t\t\t\t\t\tWHERE guid = '" . $article['guid'] . "'");
if (db_num_rows($result) == 0) {
$result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t('" . $article['title'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['guid'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['link'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['updated'] . "',\n\t\t\t\t\t\t\t\t\t'" . $article['content'] . "',\n\t\t\t\t\t\t\t\t\t'" . sha1($article['content']) . "',\n\t\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t\t'')");
$result = db_query("SELECT id FROM ttrss_entries\n\t\t\t\t\t\t\t\tWHERE guid = '" . $article['guid'] . "'");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
}
} else {
$ref_id = db_fetch_result($result, 0, "id");
}
//print "Got ref ID: $ref_id\n";
if ($ref_id) {
$feed_url = $article['feed_url'];
$feed_title = $article['feed_title'];
$feed = 'NULL';
if ($feed_url && $feed_title) {
$result = db_query("SELECT id FROM ttrss_feeds\n\t\t\t\t\t\t\t\t\tWHERE feed_url = '{$feed_url}' AND owner_uid = '{$owner_uid}'");
if (db_num_rows($result) != 0) {
$feed = db_fetch_result($result, 0, "id");
} else {
// try autocreating feed in Uncategorized...
$result = db_query("INSERT INTO ttrss_feeds (owner_uid,\n\t\t\t\t\t\t\t\t\t\tfeed_url, title) VALUES ({$owner_uid}, '{$feed_url}', '{$feed_title}')");
$result = db_query("SELECT id FROM ttrss_feeds\n\t\t\t\t\t\t\t\t\t\tWHERE feed_url = '{$feed_url}' AND owner_uid = '{$owner_uid}'");
if (db_num_rows($result) != 0) {
++$num_feeds_created;
$feed = db_fetch_result($result, 0, "id");
}
}
}
if ($feed != 'NULL') {
$feed_qpart = "feed_id = {$feed}";
} else {
$feed_qpart = "feed_id IS NULL";
}
//print "$ref_id / $feed / " . $article['title'] . "\n";
$result = db_query("SELECT int_id FROM ttrss_user_entries\n\t\t\t\t\t\t\t\tWHERE ref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' AND {$feed_qpart}");
if (db_num_rows($result) == 0) {
$marked = bool_to_sql_bool(sql_bool_to_bool($article['marked']));
$published = bool_to_sql_bool(sql_bool_to_bool($article['published']));
$score = (int) $article['score'];
$tag_cache = $article['tag_cache'];
$label_cache = db_escape_string($article['label_cache']);
$note = $article['note'];
//print "Importing " . $article['title'] . "<br/>";
++$num_imported;
$result = db_query("INSERT INTO ttrss_user_entries\n\t\t\t\t\t\t\t\t\t(ref_id, owner_uid, feed_id, unread, last_read, marked,\n\t\t\t\t\t\t\t\t\t\tpublished, score, tag_cache, label_cache, uuid, note)\n\t\t\t\t\t\t\t\t\tVALUES ({$ref_id}, {$owner_uid}, {$feed}, false,\n\t\t\t\t\t\t\t\t\t\tNULL, {$marked}, {$published}, {$score}, '{$tag_cache}',\n\t\t\t\t\t\t\t\t\t\t\t'{$label_cache}', '', '{$note}')");
$label_cache = json_decode($label_cache, true);
if (is_array($label_cache) && $label_cache["no-labels"] != 1) {
foreach ($label_cache as $label) {
label_create($label[1], $label[2], $label[3], $owner_uid);
//.........这里部分代码省略.........
示例14: update_rss_feed
function update_rss_feed($feed, $ignore_daemon = false, $no_cache = false, $rss = false)
{
$debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
_debug_suppress(!$debug_enabled);
_debug("start", $debug_enabled);
$result = db_query("SELECT title FROM ttrss_feeds\n\t\t\tWHERE id = '{$feed}'");
$title = db_fetch_result($result, 0, "title");
// feed was batch-subscribed or something, we need to get basic info
// this is not optimal currently as it fetches stuff separately TODO: optimize
if ($title == "[Unknown]") {
_debug("setting basic feed info for {$feed}...");
set_basic_feed_info($feed);
}
$result = db_query("SELECT id,update_interval,auth_login,\n\t\t\tfeed_url,auth_pass,cache_images,\n\t\t\tmark_unread_on_update, owner_uid,\n\t\t\tpubsub_state, auth_pass_encrypted,\n\t\t\tfeed_language,\n\t\t\t(SELECT max(date_entered) FROM\n\t\t\t\tttrss_entries, ttrss_user_entries where ref_id = id AND feed_id = '{$feed}') AS last_article_timestamp\n\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
if (db_num_rows($result) == 0) {
_debug("feed {$feed} NOT FOUND/SKIPPED", $debug_enabled);
return false;
}
$last_article_timestamp = @strtotime(db_fetch_result($result, 0, "last_article_timestamp"));
if (defined('_DISABLE_HTTP_304')) {
$last_article_timestamp = 0;
}
$owner_uid = db_fetch_result($result, 0, "owner_uid");
$mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
$pubsub_state = db_fetch_result($result, 0, "pubsub_state");
$auth_pass_encrypted = sql_bool_to_bool(db_fetch_result($result, 0, "auth_pass_encrypted"));
db_query("UPDATE ttrss_feeds SET last_update_started = NOW()\n\t\t\tWHERE id = '{$feed}'");
$auth_login = db_fetch_result($result, 0, "auth_login");
$auth_pass = db_fetch_result($result, 0, "auth_pass");
if ($auth_pass_encrypted) {
require_once "crypt.php";
$auth_pass = decrypt_string($auth_pass);
}
$cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
$fetch_url = db_fetch_result($result, 0, "feed_url");
$feed_language = db_escape_string(mb_strtolower(db_fetch_result($result, 0, "feed_language")));
if (!$feed_language) {
$feed_language = 'english';
}
$feed = db_escape_string($feed);
$date_feed_processed = date('Y-m-d H:i');
$cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".xml";
$pluginhost = new PluginHost();
$pluginhost->set_debug($debug_enabled);
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
$pluginhost->load(PLUGINS, PluginHost::KIND_ALL);
$pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
$pluginhost->load_data();
if ($rss && is_object($rss) && get_class($rss) == "FeedParser") {
_debug("using previously initialized parser object");
} else {
$rss_hash = false;
$force_refetch = isset($_REQUEST["force_refetch"]);
foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
$feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass);
}
// try cache
if (!$feed_data && file_exists($cache_filename) && is_readable($cache_filename) && !$auth_login && !$auth_pass && filemtime($cache_filename) > time() - 30) {
_debug("using local cache [{$cache_filename}].", $debug_enabled);
@($feed_data = file_get_contents($cache_filename));
if ($feed_data) {
$rss_hash = sha1($feed_data);
}
} else {
_debug("local cache will not be used for this feed", $debug_enabled);
}
// fetch feed from source
if (!$feed_data) {
_debug("fetching [{$fetch_url}]...", $debug_enabled);
_debug("If-Modified-Since: " . gmdate('D, d M Y H:i:s \\G\\M\\T', $last_article_timestamp), $debug_enabled);
$feed_data = fetch_file_contents($fetch_url, false, $auth_login, $auth_pass, false, $no_cache ? FEED_FETCH_NO_CACHE_TIMEOUT : FEED_FETCH_TIMEOUT, $force_refetch ? 0 : $last_article_timestamp);
global $fetch_curl_used;
if (!$fetch_curl_used) {
$tmp = @gzdecode($feed_data);
if ($tmp) {
$feed_data = $tmp;
}
}
$feed_data = trim($feed_data);
_debug("fetch done.", $debug_enabled);
// cache vanilla feed data for re-use
if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/simplepie")) {
$new_rss_hash = sha1($feed_data);
if ($new_rss_hash != $rss_hash) {
_debug("saving {$cache_filename}", $debug_enabled);
@file_put_contents($cache_filename, $feed_data);
}
}
}
if (!$feed_data) {
global $fetch_last_error;
global $fetch_last_error_code;
_debug("unable to fetch: {$fetch_last_error} [{$fetch_last_error_code}]", $debug_enabled);
$error_escaped = '';
// If-Modified-Since
if ($fetch_last_error_code != 304) {
$error_escaped = db_escape_string($fetch_last_error);
} else {
_debug("source claims data not modified, nothing to do.", $debug_enabled);
}
//.........这里部分代码省略.........
示例15: module_pref_filters
function module_pref_filters($link)
{
$subop = $_REQUEST["subop"];
$quiet = $_REQUEST["quiet"];
if ($subop == "getfiltertree") {
$root = array();
$root['id'] = 'root';
$root['name'] = __('Filters');
$root['items'] = array();
$result = db_query($link, "SELECT\n\t\t\t\t\tttrss_filters.id AS id,reg_exp,\n\t\t\t\t\tttrss_filter_types.name AS filter_type_name,\n\t\t\t\t\tttrss_filter_types.description AS filter_type_descr,\n\t\t\t\t\tenabled,\n\t\t\t\t\tinverse,\n\t\t\t\t\tfeed_id,\n\t\t\t\t\taction_id,\n\t\t\t\t\tfilter_param,\n\t\t\t\t\tfilter_type,\n\t\t\t\t\tttrss_filter_actions.description AS action_description,\n\t\t\t\t\tttrss_feeds.title AS feed_title,\n\t\t\t\t\tttrss_filter_actions.name AS action_name,\n\t\t\t\t\tttrss_filters.action_param AS action_param\n\t\t\t\tFROM\n\t\t\t\t\tttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN\n\t\t\t\t\t\tttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id)\n\t\t\t\tWHERE\n\t\t\t\t\tfilter_type = ttrss_filter_types.id AND\n\t\t\t\t\tttrss_filter_actions.id = action_id AND\n\t\t\t\t\tttrss_filters.owner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tORDER by action_description, reg_exp");
$cat = false;
$cur_action_description = "";
if (db_num_rows($result) > 0) {
while ($line = db_fetch_assoc($result)) {
if ($cur_action_description != $line['action_description']) {
if ($cat) {
array_push($root['items'], $cat);
}
$cat = array();
$cat['id'] = 'ACTION:' . $line['action_id'];
$cat['name'] = $line['action_description'];
$cat['items'] = array();
$cur_action_description = $line['action_description'];
}
if (array_search($line["action_name"], array("score", "tag", "label")) === false) {
$line["action_param"] = '';
} else {
if ($line['action_name'] == 'label') {
$tmp_result = db_query($link, "SELECT fg_color, bg_color\n\t\t\t\t\t\t\t\tFROM ttrss_labels2 WHERE caption = '" . db_escape_string($line["action_param"]) . "' AND\n\t\t\t\t\t\t\t\t\towner_uid = " . $_SESSION["uid"]);
if (db_num_rows($tmp_result) != 0) {
$fg_color = db_fetch_result($tmp_result, 0, "fg_color");
$bg_color = db_fetch_result($tmp_result, 0, "bg_color");
$tmp = "<span class=\"labelColorIndicator\" style='color : {$fg_color}; background-color : {$bg_color}'>α</span> " . $line['action_param'];
$line['action_param'] = $tmp;
}
}
}
$filter = array();
$filter['id'] = 'FILTER:' . $line['id'];
$filter['bare_id'] = $line['id'];
$filter['name'] = $line['reg_exp'];
$filter['type'] = $line['filter_type'];
$filter['enabled'] = sql_bool_to_bool($line['enabled']);
$filter['param'] = $line['action_param'];
$filter['inverse'] = sql_bool_to_bool($line['inverse']);
$filter['checkbox'] = false;
if ($line['feed_id']) {
$filter['feed'] = $line['feed_title'];
}
array_push($cat['items'], $filter);
}
array_push($root['items'], $cat);
}
$fl = array();
$fl['identifier'] = 'id';
$fl['label'] = 'name';
$fl['items'] = array($root);
print json_encode($fl);
return;
}
if ($subop == "edit") {
$filter_id = db_escape_string($_REQUEST["id"]);
$result = db_query($link, "SELECT * FROM ttrss_filters WHERE id = '{$filter_id}' AND owner_uid = " . $_SESSION["uid"]);
$reg_exp = htmlspecialchars(db_fetch_result($result, 0, "reg_exp"));
$filter_type = db_fetch_result($result, 0, "filter_type");
$feed_id = db_fetch_result($result, 0, "feed_id");
$action_id = db_fetch_result($result, 0, "action_id");
$action_param = db_fetch_result($result, 0, "action_param");
$filter_param = db_fetch_result($result, 0, "filter_param");
$enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled"));
$inverse = sql_bool_to_bool(db_fetch_result($result, 0, "inverse"));
print "<form id=\"filter_edit_form\" onsubmit='return false'>";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$filter_id}\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"editSave\">";
$result = db_query($link, "SELECT id,description\n\t\t\t\tFROM ttrss_filter_types ORDER BY description");
$filter_types = array();
while ($line = db_fetch_assoc($result)) {
//array_push($filter_types, $line["description"]);
$filter_types[$line["id"]] = __($line["description"]);
}
print "<div class=\"dlgSec\">" . __("Match") . "</div>";
print "<div class=\"dlgSecCont\">";
if ($filter_type != 5) {
$date_ops_invisible = 'style="display : none"';
}
print "<span id=\"filterDlg_dateModBox\" {$date_ops_invisible}>";
print __("Date") . " ";
$filter_params = array("before" => __("before"), "after" => __("after"));
print_select_hash("filter_date_modifier", $filter_param, $filter_params, 'dojoType="dijit.form.Select"');
print " </span>";
print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\t required=\"1\"\n\t\t\t\t\t name=\"reg_exp\" style=\"font-size : 16px;\" value=\"{$reg_exp}\">";
print "<span id=\"filterDlg_dateChkBox\" {$date_ops_invisible}>";
print " <button dojoType=\"dijit.form.Button\" onclick=\"return filterDlgCheckDate()\">" . __('Check it') . "</button>";
print "</span>";
print "<hr/> " . __("on field") . " ";
print_select_hash("filter_type", $filter_type, $filter_types, 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
print "<hr/>";
print __("in") . " ";
print_feed_select($link, "feed_id", $feed_id, 'dojoType="dijit.form.FilteringSelect"');
//.........这里部分代码省略.........