summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/db.php2
-rw-r--r--include/feedbrowser.php2
-rw-r--r--include/functions.php148
-rw-r--r--include/labels.php9
-rw-r--r--include/localized_schema.php4
-rw-r--r--include/rssfuncs.php10
-rw-r--r--include/sanity_check.php9
7 files changed, 136 insertions, 48 deletions
diff --git a/include/db.php b/include/db.php
index 0479df6a9..a70a1d878 100644
--- a/include/db.php
+++ b/include/db.php
@@ -15,7 +15,7 @@ function db_connect($host, $user, $pass, $db) {
$string .= " host=$host";
}
- if (defined('DB_PORT')) {
+ if (defined('DB_PORT') && DB_PORT) {
$string = "$string port=" . DB_PORT;
}
diff --git a/include/feedbrowser.php b/include/feedbrowser.php
index 5b33fb73c..e5ee4a70d 100644
--- a/include/feedbrowser.php
+++ b/include/feedbrowser.php
@@ -80,7 +80,7 @@
$class = ($feedctr % 2) ? "even" : "odd";
if ($line['articles_archived'] > 0) {
- $archived = sprintf(__("%d archived articles"), $line['articles_archived']);
+ $archived = sprintf(ngettext("%d archived article", "%d archived articles", $line['articles_archived']), $line['articles_archived']);
$archived = "&nbsp;<span class='subscribers'>($archived)</span>";
} else {
$archived = '';
diff --git a/include/functions.php b/include/functions.php
index c01e41004..9125247b1 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1,6 +1,8 @@
<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 106);
+ define('SCHEMA_VERSION', 109);
+
+ define('LABEL_BASE_INDEX', -1024);
$fetch_last_error = false;
$pluginhost = false;
@@ -285,8 +287,6 @@
}
function fetch_file_contents($url, $type = false, $login = false, $pass = false, $post_query = false, $timeout = false) {
- $login = urlencode($login);
- $pass = urlencode($pass);
global $fetch_last_error;
@@ -348,11 +348,13 @@
return $contents;
} else {
- if ($login && $pass ){
+ if ($login && $pass){
$url_parts = array();
preg_match("/(^[^:]*):\/\/(.*)/", $url, $url_parts);
+ $pass = urlencode($pass);
+
if ($url_parts[1] && $url_parts[2]) {
$url = $url_parts[1] . "://$login:$pass@" . $url_parts[2];
}
@@ -1034,7 +1036,7 @@
AND $ref_check_qpart AND unread = true
AND owner_uid = $owner_uid");
- } else if ($feed < 0 && $feed > -10) { // special, like starred
+ } else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred
if ($feed == -1) {
db_query($link, "UPDATE ttrss_user_entries
@@ -1085,9 +1087,9 @@
owner_uid = $owner_uid");
}
- } else if ($feed < -10) { // label
+ } else if ($feed < LABEL_BASE_INDEX) { // label
- $label_id = -$feed - 11;
+ $label_id = feed_to_label_id($feed);
db_query($link, "UPDATE ttrss_user_entries, ttrss_user_labels2
SET unread = false, last_read = NOW()
@@ -1334,9 +1336,9 @@
$match_part = "feed_id IS NULL";
}
- } else if ($feed < -10) {
+ } else if ($feed < LABEL_BASE_INDEX) {
- $label_id = -$feed - 11;
+ $label_id = feed_to_label_id($feed);
return getLabelUnread($link, $label_id, $owner_uid);
@@ -1446,7 +1448,7 @@
while ($line = db_fetch_assoc($result)) {
- $id = -$line["id"] - 11;
+ $id = label_to_feed_id($line["id"]);
$label_name = $line["caption"];
$count = $line["unread"];
@@ -1535,7 +1537,7 @@
* 5 - Couldn't download the URL content.
*/
function subscribe_to_feed($link, $url, $cat_id = 0,
- $auth_login = '', $auth_pass = '', $need_auth = false) {
+ $auth_login = '', $auth_pass = '') {
global $fetch_last_error;
@@ -1753,7 +1755,7 @@
function getFeedCatTitle($link, $id) {
if ($id == -1) {
return __("Special");
- } else if ($id < -10) {
+ } else if ($id < LABEL_BASE_INDEX) {
return __("Labels");
} else if ($id > 0) {
$result = db_query($link, "SELECT ttrss_feed_categories.title
@@ -1791,7 +1793,7 @@
return "images/recently_read.png";
break;
default:
- if ($id < -10) {
+ if ($id < LABEL_BASE_INDEX) {
return "images/label.png";
} else {
if (file_exists(ICONS_DIR . "/$id.ico"))
@@ -1816,8 +1818,8 @@
return __("Archived articles");
} else if ($id == -6) {
return __("Recently read");
- } else if ($id < -10) {
- $label_id = -$id - 11;
+ } else if ($id < LABEL_BASE_INDEX) {
+ $label_id = feed_to_label_id($id);
$result = db_query($link, "SELECT caption FROM ttrss_labels2 WHERE id = '$label_id'");
if (db_num_rows($result) == 1) {
return db_fetch_result($result, 0, "caption");
@@ -1854,6 +1856,7 @@
$params["default_view_limit"] = (int) get_pref($link, "_DEFAULT_VIEW_LIMIT");
$params["default_view_order_by"] = get_pref($link, "_DEFAULT_VIEW_ORDER_BY");
$params["bw_limit"] = (int) $_SESSION["bw_limit"];
+ $params["label_base_index"] = (int) LABEL_BASE_INDEX;
$result = db_query($link, "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
@@ -2039,6 +2042,7 @@
$data['cdm_expanded'] = get_pref($link, 'CDM_EXPANDED');
$data['dep_ts'] = calculate_dep_timestamp();
+ $data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE');
if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
@@ -2235,14 +2239,15 @@
if ($search) {
$view_query_part = " ";
} else if ($feed != -1) {
+
$unread = getFeedUnread($link, $feed, $cat_view);
if ($cat_view && $feed > 0 && $include_children)
$unread += getCategoryChildrenUnread($link, $feed);
- if ($unread > 0) {
- $view_query_part = " unread = true AND ";
- }
+ if ($unread > 0)
+ $view_query_part = " unread = true AND ";
+
}
}
@@ -2254,7 +2259,7 @@
$view_query_part = " published = true AND ";
}
- if ($view_mode == "unread") {
+ if ($view_mode == "unread" && $feed != -6) {
$view_query_part = " unread = true AND ";
}
@@ -2334,7 +2339,13 @@
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
$allow_archived = true;
- if (!$override_order) $override_order = "last_marked DESC, updated DESC";
+ if (!$override_order) {
+ if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
+ $override_order = "date_entered";
+ } else {
+ $override_order = "last_marked DESC, date_entered DESC";
+ }
+ }
} else if ($feed == -2) { // published virtual feed OR labels category
@@ -2343,7 +2354,14 @@
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
$allow_archived = true;
- if (!$override_order) $override_order = "last_published DESC, updated DESC";
+ if (!$override_order) {
+ if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
+ $override_order = "date_entered";
+ } else {
+ $override_order = "last_published DESC, date_entered DESC";
+ }
+ }
+
} else {
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
@@ -2374,8 +2392,8 @@
} else if ($feed == -4) { // all articles virtual feed
$query_strategy_part = "true";
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
- } else if ($feed <= -10) { // labels
- $label_id = -$feed - 11;
+ } else if ($feed <= LABEL_BASE_INDEX) { // labels
+ $label_id = feed_to_label_id($feed);
$query_strategy_part = "label_id = '$label_id' AND
ttrss_labels2.id = ttrss_user_labels2.label_id AND
@@ -2405,6 +2423,10 @@
$order_by = "score DESC, $order_by";
}
+ if ($view_mode == "unread_first") {
+ $order_by = "unread DESC, $order_by";
+ }
+
if ($override_order) {
$order_by = $override_order;
}
@@ -2666,7 +2688,7 @@
$entries = $doc->getElementsByTagName("*");
$allowed_elements = array('a', 'address', 'audio', 'article',
- 'b', 'big', 'blockquote', 'body', 'br', 'cite',
+ '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',
@@ -2685,16 +2707,22 @@
}
if ($entry->hasAttributes()) {
- foreach (iterator_to_array($entry->attributes) as $attr) {
+ $attrs_to_remove = array();
+
+ foreach ($entry->attributes as $attr) {
if (strpos($attr->nodeName, 'on') === 0) {
- $entry->removeAttributeNode($attr);
+ array_push($attrs_to_remove, $attr);
}
if (in_array($attr->nodeName, $disallowed_attributes)) {
- $entry->removeAttributeNode($attr);
+ array_push($attrs_to_remove, $attr);
}
}
+
+ foreach ($attrs_to_remove as $attr) {
+ $entry->removeAttributeNode($attr);
+ }
}
}
@@ -3002,7 +3030,7 @@
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
<title>Tiny Tiny RSS - ".$line["title"]."</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss.css\">
- </head><body>";
+ </head><body id=\"ttrssZoom\">";
}
$rv['content'] .= "<div class=\"postReply\" id=\"POST-$id\">";
@@ -3115,7 +3143,7 @@
if ($zoom_mode) {
$rv['content'] .= "
- <div style=\"text-align : center\">
+ <div class='footer'>
<button onclick=\"return window.close()\">".
__("Close this window")."</button></div>";
$rv['content'] .= "</body></html>";
@@ -3192,7 +3220,7 @@
$filter_id = $line["id"];
$result2 = db_query($link, "SELECT
- r.reg_exp, r.feed_id, r.cat_id, r.cat_filter, t.name AS type_name
+ r.reg_exp, r.inverse, r.feed_id, r.cat_id, r.cat_filter, t.name AS type_name
FROM ttrss_filters2_rules AS r,
ttrss_filter_types AS t
WHERE
@@ -3209,6 +3237,7 @@
$rule = array();
$rule["reg_exp"] = $rule_line["reg_exp"];
$rule["type"] = $rule_line["type_name"];
+ $rule["inverse"] = sql_bool_to_bool($rule_line["inverse"]);
array_push($rules, $rule);
}
@@ -3232,6 +3261,7 @@
$filter = array();
$filter["match_any_rule"] = sql_bool_to_bool($line["match_any_rule"]);
+ $filter["inverse"] = sql_bool_to_bool($line["inverse"]);
$filter["rules"] = $rules;
$filter["actions"] = $actions;
@@ -3853,7 +3883,7 @@
$rule['reg_exp'] = db_escape_string($link, $rule['reg_exp']);
- switch ($rule["type"]) {
+ switch ($rule["type"]) {
case "title":
$qpart = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
$rule['reg_exp'] . "')";
@@ -3881,6 +3911,8 @@
break;
}
+ if (isset($rule['inverse'])) $qpart = "NOT ($qpart)";
+
if (isset($rule["feed_id"]) && $rule["feed_id"] > 0) {
$qpart .= " AND feed_id = " . db_escape_string($link, $rule["feed_id"]);
}
@@ -3907,10 +3939,14 @@
}
if (count($query) > 0) {
- return "(" . join($filter["match_any_rule"] ? "OR" : "AND", $query) . ")";
+ $fullquery = "(" . join($filter["match_any_rule"] ? "OR" : "AND", $query) . ")";
} else {
- return "(false)";
+ $fullquery = "(false)";
}
+
+ if ($filter['inverse']) $fullquery = "(NOT $fullquery)";
+
+ return $fullquery;
}
if (!function_exists('gzdecode')) {
@@ -4084,4 +4120,50 @@
return $max_ts;
}
+ function T_js_decl($s1, $s2) {
+ if ($s1 && $s2) {
+ $s1 = preg_replace("/\n/", "", $s1);
+ $s2 = preg_replace("/\n/", "", $s2);
+
+ $s1 = preg_replace("/\"/", "\\\"", $s1);
+ $s2 = preg_replace("/\"/", "\\\"", $s2);
+
+ return "T_messages[\"$s1\"] = \"$s2\";\n";
+ }
+ }
+
+ function init_js_translations() {
+
+ print 'var T_messages = new Object();
+
+ function __(msg) {
+ if (T_messages[msg]) {
+ return T_messages[msg];
+ } else {
+ return msg;
+ }
+ }
+
+ function ngettext(msg1, msg2, n) {
+ return (parseInt(n) > 1) ? msg2 : msg1;
+ }';
+
+ $l10n = _get_reader();
+
+ for ($i = 0; $i < $l10n->total; $i++) {
+ $orig = $l10n->get_original_string($i);
+ $translation = __($orig);
+
+ print T_js_decl($orig, $translation);
+ }
+ }
+
+ function label_to_feed_id($label) {
+ return LABEL_BASE_INDEX - 1 - abs($label);
+ }
+
+ function feed_to_label_id($feed) {
+ return LABEL_BASE_INDEX - 1 + abs($feed);
+ }
+
?>
diff --git a/include/labels.php b/include/labels.php
index e45a38622..5ac8794d9 100644
--- a/include/labels.php
+++ b/include/labels.php
@@ -158,18 +158,11 @@
/* Remove access key for the label */
- $ext_id = -11 - $id;
+ $ext_id = LABEL_BASE_INDEX - 1 - $id;
db_query($link, "DELETE FROM ttrss_access_keys WHERE
feed_id = '$ext_id' AND owner_uid = $owner_uid");
- /* Disable filters that reference label being removed */
-
- db_query($link, "UPDATE ttrss_filters SET
- enabled = false WHERE action_param = '$caption'
- AND action_id = 7
- AND owner_uid = " . $owner_uid);
-
/* Remove cached data */
db_query($link, "UPDATE ttrss_user_entries SET label_cache = ''
diff --git a/include/localized_schema.php b/include/localized_schema.php
index 4a55094ef..ff9f54307 100644
--- a/include/localized_schema.php
+++ b/include/localized_schema.php
@@ -1,4 +1,4 @@
-<?php # This file has been generated at: Thu Mar 21 23:29:09 MSK 2013
+<?php # This file has been generated at: Wed Mar 27 12:43:58 MSK 2013
__("Title");
__("Title or Content");
@@ -39,7 +39,7 @@ __('Show content preview in headlines list');
__('Short date format');
__('Long date format');
__('Combined feed display');
-__('Hide feeds with no unread messages');
+__('Hide feeds with no unread articles');
__('On catchup show next feed');
__('Sort feeds by unread articles count');
__('Reverse headline order (oldest first)');
diff --git a/include/rssfuncs.php b/include/rssfuncs.php
index 193194b50..130f9142c 100644
--- a/include/rssfuncs.php
+++ b/include/rssfuncs.php
@@ -435,7 +435,7 @@
$entry_timestamp = strtotime($item->get_date());
- if ($entry_timestamp == -1 || !$entry_timestamp) {
+ if ($entry_timestamp == -1 || !$entry_timestamp || $entry_timestamp > time()) {
$entry_timestamp = time();
$no_orig_date = 'true';
} else {
@@ -996,7 +996,7 @@
}
foreach ($labels as $label) {
- $caption = $label["caption"];
+ $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)) {
@@ -1165,11 +1165,13 @@
foreach ($filters as $filter) {
$match_any_rule = $filter["match_any_rule"];
+ $inverse = $filter["inverse"];
$filter_match = false;
foreach ($filter["rules"] as $rule) {
$match = false;
$reg_exp = $rule["reg_exp"];
+ $rule_inverse = $rule["inverse"];
if (!$reg_exp)
continue;
@@ -1202,6 +1204,8 @@
break;
}
+ if ($rule_inverse) $match = !$match;
+
if ($match_any_rule) {
if ($match) {
$filter_match = true;
@@ -1215,6 +1219,8 @@
}
}
+ if ($inverse) $filter_match = !$filter_match;
+
if ($filter_match) {
foreach ($filter["actions"] AS $action) {
array_push($matches, $action);
diff --git a/include/sanity_check.php b/include/sanity_check.php
index 0373196b3..46e9e9d80 100644
--- a/include/sanity_check.php
+++ b/include/sanity_check.php
@@ -12,6 +12,10 @@
require_once "sanity_config.php";
+ if (file_exists("install") && !file_exists("config.php")) {
+ array_push($errors, "Please copy config.php-dist to config.php or run the installer in install/");
+ }
+
if (strpos(PLUGINS, "auth_") === FALSE) {
array_push($errors, "Please enable at least one authentication module via PLUGINS constant in config.php");
}
@@ -146,7 +150,8 @@
<link rel="stylesheet" type="text/css" href="utility.css">
</head>
<body>
- <div class="floatingLogo"><img src="images/logo_wide.png"></div>
+ <div class="floatingLogo"><img src="images/logo_small.png"></div>
+ <div class="content">
<h1>Startup failed</h1>
@@ -158,6 +163,8 @@
<p>You might want to check tt-rss <a href="http://tt-rss.org/wiki">wiki</a> or the
<a href="http://tt-rss.org/forum">forums</a> for more information. Please search the forums before creating new topic
for your question.</p>
+
+ </div>
</body>
</html>