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