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