]>
Commit | Line | Data |
---|---|---|
1cd17194 AD |
1 | <? |
2 | header("Content-Type: application/xml"); | |
3 | ||
82baad4a AD |
4 | require_once "config.php"; |
5 | require_once "functions.php"; | |
6 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 7 | |
d76a3b03 AD |
8 | |
9 | $link = pg_connect(DB_CONN); | |
10 | ||
11 | pg_query("set client_encoding = 'utf-8'"); | |
12 | ||
6f428bc5 | 13 | $op = $_GET["op"]; |
82baad4a | 14 | |
1cd17194 AD |
15 | if ($op == "feeds") { |
16 | ||
82baad4a AD |
17 | update_all_feeds($link); |
18 | ||
d76a3b03 AD |
19 | $result = pg_query("SELECT *, |
20 | (SELECT count(id) FROM ttrss_entries | |
21 | WHERE feed_id = ttrss_feeds.id) AS total, | |
22 | (SELECT count(id) FROM ttrss_entries | |
23 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
24 | FROM ttrss_feeds ORDER BY title"); | |
1cd17194 | 25 | |
82baad4a | 26 | print "<table width=\"100%\" class=\"feeds\">"; |
1cd17194 AD |
27 | |
28 | $lnum = 0; | |
29 | ||
6f428bc5 | 30 | while ($line = pg_fetch_assoc($result)) { |
a1a8a2be | 31 | |
6f428bc5 | 32 | $feed = $line["title"]; |
2c1dd701 AD |
33 | $feed_id = $line["id"]; |
34 | ||
d76a3b03 AD |
35 | $total = $line["total"]; |
36 | $unread = $line["unread"]; | |
37 | ||
1cd17194 | 38 | $class = ($lnum % 2) ? "even" : "odd"; |
a1a8a2be AD |
39 | |
40 | if ($unread > 0) $class .= "Unread"; | |
41 | ||
42 | print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; | |
43 | ||
44 | $feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed</a>"; | |
45 | print "<td id=\"FEEDN-$feed_id\">$feed</td>"; | |
46 | print "<td id=\"FEEDU-$feed_id\">$unread</td>"; | |
47 | print "<td id=\"FEEDT-$feed_id\">$total</td>"; | |
48 | ||
49 | print "</tr>"; | |
1cd17194 AD |
50 | ++$lnum; |
51 | } | |
52 | ||
82baad4a AD |
53 | print "<tr><td class=\"footer\" colspan=\"3\"> |
54 | <a href=\"javascript:update_feed_list()\">Update all feeds</a></td></tr>"; | |
55 | ||
a1a8a2be | 56 | print "</table>"; |
1cd17194 AD |
57 | |
58 | } | |
59 | ||
60 | if ($op == "view") { | |
61 | ||
d76a3b03 AD |
62 | $id = $_GET["id"]; |
63 | ||
a1a8a2be AD |
64 | $result = pg_query("UPDATE ttrss_entries SET unread = false WHERE id = '$id'"); |
65 | ||
d76a3b03 AD |
66 | $result = pg_query("SELECT title,link,content FROM ttrss_entries |
67 | WHERE id = '$id'"); | |
1cd17194 | 68 | |
d76a3b03 | 69 | if ($result) { |
1cd17194 | 70 | |
d76a3b03 | 71 | $line = pg_fetch_assoc($result); |
1cd17194 | 72 | |
d76a3b03 AD |
73 | print "<table class=\"feedOverview\">"; |
74 | print "<tr><td><b>Title:</b></td><td>".$line["title"]."</td></tr>"; | |
75 | print "<tr><td><b>Link:</b></td><td><a href=\"".$line["link"]."\">".$line["link"]."</a></td></tr>"; | |
76 | ||
77 | print "</table>"; | |
78 | ||
79 | print $line["content"]; | |
80 | ||
81 | ||
82 | } | |
1cd17194 AD |
83 | } |
84 | ||
85 | if ($op == "viewfeed") { | |
86 | ||
87 | $feed = $_GET["feed"]; | |
d76a3b03 | 88 | $skip = $_GET["skip"]; |
a1a8a2be AD |
89 | $ext = $_GET["ext"]; |
90 | ||
91 | if ($ext == "undefined") $ext = ""; | |
1cd17194 | 92 | |
82baad4a AD |
93 | $result = pg_query("SELECT *, |
94 | EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout | |
95 | FROM ttrss_feeds WHERE id = '$feed'"); | |
1cd17194 | 96 | |
d76a3b03 | 97 | if ($result) { |
1cd17194 | 98 | |
d76a3b03 | 99 | $line = pg_fetch_assoc($result); |
1cd17194 | 100 | |
82baad4a AD |
101 | if (!$ext && $line["update_timeout"] > MIN_UPDATE_TIME) { |
102 | ||
103 | update_rss_feed($link, $line["feed_url"], $feed); | |
d76a3b03 | 104 | |
a1a8a2be | 105 | } else { |
d76a3b03 | 106 | |
a1a8a2be | 107 | if ($ext == "MarkAllRead") { |
d76a3b03 | 108 | |
a1a8a2be AD |
109 | pg_query("UPDATE ttrss_entries SET unread = false |
110 | WHERE feed_id = '$feed'"); | |
111 | } | |
a1a8a2be AD |
112 | } |
113 | } | |
d76a3b03 | 114 | |
a1a8a2be AD |
115 | print "<table class=\"headlines\" width=\"100%\">"; |
116 | print "<tr><td colspan=\"2\" class=\"title\">" . $line["title"] . "</td></tr>"; | |
d76a3b03 | 117 | |
a1a8a2be AD |
118 | $result = pg_query("SELECT id,title,updated,unread,feed_id FROM |
119 | ttrss_entries WHERE | |
120 | feed_id = '$feed' ORDER BY updated LIMIT ".HEADLINES_PER_PAGE." OFFSET $skip"); | |
d76a3b03 | 121 | |
a1a8a2be | 122 | $lnum = 0; |
d76a3b03 | 123 | |
a1a8a2be | 124 | while ($line = pg_fetch_assoc($result)) { |
d76a3b03 | 125 | |
a1a8a2be | 126 | $class = ($lnum % 2) ? "even" : "odd"; |
d76a3b03 | 127 | |
a1a8a2be AD |
128 | if ($line["unread"] == "t") |
129 | $class .= "Unread"; | |
d76a3b03 | 130 | |
a1a8a2be | 131 | $content_link = "<a href=\"javascript:view(".$line["id"].",".$line["feed_id"].");\">".$line["title"]."</a>"; |
1cd17194 | 132 | |
a1a8a2be AD |
133 | print "<tr class='$class' id='RROW-".$line["id"]."'>"; |
134 | print "<td class='headlineUpdated'>".$line["updated"]."</td>"; | |
135 | print "<td class='headlineTitle'>$content_link</td>"; | |
d76a3b03 | 136 | |
a1a8a2be | 137 | print "</tr>"; |
d76a3b03 | 138 | |
a1a8a2be AD |
139 | ++$lnum; |
140 | } | |
d76a3b03 | 141 | |
a1a8a2be | 142 | print "<tr><td colspan=\"2\" class=\"headlineToolbar\">"; |
d76a3b03 | 143 | |
a1a8a2be AD |
144 | $next_skip = $skip + HEADLINES_PER_PAGE; |
145 | $prev_skip = $skip - HEADLINES_PER_PAGE; | |
d76a3b03 | 146 | |
a1a8a2be AD |
147 | print "<a class=\"button\" |
148 | href=\"javascript:viewfeed($feed, $prev_skip);\">Previous Page</a>"; | |
149 | print " "; | |
150 | print "<a class=\"button\" | |
151 | href=\"javascript:viewfeed($feed, $next_skip);\">Next Page</a>"; | |
152 | print " "; | |
153 | ||
154 | print "<a class=\"button\" | |
155 | href=\"javascript:viewfeed($feed, 0, 'MarkAllRead');\">Mark all as read</a>"; | |
d76a3b03 | 156 | |
a1a8a2be AD |
157 | print "</td></tr>"; |
158 | print "</table>"; | |
d76a3b03 | 159 | |
a1a8a2be AD |
160 | $result = pg_query("SELECT id, (SELECT count(id) FROM ttrss_entries |
161 | WHERE feed_id = ttrss_feeds.id) AS total, | |
162 | (SELECT count(id) FROM ttrss_entries | |
163 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
164 | FROM ttrss_feeds WHERE id = '$feed'"); | |
d76a3b03 | 165 | |
a1a8a2be AD |
166 | $total = pg_fetch_result($result, 0, "total"); |
167 | $unread = pg_fetch_result($result, 0, "unread"); | |
d76a3b03 | 168 | |
a1a8a2be AD |
169 | print "<div class=\"invisible\" id=\"FACTIVE\">$feed</div>"; |
170 | print "<div class=\"invisible\" id=\"FTOTAL\">$total</div>"; | |
171 | print "<div class=\"invisible\" id=\"FUNREAD\">$unread</div>"; | |
d76a3b03 | 172 | |
1cd17194 AD |
173 | } |
174 | ||
175 | ||
176 | ?> |