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