]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | <? |
4356293a | 2 | session_start(); |
090e250b | 3 | |
1c7f75ed AD |
4 | if (!$_SESSION["uid"]) { exit; } |
5 | ||
4356293a | 6 | define(SCHEMA_VERSION, 2); |
1cd17194 | 7 | |
82baad4a | 8 | require_once "config.php"; |
648472a7 | 9 | require_once "db.php"; |
3bac89ad | 10 | require_once "db-prefs.php"; |
82baad4a AD |
11 | require_once "functions.php"; |
12 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 13 | |
4356293a AD |
14 | $op = $_REQUEST["op"]; |
15 | ||
0bc694bf | 16 | if (($op == "rpc" || $op == "updateAllFeeds") && !$_REQUEST["noxml"]) { |
4356293a AD |
17 | header("Content-Type: application/xml"); |
18 | } | |
19 | ||
406d9489 AD |
20 | $script_started = getmicrotime(); |
21 | ||
648472a7 | 22 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
d76a3b03 | 23 | |
5136011e AD |
24 | if (!$link) { |
25 | if (DB_TYPE == "mysql") { | |
26 | print mysql_error(); | |
27 | } | |
28 | // PG seems to display its own errors just fine by default. | |
29 | return; | |
30 | } | |
31 | ||
648472a7 AD |
32 | if (DB_TYPE == "pgsql") { |
33 | pg_query("set client_encoding = 'utf-8'"); | |
34 | } | |
7ec2a838 | 35 | |
295f9b42 | 36 | /* |
7ec2a838 AD |
37 | $result = db_query($link, "SELECT schema_version FROM ttrss_version"); |
38 | ||
39 | $schema_version = db_fetch_result($result, 0, "schema_version"); | |
40 | ||
41 | if ($schema_version != SCHEMA_VERSION) { | |
42 | print "Error: database schema is invalid | |
43 | (got version $schema_version; expected ".SCHEMA_VERSION.")"; | |
44 | return; | |
45 | } | |
295f9b42 AD |
46 | */ |
47 | ||
331900c6 | 48 | $fetch = $_GET["fetch"]; |
175847de | 49 | |
8143ae1f AD |
50 | /* FIXME this needs reworking */ |
51 | ||
fc69e641 | 52 | function getGlobalCounters($link) { |
4c193675 AD |
53 | $result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries |
54 | WHERE unread = true AND | |
55 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
56 | owner_uid = " . $_SESSION["uid"]); | |
fc69e641 AD |
57 | $c_id = db_fetch_result($result, 0, "c_id"); |
58 | print "<counter id='global-unread' counter='$c_id'/>"; | |
59 | } | |
60 | ||
8143ae1f AD |
61 | function getTagCounters($link) { |
62 | $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count | |
4c193675 AD |
63 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE |
64 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
4356293a | 65 | ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND |
8143ae1f AD |
66 | post_id = ttrss_entries.id AND unread = true GROUP BY tag_name |
67 | UNION | |
4356293a AD |
68 | select tag_name,0 as count FROM ttrss_tags |
69 | WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]); | |
8143ae1f AD |
70 | |
71 | $tags = array(); | |
72 | ||
73 | while ($line = db_fetch_assoc($result)) { | |
74 | $tags[$line["tag_name"]] += $line["count"]; | |
75 | } | |
76 | ||
77 | foreach (array_keys($tags) as $tag) { | |
78 | $unread = $tags[$tag]; | |
79 | ||
80 | $tag = htmlspecialchars($tag); | |
81 | print "<tag id=\"$tag\" counter=\"$unread\"/>"; | |
82 | } | |
83 | } | |
84 | ||
090e250b AD |
85 | function getLabelCounters($link) { |
86 | ||
4c193675 AD |
87 | $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries |
88 | WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND | |
89 | unread = true AND owner_uid = ".$_SESSION["uid"]); | |
090e250b | 90 | |
d61fd764 | 91 | $count = db_fetch_result($result, 0, "count"); |
090e250b AD |
92 | |
93 | print "<label id=\"-1\" counter=\"$count\"/>"; | |
94 | ||
4356293a AD |
95 | $result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM |
96 | ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description"); | |
090e250b AD |
97 | |
98 | while ($line = db_fetch_assoc($result)) { | |
99 | ||
100 | $id = -$line["id"] - 11; | |
101 | ||
102 | error_reporting (0); | |
d61fd764 | 103 | |
4c193675 | 104 | $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries |
655be073 | 105 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND |
4c193675 | 106 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
655be073 | 107 | owner_uid = ".$_SESSION["uid"]); |
090e250b | 108 | |
d61fd764 | 109 | $count = db_fetch_result($tmp_result, 0, "count"); |
090e250b | 110 | |
ab3f3f72 | 111 | print "<label id=\"$id\" counter=\"$count\"/>"; |
090e250b AD |
112 | |
113 | error_reporting (E_ERROR | E_WARNING | E_PARSE); | |
114 | ||
115 | } | |
116 | } | |
117 | ||
8073cce7 AD |
118 | function getFeedCounter($link, $id) { |
119 | ||
120 | $result = db_query($link, "SELECT | |
4c193675 AD |
121 | count(id) as count FROM ttrss_entries,ttrss_user_entries |
122 | WHERE feed_id = '$id' AND unread = true | |
123 | AND ttrss_user_entries.ref_id = ttrss_entries.id"); | |
8073cce7 AD |
124 | |
125 | $count = db_fetch_result($result, 0, "count"); | |
126 | ||
127 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
128 | } | |
090e250b | 129 | |
8073cce7 AD |
130 | function getFeedCounters($link) { |
131 | ||
090e250b | 132 | $result = db_query($link, "SELECT id, |
4c193675 AD |
133 | (SELECT count(id) |
134 | FROM ttrss_entries,ttrss_user_entries | |
135 | WHERE feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id | |
b88917af | 136 | AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count |
4356293a | 137 | FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]); |
090e250b AD |
138 | |
139 | while ($line = db_fetch_assoc($result)) { | |
140 | ||
141 | $id = $line["id"]; | |
142 | $count = $line["count"]; | |
143 | ||
144 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
145 | } | |
146 | } | |
147 | ||
8143ae1f | 148 | function outputFeedList($link, $tags = false) { |
175847de | 149 | |
1a66d16e AD |
150 | print "<html><head> |
151 | <title>Tiny Tiny RSS : Feedlist</title> | |
430bf183 AD |
152 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
153 | ||
4769ddaf | 154 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
430bf183 AD |
155 | print "<link rel=\"stylesheet\" type=\"text/css\" |
156 | href=\"tt-rss_compact.css\"/>"; | |
157 | } else { | |
158 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
159 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
160 | } | |
161 | ||
162 | print "<script type=\"text/javascript\" src=\"functions.js\"></script> | |
1a66d16e AD |
163 | <script type=\"text/javascript\" src=\"feedlist.js\"></script> |
164 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
3745788e | 165 | </head><body onload=\"init()\">"; |
254e0e4b AD |
166 | |
167 | print "<ul class=\"feedList\" id=\"feedList\">"; | |
168 | ||
4356293a AD |
169 | $owner_uid = $_SESSION["uid"]; |
170 | ||
8143ae1f | 171 | if (!$tags) { |
254e0e4b | 172 | |
8143ae1f | 173 | /* virtual feeds */ |
254e0e4b | 174 | |
8143ae1f | 175 | $result = db_query($link, "SELECT count(id) as num_starred |
4c193675 AD |
176 | FROM ttrss_entries,ttrss_user_entries |
177 | WHERE marked = true AND | |
178 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
179 | unread = true AND owner_uid = '$owner_uid'"); | |
8143ae1f | 180 | $num_starred = db_fetch_result($result, 0, "num_starred"); |
254e0e4b | 181 | |
3745788e | 182 | $class = "virt"; |
8add756a AD |
183 | |
184 | if ($num_starred > 0) $class .= "Unread"; | |
185 | ||
186 | printFeedEntry(-1, $class, "Starred articles", $num_starred, | |
4668523d | 187 | "images/mark_set.png", $link); |
48f0adb0 | 188 | |
4769ddaf | 189 | if (get_pref($link, 'ENABLE_LABELS')) { |
8143ae1f AD |
190 | |
191 | $result = db_query($link, "SELECT id,sql_exp,description FROM | |
4356293a | 192 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); |
8143ae1f AD |
193 | |
194 | if (db_num_rows($result) > 0) { | |
195 | print "<li><hr></li>"; | |
196 | } | |
197 | ||
198 | while ($line = db_fetch_assoc($result)) { | |
48f0adb0 | 199 | |
8143ae1f AD |
200 | error_reporting (0); |
201 | ||
4c193675 AD |
202 | $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries |
203 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND | |
204 | ttrss_user_entries.ref_id = ttrss_entries.id | |
655be073 | 205 | AND owner_uid = '$owner_uid'"); |
8143ae1f AD |
206 | |
207 | $count = db_fetch_result($tmp_result, 0, "count"); | |
208 | ||
3745788e | 209 | $class = "label"; |
8143ae1f AD |
210 | |
211 | if ($count > 0) { | |
212 | $class .= "Unread"; | |
213 | } | |
214 | ||
215 | error_reporting (E_ERROR | E_WARNING | E_PARSE); | |
216 | ||
217 | printFeedEntry(-$line["id"]-11, | |
4668523d | 218 | $class, $line["description"], $count, "images/label.png", $link); |
8143ae1f AD |
219 | |
220 | } | |
48f0adb0 AD |
221 | } |
222 | ||
8143ae1f AD |
223 | print "<li><hr></li>"; |
224 | ||
225 | $result = db_query($link, "SELECT *, | |
4c193675 AD |
226 | (SELECT count(id) FROM ttrss_entries,ttrss_user_entries |
227 | WHERE feed_id = ttrss_feeds.id AND | |
228 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
229 | owner_uid = '$owner_uid') AS total, | |
230 | (SELECT count(id) FROM ttrss_entries,ttrss_user_entries | |
b88917af | 231 | WHERE feed_id = ttrss_feeds.id AND unread = true |
4c193675 | 232 | AND ttrss_user_entries.ref_id = ttrss_entries.id |
b88917af | 233 | AND owner_uid = '$owner_uid') as unread |
4356293a | 234 | FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY title"); |
8143ae1f AD |
235 | |
236 | $actid = $_GET["actid"]; | |
237 | ||
238 | /* real feeds */ | |
239 | ||
240 | $lnum = 0; | |
241 | ||
242 | $total_unread = 0; | |
243 | ||
48f0adb0 | 244 | while ($line = db_fetch_assoc($result)) { |
8143ae1f AD |
245 | |
246 | $feed = $line["title"]; | |
247 | $feed_id = $line["id"]; | |
248 | ||
249 | $subop = $_GET["subop"]; | |
250 | ||
251 | $total = $line["total"]; | |
252 | $unread = $line["unread"]; | |
253 | ||
254 | // $class = ($lnum % 2) ? "even" : "odd"; | |
48f0adb0 | 255 | |
3745788e | 256 | $class = "feed"; |
8143ae1f AD |
257 | |
258 | if ($unread > 0) $class .= "Unread"; | |
259 | ||
260 | if ($actid == $feed_id) { | |
261 | $class .= "Selected"; | |
392d4563 | 262 | } |
48f0adb0 | 263 | |
8143ae1f AD |
264 | $total_unread += $unread; |
265 | ||
4668523d | 266 | printFeedEntry($feed_id, $class, $feed, $unread, "icons/$feed_id.ico", $link); |
8143ae1f AD |
267 | |
268 | ++$lnum; | |
48f0adb0 | 269 | } |
8143ae1f | 270 | } else { |
a1a8a2be | 271 | |
8143ae1f | 272 | // tags |
a1a8a2be | 273 | |
8143ae1f AD |
274 | $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count |
275 | FROM ttrss_tags,ttrss_entries WHERE | |
4356293a | 276 | post_id = ttrss_entries.id AND unread = true |
3b0948c4 | 277 | AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name |
8143ae1f | 278 | UNION |
3b0948c4 AD |
279 | select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid' |
280 | ORDER BY tag_name"); | |
8143ae1f AD |
281 | |
282 | $tags = array(); | |
283 | ||
284 | while ($line = db_fetch_assoc($result)) { | |
285 | $tags[$line["tag_name"]] += $line["count"]; | |
1a66d16e | 286 | } |
8143ae1f AD |
287 | |
288 | foreach (array_keys($tags) as $tag) { | |
289 | ||
290 | $unread = $tags[$tag]; | |
291 | ||
292 | $class = "odd"; | |
293 | ||
294 | if ($unread > 0) { | |
295 | $class .= "Unread"; | |
296 | } | |
297 | ||
4668523d | 298 | printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link); |
8143ae1f AD |
299 | |
300 | } | |
1a66d16e | 301 | |
e828e31e | 302 | } |
82baad4a | 303 | |
dc33ec95 | 304 | if (db_num_rows($result) == 0) { |
4356293a | 305 | print "<li>No tags/feeds to display.</li>"; |
dc33ec95 AD |
306 | } |
307 | ||
8143ae1f | 308 | print "</ul>"; |
1cd17194 | 309 | |
caa4e57f AD |
310 | print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>"; |
311 | ||
c3b81db0 AD |
312 | } |
313 | ||
314 | ||
315 | if ($op == "rpc") { | |
316 | ||
317 | $subop = $_GET["subop"]; | |
318 | ||
090e250b | 319 | if ($subop == "getLabelCounters") { |
8073cce7 | 320 | $aid = $_GET["aid"]; |
090e250b AD |
321 | print "<rpc-reply>"; |
322 | getLabelCounters($link); | |
8073cce7 AD |
323 | if ($aid) { |
324 | getFeedCounter($link, $aid); | |
325 | } | |
090e250b AD |
326 | print "</rpc-reply>"; |
327 | } | |
328 | ||
329 | if ($subop == "getFeedCounters") { | |
330 | print "<rpc-reply>"; | |
331 | getFeedCounters($link); | |
332 | print "</rpc-reply>"; | |
333 | } | |
334 | ||
335 | if ($subop == "getAllCounters") { | |
336 | print "<rpc-reply>"; | |
337 | getLabelCounters($link); | |
338 | getFeedCounters($link); | |
8143ae1f | 339 | getTagCounters($link); |
fc69e641 | 340 | getGlobalCounters($link); |
090e250b | 341 | print "</rpc-reply>"; |
090e250b AD |
342 | } |
343 | ||
f4c10d44 AD |
344 | if ($subop == "mark") { |
345 | $mark = $_GET["mark"]; | |
648472a7 | 346 | $id = db_escape_string($_GET["id"]); |
f4c10d44 AD |
347 | |
348 | if ($mark == "1") { | |
349 | $mark = "true"; | |
350 | } else { | |
351 | $mark = "false"; | |
352 | } | |
353 | ||
b5137506 AD |
354 | // FIXME this needs collision testing |
355 | ||
356 | $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark | |
357 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
f4c10d44 AD |
358 | } |
359 | ||
caa4e57f | 360 | if ($subop == "updateFeed") { |
648472a7 | 361 | $feed_id = db_escape_string($_GET["feed"]); |
9cfc649a | 362 | |
648472a7 | 363 | $result = db_query($link, |
caa4e57f | 364 | "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'"); |
9cfc649a | 365 | |
648472a7 AD |
366 | if (db_num_rows($result) > 0) { |
367 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
caa4e57f AD |
368 | // update_rss_feed($link, $feed_url, $feed_id); |
369 | } | |
9cfc649a | 370 | |
caa4e57f | 371 | print "DONE-$feed_id"; |
9cfc649a | 372 | |
caa4e57f | 373 | return; |
9cfc649a AD |
374 | } |
375 | ||
090e250b | 376 | if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") { |
c5142cca | 377 | |
c3b81db0 | 378 | update_all_feeds($link, true); |
c3b81db0 | 379 | |
ab3f3f72 AD |
380 | $omode = $_GET["omode"]; |
381 | ||
382 | if (!$omode) $omode = "tfl"; | |
383 | ||
090e250b | 384 | print "<rpc-reply>"; |
ab3f3f72 AD |
385 | if (strchr($omode, "l")) getLabelCounters($link); |
386 | if (strchr($omode, "f")) getFeedCounters($link); | |
387 | if (strchr($omode, "t")) getTagCounters($link); | |
fc69e641 | 388 | getGlobalCounters($link); |
090e250b | 389 | print "</rpc-reply>"; |
c3b81db0 AD |
390 | } |
391 | ||
392 | if ($subop == "catchupPage") { | |
393 | ||
394 | $ids = split(",", $_GET["ids"]); | |
395 | ||
396 | foreach ($ids as $id) { | |
397 | ||
648472a7 | 398 | db_query($link, "UPDATE ttrss_entries SET unread=false,last_read = NOW() |
c3b81db0 AD |
399 | WHERE id = '$id'"); |
400 | ||
401 | } | |
402 | ||
403 | print "Marked active page as read."; | |
404 | } | |
295f9b42 AD |
405 | |
406 | if ($subop == "sanityCheck") { | |
407 | ||
408 | $error_code = 0; | |
409 | ||
410 | $result = db_query($link, "SELECT schema_version FROM ttrss_version"); | |
411 | ||
412 | $schema_version = db_fetch_result($result, 0, "schema_version"); | |
413 | ||
414 | if ($schema_version != SCHEMA_VERSION) { | |
415 | $error_code = 5; | |
416 | } | |
417 | ||
418 | print "<error code='$error_code'/>"; | |
419 | } | |
fefa6ca3 AD |
420 | |
421 | if ($subop == "globalPurge") { | |
422 | ||
423 | print "<rpc-reply>"; | |
424 | global_purge_old_posts($link, true); | |
425 | print "</rpc-reply>"; | |
426 | ||
427 | } | |
428 | ||
c3b81db0 AD |
429 | } |
430 | ||
431 | if ($op == "feeds") { | |
432 | ||
8143ae1f AD |
433 | $tags = $_GET["tags"]; |
434 | ||
c3b81db0 AD |
435 | $subop = $_GET["subop"]; |
436 | ||
437 | if ($subop == "catchupAll") { | |
6d15e1ef AD |
438 | db_query($link, "UPDATE ttrss_entries SET |
439 | last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]); | |
c3b81db0 AD |
440 | } |
441 | ||
8143ae1f | 442 | outputFeedList($link, $tags); |
c3b81db0 | 443 | |
1cd17194 AD |
444 | } |
445 | ||
446 | if ($op == "view") { | |
447 | ||
d76a3b03 | 448 | $id = $_GET["id"]; |
8073cce7 | 449 | $feed_id = $_GET["feed"]; |
d76a3b03 | 450 | |
4c193675 AD |
451 | $result = db_query($link, "UPDATE ttrss_user_entries |
452 | SET unread = false,last_read = NOW() | |
453 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
a1a8a2be | 454 | |
70830c87 AD |
455 | $addheader = $_GET["addheader"]; |
456 | ||
648472a7 | 457 | $result = db_query($link, "SELECT title,link,content,feed_id,comments, |
b7f4bda2 | 458 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url |
4c193675 AD |
459 | FROM ttrss_entries,ttrss_user_entries |
460 | WHERE id = '$id' AND ref_id = id"); | |
1cd17194 | 461 | |
70830c87 | 462 | if ($addheader) { |
f0601b87 | 463 | print "<html><head> |
70830c87 AD |
464 | <title>Tiny Tiny RSS : Article $id</title> |
465 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
c05608c2 | 466 | <script type=\"text/javascript\" src=\"functions.js\"></script> |
70830c87 | 467 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
f0601b87 | 468 | </head><body>"; |
70830c87 AD |
469 | } |
470 | ||
d76a3b03 | 471 | if ($result) { |
1cd17194 | 472 | |
648472a7 | 473 | $line = db_fetch_assoc($result); |
1cd17194 | 474 | |
b7f4bda2 AD |
475 | if ($line["icon_url"]) { |
476 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
477 | } else { | |
478 | $feed_icon = " "; | |
479 | } | |
d76a3b03 | 480 | |
f7181e9b AD |
481 | if ($line["comments"] && $line["link"] != $line["comments"]) { |
482 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; | |
483 | } else { | |
484 | $entry_comments = ""; | |
485 | } | |
486 | ||
e828e31e AD |
487 | print "<div class=\"postReply\">"; |
488 | ||
489 | print "<div class=\"postHeader\"><table>"; | |
490 | ||
491 | print "<tr><td><b>Title:</b></td> | |
492 | <td width='100%'>" . $line["title"] . "</td></tr>"; | |
f7181e9b | 493 | |
e828e31e | 494 | print "<tr><td><b>Link:</b></td> |
f7181e9b AD |
495 | <td width='100%'> |
496 | <a href=\"" . $line["link"] . "\">".$line["link"]."</a> | |
497 | $entry_comments</td></tr>"; | |
e828e31e AD |
498 | |
499 | print "</table></div>"; | |
500 | ||
501 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
502 | print "<div class=\"postContent\">" . $line["content"] . "</div>"; | |
503 | ||
504 | print "</div>"; | |
505 | ||
090e250b | 506 | print "<script type=\"text/javascript\"> |
8143ae1f | 507 | update_label_counters('$feed_id'); |
090e250b | 508 | </script>"; |
d76a3b03 | 509 | } |
70830c87 AD |
510 | |
511 | if ($addheader) { | |
512 | print "</body></html>"; | |
513 | } | |
1cd17194 AD |
514 | } |
515 | ||
516 | if ($op == "viewfeed") { | |
517 | ||
518 | $feed = $_GET["feed"]; | |
d76a3b03 | 519 | $skip = $_GET["skip"]; |
476cac42 | 520 | $subop = $_GET["subop"]; |
f175937c | 521 | $view_mode = $_GET["view"]; |
f0601b87 | 522 | $addheader = $_GET["addheader"]; |
cb1083a1 | 523 | $limit = $_GET["limit"]; |
a1a8a2be | 524 | |
8d7008c7 AD |
525 | if (!$feed) { |
526 | print "Error: no feed to display."; | |
527 | return; | |
528 | } | |
529 | ||
ac53063a AD |
530 | if (!$skip) $skip = 0; |
531 | ||
476cac42 | 532 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 533 | |
f0601b87 AD |
534 | if ($addheader) { |
535 | print "<html><head> | |
ac43eba1 | 536 | <title>Tiny Tiny RSS : Feed $feed</title> |
430bf183 AD |
537 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
538 | ||
4769ddaf | 539 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
430bf183 AD |
540 | print "<link rel=\"stylesheet\" |
541 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
542 | ||
543 | } else { | |
544 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
545 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
546 | } | |
547 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
f0601b87 AD |
548 | <script type=\"text/javascript\" src=\"functions.js\"></script> |
549 | <script type=\"text/javascript\" src=\"viewfeed.js\"></script> | |
b623b3ed | 550 | </head><body onload='init()'>"; |
f0601b87 AD |
551 | } |
552 | ||
dcee8f61 AD |
553 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { |
554 | ||
555 | $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds | |
556 | WHERE id = '$feed'"); | |
557 | ||
558 | $feed_url = db_fetch_result($tmp_result, 0, "feed_url"); | |
559 | ||
560 | update_rss_feed($link, $feed_url, $feed); | |
561 | ||
562 | } | |
563 | ||
0e32076b | 564 | if ($subop == "MarkAllRead") { |
d76a3b03 | 565 | |
b5137506 AD |
566 | return; // FIXME disabled |
567 | ||
0e32076b AD |
568 | if (sprintf("%d", $feed) != 0) { |
569 | ||
570 | if ($feed > 0) { | |
571 | db_query($link, "UPDATE ttrss_entries | |
572 | SET unread = false,last_read = NOW() | |
254e0e4b | 573 | WHERE feed_id = '$feed'"); |
0e32076b AD |
574 | |
575 | } else if ($feed < 0 && $feed > -10) { // special, like starred | |
576 | ||
577 | if ($feed == -1) { | |
578 | db_query($link, "UPDATE ttrss_entries | |
579 | SET unread = false,last_read = NOW() | |
5859be02 | 580 | WHERE marked = true AND owner_uid = ".$_SESSION["uid"]); |
0e32076b AD |
581 | } |
582 | ||
583 | } else if ($feed < -10) { // label | |
584 | ||
7db95187 | 585 | $label_id = -$feed - 11; |
0e32076b | 586 | |
7db95187 AD |
587 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels |
588 | WHERE id = '$label_id'"); | |
589 | ||
590 | if ($tmp_result) { | |
591 | $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp"); | |
592 | ||
593 | db_query($link, "UPDATE ttrss_entries | |
594 | SET unread = false,last_read = NOW() | |
5859be02 | 595 | WHERE $sql_exp AND owner_uid = ".$_SESSION["uid"]); |
7db95187 | 596 | } |
254e0e4b | 597 | } |
0e32076b AD |
598 | } else { // tag |
599 | // FIXME, implement catchup for tags | |
a1a8a2be | 600 | } |
0e32076b | 601 | |
a1a8a2be | 602 | } |
d76a3b03 | 603 | |
175847de | 604 | print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">"; |
ac53063a | 605 | |
c374a3fe AD |
606 | $search = $_GET["search"]; |
607 | ||
52b51244 AD |
608 | $search_mode = $_GET["smode"]; |
609 | ||
f175937c | 610 | if ($search) { |
ac53063a AD |
611 | $search_query_part = "(upper(title) LIKE upper('%$search%') |
612 | OR content LIKE '%$search%') AND"; | |
f175937c AD |
613 | } else { |
614 | $search_query_part = ""; | |
615 | } | |
616 | ||
617 | $view_query_part = ""; | |
618 | ||
619 | if ($view_mode == "Starred") { | |
620 | $view_query_part = " marked = true AND "; | |
ac53063a AD |
621 | } |
622 | ||
ac43eba1 AD |
623 | if ($view_mode == "Unread") { |
624 | $view_query_part = " unread = true AND "; | |
625 | } | |
626 | ||
b5aa95e7 AD |
627 | if ($view_mode == "Unread or Starred") { |
628 | $view_query_part = " (unread = true OR marked = true) AND "; | |
629 | } | |
630 | ||
bdd01d3f AD |
631 | if ($view_mode == "Unread or Updated") { |
632 | $view_query_part = " (unread = true OR last_read is NULL) AND "; | |
633 | } | |
634 | ||
254e0e4b | 635 | /* $result = db_query($link, "SELECT count(id) AS total_entries |
36bf7496 AD |
636 | FROM ttrss_entries WHERE |
637 | $search_query_part | |
638 | feed_id = '$feed'"); | |
e6d1c0a0 | 639 | |
254e0e4b | 640 | $total_entries = db_fetch_result($result, 0, "total_entries"); */ |
e6d1c0a0 | 641 | |
648472a7 | 642 | /* $result = db_query("SELECT count(id) AS unread_entries |
ac43eba1 AD |
643 | FROM ttrss_entries WHERE |
644 | $search_query_part | |
645 | unread = true AND | |
646 | feed_id = '$feed'"); | |
647 | ||
648472a7 | 648 | $unread_entries = db_fetch_result($result, 0, "unread_entries"); */ |
ac43eba1 | 649 | |
8d7008c7 | 650 | if ($limit && $limit != "All") { |
82c9223c | 651 | $limit_query_part = "LIMIT " . $limit; |
ad3cb710 | 652 | } |
f0601b87 | 653 | |
254e0e4b AD |
654 | $vfeed_query_part = ""; |
655 | ||
52b51244 AD |
656 | // override query strategy and enable feed display when searching globally |
657 | if ($search_mode == "All feeds") { | |
658 | $query_strategy_part = "id > 0"; | |
659 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
660 | id = feed_id) as feed_title,"; | |
661 | } else if (sprintf("%d", $feed) == 0) { | |
8143ae1f AD |
662 | $query_strategy_part = "ttrss_entries.id > 0"; |
663 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
664 | id = feed_id) as feed_title,"; | |
665 | } else if ($feed >= 0) { | |
254e0e4b | 666 | $query_strategy_part = "feed_id = '$feed'"; |
48f0adb0 | 667 | } else if ($feed == -1) { // starred virtual feed |
254e0e4b | 668 | $query_strategy_part = "marked = true"; |
48f0adb0 AD |
669 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
670 | id = feed_id) as feed_title,"; | |
671 | } else if ($feed <= -10) { // labels | |
672 | $label_id = -$feed - 11; | |
673 | ||
674 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
675 | WHERE id = '$label_id'"); | |
676 | ||
677 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
678 | ||
254e0e4b AD |
679 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
680 | id = feed_id) as feed_title,"; | |
681 | } else { | |
48f0adb0 | 682 | $query_strategy_part = "id > 0"; // dumb |
254e0e4b AD |
683 | } |
684 | ||
52b51244 | 685 | |
f99321a3 AD |
686 | $order_by = "updated DESC"; |
687 | ||
688 | // if ($feed < -10) { | |
689 | // $order_by = "feed_id,updated DESC"; | |
690 | // } | |
691 | ||
48f0adb0 AD |
692 | if ($feed < -10) error_reporting (0); |
693 | ||
8143ae1f AD |
694 | if (sprintf("%d", $feed) != 0) { |
695 | ||
696 | $result = db_query($link, "SELECT | |
697 | id,title,updated,unread,feed_id,marked,link,last_read, | |
698 | SUBSTRING(last_read,1,19) as last_read_noms, | |
699 | $vfeed_query_part | |
700 | SUBSTRING(updated,1,19) as updated_noms | |
701 | FROM | |
4c193675 | 702 | ttrss_entries,ttrss_user_entries |
8143ae1f | 703 | WHERE |
4c193675 | 704 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
aee86c2e | 705 | owner_uid = '".$_SESSION["uid"]."' AND |
8143ae1f AD |
706 | $search_query_part |
707 | $view_query_part | |
708 | $query_strategy_part ORDER BY $order_by | |
709 | $limit_query_part"); | |
710 | ||
711 | } else { | |
712 | // browsing by tag | |
713 | ||
714 | $result = db_query($link, "SELECT | |
715 | ttrss_entries.id as id,title,updated,unread,feed_id, | |
716 | marked,link,last_read, | |
c05a19f3 | 717 | SUBSTRING(last_read,1,19) as last_read_noms, |
254e0e4b | 718 | $vfeed_query_part |
c05a19f3 | 719 | SUBSTRING(updated,1,19) as updated_noms |
8143ae1f AD |
720 | FROM |
721 | ttrss_entries,ttrss_tags | |
722 | WHERE | |
aee86c2e | 723 | ttrss_entries.owner_uid = '".$_SESSION["uid"]."' AND |
8143ae1f AD |
724 | post_id = ttrss_entries.id AND tag_name = '$feed' AND |
725 | $view_query_part | |
726 | $search_query_part | |
727 | $query_strategy_part ORDER BY $order_by | |
728 | $limit_query_part"); | |
729 | } | |
d76a3b03 | 730 | |
48f0adb0 AD |
731 | if (!$result) { |
732 | print "<tr><td colspan='4' align='center'> | |
733 | Could not display feed (query failed). Please check match syntax or local configuration.</td></tr>"; | |
734 | return; | |
735 | } | |
736 | ||
a1a8a2be | 737 | $lnum = 0; |
48f0adb0 AD |
738 | |
739 | error_reporting (E_ERROR | E_WARNING | E_PARSE); | |
740 | ||
e1123aee | 741 | $num_unread = 0; |
d76a3b03 | 742 | |
648472a7 | 743 | while ($line = db_fetch_assoc($result)) { |
d76a3b03 | 744 | |
a1a8a2be | 745 | $class = ($lnum % 2) ? "even" : "odd"; |
d76a3b03 | 746 | |
ad99045e AD |
747 | $id = $line["id"]; |
748 | $feed_id = $line["feed_id"]; | |
749 | ||
c43f77f5 | 750 | // printf("L %d (%s) > U %d (%s) = %d<br>", |
c05a19f3 | 751 | // strtotime($line["last_read_noms"]), $line["last_read_noms"], |
c43f77f5 AD |
752 | // strtotime($line["updated"]), $line["updated"], |
753 | // strtotime($line["last_read"]) >= strtotime($line["updated"])); | |
754 | ||
ecb14114 | 755 | /* if ($line["last_read"] != "" && $line["updated"] != "" && |
c05a19f3 | 756 | strtotime($line["last_read_noms"]) < strtotime($line["updated_noms"])) { |
c43f77f5 AD |
757 | |
758 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
759 | alt=\"Updated\">"; | |
760 | ||
761 | } else { | |
762 | ||
5bfef089 | 763 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" |
c43f77f5 AD |
764 | alt=\"Updated\">"; |
765 | ||
ecb14114 AD |
766 | } */ |
767 | ||
4cc6ea5e AD |
768 | if ($line["last_read"] == "" && |
769 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
770 | ||
ecb14114 AD |
771 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" |
772 | alt=\"Updated\">"; | |
773 | } else { | |
774 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
775 | alt=\"Updated\">"; | |
c43f77f5 | 776 | } |
b197f117 | 777 | |
8158c57a | 778 | if ($line["unread"] == "t" || $line["unread"] == "1") { |
a1a8a2be | 779 | $class .= "Unread"; |
e1123aee AD |
780 | ++$num_unread; |
781 | } | |
d76a3b03 | 782 | |
8158c57a | 783 | if ($line["marked"] == "t" || $line["marked"] == "1") { |
f4c10d44 AD |
784 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" |
785 | alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>"; | |
786 | } else { | |
787 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
788 | alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>"; | |
789 | } | |
790 | ||
ac43eba1 | 791 | $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" . |
b197f117 AD |
792 | $line["title"] . "</a>"; |
793 | ||
d5224f0d | 794 | print "<tr class='$class' id='RROW-$id'>"; |
5f89f780 | 795 | // onclick=\"javascript:view($id,$feed_id)\"> |
b197f117 | 796 | |
8d7008c7 AD |
797 | print "<td valign='center' align='center'>$update_pic</td>"; |
798 | print "<td valign='center' align='center'>$marked_pic</td>"; | |
b197f117 | 799 | |
8d7008c7 | 800 | print "<td width='25%'> |
a3ee2a38 | 801 | <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>"; |
254e0e4b AD |
802 | |
803 | if ($line["feed_title"]) { | |
804 | print "<td width='50%'>$content_link</td>"; | |
2db4190c AD |
805 | print "<td width='20%'> |
806 | <a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>"; | |
254e0e4b AD |
807 | } else { |
808 | print "<td width='70%'>$content_link</td>"; | |
809 | } | |
d76a3b03 | 810 | |
a1a8a2be | 811 | print "</tr>"; |
d76a3b03 | 812 | |
a1a8a2be AD |
813 | ++$lnum; |
814 | } | |
d76a3b03 | 815 | |
ac53063a | 816 | if ($lnum == 0) { |
a82065a1 | 817 | print "<tr><td align='center'>No articles found.</td></tr>"; |
047bae73 | 818 | } |
a2015351 | 819 | |
a1a8a2be | 820 | print "</table>"; |
6113ef7d AD |
821 | |
822 | print "<script type=\"text/javascript\"> | |
bb7cface | 823 | document.onkeydown = hotkey_handler; |
8143ae1f | 824 | update_label_counters('$feed'); |
6113ef7d | 825 | </script>"; |
d76a3b03 | 826 | |
f0601b87 AD |
827 | if ($addheader) { |
828 | print "</body></html>"; | |
829 | } | |
830 | ||
1cd17194 AD |
831 | } |
832 | ||
0e091d38 | 833 | if ($op == "pref-rpc") { |
331900c6 | 834 | |
0e091d38 | 835 | $subop = $_GET["subop"]; |
331900c6 | 836 | |
83fe4d6d AD |
837 | if ($subop == "unread") { |
838 | $ids = split(",", $_GET["ids"]); | |
839 | foreach ($ids as $id) { | |
648472a7 | 840 | db_query($link, "UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'"); |
83fe4d6d | 841 | } |
0e091d38 AD |
842 | |
843 | print "Marked selected feeds as read."; | |
83fe4d6d AD |
844 | } |
845 | ||
846 | if ($subop == "read") { | |
847 | $ids = split(",", $_GET["ids"]); | |
848 | foreach ($ids as $id) { | |
648472a7 | 849 | db_query($link, "UPDATE ttrss_entries |
b197f117 | 850 | SET unread = false,last_read = NOW() WHERE feed_id = '$id'"); |
83fe4d6d | 851 | } |
0e091d38 AD |
852 | |
853 | print "Marked selected feeds as unread."; | |
854 | ||
855 | } | |
856 | ||
857 | } | |
858 | ||
859 | if ($op == "pref-feeds") { | |
860 | ||
861 | $subop = $_GET["subop"]; | |
862 | ||
508a81e1 | 863 | if ($subop == "editSave") { |
648472a7 AD |
864 | $feed_title = db_escape_string($_GET["t"]); |
865 | $feed_link = db_escape_string($_GET["l"]); | |
d148926e | 866 | $upd_intl = db_escape_string($_GET["ui"]); |
5d73494a | 867 | $purge_intl = db_escape_string($_GET["pi"]); |
508a81e1 AD |
868 | $feed_id = $_GET["id"]; |
869 | ||
d148926e AD |
870 | if (strtoupper($upd_intl) == "DEFAULT") |
871 | $upd_intl = 0; | |
872 | ||
5d73494a AD |
873 | if (strtoupper($purge_intl) == "DEFAULT") |
874 | $purge_intl = 0; | |
875 | ||
140aae81 AD |
876 | if (strtoupper($purge_intl) == "DISABLED") |
877 | $purge_intl = -1; | |
878 | ||
648472a7 | 879 | $result = db_query($link, "UPDATE ttrss_feeds SET |
d148926e | 880 | title = '$feed_title', feed_url = '$feed_link', |
5d73494a AD |
881 | update_interval = '$upd_intl', |
882 | purge_interval = '$purge_intl' | |
883 | WHERE id = '$feed_id'"); | |
508a81e1 | 884 | |
83fe4d6d AD |
885 | } |
886 | ||
331900c6 | 887 | if ($subop == "remove") { |
331900c6 | 888 | |
b0b4abcf | 889 | if (!WEB_DEMO_MODE) { |
331900c6 | 890 | |
b0b4abcf AD |
891 | $ids = split(",", $_GET["ids"]); |
892 | ||
893 | foreach ($ids as $id) { | |
648472a7 | 894 | db_query($link, "DELETE FROM ttrss_feeds WHERE id = '$id'"); |
4769ddaf | 895 | |
273a2f6b | 896 | $icons_dir = ICONS_DIR; |
d5caaae5 | 897 | |
4769ddaf AD |
898 | if (file_exists($icons_dir . "/$id.ico")) { |
899 | unlink($icons_dir . "/$id.ico"); | |
d5caaae5 | 900 | } |
b0b4abcf | 901 | } |
331900c6 AD |
902 | } |
903 | } | |
904 | ||
905 | if ($subop == "add") { | |
b0b4abcf AD |
906 | |
907 | if (!WEB_DEMO_MODE) { | |
331900c6 | 908 | |
648472a7 | 909 | $feed_link = db_escape_string($_GET["link"]); |
b0b4abcf | 910 | |
648472a7 | 911 | $result = db_query($link, |
4356293a | 912 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title) VALUES ('".$_SESSION["uid"]."', '$feed_link', '')"); |
331900c6 | 913 | |
648472a7 | 914 | $result = db_query($link, |
e9c54861 | 915 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'"); |
331900c6 | 916 | |
648472a7 | 917 | $feed_id = db_fetch_result($result, 0, "id"); |
331900c6 | 918 | |
b0b4abcf AD |
919 | if ($feed_id) { |
920 | update_rss_feed($link, $feed_link, $feed_id); | |
921 | } | |
922 | } | |
331900c6 | 923 | } |
a0d53889 | 924 | |
ab3d0b99 AD |
925 | $result = db_query($link, "SELECT id,title,feed_url,last_error |
926 | FROM ttrss_feeds WHERE last_error != ''"); | |
927 | ||
928 | if (db_num_rows($result) > 0) { | |
929 | ||
930 | print "<div class=\"warning\">"; | |
931 | ||
932 | print "<b>Feeds with update errors:</b>"; | |
933 | ||
934 | print "<ul class=\"nomarks\">"; | |
935 | ||
936 | while ($line = db_fetch_assoc($result)) { | |
937 | print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " . | |
938 | $line["last_error"]; | |
939 | } | |
940 | ||
941 | print "</ul>"; | |
942 | print "</div>"; | |
943 | ||
944 | } | |
945 | ||
a0d53889 AD |
946 | print "<table class=\"prefAddFeed\"><tr> |
947 | <td><input id=\"fadd_link\"></td> | |
948 | <td colspan=\"4\" align=\"right\"> | |
949 | <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr> | |
950 | </table>"; | |
951 | ||
648472a7 | 952 | $result = db_query($link, "SELECT |
d148926e | 953 | id,title,feed_url,substring(last_updated,1,16) as last_updated, |
5d73494a | 954 | update_interval,purge_interval |
c0e5a40e | 955 | FROM |
4356293a | 956 | ttrss_feeds WHERE owner_uid = '".$_SESSION["uid"]."' ORDER by title"); |
1cd17194 | 957 | |
331900c6 | 958 | print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">"; |
007bda35 | 959 | print "<tr class=\"title\"> |
5d73494a AD |
960 | <td> </td><td>Select</td><td width=\"30%\">Title</td> |
961 | <td width=\"30%\">Link</td> | |
962 | <td width=\"10%\">Update Interval</td> | |
963 | <td width=\"10%\">Purge Days</td> | |
d148926e | 964 | <td>Last updated</td></tr>"; |
007bda35 AD |
965 | |
966 | $lnum = 0; | |
967 | ||
648472a7 | 968 | while ($line = db_fetch_assoc($result)) { |
007bda35 AD |
969 | |
970 | $class = ($lnum % 2) ? "even" : "odd"; | |
9b307248 | 971 | |
331900c6 | 972 | $feed_id = $line["id"]; |
603c27f8 AD |
973 | |
974 | $edit_feed_id = $_GET["id"]; | |
975 | ||
9b307248 AD |
976 | if ($subop == "edit" && $feed_id != $edit_feed_id) { |
977 | $class .= "Grayed"; | |
978 | } | |
979 | ||
331900c6 | 980 | print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; |
007bda35 | 981 | |
273a2f6b | 982 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
c0e5a40e AD |
983 | |
984 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
985 | $feed_icon = "<img width=\"16\" height=\"16\" | |
273a2f6b | 986 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; |
c0e5a40e AD |
987 | } else { |
988 | $feed_icon = " "; | |
989 | } | |
990 | print "<td align='center'>$feed_icon</td>"; | |
991 | ||
6e0584e9 AD |
992 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); |
993 | $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); | |
994 | ||
9b307248 | 995 | if (!$edit_feed_id || $subop != "edit") { |
603c27f8 AD |
996 | |
997 | print "<td><input onclick='toggleSelectRow(this);' | |
331900c6 | 998 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
603c27f8 AD |
999 | |
1000 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
5d73494a | 1001 | $edit_title . "</a></td>"; |
603c27f8 | 1002 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
5d73494a | 1003 | $edit_link . "</a></td>"; |
d148926e AD |
1004 | |
1005 | if ($line["update_interval"] == "0") | |
1006 | $line["update_interval"] = "Default"; | |
1007 | ||
5d73494a AD |
1008 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
1009 | $line["update_interval"] . "</a></td>"; | |
d148926e | 1010 | |
5d73494a AD |
1011 | if ($line["purge_interval"] == "0") |
1012 | $line["purge_interval"] = "Default"; | |
1013 | ||
140aae81 AD |
1014 | if ($line["purge_interval"] < 0) |
1015 | $line["purge_interval"] = "Disabled"; | |
1016 | ||
5d73494a AD |
1017 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
1018 | $line["purge_interval"] . "</a></td>"; | |
9b307248 AD |
1019 | |
1020 | } else if ($feed_id != $edit_feed_id) { | |
1021 | ||
e9c54861 AD |
1022 | print "<td><input disabled=\"true\" type=\"checkbox\" |
1023 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
9b307248 | 1024 | |
6e0584e9 AD |
1025 | print "<td>$edit_title</td>"; |
1026 | print "<td>$edit_link</td>"; | |
9b307248 | 1027 | |
d148926e AD |
1028 | if ($line["update_interval"] == "0") |
1029 | $line["update_interval"] = "Default"; | |
1030 | ||
1031 | print "<td>" . $line["update_interval"] . "</td>"; | |
1032 | ||
5d73494a AD |
1033 | if ($line["purge_interval"] == "0") |
1034 | $line["purge_interval"] = "Default"; | |
1035 | ||
140aae81 AD |
1036 | if ($line["purge_interval"] < 0) |
1037 | $line["purge_interval"] = "Disabled"; | |
1038 | ||
5d73494a AD |
1039 | print "<td>" . $line["purge_interval"] . "</td>"; |
1040 | ||
603c27f8 AD |
1041 | } else { |
1042 | ||
e6cb77a0 | 1043 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; |
603c27f8 | 1044 | |
6e0584e9 AD |
1045 | print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>"; |
1046 | print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>"; | |
d148926e | 1047 | print "<td><input id=\"iedit_updintl\" value=\"".$line["update_interval"]."\"></td>"; |
5d73494a | 1048 | print "<td><input id=\"iedit_purgintl\" value=\"".$line["purge_interval"]."\"></td>"; |
d148926e | 1049 | |
603c27f8 | 1050 | } |
0afbd851 AD |
1051 | |
1052 | if (!$line["last_updated"]) $line["last_updated"] = "Never"; | |
1053 | ||
007bda35 | 1054 | print "<td>" . $line["last_updated"] . "</td>"; |
603c27f8 | 1055 | |
007bda35 AD |
1056 | print "</tr>"; |
1057 | ||
1058 | ++$lnum; | |
1059 | } | |
1060 | ||
0afbd851 AD |
1061 | if ($lnum == 0) { |
1062 | print "<tr><td colspan=\"5\" align=\"center\">No feeds defined.</td></tr>"; | |
1063 | } | |
1064 | ||
007bda35 AD |
1065 | print "</table>"; |
1066 | ||
603c27f8 AD |
1067 | print "<p>"; |
1068 | ||
1069 | if ($subop == "edit") { | |
1070 | print "Edit feed: | |
e828e31e AD |
1071 | <input type=\"submit\" class=\"button\" |
1072 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> | |
1073 | <input type=\"submit\" class=\"button\" | |
8158c57a | 1074 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
603c27f8 AD |
1075 | } else { |
1076 | ||
603c27f8 AD |
1077 | print " |
1078 | Selection: | |
e828e31e AD |
1079 | <input type=\"submit\" class=\"button\" |
1080 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> | |
1081 | <input type=\"submit\" class=\"button\" | |
1082 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
1083 | ||
4769ddaf | 1084 | if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) { |
f92db4f5 | 1085 | print " |
e828e31e AD |
1086 | <input type=\"submit\" class=\"button\" |
1087 | onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\"> | |
1088 | <input type=\"submit\" class=\"button\" | |
1089 | onclick=\"javascript:unreadSelectedFeeds()\" value=\"Mark as unread\"> "; | |
f92db4f5 AD |
1090 | } |
1091 | print " | |
e828e31e AD |
1092 | All feeds: |
1093 | <input type=\"submit\" | |
8158c57a | 1094 | class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">"; |
10c5820d | 1095 | |
603c27f8 AD |
1096 | } |
1097 | ||
f5a50b25 AD |
1098 | print "<h3>OPML Import</h3> |
1099 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> | |
1100 | File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
1101 | <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\" | |
1102 | type=\"submit\" value=\"Import\"> | |
1103 | </form>"; | |
1104 | ||
007bda35 AD |
1105 | } |
1106 | ||
a0d53889 AD |
1107 | if ($op == "pref-filters") { |
1108 | ||
1109 | $subop = $_GET["subop"]; | |
1110 | ||
1111 | if ($subop == "editSave") { | |
a0d53889 | 1112 | |
648472a7 AD |
1113 | $regexp = db_escape_string($_GET["r"]); |
1114 | $descr = db_escape_string($_GET["d"]); | |
1115 | $match = db_escape_string($_GET["m"]); | |
1116 | $filter_id = db_escape_string($_GET["id"]); | |
0afbd851 | 1117 | |
648472a7 | 1118 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 1119 | reg_exp = '$regexp', |
0afbd851 AD |
1120 | description = '$descr', |
1121 | filter_type = (SELECT id FROM ttrss_filter_types WHERE | |
1122 | description = '$match') | |
1123 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
1124 | } |
1125 | ||
1126 | if ($subop == "remove") { | |
1127 | ||
1128 | if (!WEB_DEMO_MODE) { | |
1129 | ||
1130 | $ids = split(",", $_GET["ids"]); | |
1131 | ||
1132 | foreach ($ids as $id) { | |
648472a7 | 1133 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
1134 | |
1135 | } | |
1136 | } | |
1137 | } | |
1138 | ||
1139 | if ($subop == "add") { | |
1140 | ||
de435974 | 1141 | if (!WEB_DEMO_MODE) { |
a0d53889 | 1142 | |
8158c57a | 1143 | $regexp = db_escape_string($_GET["regexp"]); |
648472a7 | 1144 | $match = db_escape_string($_GET["match"]); |
a0d53889 | 1145 | |
648472a7 | 1146 | $result = db_query($link, |
4356293a | 1147 | "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid) VALUES |
de435974 | 1148 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
4356293a | 1149 | description = '$match'),'".$_SESSION["uid"]."')"); |
de435974 | 1150 | } |
a0d53889 AD |
1151 | } |
1152 | ||
648472a7 | 1153 | $result = db_query($link, "SELECT description |
a0d53889 AD |
1154 | FROM ttrss_filter_types ORDER BY description"); |
1155 | ||
1156 | $filter_types = array(); | |
1157 | ||
648472a7 | 1158 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
1159 | array_push($filter_types, $line["description"]); |
1160 | } | |
1161 | ||
1162 | print "<table class=\"prefAddFeed\"><tr> | |
ea6774cf | 1163 | <td><input id=\"fadd_regexp\"></td> |
a0d53889 | 1164 | <td>"; |
bdc00fe0 | 1165 | print_select("fadd_match", "Title", $filter_types); |
a0d53889 AD |
1166 | |
1167 | print"</td><td colspan=\"4\" align=\"right\"> | |
1168 | <a class=\"button\" href=\"javascript:addFilter()\">Add filter</a></td></tr> | |
1169 | </table>"; | |
1170 | ||
648472a7 | 1171 | $result = db_query($link, "SELECT |
4b3dff6e | 1172 | id,reg_exp,description, |
a0d53889 AD |
1173 | (SELECT name FROM ttrss_filter_types WHERE |
1174 | id = filter_type) as filter_type_name, | |
1175 | (SELECT description FROM ttrss_filter_types | |
1176 | WHERE id = filter_type) as filter_type_descr | |
1177 | FROM | |
4356293a AD |
1178 | ttrss_filters |
1179 | WHERE | |
1180 | owner_uid = ".$_SESSION["uid"]." | |
1181 | ORDER by reg_exp"); | |
a0d53889 AD |
1182 | |
1183 | print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">"; | |
1184 | ||
1185 | print "<tr class=\"title\"> | |
0afbd851 AD |
1186 | <td width=\"5%\">Select</td><td width=\"40%\">Filter expression</td> |
1187 | <td width=\"40%\">Description</td><td width=\"10%\">Match</td></tr>"; | |
a0d53889 AD |
1188 | |
1189 | $lnum = 0; | |
1190 | ||
648472a7 | 1191 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
1192 | |
1193 | $class = ($lnum % 2) ? "even" : "odd"; | |
1194 | ||
1195 | $filter_id = $line["id"]; | |
1196 | $edit_filter_id = $_GET["id"]; | |
1197 | ||
1198 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
1199 | $class .= "Grayed"; | |
1200 | } | |
1201 | ||
1202 | print "<tr class=\"$class\" id=\"FILRR-$filter_id\">"; | |
1203 | ||
4b3dff6e | 1204 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); |
ea6774cf AD |
1205 | $line["description"] = htmlspecialchars($line["description"]); |
1206 | ||
a0d53889 AD |
1207 | if (!$edit_filter_id || $subop != "edit") { |
1208 | ||
0afbd851 AD |
1209 | if (!$line["description"]) $line["description"] = "[No description]"; |
1210 | ||
a0d53889 AD |
1211 | print "<td><input onclick='toggleSelectRow(this);' |
1212 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; | |
1213 | ||
1214 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
4b3dff6e | 1215 | $line["reg_exp"] . "</td>"; |
a0d53889 AD |
1216 | |
1217 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
1218 | $line["description"] . "</td>"; | |
1219 | ||
1220 | print "<td>".$line["filter_type_descr"]."</td>"; | |
1221 | ||
1222 | } else if ($filter_id != $edit_filter_id) { | |
1223 | ||
0afbd851 AD |
1224 | if (!$line["description"]) $line["description"] = "[No description]"; |
1225 | ||
a0d53889 AD |
1226 | print "<td><input disabled=\"true\" type=\"checkbox\" |
1227 | id=\"FICHK-".$line["id"]."\"></td>"; | |
1228 | ||
4b3dff6e | 1229 | print "<td>".$line["reg_exp"]."</td>"; |
a0d53889 AD |
1230 | print "<td>".$line["description"]."</td>"; |
1231 | print "<td>".$line["filter_type_descr"]."</td>"; | |
1232 | ||
1233 | } else { | |
1234 | ||
e6cb77a0 | 1235 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; |
a0d53889 | 1236 | |
4b3dff6e | 1237 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. |
a0d53889 AD |
1238 | "\"></td>"; |
1239 | ||
1240 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
1241 | "\"></td>"; | |
1242 | ||
1243 | print "<td>"; | |
1244 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
1245 | print "</td>"; | |
1246 | ||
1247 | } | |
1248 | ||
1249 | ||
1250 | print "</tr>"; | |
1251 | ||
1252 | ++$lnum; | |
1253 | } | |
1254 | ||
0afbd851 AD |
1255 | if ($lnum == 0) { |
1256 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
1257 | } | |
1258 | ||
a0d53889 AD |
1259 | print "</table>"; |
1260 | ||
1261 | print "<p>"; | |
1262 | ||
1263 | if ($subop == "edit") { | |
e828e31e AD |
1264 | print "Edit feed: |
1265 | <input type=\"submit\" class=\"button\" | |
1266 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\"> | |
1267 | <input type=\"submit\" class=\"button\" | |
1268 | onclick=\"javascript:filterEditSave()\" value=\"Save\">"; | |
a0d53889 AD |
1269 | |
1270 | } else { | |
1271 | ||
1272 | print " | |
e828e31e AD |
1273 | Selection: |
1274 | <input type=\"submit\" class=\"button\" | |
1275 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> | |
1276 | <input type=\"submit\" class=\"button\" | |
1277 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; | |
a0d53889 AD |
1278 | } |
1279 | } | |
1280 | ||
48f0adb0 AD |
1281 | if ($op == "pref-labels") { |
1282 | ||
1283 | $subop = $_GET["subop"]; | |
1284 | ||
1285 | if ($subop == "editSave") { | |
1286 | ||
1287 | $sql_exp = $_GET["s"]; | |
1288 | $descr = $_GET["d"]; | |
1289 | $label_id = db_escape_string($_GET["id"]); | |
1290 | ||
1291 | // print "$sql_exp : $descr : $label_id"; | |
1292 | ||
1293 | $result = db_query($link, "UPDATE ttrss_labels SET | |
1294 | sql_exp = '$sql_exp', | |
1295 | description = '$descr' | |
1296 | WHERE id = '$label_id'"); | |
1297 | } | |
1298 | ||
1299 | if ($subop == "remove") { | |
1300 | ||
1301 | if (!WEB_DEMO_MODE) { | |
1302 | ||
1303 | $ids = split(",", $_GET["ids"]); | |
1304 | ||
1305 | foreach ($ids as $id) { | |
1306 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
1307 | ||
1308 | } | |
1309 | } | |
1310 | } | |
1311 | ||
1312 | if ($subop == "add") { | |
1313 | ||
1314 | if (!WEB_DEMO_MODE) { | |
1315 | ||
1316 | $exp = $_GET["exp"]; | |
1317 | ||
1318 | $result = db_query($link, | |
4356293a AD |
1319 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) |
1320 | VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); | |
48f0adb0 AD |
1321 | } |
1322 | } | |
1323 | ||
1324 | print "<table class=\"prefAddFeed\"><tr> | |
1325 | <td><input id=\"ladd_expr\"></td>"; | |
1326 | ||
1327 | print"<td colspan=\"4\" align=\"right\"> | |
1328 | <a class=\"button\" href=\"javascript:addLabel()\">Add label</a></td></tr> | |
1329 | </table>"; | |
1330 | ||
1331 | $result = db_query($link, "SELECT | |
1332 | id,sql_exp,description | |
1333 | FROM | |
4356293a AD |
1334 | ttrss_labels |
1335 | WHERE | |
1336 | owner_uid = ".$_SESSION["uid"]." | |
1337 | ORDER by description"); | |
48f0adb0 AD |
1338 | |
1339 | print "<p><table width=\"100%\" class=\"prefLabelList\" id=\"prefLabelList\">"; | |
1340 | ||
1341 | print "<tr class=\"title\"> | |
7dc66a61 AD |
1342 | <td width=\"5%\">Select</td><td width=\"40%\">SQL expression |
1343 | <a class=\"helpLink\" href=\"javascript:popupHelp(1)\">(?)</a> | |
1344 | </td> | |
48f0adb0 AD |
1345 | <td width=\"40%\">Caption</td></tr>"; |
1346 | ||
1347 | $lnum = 0; | |
1348 | ||
1349 | while ($line = db_fetch_assoc($result)) { | |
1350 | ||
1351 | $class = ($lnum % 2) ? "even" : "odd"; | |
1352 | ||
1353 | $label_id = $line["id"]; | |
1354 | $edit_label_id = $_GET["id"]; | |
1355 | ||
1356 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
1357 | $class .= "Grayed"; | |
1358 | } | |
1359 | ||
1360 | print "<tr class=\"$class\" id=\"LILRR-$label_id\">"; | |
1361 | ||
1362 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
1363 | $line["description"] = htmlspecialchars($line["description"]); | |
1364 | ||
1365 | if (!$edit_label_id || $subop != "edit") { | |
1366 | ||
1367 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
1368 | ||
1369 | print "<td><input onclick='toggleSelectRow(this);' | |
1370 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; | |
1371 | ||
1372 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
1373 | $line["sql_exp"] . "</td>"; | |
1374 | ||
1375 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
1376 | $line["description"] . "</td>"; | |
1377 | ||
1378 | } else if ($label_id != $edit_label_id) { | |
1379 | ||
1380 | if (!$line["description"]) $line["description"] = "[No description]"; | |
1381 | ||
1382 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1383 | id=\"LICHK-".$line["id"]."\"></td>"; | |
1384 | ||
1385 | print "<td>".$line["sql_exp"]."</td>"; | |
1386 | print "<td>".$line["description"]."</td>"; | |
1387 | ||
1388 | } else { | |
1389 | ||
e6cb77a0 | 1390 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; |
48f0adb0 AD |
1391 | |
1392 | print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. | |
1393 | "\"></td>"; | |
1394 | ||
1395 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
1396 | "\"></td>"; | |
1397 | ||
1398 | } | |
1399 | ||
1400 | ||
1401 | print "</tr>"; | |
1402 | ||
1403 | ++$lnum; | |
1404 | } | |
1405 | ||
1406 | if ($lnum == 0) { | |
1407 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
1408 | } | |
1409 | ||
1410 | print "</table>"; | |
1411 | ||
1412 | print "<p>"; | |
1413 | ||
1414 | if ($subop == "edit") { | |
1415 | print "Edit label: | |
1416 | <input type=\"submit\" class=\"button\" | |
1417 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\"> | |
1418 | <input type=\"submit\" class=\"button\" | |
1419 | onclick=\"javascript:labelEditSave()\" value=\"Save\">"; | |
1420 | ||
1421 | } else { | |
1422 | ||
1423 | print " | |
1424 | Selection: | |
1425 | <input type=\"submit\" class=\"button\" | |
1426 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> | |
1427 | <input type=\"submit\" class=\"button\" | |
1428 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; | |
1429 | } | |
1430 | } | |
1431 | ||
e828e31e AD |
1432 | if ($op == "error") { |
1433 | print "<div width=\"100%\" align='center'>"; | |
1434 | $msg = $_GET["msg"]; | |
1435 | print $msg; | |
1436 | print "</div>"; | |
1437 | } | |
1438 | ||
7dc66a61 AD |
1439 | if ($op == "help") { |
1440 | print "<html><head> | |
1441 | <title>Tiny Tiny RSS : Help</title> | |
1442 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
1443 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
7dc66a61 AD |
1444 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
1445 | </head><body>"; | |
1446 | ||
1447 | $tid = sprintf("%d", $_GET["tid"]); | |
1448 | ||
1449 | /* FIXME this badly needs real implementation */ | |
1450 | ||
1451 | print "<div class='helpResponse'>"; | |
1452 | ||
1453 | ?> | |
1454 | ||
1455 | <h1>Help for SQL expressions</h1> | |
1456 | ||
1457 | <h2>Description</h2> | |
1458 | ||
1459 | <p>The «SQL expression» is added to WHERE clause of | |
d1f948d1 | 1460 | view feed query. You can match on ttrss_entries table fields |
7dc66a61 AD |
1461 | and even use subselect to query additional information. This |
1462 | functionality is considered to be advanced and requires basic | |
1463 | understanding of SQL.</p> | |
1464 | ||
1465 | <h2>Examples</h2> | |
1466 | ||
1467 | <pre>unread = true</pre> | |
1468 | ||
1469 | Matches all unread articles | |
1470 | ||
1471 | <pre>title like '%Linux%'</pre> | |
1472 | ||
1473 | Matches all articles which mention Linux in the title. You get the idea. | |
1474 | ||
1475 | <p>See the database schema included in the distribution package for gruesome | |
1476 | details.</p> | |
1477 | ||
1478 | <? | |
1479 | ||
1480 | print "<div align='center'> | |
1481 | <a class=\"helpLink\" | |
1482 | href=\"javascript:window.close()\">(Close this window)</a></div>"; | |
1483 | ||
1484 | print "</div>"; | |
1485 | ||
1486 | print "</body></html>"; | |
1487 | ||
1488 | } | |
1489 | ||
f84a97a3 AD |
1490 | if ($op == "dlg") { |
1491 | $id = $_GET["id"]; | |
6de5d056 | 1492 | $param = $_GET["param"]; |
f84a97a3 AD |
1493 | |
1494 | if ($id == "quickAddFeed") { | |
033e47e0 AD |
1495 | print "Feed URL: <input |
1496 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
1497 | id=\"qafInput\"> | |
f84a97a3 AD |
1498 | <input class=\"button\" |
1499 | type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\"> | |
1500 | <input class=\"button\" | |
1501 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
1502 | value=\"Cancel\">"; | |
1503 | } | |
6de5d056 AD |
1504 | |
1505 | if ($id == "quickDelFeed") { | |
1506 | ||
1507 | $param = db_escape_string($param); | |
1508 | ||
1509 | $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'"); | |
1510 | ||
1511 | if ($result) { | |
1512 | ||
1513 | $f_title = db_fetch_result($result, 0, "title"); | |
1514 | ||
1515 | print "Remove current feed ($f_title)? | |
1516 | <input class=\"button\" | |
1517 | type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\"> | |
1518 | <input class=\"button\" | |
1519 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
1520 | value=\"Cancel\">"; | |
1521 | } else { | |
1522 | print "Error: Feed $param not found. | |
1523 | <input class=\"button\" | |
1524 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
1525 | value=\"Cancel\">"; | |
1526 | } | |
1527 | } | |
1528 | ||
033e47e0 AD |
1529 | if ($id == "search") { |
1530 | ||
1531 | print "<input id=\"searchbox\" class=\"extSearch\" | |
1532 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
1533 | onchange=\"javascript:search()\"> | |
1534 | <select id=\"searchmodebox\"> | |
1535 | <option selected>All feeds</option> | |
1536 | <option>This feed</option> | |
1537 | </select> | |
1538 | <input type=\"submit\" | |
1539 | class=\"button\" onclick=\"javascript:search()\" value=\"Search\"> | |
1540 | <input class=\"button\" | |
1541 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
1542 | value=\"Close\">"; | |
1543 | ||
1544 | } | |
1545 | ||
f84a97a3 AD |
1546 | } |
1547 | ||
e65af9c1 AD |
1548 | if ($op == "updateAllFeeds") { |
1549 | update_all_feeds($link, true); | |
1550 | ||
1551 | print "<rpc-reply>"; | |
1552 | getLabelCounters($link); | |
1553 | getFeedCounters($link); | |
1554 | getTagCounters($link); | |
1555 | getGlobalCounters($link); | |
1556 | print "</rpc-reply>"; | |
1557 | ||
1558 | } | |
1559 | ||
77e96719 AD |
1560 | if ($op == "pref-prefs") { |
1561 | ||
b1895692 | 1562 | $subop = $_REQUEST["subop"]; |
77e96719 AD |
1563 | |
1564 | if ($subop == "Save configuration") { | |
1565 | ||
01d68cf9 AD |
1566 | if (WEB_DEMO_MODE) return; |
1567 | ||
77e96719 AD |
1568 | foreach (array_keys($_POST) as $pref_name) { |
1569 | ||
1570 | $pref_name = db_escape_string($pref_name); | |
1571 | $value = db_escape_string($_POST[$pref_name]); | |
1572 | ||
1573 | $result = db_query($link, "SELECT type_name | |
1574 | FROM ttrss_prefs,ttrss_prefs_types | |
1575 | WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id"); | |
1576 | ||
1577 | if (db_num_rows($result) > 0) { | |
1578 | ||
1579 | $type_name = db_fetch_result($result, 0, "type_name"); | |
1580 | ||
5da169d9 AD |
1581 | // print "$pref_name : $type_name : $value<br>"; |
1582 | ||
77e96719 | 1583 | if ($type_name == "bool") { |
5da169d9 | 1584 | if ($value == "1") { |
77e96719 AD |
1585 | $value = "true"; |
1586 | } else { | |
1587 | $value = "false"; | |
1588 | } | |
1589 | } else if ($type_name == "integer") { | |
1590 | $value = sprintf("%d", $value); | |
1591 | } | |
1592 | ||
1593 | // print "$pref_name : $type_name : $value<br>"; | |
1594 | ||
ff485f1d AD |
1595 | db_query($link, "UPDATE ttrss_user_prefs SET value = '$value' |
1596 | WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]); | |
77e96719 AD |
1597 | |
1598 | } | |
1599 | ||
1600 | header("Location: prefs.php"); | |
1601 | ||
1602 | } | |
1603 | ||
b1895692 AD |
1604 | } else if ($subop == "getHelp") { |
1605 | ||
1606 | $pref_name = db_escape_string($_GET["pn"]); | |
1607 | ||
1608 | $result = db_query($link, "SELECT help_text FROM ttrss_prefs | |
1609 | WHERE pref_name = '$pref_name'"); | |
1610 | ||
1611 | if (db_num_rows($result) > 0) { | |
1612 | $help_text = db_fetch_result($result, 0, "help_text"); | |
1613 | print $help_text; | |
1614 | } else { | |
1615 | print "Unknown option: $pref_name"; | |
1616 | } | |
1617 | ||
1c7f75ed AD |
1618 | } else if ($subop == "Change password") { |
1619 | ||
1620 | if (WEB_DEMO_MODE) return; | |
1621 | ||
1622 | $old_pw = $_POST["OLD_PASSWORD"]; | |
1623 | $new_pw = $_POST["OLD_PASSWORD"]; | |
1624 | ||
1625 | $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]); | |
1626 | $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]); | |
1627 | ||
1628 | $active_uid = $_SESSION["uid"]; | |
1629 | ||
1630 | if ($old_pw && $new_pw) { | |
1631 | ||
1632 | $login = db_escape_string($_SERVER['PHP_AUTH_USER']); | |
1633 | ||
1634 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
1635 | id = '$active_uid' AND (pwd_hash = '$old_pw' OR | |
1636 | pwd_hash = '$old_pw_hash')"); | |
1637 | ||
1638 | if (db_num_rows($result) == 1) { | |
1639 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash' | |
1640 | WHERE id = '$active_uid'"); | |
1641 | } | |
1642 | } | |
1643 | ||
1644 | header("Location: prefs.php"); | |
1645 | ||
77e96719 AD |
1646 | } else if ($subop == "Reset to defaults") { |
1647 | ||
01d68cf9 AD |
1648 | if (WEB_DEMO_MODE) return; |
1649 | ||
e1aa0559 AD |
1650 | if (DB_TYPE == "pgsql") { |
1651 | db_query($link,"UPDATE ttrss_user_prefs | |
1652 | SET value = ttrss_prefs.def_value | |
1653 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
1654 | ttrss_prefs.pref_name = ttrss_user_prefs.pref_name"); | |
1655 | } else { | |
1656 | db_query($link, "DELETE FROM ttrss_user_prefs | |
1657 | WHERE owner_uid = ".$_SESSION["uid"]); | |
1658 | initialize_user_prefs($link, $_SESSION["uid"]); | |
1659 | } | |
5da169d9 | 1660 | |
77e96719 AD |
1661 | header("Location: prefs.php"); |
1662 | ||
1663 | } else { | |
1664 | ||
7d4c898a | 1665 | if (!SINGLE_USER_MODE) { |
1c7f75ed | 1666 | |
7d4c898a AD |
1667 | print "<form action=\"backend.php\" method=\"POST\">"; |
1668 | ||
1669 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
1670 | print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>"; | |
1671 | ||
1672 | print "<tr><td width=\"40%\">Old password</td>"; | |
1673 | print "<td><input class=\"editbox\" type=\"password\" | |
1674 | name=\"OLD_PASSWORD\"></td></tr>"; | |
1675 | ||
1676 | print "<tr><td width=\"40%\">New password</td>"; | |
1677 | ||
1678 | print "<td><input class=\"editbox\" type=\"password\" | |
1679 | name=\"NEW_PASSWORD\"></td></tr>"; | |
1680 | ||
1681 | print "</table>"; | |
1682 | ||
1683 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
1684 | ||
1685 | print "<p><input class=\"button\" type=\"submit\" | |
1686 | value=\"Change password\" name=\"subop\">"; | |
1687 | ||
1688 | print "</form>"; | |
1c7f75ed | 1689 | |
7d4c898a | 1690 | } |
1c7f75ed | 1691 | |
77e96719 | 1692 | $result = db_query($link, "SELECT |
ff485f1d | 1693 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, |
77e96719 | 1694 | section_name,def_value |
ff485f1d | 1695 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs |
77e96719 | 1696 | WHERE type_id = ttrss_prefs_types.id AND |
ff485f1d | 1697 | section_id = ttrss_prefs_sections.id AND |
a2411bd9 AD |
1698 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND |
1699 | owner_uid = ".$_SESSION["uid"]." | |
650bc435 | 1700 | ORDER BY section_id,short_desc"); |
77e96719 AD |
1701 | |
1702 | print "<form action=\"backend.php\" method=\"POST\">"; | |
1703 | ||
77e96719 AD |
1704 | $lnum = 0; |
1705 | ||
1706 | $active_section = ""; | |
1707 | ||
1708 | while ($line = db_fetch_assoc($result)) { | |
1709 | ||
1710 | if ($active_section != $line["section_name"]) { | |
59a654ba AD |
1711 | |
1712 | if ($active_section != "") { | |
1c7f75ed | 1713 | print "</table>"; |
59a654ba | 1714 | } |
1c7f75ed AD |
1715 | |
1716 | print "<p><table width=\"100%\" class=\"prefPrefsList\">"; | |
59a654ba AD |
1717 | |
1718 | $active_section = $line["section_name"]; | |
1719 | ||
77e96719 | 1720 | print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>"; |
59a654ba AD |
1721 | // print "<tr class=\"title\"> |
1722 | // <td width=\"25%\">Option</td><td>Value</td></tr>"; | |
7268adf7 AD |
1723 | |
1724 | $lnum = 0; | |
77e96719 AD |
1725 | } |
1726 | ||
650bc435 | 1727 | // $class = ($lnum % 2) ? "even" : "odd"; |
77e96719 | 1728 | |
650bc435 | 1729 | print "<tr>"; |
77e96719 | 1730 | |
77e96719 AD |
1731 | $type_name = $line["type_name"]; |
1732 | $pref_name = $line["pref_name"]; | |
1733 | $value = $line["value"]; | |
1734 | $def_value = $line["def_value"]; | |
b1895692 AD |
1735 | $help_text = $line["help_text"]; |
1736 | ||
1737 | print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"]; | |
1738 | ||
1739 | if ($help_text) print "<div class=\"prefHelp\">$help_text</div>"; | |
1740 | ||
1741 | print "</td>"; | |
77e96719 AD |
1742 | |
1743 | print "<td>"; | |
1744 | ||
1745 | if ($type_name == "bool") { | |
1746 | // print_select($pref_name, $value, array("true", "false")); | |
1747 | ||
1748 | if ($value == "true") { | |
1749 | $value = "Yes"; | |
1750 | } else { | |
1751 | $value = "No"; | |
1752 | } | |
1753 | ||
1754 | print_radio($pref_name, $value, array("Yes", "No")); | |
1755 | ||
1756 | } else { | |
1757 | print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">"; | |
1758 | } | |
1759 | ||
1760 | print "</td>"; | |
1761 | ||
1762 | print "</tr>"; | |
1763 | ||
1764 | $lnum++; | |
1765 | } | |
1766 | ||
1767 | print "</table>"; | |
1768 | ||
1769 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
1770 | ||
1771 | print "<p><input class=\"button\" type=\"submit\" | |
1772 | name=\"subop\" value=\"Save configuration\">"; | |
1773 | ||
1774 | print " <input class=\"button\" type=\"submit\" | |
1775 | name=\"subop\" value=\"Reset to defaults\"></p>"; | |
1776 | ||
1777 | print "</form>"; | |
1778 | ||
1779 | } | |
1780 | ||
1781 | } | |
1782 | ||
e6cb77a0 AD |
1783 | if ($op == "pref-users") { |
1784 | ||
1785 | $subop = $_GET["subop"]; | |
1786 | ||
1787 | if ($subop == "editSave") { | |
1788 | ||
1789 | if (!WEB_DEMO_MODE) { | |
1790 | ||
1791 | $login = db_escape_string($_GET["l"]); | |
1792 | $uid = db_escape_string($_GET["id"]); | |
1793 | $access_level = sprintf("%d", $_GET["al"]); | |
1794 | ||
1795 | db_query($link, "UPDATE ttrss_users SET login = '$login', access_level = '$access_level' WHERE id = '$uid'"); | |
1796 | ||
1797 | } | |
1798 | } else if ($subop == "remove") { | |
1799 | ||
1800 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
1801 | ||
1802 | $ids = split(",", $_GET["ids"]); | |
1803 | ||
1804 | foreach ($ids as $id) { | |
1805 | db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]); | |
1806 | ||
1807 | } | |
1808 | } | |
1809 | } else if ($subop == "add") { | |
1810 | ||
1811 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
1812 | ||
1813 | $login = db_escape_string($_GET["login"]); | |
1814 | $tmp_user_pwd = make_password(8); | |
1815 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
1816 | ||
1817 | db_query($link, "INSERT INTO ttrss_users (login,pwd_hash,access_level) | |
1818 | VALUES ('$login', '$pwd_hash', 0)"); | |
1819 | ||
1820 | ||
1821 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
1822 | login = '$login' AND pwd_hash = '$pwd_hash'"); | |
1823 | ||
1824 | if (db_num_rows($result) == 1) { | |
1825 | ||
1826 | $new_uid = db_fetch_result($result, 0, "id"); | |
1827 | ||
1828 | print "<div class=\"notice\">Added user <b>".$_GET["login"]. | |
1829 | "</b> with password <b>$tmp_user_pwd</b>.</div>"; | |
1830 | ||
1831 | initialize_user($link, $new_uid); | |
1832 | ||
1833 | } else { | |
1834 | ||
1835 | print "<div class=\"warning\">Error while adding user <b>". | |
1836 | $_GET["login"].".</b></div>"; | |
1837 | ||
1838 | } | |
1839 | } | |
1840 | } else if ($subop == "resetPass") { | |
1841 | ||
1842 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
1843 | ||
1844 | $uid = db_escape_string($_GET["id"]); | |
1845 | ||
1846 | $result = db_query($link, "SELECT login FROM ttrss_users WHERE id = '$uid'"); | |
1847 | ||
1848 | $login = db_fetch_result($result, 0, "login"); | |
1849 | $tmp_user_pwd = make_password(8); | |
1850 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
1851 | ||
1852 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash' | |
1853 | WHERE id = '$uid'"); | |
1854 | ||
1855 | print "<div class=\"notice\">Changed password of | |
1856 | user <b>$login</b> to <b>$tmp_user_pwd</b>.</div>"; | |
1857 | ||
1858 | } | |
1859 | } | |
1860 | ||
1861 | print "<table class=\"prefAddFeed\"><tr> | |
1862 | <td><input id=\"uadd_box\"></td>"; | |
1863 | ||
1864 | print"<td colspan=\"4\" align=\"right\"> | |
1865 | <a class=\"button\" href=\"javascript:addUser()\">Add user</a></td></tr> | |
1866 | </table>"; | |
1867 | ||
1868 | $result = db_query($link, "SELECT | |
f6f32198 | 1869 | id,login,access_level,last_login |
e6cb77a0 AD |
1870 | FROM |
1871 | ttrss_users | |
1872 | ORDER by login"); | |
1873 | ||
1a7572cb AD |
1874 | print "<div id=\"prefUserDetails\">PLACEHOLDER</div>"; |
1875 | ||
e6cb77a0 AD |
1876 | print "<p><table width=\"100%\" class=\"prefUserList\" id=\"prefUserList\">"; |
1877 | ||
1878 | print "<tr class=\"title\"> | |
f6f32198 AD |
1879 | <td width=\"5%\">Select</td> |
1880 | <td width='30%'>Username</td> | |
1881 | <td width='30%'>Access Level</td> | |
1882 | <td width='30%'>Last login</td></tr>"; | |
e6cb77a0 AD |
1883 | |
1884 | $lnum = 0; | |
1885 | ||
1886 | while ($line = db_fetch_assoc($result)) { | |
1887 | ||
1888 | $class = ($lnum % 2) ? "even" : "odd"; | |
1889 | ||
1890 | $uid = $line["id"]; | |
1891 | $edit_uid = $_GET["id"]; | |
1892 | ||
1893 | if ($uid == $_SESSION["uid"] || ($subop == "edit" && $uid != $edit_uid)) { | |
1894 | $class .= "Grayed"; | |
1895 | } | |
1896 | ||
1897 | print "<tr class=\"$class\" id=\"UMRR-$uid\">"; | |
1898 | ||
1899 | $line["login"] = htmlspecialchars($line["login"]); | |
1900 | ||
1901 | if ($uid == $_SESSION["uid"]) { | |
1902 | ||
1903 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1904 | id=\"UMCHK-".$line["id"]."\"></td>"; | |
1905 | ||
1906 | print "<td>".$line["login"]."</td>"; | |
1907 | print "<td>".$line["access_level"]."</td>"; | |
e6cb77a0 AD |
1908 | |
1909 | } else if (!$edit_uid || $subop != "edit") { | |
1910 | ||
1911 | print "<td><input onclick='toggleSelectRow(this);' | |
1a7572cb | 1912 | type=\"checkbox\" id=\"UMCHK-$uid\"></td>"; |
e6cb77a0 AD |
1913 | |
1914 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
1915 | $line["login"] . "</td>"; | |
1916 | ||
1917 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
1918 | $line["access_level"] . "</td>"; | |
1919 | ||
1920 | } else if ($uid != $edit_uid) { | |
1921 | ||
1922 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1923 | id=\"UMCHK-".$line["id"]."\"></td>"; | |
1924 | ||
1925 | print "<td>".$line["login"]."</td>"; | |
1926 | print "<td>".$line["access_level"]."</td>"; | |
1927 | ||
1928 | } else { | |
1929 | ||
1930 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
1931 | ||
1932 | print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"]. | |
1933 | "\"></td>"; | |
1934 | ||
1935 | print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"]. | |
1936 | "\"></td>"; | |
1937 | ||
1938 | } | |
1939 | ||
f6f32198 AD |
1940 | print "<td>".$line["last_login"]."</td>"; |
1941 | ||
e6cb77a0 AD |
1942 | print "</tr>"; |
1943 | ||
1944 | ++$lnum; | |
1945 | } | |
1946 | ||
1947 | print "</table>"; | |
1948 | ||
1949 | print "<p>"; | |
1950 | ||
1951 | if ($subop == "edit") { | |
1952 | print "Edit label: | |
1953 | <input type=\"submit\" class=\"button\" | |
1954 | onclick=\"javascript:userEditCancel()\" value=\"Cancel\"> | |
1955 | <input type=\"submit\" class=\"button\" | |
1956 | onclick=\"javascript:userEditSave()\" value=\"Save\">"; | |
1957 | ||
1958 | } else { | |
1959 | ||
1960 | print " | |
1961 | Selection: | |
1962 | <input type=\"submit\" class=\"button\" | |
717f5e64 | 1963 | onclick=\"javascript:selectedUserDetails()\" value=\"User details\"> |
e6cb77a0 AD |
1964 | <input type=\"submit\" class=\"button\" |
1965 | onclick=\"javascript:editSelectedUser()\" value=\"Edit\"> | |
1966 | <input type=\"submit\" class=\"button\" | |
717f5e64 AD |
1967 | onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\"> |
1968 | <input type=\"submit\" class=\"button\" | |
1969 | onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">"; | |
1970 | ||
1971 | } | |
1972 | } | |
1973 | ||
1974 | if ($op == "user-details") { | |
1975 | ||
1976 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { | |
1977 | return; | |
1978 | } | |
1979 | ||
1a7572cb | 1980 | /* print "<html><head> |
717f5e64 AD |
1981 | <title>Tiny Tiny RSS : User Details</title> |
1982 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
1983 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
1a7572cb | 1984 | </head><body>"; */ |
717f5e64 AD |
1985 | |
1986 | $uid = sprintf("%d", $_GET["id"]); | |
1987 | ||
717f5e64 AD |
1988 | print "<div class='userDetails'>"; |
1989 | ||
1990 | $result = db_query($link, "SELECT login,last_login,access_level | |
1991 | FROM ttrss_users | |
1992 | WHERE id = '$uid'"); | |
1993 | ||
1994 | if (db_num_rows($result) == 0) { | |
1995 | print "<h1>User not found</h1>"; | |
1996 | return; | |
1997 | } | |
1998 | ||
1999 | print "<h1>User Details</h1>"; | |
2000 | ||
2001 | print "<table width='100%'>"; | |
2002 | ||
2003 | $login = db_fetch_result($result, 0, "login"); | |
2004 | $last_login = db_fetch_result($result, 0, "last_login"); | |
2005 | $access_level = db_fetch_result($result, 0, "access_level"); | |
2006 | ||
2007 | print "<tr><td>Username</td><td>$login</td></tr>"; | |
2008 | print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
2009 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
2010 | ||
2011 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds | |
2012 | WHERE owner_uid = '$uid'"); | |
2013 | ||
2014 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
2015 | ||
2016 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; | |
2017 | ||
2018 | $result = db_query($link, "SELECT | |
2019 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size | |
2020 | FROM ttrss_entries WHERE owner_uid = '$uid'"); | |
2021 | ||
d9f115c3 | 2022 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
717f5e64 | 2023 | |
d9f115c3 | 2024 | print "<tr><td>Approx. DB size</td><td>$db_size KBytes</td></tr>"; |
717f5e64 AD |
2025 | |
2026 | print "</table>"; | |
2027 | ||
2028 | print "<h1>Subscribed feeds</h1>"; | |
2029 | ||
2030 | $result = db_query($link, "SELECT id,title,feed_url FROM ttrss_feeds | |
d9f115c3 | 2031 | WHERE owner_uid = '$uid' ORDER BY title"); |
717f5e64 AD |
2032 | |
2033 | print "<ul class=\"nomarks\">"; | |
2034 | ||
2035 | while ($line = db_fetch_assoc($result)) { | |
2036 | ||
2037 | $icon_file = ICONS_URL."/".$line["id"].".ico"; | |
2038 | ||
2039 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
2040 | $feed_icon = "<img class=\"feedIcon\" src=\"$icon_file\">"; | |
2041 | } else { | |
2042 | $feed_icon = "<img class=\"feedIcon\" src=\"images/blank_icon.gif\">"; | |
2043 | } | |
2044 | ||
2045 | print "<li>$feed_icon <a href=\"".$line["feed_url"]."\">".$line["title"]."</a></li>"; | |
e6cb77a0 | 2046 | } |
717f5e64 AD |
2047 | |
2048 | print "</ul>"; | |
2049 | ||
717f5e64 AD |
2050 | print "</div>"; |
2051 | ||
1a7572cb AD |
2052 | print "<div align='center'> |
2053 | <input type='submit' class='button' | |
2054 | onclick=\"closeUserDetails()\" value=\"Close this window\"></div>"; | |
2055 | ||
2056 | // print "</body></html>"; | |
717f5e64 | 2057 | |
e6cb77a0 AD |
2058 | } |
2059 | ||
4b3dff6e | 2060 | db_close($link); |
1cd17194 | 2061 | ?> |
406d9489 AD |
2062 | |
2063 | <!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> | |
2064 |