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