<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 113);
+ define('SCHEMA_VERSION', 115);
define('LABEL_BASE_INDEX', -1024);
define('PLUGIN_FEED_BASE_INDEX', -128);
require_once 'config.php';
+ /**
+ * Define a constant if not already defined
+ *
+ * @param string $name The constant name.
+ * @param mixed $value The constant value.
+ * @access public
+ * @return boolean True if defined successfully or not.
+ */
+ function define_default($name, $value) {
+ defined($name) or define($name, $value);
+ }
+
+ ///// Some defaults that you can override in config.php //////
+
+ define_default('FEED_FETCH_TIMEOUT', 45);
+ // How may seconds to wait for response when requesting feed from a site
+ define_default('FEED_FETCH_NO_CACHE_TIMEOUT', 15);
+ // How may seconds to wait for response when requesting feed from a
+ // site when that feed wasn't cached before
+ define_default('FILE_FETCH_TIMEOUT', 45);
+ // Default timeout when fetching files from remote sites
+ define_default('FILE_FETCH_CONNECT_TIMEOUT', 15);
+ // How many seconds to wait for initial response from website when
+ // fetching files from remote sites
+
if (DB_TYPE == "pgsql") {
define('SUBSTRING_FOR_DATE', 'SUBSTRING_FOR_DATE');
} else {
define('SUBSTRING_FOR_DATE', 'SUBSTRING');
}
- define('THEME_VERSION_REQUIRED', 1.1);
-
/**
* Return available translations names.
*
"pl_PL" => "Polski",
"ru_RU" => "Русский",
"pt_BR" => "Portuguese/Brazil",
- "zh_CN" => "Simplified Chinese");
+ "zh_CN" => "Simplified Chinese",
+ "sv_SE" => "Svenska",
+ "fi_FI" => "Suomi");
return $tr;
}
global $fetch_last_error;
global $fetch_last_error_code;
- if (function_exists('curl_init') && !ini_get("open_basedir")) {
+ if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) {
if (ini_get("safe_mode")) {
$ch = curl_init(geturl($url));
array("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T', $timestamp)));
}
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : 15);
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : 45);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT);
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode"));
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$data = @file_get_contents($url);
- @$gzdecoded = gzdecode($data);
- if ($gzdecoded) $data = $gzdecoded;
-
if (!$data && function_exists('error_get_last')) {
$error = error_get_last();
$fetch_last_error = $error["message"];
@session_start();
$_SESSION["uid"] = $user_id;
+ $_SESSION["version"] = VERSION;
$result = db_query($link, "SELECT login,access_level,pwd_hash FROM ttrss_users
WHERE id = '$user_id'");
$_SESSION["uid"]);
$_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
+ $_SESSION["user_agent"] = sha1($_SERVER['HTTP_USER_AGENT']);
$_SESSION["pwd_hash"] = db_fetch_result($result, 0, "pwd_hash");
$_SESSION["last_version_check"] = time();
cache_prefs($link);
load_user_plugins($link, $_SESSION["uid"]);
} else {
- if (!$_SESSION["uid"] || !validate_session($link)) {
+ if (!validate_session($link)) $_SESSION["uid"] = false;
+
+ if (!$_SESSION["uid"]) {
if (AUTH_AUTO_LOGIN && authenticate_user($link, null, null)) {
$_SESSION["ref_schema_version"] = get_schema_version($link, true);
authenticate_user($link, null, null, true);
}
- if (!$_SESSION["uid"]) render_login_form($link);
+ if (!$_SESSION["uid"]) {
+ @session_destroy();
+ setcookie(session_name(), '', time()-42000, '/');
+
+ render_login_form($link);
+ exit;
+ }
} else {
/* bump login timestamp */
$intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE");
if (DB_TYPE == "pgsql") {
- $match_part = "updated > NOW() - INTERVAL '$intl hour' ";
+ $match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
} else {
- $match_part = "updated > DATE_SUB(NOW(),
+ $match_part = "date_entered > DATE_SUB(NOW(),
INTERVAL $intl HOUR) ";
}
SET unread = false, last_read = NOW() WHERE ref_id IN
(SELECT id FROM
(SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
- AND owner_uid = $owner_uid AND unread = true AND feed_id = $feed AND $date_qpart AND $match_part) as tmp)");
+ AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $match_part) as tmp)");
}
if ($feed == -4) {
foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS",
"ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP",
- "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", "DEFAULT_ARTICLE_LIMIT",
+ "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE",
"HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) {
$params[strtolower($param)] = (int) get_pref($link, $param);
"prev_article" => __("Open previous article"),
"next_article_noscroll" => __("Open next article (don't scroll long articles)"),
"prev_article_noscroll" => __("Open previous article (don't scroll long articles)"),
+ "next_article_noexpand" => __("Move to next article (don't expand or mark read)"),
+ "prev_article_noexpand" => __("Move to previous article (don't expand or mark read)"),
"search_dialog" => __("Show search dialog")),
__("Article") => array(
"toggle_mark" => __("Toggle starred"),
"select_article_cursor" => __("Select article under cursor"),
"email_article" => __("Email article"),
"close_article" => __("Close/collapse article"),
+ "toggle_expand" => __("Toggle article expansion (combined mode)"),
"toggle_widescreen" => __("Toggle widescreen mode"),
"toggle_embed_original" => __("Toggle embed original")),
__("Article selection") => array(
"help_dialog" => __("Show help dialog"))
);
+ global $pluginhost;
+ foreach ($pluginhost->get_hooks($pluginhost::HOOK_HOTKEY_INFO) as $plugin) {
+ $hotkeys = $plugin->hook_hotkey_info($hotkeys);
+ }
+
return $hotkeys;
}
$commandpair = explode(":", mb_strtolower($k), 2);
- if ($commandpair[0] == "note" && $commandpair[1]) {
-
- if ($commandpair[1] == "true")
- array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))");
- else
- array_push($query_keywords, "($not (note IS NULL OR note = ''))");
-
- } else if ($commandpair[0] == "star" && $commandpair[1]) {
-
- if ($commandpair[1] == "true")
- array_push($query_keywords, "($not (marked = true))");
- else
- array_push($query_keywords, "($not (marked = false))");
-
- } else if ($commandpair[0] == "pub" && $commandpair[1]) {
+ switch ($commandpair[0]) {
+ case "title":
+ if ($commandpair[1]) {
+ array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE '%".
+ db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
+ }
+ break;
+ case "author":
+ if ($commandpair[1]) {
+ array_push($query_keywords, "($not (LOWER(author) LIKE '%".
+ db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
+ }
+ break;
+ case "note":
+ if ($commandpair[1]) {
+ if ($commandpair[1] == "true")
+ array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))");
+ else if ($commandpair[1] == "false")
+ array_push($query_keywords, "($not (note IS NULL OR note = ''))");
+ else
+ array_push($query_keywords, "($not (LOWER(note) LIKE '%".
+ db_escape_string($link, mb_strtolower($commandpair[1]))."%'))");
+ }
+ break;
+ case "star":
- if ($commandpair[1] == "true")
- array_push($query_keywords, "($not (published = true))");
- else
- array_push($query_keywords, "($not (published = false))");
+ if ($commandpair[1]) {
+ if ($commandpair[1] == "true")
+ array_push($query_keywords, "($not (marked = true))");
+ else
+ array_push($query_keywords, "($not (marked = false))");
+ }
+ break;
+ case "pub":
+ if ($commandpair[1]) {
+ if ($commandpair[1] == "true")
+ array_push($query_keywords, "($not (published = true))");
+ else
+ array_push($query_keywords, "($not (published = false))");
- } else if (strpos($k, "@") === 0) {
+ }
+ break;
+ default:
+ if (strpos($k, "@") === 0) {
- $user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']);
- $orig_ts = strtotime(substr($k, 1));
- $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC'));
+ $user_tz_string = get_pref($link, 'USER_TIMEZONE', $_SESSION['uid']);
+ $orig_ts = strtotime(substr($k, 1));
+ $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC'));
- //$k = date("Y-m-d", strtotime(substr($k, 1)));
+ //$k = date("Y-m-d", strtotime(substr($k, 1)));
- array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')");
- } else {
- array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
- OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
+ array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')");
+ } else {
+ array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
+ OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
+ }
}
}
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else if ($feed == -4) { // all articles virtual feed
+ $allow_archived = true;
$query_strategy_part = "true";
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else if ($feed <= LABEL_BASE_INDEX) { // labels
$query_strategy_part = "true";
}
- if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
- $date_sort_field = "updated";
- } else {
- $date_sort_field = "date_entered";
- }
-
- $order_by = "$date_sort_field DESC, updated DESC";
+ $order_by = "score DESC, date_entered DESC, updated DESC";
if ($view_mode == "unread_first") {
$order_by = "unread DESC, $order_by";
}
- $allowed_elements = array('a', 'address', 'audio', 'article',
- 'b', 'big', 'blockquote', 'body', 'br', 'cite', 'center',
- 'code', 'dd', 'del', 'details', 'div', 'dl', 'font',
- 'dt', 'em', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
- 'header', 'html', 'i', 'img', 'ins', 'kbd',
- 'li', 'nav', 'noscript', 'ol', 'p', 'pre', 'q', 's','small',
+ $allowed_elements = array('a', 'address', 'audio', 'article', 'aside',
+ 'b', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br',
+ 'caption', 'cite', 'center', 'code', 'col', 'colgroup',
+ 'data', 'dd', 'del', 'details', 'div', 'dl', 'font',
+ 'dt', 'em', 'footer', 'figure', 'figcaption',
+ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'html', 'i',
+ 'img', 'ins', 'kbd', 'li', 'main', 'mark', 'nav', 'noscript',
+ 'ol', 'p', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'small',
'source', 'span', 'strike', 'strong', 'sub', 'summary',
- 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead',
+ 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time',
'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video' );
if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe';
$parent_insert = "NULL";
}
+ $feed_cat = mb_substr($feed_cat, 0, 250);
+
$result = db_query($link,
"SELECT id FROM ttrss_feed_categories
WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);