Skip to content

Commit a5bbb2b

Browse files
committed
Merge pull request torne#1 from gothfox/master
Update from original
2 parents 12727ad + 2f43089 commit a5bbb2b

230 files changed

Lines changed: 60655 additions & 31303 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
*~
33
*.DS_Store
44
#*
5-
lib/floIcon.php
65
.idea/*
76
config.php
87
feed-icons/*
98
cache/*/*
109
lock/*
1110
tags
11+
plugins/fever
1212
cache/htmlpurifier/*/*ser
1313
lib/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/*/*ser
1414
web.config

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,25 @@ Tiny Tiny RSS
44
Web-based news feed aggregator, designed to allow you to read news from
55
any location, while feeling as close to a real desktop application as possible.
66

7-
http://tt-rss.org
7+
http://tt-rss.org (http://mirror.tt-rss.org)
88

9-
Licensed under GNU GPL version 2
9+
This program is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
This program is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU General Public License for more details.
18+
19+
You should have received a copy of the GNU General Public License
20+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1021

1122
Copyright (c) 2005 Andrew Dolgov (unless explicitly stated otherwise).
1223

24+
Uses Silk icons by Mark James: http://www.famfamfam.com/lab/icons/silk/
25+
1326
## Requirements
1427

1528
* Compatible web browser (http://tt-rss.org/wiki/CompatibleBrowsers)

atom-to-html.xsl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
<div class="rss">
2323

24-
<img class="feedicon" src="images/pub_set.svg" style="width : 64px; height : 64px;"
25-
alt="feed icon"/>
26-
2724
<h1><xsl:value-of select="atom:title"/></h1>
2825

2926
<p class="description">This feed has been exported from

classes/api.php

Lines changed: 73 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class API extends Handler {
44

5-
const API_LEVEL = 7;
5+
const API_LEVEL = 9;
66

77
const STATUS_OK = 0;
88
const STATUS_ERR = 1;
@@ -77,6 +77,7 @@ function login() {
7777
$this->wrap(self::STATUS_OK, array("session_id" => session_id(),
7878
"api_level" => self::API_LEVEL));
7979
} else { // else we are not logged in
80+
user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
8081
$this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
8182
}
8283
} else {
@@ -199,11 +200,15 @@ function getHeadlines() {
199200
$include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
200201
$sanitize_content = !isset($_REQUEST["sanitize"]) ||
201202
sql_bool_to_bool($_REQUEST["sanitize"]);
203+
$force_update = sql_bool_to_bool($_REQUEST["force_update"]);
202204

203205
$override_order = false;
204206
switch ($_REQUEST["order_by"]) {
207+
case "title":
208+
$override_order = "ttrss_entries.title";
209+
break;
205210
case "date_reverse":
206-
$override_order = "date_entered, updated";
211+
$override_order = "score DESC, date_entered, updated";
207212
break;
208213
case "feed_dates":
209214
$override_order = "updated DESC";
@@ -218,7 +223,7 @@ function getHeadlines() {
218223
$headlines = $this->api_get_headlines($feed_id, $limit, $offset,
219224
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,
220225
$include_attachments, $since_id, $search, $search_mode,
221-
$include_nested, $sanitize_content);
226+
$include_nested, $sanitize_content, $force_update);
222227

223228
$this->wrap(self::STATUS_OK, $headlines);
224229
} else {
@@ -309,8 +314,8 @@ function getArticle() {
309314

310315
if ($article_id) {
311316

312-
$query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id,
313-
marked,unread,published,score,
317+
$query = "SELECT id,title,link,content,feed_id,comments,int_id,
318+
marked,unread,published,score,note,lang,
314319
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
315320
author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
316321
FROM ttrss_entries,ttrss_user_entries
@@ -338,11 +343,13 @@ function getArticle() {
338343
"comments" => $line["comments"],
339344
"author" => $line["author"],
340345
"updated" => (int) strtotime($line["updated"]),
341-
"content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"],
346+
"content" => $line["content"],
342347
"feed_id" => $line["feed_id"],
343348
"attachments" => $attachments,
344349
"score" => (int)$line["score"],
345-
"feed_title" => $line["feed_title"]
350+
"feed_title" => $line["feed_title"],
351+
"note" => $line["note"],
352+
"lang" => $line["lang"]
346353
);
347354

348355
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
@@ -423,14 +430,14 @@ function getLabels() {
423430

424431
$checked = false;
425432
foreach ($article_labels as $al) {
426-
if ($al[0] == $line['id']) {
433+
if (feed_to_label_id($al[0]) == $line['id']) {
427434
$checked = true;
428435
break;
429436
}
430437
}
431438

432439
array_push($rv, array(
433-
"id" => (int)$line['id'],
440+
"id" => (int)label_to_feed_id($line['id']),
434441
"caption" => $line['caption'],
435442
"fg_color" => $line['fg_color'],
436443
"bg_color" => $line['bg_color'],
@@ -447,7 +454,7 @@ function setArticleLabel() {
447454
$assign = (bool) $this->dbh->escape_string($_REQUEST['assign']) == "true";
448455

449456
$label = $this->dbh->escape_string(label_find_caption(
450-
$label_id, $_SESSION["uid"]));
457+
feed_to_label_id($label_id), $_SESSION["uid"]));
451458

452459
$num_updated = 0;
453460

@@ -511,7 +518,7 @@ static function api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_n
511518
if ($unread || !$unread_only) {
512519

513520
$row = array(
514-
"id" => $cv["id"],
521+
"id" => (int) $cv["id"],
515522
"title" => $cv["description"],
516523
"unread" => $cv["counter"],
517524
"cat_id" => -2,
@@ -557,7 +564,7 @@ static function api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_n
557564

558565
if ($unread || !$unread_only) {
559566
$row = array(
560-
"id" => $line["id"],
567+
"id" => (int) $line["id"],
561568
"title" => $line["title"],
562569
"unread" => $unread,
563570
"is_cat" => true,
@@ -626,7 +633,28 @@ static function api_get_headlines($feed_id, $limit, $offset,
626633
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
627634
$include_attachments, $since_id,
628635
$search = "", $search_mode = "",
629-
$include_nested = false, $sanitize_content = true) {
636+
$include_nested = false, $sanitize_content = true, $force_update = false) {
637+
638+
if ($force_update && $feed_id > 0 && is_numeric($feed_id)) {
639+
// Update the feed if required with some basic flood control
640+
641+
$result = db_query(
642+
"SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
643+
FROM ttrss_feeds WHERE id = '$feed_id'");
644+
645+
if (db_num_rows($result) != 0) {
646+
$last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));
647+
$cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
648+
649+
if (!$cache_images && time() - $last_updated > 120) {
650+
include "rssfuncs.php";
651+
update_rss_feed($feed_id, true, true);
652+
} else {
653+
db_query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
654+
WHERE id = '$feed_id'");
655+
}
656+
}
657+
}
630658

631659
$qfh_ret = queryFeedHeadlines($feed_id, $limit,
632660
$view_mode, $is_cat, $search, $search_mode,
@@ -638,11 +666,31 @@ static function api_get_headlines($feed_id, $limit, $offset,
638666
$headlines = array();
639667

640668
while ($line = db_fetch_assoc($result)) {
669+
$line["content_preview"] = truncate_string(strip_tags($line["content"]), 100);
670+
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
671+
$line = $p->hook_query_headlines($line, 100, true);
672+
}
673+
641674
$is_updated = ($line["last_read"] == "" &&
642675
($line["unread"] != "t" && $line["unread"] != "1"));
643676

644677
$tags = explode(",", $line["tag_cache"]);
645-
$labels = json_decode($line["label_cache"], true);
678+
679+
$label_cache = $line["label_cache"];
680+
$labels = false;
681+
682+
if ($label_cache) {
683+
$label_cache = json_decode($label_cache, true);
684+
685+
if ($label_cache) {
686+
if ($label_cache["no-labels"] == 1)
687+
$labels = array();
688+
else
689+
$labels = $label_cache;
690+
}
691+
}
692+
693+
if (!is_array($labels)) $labels = get_article_labels($line["id"]);
646694

647695
//if (!$tags) $tags = get_article_tags($line["id"]);
648696
//if (!$labels) $labels = get_article_labels($line["id"]);
@@ -660,28 +708,22 @@ static function api_get_headlines($feed_id, $limit, $offset,
660708
"tags" => $tags,
661709
);
662710

663-
if ($include_attachments)
664-
$headline_row['attachments'] = get_article_enclosures(
665-
$line['id']);
711+
if ($include_attachments)
712+
$headline_row['attachments'] = get_article_enclosures(
713+
$line['id']);
666714

667-
if ($show_excerpt) {
668-
$excerpt = truncate_string(strip_tags($line["content_preview"]), 100);
669-
$headline_row["excerpt"] = $excerpt;
670-
}
715+
if ($show_excerpt)
716+
$headline_row["excerpt"] = $line["content_preview"];
671717

672718
if ($show_content) {
673719

674-
if ($line["cached_content"] != "") {
675-
$line["content_preview"] =& $line["cached_content"];
676-
}
677-
678720
if ($sanitize_content) {
679721
$headline_row["content"] = sanitize(
680-
$line["content_preview"],
722+
$line["content"],
681723
sql_bool_to_bool($line['hide_images']),
682-
false, $line["site_url"]);
724+
false, $line["site_url"], false, $line["id"]);
683725
} else {
684-
$headline_row["content"] = $line["content_preview"];
726+
$headline_row["content"] = $line["content"];
685727
}
686728
}
687729

@@ -699,7 +741,10 @@ static function api_get_headlines($feed_id, $limit, $offset,
699741
$headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
700742

701743
$headline_row["author"] = $line["author"];
744+
702745
$headline_row["score"] = (int)$line["score"];
746+
$headline_row["note"] = $line["note"];
747+
$headline_row["lang"] = $line["lang"];
703748

704749
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
705750
$headline_row = $p->hook_render_article_api(array("headline" => $headline_row));

classes/article.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ function view() {
3030
$id = $this->dbh->escape_string($_REQUEST["id"]);
3131
$cids = explode(",", $this->dbh->escape_string($_REQUEST["cids"]));
3232
$mode = $this->dbh->escape_string($_REQUEST["mode"]);
33-
$omode = $this->dbh->escape_string($_REQUEST["omode"]);
3433

3534
// in prefetch mode we only output requested cids, main article
3635
// just gets marked as read (it already exists in client cache)
@@ -108,7 +107,7 @@ static function create_published_article($title, $url, $content, $labels_str,
108107

109108
// only check for our user data here, others might have shared this with different content etc
110109
$result = db_query("SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
111-
link = '$url' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
110+
guid = '$guid' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
112111

113112
if (db_num_rows($result) != 0) {
114113
$ref_id = db_fetch_result($result, 0, "id");

classes/db/mysql.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ function escape_string($s, $strip_tags = true) {
2626
}
2727

2828
function query($query, $die_on_error = true) {
29-
$result = mysql_query($query, $this->link);
29+
$result = @mysql_query($query, $this->link);
3030
if (!$result) {
31-
user_error("Query $query failed: " . ($this->link ? mysql_error($this->link) : "No connection"),
31+
$error = @mysql_error($this->link);
32+
33+
@mysql_query("ROLLBACK", $this->link);
34+
user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
3235
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
3336
}
3437
return $result;

classes/db/mysqli.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ function escape_string($s, $strip_tags = true) {
2424
}
2525

2626
function query($query, $die_on_error = true) {
27-
$result = mysqli_query($this->link, $query);
27+
$result = @mysqli_query($this->link, $query);
2828
if (!$result) {
29-
user_error("Query $query failed: " . ($this->link ? mysqli_error($this->link) : "No connection"),
29+
$error = @mysqli_error($this->link);
30+
31+
@mysqli_query($this->link, "ROLLBACK");
32+
user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
3033
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
3134
}
3235

classes/db/pgsql.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ function escape_string($s, $strip_tags = true) {
3535
}
3636

3737
function query($query, $die_on_error = true) {
38-
$result = pg_query($query);
38+
$result = @pg_query($this->link, $query);
3939

4040
if (!$result) {
41+
$error = @pg_last_error($this->link);
42+
43+
@pg_query($this->link, "ROLLBACK");
4144
$query = htmlspecialchars($query); // just in case
42-
user_error("Query $query failed: " . ($this->link ? pg_last_error($this->link) : "No connection"),
45+
user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
4346
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
4447
}
4548
return $result;

classes/dlg.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function importOpml() {
1616
print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
1717

1818
print "<div class=\"prefFeedOPMLHolder\">";
19-
$owner_uid = $_SESSION["uid"];
2019

2120
$this->dbh->query("BEGIN");
2221

@@ -176,7 +175,7 @@ function printTagSelect() {
176175

177176
while ($row = $this->dbh->fetch_assoc($result)) {
178177
$tmp = htmlspecialchars($row["tag_name"]);
179-
print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
178+
print "<option value=\"$tmp\">$tmp</option>";
180179
}
181180

182181
print "</select>";

classes/feedenclosure.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ class FeedEnclosure {
33
public $link;
44
public $type;
55
public $length;
6+
public $title;
7+
public $height;
8+
public $width;
69
}
710
?>

0 commit comments

Comments
 (0)