public static function getInstance() { if (self::$instance == null) { self::$instance = new self(); } return self::$instance; }
function index() { print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Error Log') . "\">"; if (LOG_DESTINATION == "sql") { $result = $this->dbh->query("SELECT errno, errstr, filename, lineno,\n\t\t\t\tcreated_at, login FROM ttrss_error_log\n\t\t\t\tLEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)\n\t\t\t\tORDER BY ttrss_error_log.id DESC\n\t\t\t\tLIMIT 100"); print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"updateSystemList()\">" . __('Refresh') . "</button> "; print " <button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"clearSqlLog()\">" . __('Clear log') . "</button> "; print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; print "<tr class=\"title\">\n\t\t\t\t<td width='5%'>" . __("Error") . "</td>\n\t\t\t\t<td>" . __("Filename") . "</td>\n\t\t\t\t<td>" . __("Message") . "</td>\n\t\t\t\t<td width='5%'>" . __("User") . "</td>\n\t\t\t\t<td width='5%'>" . __("Date") . "</td>\n\t\t\t\t</tr>"; while ($line = $this->dbh->fetch_assoc($result)) { print "<tr class=\"errrow\">"; foreach ($line as $k => $v) { $line[$k] = htmlspecialchars($v); } print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>"; print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>"; print "<td class='errstr'>" . $line["errstr"] . "</td>"; print "<td class='login'>" . $line["login"] . "</td>"; print "<td class='timestamp'>" . make_local_datetime($line["created_at"], false) . "</td>"; print "</tr>"; } print "</table>"; } else { print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); } print "</div>"; PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefSystem"); print "</div>"; #container }
function catchall($method) { $plugin = PluginHost::getInstance()->get_plugin($_REQUEST["plugin"]); if ($plugin) { if (method_exists($plugin, $method)) { $plugin->{$method}(); } else { print error_json(13); } } else { print error_json(14); } }
function catchall($method) { $plugin = PluginHost::getInstance()->get_plugin($_REQUEST["plugin"]); if (!$plugin) { print json_encode(array("error" => "PLUGIN_NOT_FOUND")); return; } if (!method_exists($plugin, $method)) { print json_encode(array("error" => "METHOD_NOT_FOUND")); return; } $plugin->{$method}(); }
function housekeeping_common($debug) { expire_cached_files($debug); expire_lock_files($debug); expire_error_log($debug); $count = update_feedbrowser_cache(); _debug("Feedbrowser updated, {$count} feeds processed."); purge_orphans(true); $rc = cleanup_tags(14, 50000); _debug("Cleaned {$rc} cached tags."); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", ""); }
require_once "sessions.php"; require_once "functions.php"; require_once "sanity_check.php"; require_once "config.php"; require_once "db.php"; require_once "db-prefs.php"; startup_gettext(); $script_started = microtime(true); if (!init_plugins()) { return; } if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { ob_start("ob_gzhandler"); } $method = $_REQUEST["op"]; $override = PluginHost::getInstance()->lookup_handler("public", $method); if ($override) { $handler = $override; } else { $handler = new Handler_Public($_REQUEST); } if (implements_interface($handler, "IHandler") && $handler->before($method)) { if ($method && method_exists($handler, $method)) { $handler->{$method}(); } else { if (method_exists($handler, 'index')) { $handler->index(); } } $handler->after(); return;
static function api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100, $check_first_id = false) { if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { // Update the feed if required with some basic flood control $result = db_query("SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed_id}'"); if (db_num_rows($result) != 0) { $last_updated = strtotime(db_fetch_result($result, 0, "last_updated")); $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); if (!$cache_images && time() - $last_updated > 120) { include "rssfuncs.php"; update_rss_feed($feed_id, true, true); } else { db_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_id}'"); } } } /*$qfh_ret = queryFeedHeadlines($feed_id, $limit, $view_mode, $is_cat, $search, false, $order, $offset, 0, false, $since_id, $include_nested);*/ //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, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) { $params = array("feed" => $feed_id, "limit" => $limit, "view_mode" => $view_mode, "cat_view" => $is_cat, "search" => $search, "override_order" => $order, "offset" => $offset, "since_id" => $since_id, "include_children" => $include_nested, "check_first_id" => $check_first_id, "api_request" => true); $qfh_ret = queryFeedHeadlines($params); $result = $qfh_ret[0]; $feed_title = $qfh_ret[1]; $first_id = $qfh_ret[6]; $headlines = array(); $headlines_header = array('id' => $feed_id, 'first_id' => $first_id, 'is_cat' => $is_cat); if (!is_numeric($result)) { while ($line = db_fetch_assoc($result)) { $line["content_preview"] = truncate_string(strip_tags($line["content"]), $excerpt_length); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, $excerpt_length, true); } $is_updated = $line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1"); $tags = explode(",", $line["tag_cache"]); $label_cache = $line["label_cache"]; $labels = false; if ($label_cache) { $label_cache = json_decode($label_cache, true); if ($label_cache) { if ($label_cache["no-labels"] == 1) { $labels = array(); } else { $labels = $label_cache; } } } if (!is_array($labels)) { $labels = get_article_labels($line["id"]); } //if (!$tags) $tags = get_article_tags($line["id"]); //if (!$labels) $labels = get_article_labels($line["id"]); $headline_row = array("id" => (int) $line["id"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "updated" => (int) strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], "tags" => $tags); if ($include_attachments) { $headline_row['attachments'] = get_article_enclosures($line['id']); } if ($show_excerpt) { $headline_row["excerpt"] = $line["content_preview"]; } if ($show_content) { if ($sanitize_content) { $headline_row["content"] = sanitize($line["content"], sql_bool_to_bool($line['hide_images']), false, $line["site_url"], false, $line["id"]); } else { $headline_row["content"] = $line["content"]; } } // unify label output to ease parsing if ($labels["no-labels"] == 1) { $labels = array(); } $headline_row["labels"] = $labels; $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : $feed_title; $headline_row["comments_count"] = (int) $line["num_comments"]; $headline_row["comments_link"] = $line["comments"]; $headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]); $headline_row["author"] = $line["author"]; $headline_row["score"] = (int) $line["score"]; $headline_row["note"] = $line["note"]; $headline_row["lang"] = $line["lang"]; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { $headline_row = $p->hook_render_article_api(array("headline" => $headline_row)); } array_push($headlines, $headline_row); } } else { if (is_numeric($result) && $result == -1) { $headlines_header['first_id_changed'] = true; } } return array($headlines, $headlines_header); }
/** * @return array (code => Status code, message => error message if available) * * 0 - OK, Feed already exists * 1 - OK, Feed added * 2 - Invalid URL * 3 - URL content is HTML, no feeds available * 4 - URL content is HTML which contains multiple feeds. * Here you should call extractfeedurls in rpc-backend * to get all possible feeds. * 5 - Couldn't download the URL content. * 6 - Content is an invalid XML. */ function subscribe_to_feed($url, $cat_id = 0, $auth_login = '', $auth_pass = '') { global $fetch_last_error; require_once "include/rssfuncs.php"; $url = fix_url($url); if (!$url || !validate_feed_url($url)) { return array("code" => 2); } $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass); if (!$contents) { return array("code" => 5, "message" => $fetch_last_error); } foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) { $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass); } if (is_html($contents)) { $feedUrls = get_feeds_from_html($url, $contents); if (count($feedUrls) == 0) { return array("code" => 3); } else { if (count($feedUrls) > 1) { return array("code" => 4, "feeds" => $feedUrls); } } //use feed url as new URL $url = key($feedUrls); } if ($cat_id == "0" || !$cat_id) { $cat_qpart = "NULL"; } else { $cat_qpart = "'{$cat_id}'"; } $result = db_query("SELECT id FROM ttrss_feeds\n\t\t\tWHERE feed_url = '{$url}' AND owner_uid = " . $_SESSION["uid"]); if (strlen(FEED_CRYPT_KEY) > 0) { require_once "crypt.php"; $auth_pass = substr(encrypt_string($auth_pass), 0, 250); $auth_pass_encrypted = 'true'; } else { $auth_pass_encrypted = 'false'; } $auth_pass = db_escape_string($auth_pass); if (db_num_rows($result) == 0) { $result = db_query("INSERT INTO ttrss_feeds\n\t\t\t\t\t(owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted)\n\t\t\t\tVALUES ('" . $_SESSION["uid"] . "', '{$url}',\n\t\t\t\t'[Unknown]', {$cat_qpart}, '{$auth_login}', '{$auth_pass}', 0, {$auth_pass_encrypted})"); $result = db_query("SELECT id FROM ttrss_feeds WHERE feed_url = '{$url}'\n\t\t\t\t\tAND owner_uid = " . $_SESSION["uid"]); $feed_id = db_fetch_result($result, 0, "id"); if ($feed_id) { set_basic_feed_info($feed_id); } return array("code" => 1); } else { return array("code" => 0); } }
function saveConfig() { $config = (array) $_POST['refSpoofFeed']; $this->host->set($this, 'feeds', $config); echo __("Configuration saved."); }
?> <div id="userConfigTab" dojoType="dijit.layout.ContentPane" href="backend.php?op=pref-users" title="<?php echo __('Users'); ?> "></div> <div id="systemConfigTab" dojoType="dijit.layout.ContentPane" href="backend.php?op=pref-system" title="<?php echo __('System'); ?> "></div> <?php } PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TABS, "hook_prefs_tabs", false); ?> </div> <div id="footer" dojoType="dijit.layout.ContentPane" region="bottom"> <a class="insensitive" target="_blank" href="http://tt-rss.org/"> Tiny Tiny RSS</a> <?php if (!defined('HIDE_VERSION')) { ?> v<?php echo VERSION; ?> <?php } ?>
$filter["rule"] = array(json_encode(array("reg_exp" => $line["reg_exp"], "feed_id" => $feed_id, "filter_type" => $line["filter_type"]))); $filter["action"] = array(json_encode(array("action_id" => $line["action_id"], "action_param_label" => $line["action_param"], "action_param" => $line["action_param"]))); // Oh god it's full of hacks $_REQUEST = $filter; $_SESSION["uid"] = $owner_uid; $filters = new Pref_Filters($link, $_REQUEST); $filters->add(); } } } if (in_array("-force-update", $op)) { _debug("marking all feeds as needing update..."); db_query($link, "UPDATE ttrss_feeds SET last_update_started = '1970-01-01',\n\t\t\t\tlast_updated = '1970-01-01'"); } if (in_array("-list-plugins", $op)) { $tmppluginhost = new PluginHost($link); $tmppluginhost->load_all($tmppluginhost::KIND_ALL); $enabled = array_map("trim", explode(",", PLUGINS)); echo "List of all available plugins:\n"; foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); $status = $about[3] ? "system" : "user"; if (in_array($name, $enabled)) { $name .= "*"; } printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", $name, $status, $about[0], $about[2], $about[1]); } echo "Plugins marked by * are currently enabled for all users.\n"; } $pluginhost->run_commands($op); db_close($link);
static function create_published_article($title, $url, $content, $labels_str, $owner_uid) { $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash if (!$content) { $pluginhost = new PluginHost(); $pluginhost->load_all(PluginHost::KIND_ALL, $owner_uid); $pluginhost->load_data(); $af_readability = $pluginhost->get_plugin("Af_Readability"); if ($af_readability) { $enable_share_anything = $pluginhost->get($af_readability, "enable_share_anything"); if ($enable_share_anything) { $extracted_content = $af_readability->extract_content($url); if ($extracted_content) { $content = db_escape_string($extracted_content); } } } } $content_hash = sha1($content); if ($labels_str != "") { $labels = explode(",", $labels_str); } else { $labels = array(); } $rc = false; if (!$title) { $title = $url; } if (!$title && !$url) { return false; } if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { return false; } db_query("BEGIN"); // only check for our user data here, others might have shared this with different content etc $result = db_query("SELECT id FROM ttrss_entries, ttrss_user_entries WHERE\n\t\t\tguid = '{$guid}' AND ref_id = id AND owner_uid = '{$owner_uid}' LIMIT 1"); if (db_num_rows($result) != 0) { $ref_id = db_fetch_result($result, 0, "id"); $result = db_query("SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' LIMIT 1"); if (db_num_rows($result) != 0) { $int_id = db_fetch_result($result, 0, "int_id"); db_query("UPDATE ttrss_entries SET\n\t\t\t\t\tcontent = '{$content}', content_hash = '{$content_hash}' WHERE id = '{$ref_id}'"); db_query("UPDATE ttrss_user_entries SET published = true,\n\t\t\t\t\t\tlast_published = NOW() WHERE\n\t\t\t\t\t\tint_id = '{$int_id}' AND owner_uid = '{$owner_uid}'"); } else { db_query("INSERT INTO ttrss_user_entries\n\t\t\t\t\t(ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache,\n\t\t\t\t\t\tlast_read, note, unread, last_published)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('{$ref_id}', '', NULL, NULL, {$owner_uid}, true, '', '', NOW(), '', false, NOW())"); } if (count($labels) != 0) { foreach ($labels as $label) { label_add_article($ref_id, trim($label), $owner_uid); } } $rc = true; } else { $result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t(title, guid, link, updated, content, content_hash, date_entered, date_updated)\n\t\t\t\tVALUES\n\t\t\t\t('{$title}', '{$guid}', '{$url}', NOW(), '{$content}', '{$content_hash}', NOW(), NOW())"); $result = db_query("SELECT id FROM ttrss_entries WHERE guid = '{$guid}'"); if (db_num_rows($result) != 0) { $ref_id = db_fetch_result($result, 0, "id"); db_query("INSERT INTO ttrss_user_entries\n\t\t\t\t\t(ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache,\n\t\t\t\t\t\tlast_read, note, unread, last_published)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('{$ref_id}', '', NULL, NULL, {$owner_uid}, true, '', '', NOW(), '', false, NOW())"); if (count($labels) != 0) { foreach ($labels as $label) { label_add_article($ref_id, trim($label), $owner_uid); } } $rc = true; } } db_query("COMMIT"); return $rc; }
function search() { $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2); $active_feed_id = sprintf("%d", $this->params[0]); $is_cat = $this->params[1] != "false"; print "<div class=\"dlgSec\">" . __('Look for') . "</div>"; print "<div class=\"dlgSecCont\">"; print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\tstyle=\"font-size : 16px; width : 20em;\"\n\t\t\trequired=\"1\" name=\"query\" type=\"search\" value=''>"; print "<hr/><span style='float : right'>" . T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat)) . "</span>"; print "</div>"; print "<div class=\"dlgButtons\">"; if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) { print "<div style=\"float : left\">\n\t\t\t\t<a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">" . __("Search syntax") . "</a>\n\t\t\t\t</div>"; } print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">" . __('Search') . "</button>\n\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">" . __('Cancel') . "</button>\n\t\t</div>"; }
function index() { if (!function_exists('curl_init')) { print "<div style='padding : 1em'>"; print_error("This functionality requires CURL functions. Please enable CURL in your PHP configuration (you might also want to disable open_basedir in php.ini) and reload this page."); print "</div>"; } print "<div id=\"pref-instance-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">"; print "<div id=\"pref-instance-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">"; print "<div id=\"pref-instance-toolbar\" dojoType=\"dijit.Toolbar\">"; $sort = db_escape_string($_REQUEST["sort"]); if (!$sort || $sort == "undefined") { $sort = "access_url"; } print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>"; print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; print "<div onclick=\"selectTableRows('prefInstanceList', 'all')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>"; print "<div onclick=\"selectTableRows('prefInstanceList', 'none')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>"; print "</div></div>"; print "<button dojoType=\"dijit.form.Button\" onclick=\"addInstance()\">" . __('Link instance') . "</button>"; print "<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedInstance()\">" . __('Edit') . "</button>"; print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedInstances()\">" . __('Remove') . "</button>"; print "</div>"; #toolbar $result = db_query("SELECT *,\n\t\t\t(SELECT COUNT(*) FROM ttrss_linked_feeds\n\t\t\t\tWHERE instance_id = ttrss_linked_instances.id) AS num_feeds\n\t\t\tFROM ttrss_linked_instances\n\t\t\tORDER BY {$sort}"); print "<p class=\"insensitive\" style='margin-left : 1em;'>" . __("You can connect other instances of Tiny Tiny RSS to this one to share Popular feeds. Link to this instance of Tiny Tiny RSS by using this URL:"); print " <a href=\"#\" onclick=\"alert('" . htmlspecialchars(get_self_url_prefix()) . "')\">(display url)</a>"; print "<p><table width='100%' id='prefInstanceList' class='prefInstanceList' cellspacing='0'>"; print "<tr class=\"title\">\n\t\t\t<td align='center' width=\"5%\"> </td>\n\t\t\t<td width=''><a href=\"#\" onclick=\"updateInstanceList('access_url')\">" . __('Instance URL') . "</a></td>\n\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateInstanceList('access_key')\">" . __('Access key') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('last_connected')\">" . __('Last connected') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('last_status_out')\">" . __('Status') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('num_feeds')\">" . __('Stored feeds') . "</a></td>\n\t\t\t</tr>"; $lnum = 0; while ($line = db_fetch_assoc($result)) { $class = $lnum % 2 ? "even" : "odd"; $id = $line['id']; $this_row_id = "id=\"LIRR-{$id}\""; $line["last_connected"] = make_local_datetime($line["last_connected"], false); print "<tr class=\"{$class}\" {$this_row_id}>"; print "<td align='center'><input onclick='toggleSelectRow(this);'\n\t\t\t\ttype=\"checkbox\" id=\"LICHK-{$id}\"></td>"; $onclick = "onclick='editInstance({$id}, event)' title='" . __('Click to edit') . "'"; $access_key = mb_substr($line['access_key'], 0, 4) . '...' . mb_substr($line['access_key'], -4); print "<td {$onclick}>" . htmlspecialchars($line['access_url']) . "</td>"; print "<td {$onclick}>" . htmlspecialchars($access_key) . "</td>"; print "<td {$onclick}>" . htmlspecialchars($line['last_connected']) . "</td>"; print "<td {$onclick}>" . $this->status_codes[$line['last_status_out']] . "</td>"; print "<td {$onclick}>" . htmlspecialchars($line['num_feeds']) . "</td>"; print "</tr>"; ++$lnum; } print "</table>"; print "</div>"; #pane PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefInstances"); print "</div>"; #container }
</div> <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...'); ?> </div> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...'); ?> </div> --> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help'); ?> </div> <?php foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) { echo $p->hook_action_item(); } ?> <?php if (!$_SESSION["hide_logout"]) { ?> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcLogout')"><?php echo __('Logout'); ?> </div> <?php } ?> </div>
function format_article_enclosures($id, $always_display_enclosures, $article_content, $hide_images = false) { $result = get_article_enclosures($id); $rv = ''; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) { $retval = $plugin->hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images); if (is_array($retval)) { $rv = $retval[0]; $result = $retval[1]; } else { $rv = $retval; } } if ($rv === '' && !empty($result)) { $entries_html = array(); $entries = array(); $entries_inline = array(); foreach ($result as $line) { $url = $line["content_url"]; $ctype = $line["content_type"]; $title = $line["title"]; $width = $line["width"]; $height = $line["height"]; if (!$ctype) { $ctype = __("unknown type"); } $filename = substr($url, strrpos($url, "/") + 1); $player = format_inline_player($url, $ctype); if ($player) { array_push($entries_inline, $player); } # $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" . # $filename . " (" . $ctype . ")" . "</a>"; $entry = "<div onclick=\"window.open('" . htmlspecialchars($url) . "')\"\n\t\t\t\t\tdojoType=\"dijit.MenuItem\">{$filename} ({$ctype})</div>"; array_push($entries_html, $entry); $entry = array(); $entry["type"] = $ctype; $entry["filename"] = $filename; $entry["url"] = $url; $entry["title"] = $title; $entry["width"] = $width; $entry["height"] = $height; array_push($entries, $entry); } if ($_SESSION['uid'] && !get_pref("STRIP_IMAGES") && !$_SESSION["bw_limit"]) { if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) { foreach ($entries as $entry) { if (preg_match("/image/", $entry["type"]) || preg_match("/\\.(jpg|png|gif|bmp)/i", $entry["filename"])) { if (!$hide_images) { $encsize = ''; if ($entry['height'] > 0) { $encsize .= ' height="' . intval($entry['width']) . '"'; } if ($entry['width'] > 0) { $encsize .= ' width="' . intval($entry['height']) . '"'; } $rv .= "<p><img\n\t\t\t\t\t\t\t\t\talt=\"" . htmlspecialchars($entry["filename"]) . "\"\n\t\t\t\t\t\t\t\t\tsrc=\"" . htmlspecialchars($entry["url"]) . "\"\n\t\t\t\t\t\t\t\t\t" . $encsize . " /></p>"; } else { $rv .= "<p><a target=\"_blank\"\n\t\t\t\t\t\t\t\t\thref=\"" . htmlspecialchars($entry["url"]) . "\"\n\t\t\t\t\t\t\t\t\t>" . htmlspecialchars($entry["url"]) . "</a></p>"; } if ($entry['title']) { $rv .= "<div class=\"enclosure_title\">{$entry['title']}</div>"; } } } } } if (count($entries_inline) > 0) { $rv .= "<hr clear='both'/>"; foreach ($entries_inline as $entry) { $rv .= $entry; } $rv .= "<hr clear='both'/>"; } $rv .= "<select class=\"attachments\" onchange=\"openSelectedAttachment(this)\">" . "<option value=''>" . __('Attachments') . "</option>"; foreach ($entries as $entry) { if ($entry["title"]) { $title = "— " . truncate_string($entry["title"], 30); } else { $title = ""; } $rv .= "<option value=\"" . htmlspecialchars($entry["url"]) . "\">" . htmlspecialchars($entry["filename"]) . "{$title}</option>"; } $rv .= "</select>"; } return $rv; }
function search() { $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2); $active_feed_id = sprintf("%d", $this->params[0]); $is_cat = $this->params[1] != "false"; print "<div class=\"dlgSec\">" . __('Look for') . "</div>"; print "<div class=\"dlgSecCont\">"; print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\tstyle=\"font-size : 16px; width : 20em;\"\n\t\t\trequired=\"1\" name=\"query\" type=\"search\" value=''>"; print "<hr/>" . __('Limit search to:') . " "; print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">\n\t\t\t<option value=\"all_feeds\">" . __('All feeds') . "</option>"; $feed_title = getFeedTitle($active_feed_id); if (!$is_cat) { $feed_cat_title = getFeedCatTitle($active_feed_id); } else { $feed_cat_title = getCategoryTitle($active_feed_id); } if ($active_feed_id && !$is_cat) { print "<option selected=\"1\" value=\"this_feed\">{$feed_title}</option>"; } else { print "<option disabled=\"1\" value=\"false\">" . __('This feed') . "</option>"; } if ($is_cat) { $cat_preselected = "selected=\"1\""; } if (get_pref('ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) { print "<option {$cat_preselected} value=\"this_cat\">{$feed_cat_title}</option>"; } else { //print "<option disabled>".__('This category')."</option>"; } print "</select>"; print "</div>"; print "<div class=\"dlgButtons\">"; if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) { print "<div style=\"float : left\">\n\t\t\t\t<a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">" . __("Search syntax") . "</a>\n\t\t\t\t</div>"; } print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">" . __('Search') . "</button>\n\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">" . __('Cancel') . "</button>\n\t\t</div>"; }
function init_plugins() { PluginHost::getInstance()->load(PLUGINS, PluginHost::KIND_ALL); return true; }
function clearplugindata() { $name = $this->dbh->escape_string($_REQUEST["name"]); PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name)); }
authenticate_user("admin", null); } if ($_SESSION["uid"]) { if (!validate_session()) { header("Content-Type: text/json"); print error_json(6); return; } load_user_plugins($_SESSION["uid"]); } $purge_intervals = array(0 => __("Use default"), -1 => __("Never purge"), 5 => __("1 week old"), 14 => __("2 weeks old"), 31 => __("1 month old"), 60 => __("2 months old"), 90 => __("3 months old")); $update_intervals = array(0 => __("Default interval"), -1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly")); $update_intervals_nodefault = array(-1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly")); $access_level_names = array(0 => __("User"), 5 => __("Power User"), 10 => __("Administrator")); $op = str_replace("-", "_", $op); $override = PluginHost::getInstance()->lookup_handler($op, $method); if (class_exists($op) || $override) { if ($override) { $handler = $override; } else { $handler = new $op($_REQUEST); } if ($handler && implements_interface($handler, 'IHandler')) { if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { if ($handler->before($method)) { if ($method && method_exists($handler, $method)) { $handler->{$method}(); } else { if (method_exists($handler, "catchall")) { $handler->catchall($method); }
function index() { global $access_level_names; print "<div id=\"pref-user-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">"; print "<div id=\"pref-user-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">"; print "<div id=\"pref-user-toolbar\" dojoType=\"dijit.Toolbar\">"; $user_search = $this->dbh->escape_string($_REQUEST["search"]); if (array_key_exists("search", $_REQUEST)) { $_SESSION["prefs_user_search"] = $user_search; } else { $user_search = $_SESSION["prefs_user_search"]; } print "<div style='float : right; padding-right : 4px;'>\n\t\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"user_search\" size=\"20\" type=\"search\"\n\t\t\t\t\tvalue=\"{$user_search}\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"updateUsersList()\">" . __('Search') . "</button>\n\t\t\t\t</div>"; $sort = $this->dbh->escape_string($_REQUEST["sort"]); if (!$sort || $sort == "undefined") { $sort = "login"; } print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>"; print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; print "<div onclick=\"selectTableRows('prefUserList', 'all')\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>"; print "<div onclick=\"selectTableRows('prefUserList', 'none')\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>"; print "</div></div>"; print "<button dojoType=\"dijit.form.Button\" onclick=\"addUser()\">" . __('Create user') . "</button>"; print "\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"selectedUserDetails()\">" . __('Details') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedUser()\">" . __('Edit') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedUsers()\">" . __('Remove') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"resetSelectedUserPass()\">" . __('Reset password') . "</button dojoType=\"dijit.form.Button\">"; PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefUsersToolbar"); print "</div>"; #toolbar print "</div>"; #pane print "<div id=\"pref-user-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">"; print "<div id=\"sticky-status-msg\"></div>"; if ($user_search) { $user_search = explode(" ", $user_search); $tokens = array(); foreach ($user_search as $token) { $token = trim($token); array_push($tokens, "(UPPER(login) LIKE UPPER('%{$token}%'))"); } $user_search_query = "(" . join($tokens, " AND ") . ") AND "; } else { $user_search_query = ""; } $result = $this->dbh->query("SELECT\n\t\t\t\t\tid,login,access_level,email,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_login,1,16) as last_login,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(created,1,16) as created\n\t\t\t\tFROM\n\t\t\t\t\tttrss_users\n\t\t\t\tWHERE\n\t\t\t\t\t{$user_search_query}\n\t\t\t\t\tid > 0\n\t\t\t\tORDER BY {$sort}"); if ($this->dbh->num_rows($result) > 0) { print "<p><table width=\"100%\" cellspacing=\"0\"\n\t\t\t\tclass=\"prefUserList\" id=\"prefUserList\">"; print "<tr class=\"title\">\n\t\t\t\t\t\t<td align='center' width=\"5%\"> </td>\n\t\t\t\t\t\t<td width='30%'><a href=\"#\" onclick=\"updateUsersList('login')\">" . __('Login') . "</a></td>\n\t\t\t\t\t\t<td width='30%'><a href=\"#\" onclick=\"updateUsersList('access_level')\">" . __('Access Level') . "</a></td>\n\t\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('created')\">" . __('Registered') . "</a></td>\n\t\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('last_login')\">" . __('Last login') . "</a></td></tr>"; $lnum = 0; while ($line = $this->dbh->fetch_assoc($result)) { $uid = $line["id"]; print "<tr id=\"UMRR-{$uid}\">"; $line["login"] = htmlspecialchars($line["login"]); $line["created"] = make_local_datetime($line["created"], false); $line["last_login"] = make_local_datetime($line["last_login"], false); print "<td align='center'><input onclick='toggleSelectRow2(this);'\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" type=\"checkbox\"\n\t\t\t\t\tid=\"UMCHK-{$uid}\"></td>"; $onclick = "onclick='editUser({$uid}, event)' title='" . __('Click to edit') . "'"; print "<td {$onclick}><img src='images/user.png' class='markedPic' alt=''> " . $line["login"] . "</td>"; if (!$line["email"]) { $line["email"] = " "; } print "<td {$onclick}>" . $access_level_names[$line["access_level"]] . "</td>"; print "<td {$onclick}>" . $line["created"] . "</td>"; print "<td {$onclick}>" . $line["last_login"] . "</td>"; print "</tr>"; ++$lnum; } print "</table>"; } else { print "<p>"; if (!$user_search) { print_warning(__('No users defined.')); } else { print_warning(__('No matching users found.')); } print "</p>"; } print "</div>"; #pane PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefUsers"); print "</div>"; #container }
function index() { $pluginhost = PluginHost::getInstance(); $json_conf = $pluginhost->get($this, 'json_conf'); $showInfoEnabled = $pluginhost->get($this, 'af_fullpost_showinfo'); if ($showInfoEnabled) { $fullPostChecked = "checked=\"1\""; } else { $fullPostChecked = ""; } print "<p>Comma-separated list or one address per lin of webaddresses, for which you don't would fetch the full post.<br>Example: site1.com, site2.org, site3.de</p>"; print "<form dojoType=\"dijit.form.Form\">"; print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tif (transport.responseText.indexOf('error')>=0) notify_error(transport.responseText);\n\t\t\t\t\t\telse notify_info(transport.responseText);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t//this.reset();\n\t\t\t}\n\t\t\t</script>"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"af_fullpost\">"; print "<table width='100%'><tr><td>"; print "Show processed by Readability info on article bottom: <input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"af_fullpost_showinfo\" id=\"af_fullpost_showinfo\" {$fullPostChecked}>"; print "</tr></td>"; print "<tr><td>"; print "<textarea dojoType=\"dijit.form.SimpleTextarea\" name=\"json_conf\" style=\"font-size: 12px; width: 99%; height: 500px;\">{$json_conf}</textarea>"; print "</td></tr></table>"; print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save") . "</button>"; print "</form>"; }
function init_connection($link) { if ($link) { if (DB_TYPE == "pgsql") { pg_query($link, "set client_encoding = 'UTF-8'"); pg_set_client_encoding("UNICODE"); pg_query($link, "set datestyle = 'ISO, european'"); pg_query($link, "set TIME ZONE 0"); } else { db_query($link, "SET time_zone = '+0:0'"); if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { db_query($link, "SET NAMES " . MYSQL_CHARSET); } } global $pluginhost; $pluginhost = new PluginHost($link); $pluginhost->load(PLUGINS, $pluginhost::KIND_ALL); return true; } else { print "Unable to connect to database:" . db_last_error(); return false; } }
function index() { $sort = $this->dbh->escape_string($_REQUEST["sort"]); if (!$sort || $sort == "undefined") { $sort = "reg_exp"; } $filter_search = $this->dbh->escape_string($_REQUEST["search"]); if (array_key_exists("search", $_REQUEST)) { $_SESSION["prefs_filter_search"] = $filter_search; } else { $filter_search = $_SESSION["prefs_filter_search"]; } print "<div id=\"pref-filter-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">"; print "<div id=\"pref-filter-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">"; print "<div id=\"pref-filter-toolbar\" dojoType=\"dijit.Toolbar\">"; $filter_search = $this->dbh->escape_string($_REQUEST["search"]); if (array_key_exists("search", $_REQUEST)) { $_SESSION["prefs_filter_search"] = $filter_search; } else { $filter_search = $_SESSION["prefs_filter_search"]; } print "<div style='float : right; padding-right : 4px;'>\n\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"filter_search\" size=\"20\" type=\"search\"\n\t\t\t\tvalue=\"{$filter_search}\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"updateFilterList()\">" . __('Search') . "</button>\n\t\t\t</div>"; print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>"; print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>"; print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>"; print "</div></div>"; print "<button dojoType=\"dijit.form.Button\" onclick=\"return quickAddFilter()\">" . __('Create filter') . "</button> "; print "<button dojoType=\"dijit.form.Button\" onclick=\"return joinSelectedFilters()\">" . __('Combine') . "</button> "; print "<button dojoType=\"dijit.form.Button\" onclick=\"return editSelectedFilter()\">" . __('Edit') . "</button> "; print "<button dojoType=\"dijit.form.Button\" onclick=\"return resetFilterOrder()\">" . __('Reset sort order') . "</button> "; print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">" . __('Remove') . "</button> "; if (defined('_ENABLE_FEED_DEBUGGING')) { print "<button dojoType=\"dijit.form.Button\" onclick=\"rescore_all_feeds()\">" . __('Rescore articles') . "</button> "; } print "</div>"; # toolbar print "</div>"; # toolbar-frame print "<div id=\"pref-filter-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">"; print "<div id=\"filterlistLoading\">\n\t\t<img src='images/indicator_tiny.gif'>" . __("Loading, please wait...") . "</div>"; print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\"\n\t\t\turl=\"backend.php?op=pref-filters&method=getfiltertree\">\n\t\t</div>\n\t\t<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\"\n\t\t\tquery=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Filters\"\n\t\t\tchildrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">\n\t\t</div>\n\t\t<div dojoType=\"fox.PrefFilterTree\" id=\"filterTree\"\n\t\t\tdndController=\"dijit.tree.dndSource\"\n\t\t\tbetweenThreshold=\"5\"\n\t\t\tmodel=\"filterModel\" openOnClick=\"true\">\n\t\t<script type=\"dojo/method\" event=\"onLoad\" args=\"item\">\n\t\t\tElement.hide(\"filterlistLoading\");\n\t\t</script>\n\t\t<script type=\"dojo/method\" event=\"onClick\" args=\"item\">\n\t\t\tvar id = String(item.id);\n\t\t\tvar bare_id = id.substr(id.indexOf(':')+1);\n\n\t\t\tif (id.match('FILTER:')) {\n\t\t\t\teditFilter(bare_id);\n\t\t\t}\n\t\t</script>\n\n\t\t</div>"; print "</div>"; #pane PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefFilters"); print "</div>"; #container }
function index() { global $access_level_names; $prefs_blacklist = array("HIDE_READ_FEEDS", "FEEDS_SORT_BY_UNREAD", "STRIP_UNSAFE_TAGS"); $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME"); $_SESSION["prefs_op_result"] = ""; print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Personal data / Authentication') . "\">"; print "<form dojoType=\"dijit.form.Form\" id=\"changeUserdataForm\">"; print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tnotify_callback2(transport);\n\t\t\t} });\n\n\t\t}\n\t\t</script>"; print "<table width=\"100%\" class=\"prefPrefsList\">"; print "<h2>" . __("Personal data") . "</h2>"; $result = db_query($this->link, "SELECT email,full_name,otp_enabled,\n\t\t\taccess_level FROM ttrss_users\n\t\t\tWHERE id = " . $_SESSION["uid"]); $email = htmlspecialchars(db_fetch_result($result, 0, "email")); $full_name = htmlspecialchars(db_fetch_result($result, 0, "full_name")); $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled")); print "<tr><td width=\"40%\">" . __('Full name') . "</td>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\"\n\t\t\tvalue=\"{$full_name}\"></td></tr>"; print "<tr><td width=\"40%\">" . __('E-mail') . "</td>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"email\" required=\"1\" value=\"{$email}\"></td></tr>"; if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) { $access_level = db_fetch_result($result, 0, "access_level"); print "<tr><td width=\"40%\">" . __('Access level') . "</td>"; print "<td>" . $access_level_names[$access_level] . "</td></tr>"; } print "</table>"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">"; print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save data") . "</button>"; print "</form>"; if ($_SESSION["auth_module"]) { global $pluginhost; $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); } else { $authenticator = false; } if ($authenticator && method_exists($authenticator, "change_password")) { print "<h2>" . __("Password") . "</h2>"; $result = db_query($this->link, "SELECT id FROM ttrss_users\n\t\t\t\tWHERE id = " . $_SESSION["uid"] . " AND pwd_hash\n\t\t\t\t= 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'"); if (db_num_rows($result) != 0) { print format_warning(__("Your password is at default value, please change it."), "default_pass_warning"); } print "<form dojoType=\"dijit.form.Form\">"; print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tnotify_progress('Changing password...', true);\n\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnotify_info(transport.responseText);\n\t\t\t\t\t\t\tvar warn = \$('default_pass_warning');\n\t\t\t\t\t\t\tif (warn) Element.hide(warn);\n\t\t\t\t\t\t}\n\t\t\t\t}});\n\t\t\t\tthis.reset();\n\t\t\t}\n\t\t\t</script>"; if ($otp_enabled) { print_notice("Changing your current password will disable OTP."); } print "<table width=\"100%\" class=\"prefPrefsList\">"; print "<tr><td width=\"40%\">" . __("Old password") . "</td>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"old_password\"></td></tr>"; print "<tr><td width=\"40%\">" . __("New password") . "</td>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\tname=\"new_password\"></td></tr>"; print "<tr><td width=\"40%\">" . __("Confirm password") . "</td>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"confirm_password\"></td></tr>"; print "</table>"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">"; print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Change password") . "</button>"; print "</form>"; if ($_SESSION["auth_module"] == "auth_internal") { print "<h2>" . __("One time passwords / Authenticator") . "</h2>"; if ($otp_enabled) { print_notice("One time passwords are currently enabled. Enter your current password below to disable."); print "<form dojoType=\"dijit.form.Form\">"; print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\t\tevt.preventDefault();\n\t\t\t\tif (this.validate()) {\n\t\t\t\t\tnotify_progress('Disabling OTP', true);\n\n\t\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}});\n\t\t\t\t\tthis.reset();\n\t\t\t\t}\n\t\t\t\t</script>"; print "<table width=\"100%\" class=\"prefPrefsList\">"; print "<tr><td width=\"40%\">" . __("Enter your password") . "</td>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\t\tname=\"password\"></td></tr>"; print "</table>"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpdisable\">"; print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Disable OTP") . "</button>"; print "</form>"; } else { print "<p>" . __("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP.") . "</p>"; print "<p>" . __("Scan the following code by the Authenticator application:") . "</p>"; $csrf_token = $_SESSION["csrf_token"]; print "<img src=\"backend.php?op=pref-prefs&method=otpqrcode&csrf_token={$csrf_token}\">"; print "<form dojoType=\"dijit.form.Form\" id=\"changeOtpForm\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpenable\">"; print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\tif (this.validate()) {\n\t\t\t\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} });\n\n\t\t\t\t\t}\n\t\t\t\t\t</script>"; print "<table width=\"100%\" class=\"prefPrefsList\">"; print "<tr><td width=\"40%\">" . __("Enter your password") . "</td>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\t\t\tname=\"password\"></td></tr>"; print "<tr><td colspan=\"2\">"; print "<input dojoType=\"dijit.form.CheckBox\" required=\"1\"\n\t\t\t\t\t\ttype=\"checkbox\" id=\"enable_otp\" name=\"enable_otp\"/> "; print "<label for=\"enable_otp\">" . __("I have scanned the code and would like to enable OTP") . "</label>"; print "</td></tr><tr><td colspan=\"2\">"; print "</td></tr>"; print "</table>"; print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Enable OTP") . "</button>"; print "</form>"; } } } global $pluginhost; $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsAuth"); print "</div>"; #pane print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"" . __('Preferences') . "\">"; print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">"; print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tconsole.log(dojo.objectToQuery(this.getValues()));\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tvar msg = transport.responseText;\n\t\t\t\t\tif (msg.match('PREFS_THEME_CHANGED')) {\n\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnotify_info(msg);\n\t\t\t\t\t}\n\t\t\t} });\n\t\t}\n\t\t</script>"; print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">'; if ($_SESSION["profile"]) { print_notice("Some preferences are only available in default profile."); } if ($_SESSION["profile"]) { initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]); $profile_qpart = "profile = '" . $_SESSION["profile"] . "'"; } else { initialize_user_prefs($this->link, $_SESSION["uid"]); $profile_qpart = "profile IS NULL"; } if ($_SESSION["prefs_show_advanced"]) { $access_query = "true"; } else { $access_query = "(access_level = 0 AND section_id != 3)"; } $result = db_query($this->link, "SELECT DISTINCT\n\t\t\tttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,\n\t\t\tttrss_prefs_sections.order_id,\n\t\t\tsection_name,def_value,section_id\n\t\t\tFROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs\n\t\t\tWHERE type_id = ttrss_prefs_types.id AND\n\t\t\t\t{$profile_qpart} AND\n\t\t\t\tsection_id = ttrss_prefs_sections.id AND\n\t\t\t\tttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND\n\t\t\t\t{$access_query} AND\n\t\t\t\tshort_desc != '' AND\n\t\t\t\towner_uid = " . $_SESSION["uid"] . "\n\t\t\tORDER BY ttrss_prefs_sections.order_id,short_desc"); $lnum = 0; $active_section = ""; while ($line = db_fetch_assoc($result)) { if (in_array($line["pref_name"], $prefs_blacklist)) { continue; } if ($_SESSION["profile"] && in_array($line["pref_name"], $profile_blacklist)) { continue; } if ($active_section != $line["section_name"]) { if ($active_section != "") { print "</table>"; } print "<table width=\"100%\" class=\"prefPrefsList\">"; $active_section = $line["section_name"]; print "<tr><td colspan=\"3\"><h3>" . __($active_section) . "</h3></td></tr>"; $lnum = 0; } print "<tr>"; $type_name = $line["type_name"]; $pref_name = $line["pref_name"]; $value = $line["value"]; $def_value = $line["def_value"]; $help_text = $line["help_text"]; print "<td width=\"40%\" class=\"prefName\" id=\"{$pref_name}\">" . __($line["short_desc"]); if ($help_text) { print "<div class=\"prefHelp\">" . __($help_text) . "</div>"; } print "</td>"; print "<td class=\"prefValue\">"; if ($pref_name == "USER_TIMEZONE") { $timezones = explode("\n", file_get_contents("lib/timezones.txt")); print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); } else { if ($pref_name == "USER_STYLESHEET") { print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"customizeCSS()\">" . __('Customize') . "</button>"; } else { if ($pref_name == "DEFAULT_ARTICLE_LIMIT") { $limits = array(15, 30, 45, 60); print_select($pref_name, $value, $limits, 'dojoType="dijit.form.Select"'); } else { if ($pref_name == "DEFAULT_UPDATE_INTERVAL") { global $update_intervals_nodefault; print_select_hash($pref_name, $value, $update_intervals_nodefault, 'dojoType="dijit.form.Select"'); } else { if ($type_name == "bool") { if ($value == "true") { $value = __("Yes"); } else { $value = __("No"); } if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { $disabled = "disabled=\"1\""; $value = __("Yes"); } else { $disabled = ""; } print_radio($pref_name, $value, __("Yes"), array(__("Yes"), __("No")), $disabled); } else { if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'DEFAULT_ARTICLE_LIMIT', 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) { $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : ''; if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { $disabled = "disabled=\"1\""; $value = FORCE_ARTICLE_PURGE; } else { $disabled = ""; } print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\trequired=\"1\" {$regexp} {$disabled}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">"; } else { if ($pref_name == "SSL_CERT_SERIAL") { print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"SSL_CERT_SERIAL\" readonly=\"1\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">"; $cert_serial = htmlspecialchars(get_ssl_certificate_id()); $has_serial = $cert_serial ? "false" : "true"; print " <button dojoType=\"dijit.form.Button\" disabled=\"{$has_serial}\"\n\t\t\t\t\tonclick=\"insertSSLserial('{$cert_serial}')\">" . __('Register') . "</button>"; print " <button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"insertSSLserial('')\">" . __('Clear') . "</button>"; } else { if ($pref_name == 'DIGEST_PREFERRED_TIME') { print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"{$pref_name}\" regexp=\"[012]?\\d:\\d\\d\" placeHolder=\"12:00\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\"><div class=\"insensitive\">" . T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>"; } else { $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : ''; print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\t{$regexp}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">"; } } } } } } } } print "</td>"; print "</tr>"; $lnum++; } print "</table>"; global $pluginhost; $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsInside"); print '</div>'; # inside pane print '<div dojoType="dijit.layout.ContentPane" region="bottom">'; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">"; print "<button dojoType=\"dijit.form.Button\" type=\"submit\">" . __('Save configuration') . "</button> "; print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">" . __('Manage profiles') . "</button> "; print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">" . __('Reset to defaults') . "</button>"; print " "; $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : ""; print "<input onclick='toggleAdvancedPrefs()'\n\t\t\t\tid='prefs_show_advanced'\n\t\t\t\tdojoType=\"dijit.form.CheckBox\"\n\t\t\t\t{$checked}\n\t\t\t\ttype=\"checkbox\"></input>\n\t\t\t\t<label for='prefs_show_advanced'>" . __("Show additional preferences") . "</label>"; global $pluginhost; $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsOutside"); print "</form>"; print '</div>'; # inner pane print '</div>'; # border container print "</div>"; #pane print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Plugins') . "\">"; print "<h2>" . __("Plugins") . "</h2>"; print_notice("You will need to reload Tiny Tiny RSS for plugin changes to take effect."); print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">"; print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tnotify('');\n\t\t\t\t\tif (confirm(__('Selected plugins have been enabled. Reload?'))) {\n\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t}\n\t\t\t} });\n\n\t\t}\n\t\t</script>"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setplugins\">"; print "<table width='100%' class='prefPluginsList'>"; print "<tr><td colspan='4'><h3>" . __("System plugins") . "</h3></td></tr>"; print "<tr class=\"title\">\n\t\t\t\t<td width=\"5%\"> </td>\n\t\t\t\t<td width='10%'>" . __('Plugin') . "</td>\n\t\t\t\t<td width=''>" . __('Description') . "</td>\n\t\t\t\t<td width='5%'>" . __('Version') . "</td>\n\t\t\t\t<td width='10%'>" . __('Author') . "</td></tr>"; $system_enabled = array_map("trim", explode(",", PLUGINS)); $user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS"))); $tmppluginhost = new PluginHost($this->link); $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]); $tmppluginhost->load_data(true); foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); if ($about[3] && strpos($name, "example") === FALSE) { if (in_array($name, $system_enabled)) { $checked = "checked='1'"; } else { $checked = ""; } print "<tr>"; print "<td align='center'><input disabled='1'\n\t\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" {$checked}\n\t\t\t\t\t\ttype=\"checkbox\"></td>"; print "<td>{$name}</td>"; print "<td>" . htmlspecialchars($about[1]) . "</td>"; print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>"; print "<td>" . htmlspecialchars($about[2]) . "</td>"; if (count($tmppluginhost->get_all($plugin)) > 0) { if (in_array($name, $system_enabled)) { print "<td><a href='#' onclick=\"clearPluginData('{$name}')\"\n\t\t\t\t\t\t\tclass='visibleLink'>" . __("Clear data") . "</a></td>"; } } print "</tr>"; } } print "<tr><td colspan='4'><h3>" . __("User plugins") . "</h3></td></tr>"; print "<tr class=\"title\">\n\t\t\t\t<td width=\"5%\"> </td>\n\t\t\t\t<td width='10%'>" . __('Plugin') . "</td>\n\t\t\t\t<td width=''>" . __('Description') . "</td>\n\t\t\t\t<td width='5%'>" . __('Version') . "</td>\n\t\t\t\t<td width='10%'>" . __('Author') . "</td></tr>"; foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); if (!$about[3] && strpos($name, "example") === FALSE) { if (in_array($name, $system_enabled)) { $checked = "checked='1'"; $disabled = "disabled='1'"; $rowclass = ''; } else { if (in_array($name, $user_enabled)) { $checked = "checked='1'"; $disabled = ""; $rowclass = "Selected"; } else { $checked = ""; $disabled = ""; $rowclass = ''; } } print "<tr class='{$rowclass}'>"; print "<td align='center'><input id='FPCHK-{$name}' name='plugins[]' value='{$name}' onclick='toggleSelectRow2(this);'\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" {$checked} {$disabled}\n\t\t\t\t\ttype=\"checkbox\"></td>"; print "<td><label for='FPCHK-{$name}'>{$name}</label></td>"; print "<td><label for='FPCHK-{$name}'>" . htmlspecialchars($about[1]) . "</label></td>"; print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>"; print "<td>" . htmlspecialchars($about[2]) . "</td>"; if (count($tmppluginhost->get_all($plugin)) > 0) { if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { print "<td><a href='#' onclick=\"clearPluginData('{$name}')\" class='visibleLink'>" . __("Clear data") . "</a></td>"; } } print "</tr>"; } } print "</table>"; print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Enable selected plugins") . "</button></p>"; print "</form>"; print "</div>"; #pane global $pluginhost; $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefPrefs"); print "</div>"; #container }
function globalUpdateFeeds() { RPC::updaterandomfeed_real($this->dbh); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false); }
function update_rss_feed($feed, $ignore_daemon = false, $no_cache = false) { $debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']; _debug("start", $debug_enabled); $result = db_query("SELECT id,update_interval,auth_login,\n\t\t\tfeed_url,auth_pass,cache_images,last_updated,\n\t\t\tmark_unread_on_update, owner_uid,\n\t\t\tpubsub_state, auth_pass_encrypted,\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_updated = db_fetch_result($result, 0, "last_updated"); $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 = 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(); $rss = false; $rss_hash = false; $force_refetch = isset($_REQUEST["force_refetch"]); if (file_exists($cache_filename) && is_readable($cache_filename) && !$auth_login && !$auth_pass && filemtime($cache_filename) > time() - 30) { _debug("using local cache.", $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); } if (!$rss) { foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) { $feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed); } 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); /* if ($feed_data) { $error = verify_feed_xml($feed_data); if ($error) { _debug("error verifying XML, code: " . $error->code, $debug_enabled); if ($error->code == 26) { _debug("got error 26, trying to decode entities...", $debug_enabled); $feed_data = html_entity_decode($feed_data, ENT_COMPAT, 'UTF-8'); $error = verify_feed_xml($feed_data); if ($error) $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); } db_query("UPDATE ttrss_feeds SET last_error = '{$error_escaped}',\n\t\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'"); return; } } foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) { $feed_data = $plugin->hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed); } // set last update to now so if anything *simplepie* crashes later we won't be // continuously failing on the same feed //db_query("UPDATE ttrss_feeds SET last_updated = NOW() WHERE id = '$feed'"); if (!$rss) { $rss = new FeedParser($feed_data); $rss->init(); } // print_r($rss); $feed = db_escape_string($feed); if (!$rss->error()) { // cache data for later if (!$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/simplepie")) { $new_rss_hash = sha1($rss_data); if ($new_rss_hash != $rss_hash && count($rss->get_items()) > 0) { _debug("saving {$cache_filename}", $debug_enabled); @file_put_contents($cache_filename, $feed_data); } } // We use local pluginhost here because we need to load different per-user feed plugins $pluginhost->run_hooks(PluginHost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss); _debug("processing feed data...", $debug_enabled); // db_query("BEGIN"); if (DB_TYPE == "pgsql") { $favicon_interval_qpart = "favicon_last_checked < NOW() - INTERVAL '12 hour'"; } else { $favicon_interval_qpart = "favicon_last_checked < DATE_SUB(NOW(), INTERVAL 12 HOUR)"; } $result = db_query("SELECT title,site_url,owner_uid,favicon_avg_color,\n\t\t\t\t(favicon_last_checked IS NULL OR {$favicon_interval_qpart}) AS\n\t\t\t\t\t\tfavicon_needs_check\n\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'"); $registered_title = db_fetch_result($result, 0, "title"); $orig_site_url = db_fetch_result($result, 0, "site_url"); $favicon_needs_check = sql_bool_to_bool(db_fetch_result($result, 0, "favicon_needs_check")); $favicon_avg_color = db_fetch_result($result, 0, "favicon_avg_color"); $owner_uid = db_fetch_result($result, 0, "owner_uid"); $site_url = db_escape_string(mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245)); _debug("site_url: {$site_url}", $debug_enabled); _debug("feed_title: " . $rss->get_title(), $debug_enabled); if ($favicon_needs_check || $force_refetch) { /* terrible hack: if we crash on floicon shit here, we won't check * the icon avgcolor again (unless the icon got updated) */ $favicon_file = ICONS_DIR . "/{$feed}.ico"; $favicon_modified = @filemtime($favicon_file); _debug("checking favicon...", $debug_enabled); check_feed_favicon($site_url, $feed); $favicon_modified_new = @filemtime($favicon_file); if ($favicon_modified_new > $favicon_modified) { $favicon_avg_color = ''; } if (file_exists($favicon_file) && function_exists("imagecreatefromstring") && $favicon_avg_color == '') { require_once "colors.php"; db_query("UPDATE ttrss_feeds SET favicon_avg_color = 'fail' WHERE\n\t\t\t\t\t\t\tid = '{$feed}'"); $favicon_color = db_escape_string(calculate_avg_color($favicon_file)); $favicon_colorstring = ",favicon_avg_color = '" . $favicon_color . "'"; } else { if ($favicon_avg_color == 'fail') { _debug("floicon failed on this file, not trying to recalculate avg color", $debug_enabled); } } db_query("UPDATE ttrss_feeds SET favicon_last_checked = NOW()\n\t\t\t\t\t{$favicon_colorstring}\n\t\t\t\t\tWHERE id = '{$feed}'"); } if (!$registered_title || $registered_title == "[Unknown]") { $feed_title = db_escape_string($rss->get_title()); if ($feed_title) { _debug("registering title: {$feed_title}", $debug_enabled); db_query("UPDATE ttrss_feeds SET\n\t\t\t\t\t\ttitle = '{$feed_title}' WHERE id = '{$feed}'"); } } if ($site_url && $orig_site_url != $site_url) { db_query("UPDATE ttrss_feeds SET\n\t\t\t\t\tsite_url = '{$site_url}' WHERE id = '{$feed}'"); } _debug("loading filters & labels...", $debug_enabled); $filters = load_filters($feed, $owner_uid); $labels = get_all_labels($owner_uid); _debug("" . count($filters) . " filters loaded.", $debug_enabled); $items = $rss->get_items(); if (!is_array($items)) { _debug("no articles found.", $debug_enabled); db_query("UPDATE ttrss_feeds\n\t\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'"); return; // no articles } if ($pubsub_state != 2 && PUBSUBHUBBUB_ENABLED) { _debug("checking for PUSH hub...", $debug_enabled); $feed_hub_url = false; $links = $rss->get_links('hub'); if ($links && is_array($links)) { foreach ($links as $l) { $feed_hub_url = $l; break; } } _debug("feed hub url: {$feed_hub_url}", $debug_enabled); if ($feed_hub_url && function_exists('curl_init') && !ini_get("open_basedir")) { require_once 'lib/pubsubhubbub/subscriber.php'; $callback_url = get_self_url_prefix() . "/public.php?op=pubsub&id={$feed}"; $s = new Subscriber($feed_hub_url, $callback_url); $rc = $s->subscribe($fetch_url); _debug("feed hub url found, subscribe request sent.", $debug_enabled); db_query("UPDATE ttrss_feeds SET pubsub_state = 1\n\t\t\t\t\t\tWHERE id = '{$feed}'"); } } _debug("processing articles...", $debug_enabled); foreach ($items as $item) { if ($_REQUEST['xdebug'] == 3) { print_r($item); } $entry_guid = $item->get_id(); if (!$entry_guid) { $entry_guid = $item->get_link(); } if (!$entry_guid) { $entry_guid = make_guid_from_title($item->get_title()); } _debug("f_guid {$entry_guid}", $debug_enabled); if (!$entry_guid) { continue; } $entry_guid = "{$owner_uid},{$entry_guid}"; $entry_guid_hashed = db_escape_string('SHA1:' . sha1($entry_guid)); _debug("guid {$entry_guid} / {$entry_guid_hashed}", $debug_enabled); $entry_timestamp = ""; $entry_timestamp = $item->get_date(); _debug("orig date: " . $item->get_date(), $debug_enabled); if ($entry_timestamp == -1 || !$entry_timestamp || $entry_timestamp > time()) { $entry_timestamp = time(); $no_orig_date = 'true'; } else { $no_orig_date = 'false'; } $entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp); _debug("date {$entry_timestamp} [{$entry_timestamp_fmt}]", $debug_enabled); // $entry_title = html_entity_decode($item->get_title(), ENT_COMPAT, 'UTF-8'); // $entry_title = decode_numeric_entities($entry_title); $entry_title = $item->get_title(); $entry_link = rewrite_relative_url($site_url, $item->get_link()); _debug("title {$entry_title}", $debug_enabled); _debug("link {$entry_link}", $debug_enabled); if (!$entry_title) { $entry_title = date("Y-m-d H:i:s", $entry_timestamp); } $entry_content = $item->get_content(); if (!$entry_content) { $entry_content = $item->get_description(); } if ($_REQUEST["xdebug"] == 2) { print "content: "; print $entry_content; print "\n"; } $entry_comments = $item->get_comments_url(); $entry_author = $item->get_author(); $entry_guid = db_escape_string(mb_substr($entry_guid, 0, 245)); $entry_comments = db_escape_string(mb_substr(trim($entry_comments), 0, 245)); $entry_author = db_escape_string(mb_substr(trim($entry_author), 0, 245)); $num_comments = (int) $item->get_comments_count(); _debug("author {$entry_author}", $debug_enabled); _debug("num_comments: {$num_comments}", $debug_enabled); _debug("looking for tags...", $debug_enabled); // parse <category> entries into tags $additional_tags = array(); $additional_tags_src = $item->get_categories(); if (is_array($additional_tags_src)) { foreach ($additional_tags_src as $tobj) { array_push($additional_tags, $tobj); } } $entry_tags = array_unique($additional_tags); for ($i = 0; $i < count($entry_tags); $i++) { $entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8'); } _debug("tags found: " . join(",", $entry_tags), $debug_enabled); _debug("done collecting data.", $debug_enabled); // TODO: less memory-hungry implementation _debug("applying plugin filters..", $debug_enabled); // FIXME not sure if owner_uid is a good idea here, we may have a base entry without user entry (?) $result = db_query("SELECT plugin_data,title,content,link,tag_cache,author FROM ttrss_entries, ttrss_user_entries\n\t\t\t\t\tWHERE ref_id = id AND (guid = '" . db_escape_string($entry_guid) . "' OR guid = '{$entry_guid_hashed}') AND owner_uid = {$owner_uid}"); if (db_num_rows($result) != 0) { $entry_plugin_data = db_fetch_result($result, 0, "plugin_data"); $stored_article = array("title" => db_fetch_result($result, 0, "title"), "content" => db_fetch_result($result, 0, "content"), "link" => db_fetch_result($result, 0, "link"), "tags" => explode(",", db_fetch_result($result, 0, "tag_cache")), "author" => db_fetch_result($result, 0, "author")); } else { $entry_plugin_data = ""; $stored_article = array(); } $article = array("owner_uid" => $owner_uid, "guid" => $entry_guid, "title" => $entry_title, "content" => $entry_content, "link" => $entry_link, "tags" => $entry_tags, "plugin_data" => $entry_plugin_data, "author" => $entry_author, "stored" => $stored_article); foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) { $article = $plugin->hook_article_filter($article); } $entry_tags = $article["tags"]; $entry_guid = db_escape_string($entry_guid); $entry_title = db_escape_string($article["title"]); $entry_author = db_escape_string($article["author"]); $entry_link = db_escape_string($article["link"]); $entry_plugin_data = db_escape_string($article["plugin_data"]); $entry_content = $article["content"]; // escaped below _debug("plugin data: {$entry_plugin_data}", $debug_enabled); if ($cache_images && is_writable(CACHE_DIR . '/images')) { cache_images($entry_content, $site_url, $debug_enabled); } $entry_content = db_escape_string($entry_content, false); $content_hash = "SHA1:" . sha1($entry_content); db_query("BEGIN"); $result = db_query("SELECT id FROM\tttrss_entries\n\t\t\t\t\tWHERE (guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}')"); if (db_num_rows($result) == 0) { _debug("base guid [{$entry_guid}] not found", $debug_enabled); // base post entry does not exist, create it $result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tplugin_data,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid_hashed}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t{$no_orig_date},\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$date_feed_processed}',\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_plugin_data}',\n\t\t\t\t\t\t\t'{$entry_author}')"); $article_labels = array(); } else { // we keep encountering the entry in feeds, so we need to // update date_updated column so that we don't get horrible // dupes when the entry gets purged and reinserted again e.g. // in the case of SLOW SLOW OMG SLOW updating feeds $base_entry_id = db_fetch_result($result, 0, "id"); db_query("UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'"); $article_labels = get_article_labels($base_entry_id, $owner_uid); } // now it should exist, if not - bad luck then $result = db_query("SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,plugin_data,guid,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}'"); $entry_ref_id = 0; $entry_int_id = 0; if (db_num_rows($result) == 1) { _debug("base guid found, checking for user record", $debug_enabled); // this will be used below in update handler $orig_content_hash = db_fetch_result($result, 0, "content_hash"); $orig_title = db_fetch_result($result, 0, "title"); $orig_num_comments = db_fetch_result($result, 0, "num_comments"); $orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated")); $orig_plugin_data = db_fetch_result($result, 0, "plugin_data"); $ref_id = db_fetch_result($result, 0, "id"); $entry_ref_id = $ref_id; /* $stored_guid = db_fetch_result($result, 0, "guid"); if ($stored_guid != $entry_guid_hashed) { if ($debug_enabled) _debug("upgrading compat guid to hashed one", $debug_enabled); db_query("UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE id = '$ref_id'"); } */ // check for user post link to main table // do we allow duplicate posts with same GUID in different feeds? if (get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) { $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)"; } else { $dupcheck_qpart = ""; } /* Collect article tags here so we could filter by them: */ $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags); if ($debug_enabled) { _debug("article filters: ", $debug_enabled); if (count($article_filters) != 0) { print_r($article_filters); } } if (find_article_filter($article_filters, "filter")) { db_query("COMMIT"); // close transaction in progress continue; } $score = calculate_article_score($article_filters); _debug("initial score: {$score}", $debug_enabled); $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}"; // if ($_REQUEST["xdebug"]) print "$query\n"; $result = db_query($query); // okay it doesn't exist - create user entry if (db_num_rows($result) == 0) { _debug("user record not found, creating...", $debug_enabled); if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) { $unread = 'true'; $last_read_qpart = 'NULL'; } else { $unread = 'false'; $last_read_qpart = 'NOW()'; } if (find_article_filter($article_filters, 'mark') || $score > 1000) { $marked = 'true'; } else { $marked = 'false'; } if (find_article_filter($article_filters, 'publish')) { $published = 'true'; } else { $published = 'false'; } // N-grams if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) { $result = db_query("SELECT COUNT(*) AS similar FROM\n\t\t\t\t\t\t\t\t\tttrss_entries,ttrss_user_entries\n\t\t\t\t\t\t\t\tWHERE ref_id = id AND updated >= NOW() - INTERVAL '7 day'\n\t\t\t\t\t\t\t\t\tAND similarity(title, '{$entry_title}') >= " . _NGRAM_TITLE_DUPLICATE_THRESHOLD . "\n\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid}"); $ngram_similar = db_fetch_result($result, 0, "similar"); _debug("N-gram similar results: {$ngram_similar}", $debug_enabled); if ($ngram_similar > 0) { $unread = 'false'; } } $last_marked = $marked == 'true' ? 'NOW()' : 'NULL'; $last_published = $published == 'true' ? 'NOW()' : 'NULL'; $result = db_query("INSERT INTO ttrss_user_entries\n\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\tpublished, score, tag_cache, label_cache, uuid,\n\t\t\t\t\t\t\t\tlast_marked, last_published)\n\t\t\t\t\t\t\tVALUES ('{$ref_id}', '{$owner_uid}', '{$feed}', {$unread},\n\t\t\t\t\t\t\t\t{$last_read_qpart}, {$marked}, {$published}, '{$score}', '', '',\n\t\t\t\t\t\t\t\t'', {$last_marked}, {$last_published})"); if (PUBSUBHUBBUB_HUB && $published == 'true') { $rss_link = get_self_url_prefix() . "/public.php?op=rss&id=-2&key=" . get_feed_access_key(-2, false, $owner_uid); $p = new Publisher(PUBSUBHUBBUB_HUB); $pubsub_result = $p->publish_update($rss_link); } $result = db_query("SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' AND\n\t\t\t\t\t\t\t\tfeed_id = '{$feed}' LIMIT 1"); if (db_num_rows($result) == 1) { $entry_int_id = db_fetch_result($result, 0, "int_id"); } } else { _debug("user record FOUND", $debug_enabled); $entry_ref_id = db_fetch_result($result, 0, "ref_id"); $entry_int_id = db_fetch_result($result, 0, "int_id"); } _debug("RID: {$entry_ref_id}, IID: {$entry_int_id}", $debug_enabled); $post_needs_update = false; $update_insignificant = false; if ($orig_num_comments != $num_comments) { $post_needs_update = true; $update_insignificant = true; } if ($entry_plugin_data != $orig_plugin_data) { $post_needs_update = true; $update_insignificant = true; } if ($content_hash != $orig_content_hash) { $post_needs_update = true; $update_insignificant = false; } if (db_escape_string($orig_title) != $entry_title) { $post_needs_update = true; $update_insignificant = false; } // if post needs update, update it and mark all user entries // linking to this post as updated if ($post_needs_update) { if (defined('DAEMON_EXTENDED_DEBUG')) { _debug("post {$entry_guid_hashed} needs update...", $debug_enabled); } // print "<!-- post $orig_title needs update : $post_needs_update -->"; db_query("UPDATE ttrss_entries\n\t\t\t\t\t\t\tSET title = '{$entry_title}', content = '{$entry_content}',\n\t\t\t\t\t\t\t\tcontent_hash = '{$content_hash}',\n\t\t\t\t\t\t\t\tupdated = '{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t\tnum_comments = '{$num_comments}',\n\t\t\t\t\t\t\t\tplugin_data = '{$entry_plugin_data}'\n\t\t\t\t\t\t\tWHERE id = '{$ref_id}'"); if (!$update_insignificant) { if ($mark_unread_on_update) { db_query("UPDATE ttrss_user_entries\n\t\t\t\t\t\t\t\t\tSET last_read = null, unread = true WHERE ref_id = '{$ref_id}'"); } } } } db_query("COMMIT"); _debug("assigning labels...", $debug_enabled); assign_article_to_label_filters($entry_ref_id, $article_filters, $owner_uid, $article_labels); _debug("looking for enclosures...", $debug_enabled); // enclosures $enclosures = array(); $encs = $item->get_enclosures(); if (is_array($encs)) { foreach ($encs as $e) { $e_item = array($e->link, $e->type, $e->length); array_push($enclosures, $e_item); } } if ($debug_enabled) { _debug("article enclosures:", $debug_enabled); print_r($enclosures); } db_query("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("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("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("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('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("filtered article tags:", $debug_enabled); print_r($filtered_tags); } // Save article tags in the database if (count($filtered_tags) > 0) { db_query("BEGIN"); foreach ($filtered_tags as $tag) { $tag = sanitize_tag($tag); $tag = db_escape_string($tag); if (!tag_is_valid($tag)) { continue; } $result = db_query("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("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("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("COMMIT"); } if (get_pref("AUTO_ASSIGN_LABELS", $owner_uid, false)) { _debug("auto-assigning labels...", $debug_enabled); foreach ($labels as $label) { $caption = preg_quote($label["caption"]); if ($caption && preg_match("/\\b{$caption}\\b/i", "{$tags_str} " . strip_tags($entry_content) . " {$entry_title}")) { if (!labels_contains_caption($article_labels, $caption)) { label_add_article($entry_ref_id, $caption, $owner_uid); } } } } _debug("article processed", $debug_enabled); } _debug("purging feed...", $debug_enabled); purge_feed($feed, 0, $debug_enabled); db_query("UPDATE ttrss_feeds\n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'"); // db_query("COMMIT"); } else { $error_msg = db_escape_string(mb_substr($rss->error(), 0, 245)); _debug("error fetching feed: {$error_msg}", $debug_enabled); db_query("UPDATE ttrss_feeds SET last_error = '{$error_msg}',\n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'"); } unset($rss); _debug("done", $debug_enabled); }
function globalUpdateFeeds() { include "rssfuncs.php"; // Update all feeds needing a update. update_daemon_common(0, true, false); housekeeping_common(false); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); }
function index() { print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Feeds') . "\">"; $result = $this->dbh->query("SELECT COUNT(id) AS num_errors\n\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]); $num_errors = $this->dbh->fetch_result($result, 0, "num_errors"); if ($num_errors > 0) { $error_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t \t\tonclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . __("Feeds with errors") . "</button>"; } $inactive_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tid=\"pref_feeds_inactive_btn\"\n\t\t\t\tstyle=\"display : none\"\n\t\t\t\tonclick=\"showInactiveFeeds()\">" . __("Inactive feeds") . "</button>"; $feed_search = $this->dbh->escape_string($_REQUEST["search"]); if (array_key_exists("search", $_REQUEST)) { $_SESSION["prefs_feed_search"] = $feed_search; } else { $feed_search = $_SESSION["prefs_feed_search"]; } print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; print "<div region='top' dojoType=\"dijit.Toolbar\">"; #toolbar print "<div style='float : right; padding-right : 4px;'>\n\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\"\n\t\t\t\tvalue=\"{$feed_search}\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">" . __('Search') . "</button>\n\t\t\t</div>"; print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>"; print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>"; print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>"; print "</div></div>"; print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Feeds') . "</span>"; print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; print "<div onclick=\"quickAddFeed()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Subscribe to feed') . "</div>"; print "<div onclick=\"editSelectedFeed()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Edit selected feeds') . "</div>"; print "<div onclick=\"resetFeedOrder()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Reset sort order') . "</div>"; print "<div onclick=\"batchSubscribe()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Batch subscribe') . "</div>"; print "<div dojoType=\"dijit.MenuItem\" onclick=\"removeSelectedFeeds()\">" . __('Unsubscribe') . "</div> "; print "</div></div>"; if (get_pref('ENABLE_FEED_CATS')) { print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Categories') . "</span>"; print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; print "<div onclick=\"createCategory()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Add category') . "</div>"; print "<div onclick=\"resetCatOrder()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Reset sort order') . "</div>"; print "<div onclick=\"removeSelectedCategories()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Remove selected') . "</div>"; print "</div></div>"; } print $error_button; print $inactive_button; if (defined('_ENABLE_FEED_DEBUGGING')) { print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">\n\t\t\t\t<option value=\"facDefault\" selected>" . __('More actions...') . "</option>"; if (FORCE_ARTICLE_PURGE == 0) { print "<option value=\"facPurge\">" . __('Manual purge') . "</option>"; } print "\n\t\t\t\t<option value=\"facClear\">" . __('Clear feed data') . "</option>\n\t\t\t\t<option value=\"facRescore\">" . __('Rescore articles') . "</option>"; print "</select>"; } print "</div>"; # toolbar //print '</div>'; print '<div dojoType="dijit.layout.ContentPane" region="center">'; print "<div id=\"feedlistLoading\">\n\t\t<img src='images/indicator_tiny.gif'>" . __("Loading, please wait...") . "</div>"; print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\"\n\t\t\turl=\"backend.php?op=pref-feeds&method=getfeedtree\">\n\t\t</div>\n\t\t<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\"\n\t\tquery=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\"\n\t\t\tchildrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">\n\t\t</div>\n\t\t<div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\"\n\t\t\tdndController=\"dijit.tree.dndSource\"\n\t\t\tbetweenThreshold=\"5\"\n\t\t\tmodel=\"feedModel\" openOnClick=\"false\">\n\t\t<script type=\"dojo/method\" event=\"onClick\" args=\"item\">\n\t\t\tvar id = String(item.id);\n\t\t\tvar bare_id = id.substr(id.indexOf(':')+1);\n\n\t\t\tif (id.match('FEED:')) {\n\t\t\t\teditFeed(bare_id);\n\t\t\t} else if (id.match('CAT:')) {\n\t\t\t\teditCat(bare_id, item);\n\t\t\t}\n\t\t</script>\n\t\t<script type=\"dojo/method\" event=\"onLoad\" args=\"item\">\n\t\t\tElement.hide(\"feedlistLoading\");\n\n\t\t\tcheckInactiveFeeds();\n\t\t</script>\n\t\t</div>"; # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\"> # ".__('<b>Hint:</b> you can drag feeds and categories around.')." # </div>"; print '</div>'; print '</div>'; print "</div>"; # feeds pane print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('OPML') . "\">"; print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . __("Only main settings profile can be migrated using OPML.") . "</p>"; print "<iframe id=\"upload_iframe\"\n\t\t\tname=\"upload_iframe\" onload=\"opmlImportComplete(this)\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>"; print "<form name=\"opml_form\" style='display : block' target=\"upload_iframe\"\n\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\taction=\"backend.php\">\n\t\t\t<input id=\"opml_file\" name=\"opml_file\" type=\"file\"> \n\t\t\t<input type=\"hidden\" name=\"op\" value=\"dlg\">\n\t\t\t<input type=\"hidden\" name=\"method\" value=\"importOpml\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . __('Import my OPML') . "</button>"; print "<hr>"; $opml_export_filename = "TinyTinyRSS_" . date("Y-m-d") . ".opml"; print "<p>" . __('Filename:') . " <input type=\"text\" id=\"filename\" value=\"{$opml_export_filename}\" /> " . __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>"; print "</p><button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . __('Export OPML') . "</button></p></form>"; print "<hr>"; print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . "</p>"; print_warning("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds."); print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('" . __("Public OPML URL") . "','pubOPMLUrl')\">" . __('Display published OPML URL') . "</button> "; PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefFeedsOPML"); print "</div>"; # pane if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) { print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Firefox integration') . "\">"; print_notice(__('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.')); print "<p>"; print "<button onclick='window.navigator.registerContentHandler(" . "\"application/vnd.mozilla.maybe.feed\", " . "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . __('Click here to register this site as a feed reader.') . "</button>"; print "</p>"; print "</div>"; # pane } print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Published & shared articles / Generated feeds') . "\">"; print "<p>" . __('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.') . "</p>"; $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . "/public.php?op=rss&id=-2&view-mode=all_articles"); print "<p>"; print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('" . __("View as RSS") . "','generatedFeed', '{$rss_url}')\">" . __('Display URL') . "</button> "; print "<button class=\"warning\" dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">" . __('Clear all generated URLs') . "</button> "; print "</p>"; PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefFeedsPublishedGenerated"); print "</div>"; #pane PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefFeeds"); print "</div>"; #container }
function newaction() { $action = json_decode($_REQUEST["action"], true); if ($action) { $action_param = $this->dbh->escape_string($action["action_param"]); $action_id = (int) $action["action_id"]; } else { $action_param = ""; $action_id = 0; } print "<form name='filter_new_action_form' id='filter_new_action_form'>"; print "<div class=\"dlgSec\">" . __("Perform Action") . "</div>"; print "<div class=\"dlgSecCont\">"; print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"\n\t\t\tonchange=\"filterDlgCheckAction(this)\">"; $result = $this->dbh->query("SELECT id,description FROM ttrss_filter_actions\n\t\t\tORDER BY name"); while ($line = $this->dbh->fetch_assoc($result)) { $is_selected = $line["id"] == $action_id ? "selected='1'" : ""; printf("<option {$is_selected} value='%d'>%s</option>", $line["id"], __($line["description"])); } print "</select>"; $param_box_hidden = $action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9 ? "" : "display : none"; $param_hidden = $action_id == 4 || $action_id == 6 ? "" : "display : none"; $label_param_hidden = $action_id == 7 ? "" : "display : none"; $plugin_param_hidden = $action_id == 9 ? "" : "display : none"; print "<span id=\"filterDlg_paramBox\" style=\"{$param_box_hidden}\">"; print " "; //print " " . __("with parameters:") . " "; print "<input dojoType=\"dijit.form.TextBox\"\n\t\t\tid=\"filterDlg_actionParam\" style=\"{$param_hidden}\"\n\t\t\tname=\"action_param\" value=\"{$action_param}\">"; print_label_select("action_param_label", $action_param, "id=\"filterDlg_actionParamLabel\" style=\"{$label_param_hidden}\"\n\t\t\tdojoType=\"dijit.form.Select\""); $filter_actions = PluginHost::getInstance()->get_filter_actions(); $filter_action_hash = array(); foreach ($filter_actions as $fclass => $factions) { foreach ($factions as $faction) { $filter_action_hash[$fclass . ":" . $faction["action"]] = $fclass . ": " . $faction["description"]; } } if (count($filter_action_hash) == 0) { $filter_plugin_disabled = "disabled"; $filter_action_hash["no-data"] = __("No actions available"); } else { $filter_plugin_disabled = ""; } print_select_hash("filterDlg_actionParamPlugin", $action_param, $filter_action_hash, "style=\"{$plugin_param_hidden}\" dojoType=\"dijit.form.Select\" {$filter_plugin_disabled}", "action_param_plugin"); print "</span>"; print " "; // tiny layout hack print "</div>"; print "<div class=\"dlgButtons\">"; print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewActionDlg').execute()\">" . ($action ? __("Save action") : __('Add action')) . "</button> "; print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterNewActionDlg').hide()\">" . __('Cancel') . "</button>"; print "</div>"; print "</form>"; }