]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | <? |
4356293a | 2 | session_start(); |
090e250b | 3 | |
cce28758 AD |
4 | if ($_GET["debug"]) { |
5 | define('DEFAULT_ERROR_LEVEL', E_ALL); | |
6 | } else { | |
7 | define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); | |
8 | } | |
9 | ||
10 | error_reporting(DEFAULT_ERROR_LEVEL); | |
11 | ||
262bd8ea AD |
12 | $op = $_REQUEST["op"]; |
13 | ||
a2770077 | 14 | if ((!$op || $op == "rpc" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { |
262bd8ea AD |
15 | header("Content-Type: application/xml"); |
16 | } | |
17 | ||
a2770077 | 18 | if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") { |
262bd8ea | 19 | |
a2770077 | 20 | if ($op == "rpc") { |
262bd8ea AD |
21 | print "<error error-code=\"6\"/>"; |
22 | } | |
23 | exit; | |
24 | } | |
1c7f75ed | 25 | |
a2770077 AD |
26 | if (!$op) { |
27 | print "<error error-code=\"7\"/>"; | |
28 | exit; | |
29 | } | |
30 | ||
cce28758 | 31 | define('SCHEMA_VERSION', 2); |
1cd17194 | 32 | |
66581886 | 33 | require_once "sanity_check.php"; |
82baad4a | 34 | require_once "config.php"; |
648472a7 | 35 | require_once "db.php"; |
3bac89ad | 36 | require_once "db-prefs.php"; |
82baad4a AD |
37 | require_once "functions.php"; |
38 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 39 | |
406d9489 AD |
40 | $script_started = getmicrotime(); |
41 | ||
648472a7 | 42 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
d76a3b03 | 43 | |
5136011e AD |
44 | if (!$link) { |
45 | if (DB_TYPE == "mysql") { | |
46 | print mysql_error(); | |
47 | } | |
48 | // PG seems to display its own errors just fine by default. | |
49 | return; | |
50 | } | |
51 | ||
648472a7 AD |
52 | if (DB_TYPE == "pgsql") { |
53 | pg_query("set client_encoding = 'utf-8'"); | |
54 | } | |
7ec2a838 | 55 | |
331900c6 | 56 | $fetch = $_GET["fetch"]; |
175847de | 57 | |
1572afe5 AD |
58 | function getAllCounters($link) { |
59 | getLabelCounters($link); | |
60 | getFeedCounters($link); | |
61 | getTagCounters($link); | |
62 | getGlobalCounters($link); | |
63 | } | |
64 | ||
0ee2d12f AD |
65 | function getFeedUnread($link, $feed) { |
66 | $n_feed = sprintf("%d", $feed); | |
67 | ||
68 | if ($n_feed == -1) { | |
69 | $match_part = "marked = true"; | |
70 | } else if ($feed > 0) { | |
71 | $match_part = "feed_id = '$n_feed'"; | |
72 | } else if ($feed < -10) { | |
73 | $label_id = -$feed - 11; | |
74 | ||
75 | $result = db_query($link, "SELECT sql_exp FROM ttrss_labels WHERE | |
76 | id = '$label_id' AND owner_uid = " . $_SESSION["uid"]); | |
77 | ||
78 | $match_part = db_fetch_result($result, 0, "sql_exp"); | |
79 | } | |
80 | ||
81 | if ($match_part) { | |
82 | ||
83 | $result = db_query($link, "SELECT count(int_id) AS unread | |
84 | FROM ttrss_user_entries | |
85 | WHERE unread = true AND $match_part AND owner_uid = " . $_SESSION["uid"]); | |
86 | ||
87 | } else { | |
88 | ||
89 | $result = db_query($link, "SELECT COUNT(post_int_id) AS unread | |
90 | FROM ttrss_tags,ttrss_user_entries | |
91 | WHERE tag_name = '$feed' AND post_int_id = int_id AND unread = true AND | |
92 | ttrss_tags.owner_uid = " . $_SESSION["uid"]); | |
93 | } | |
94 | ||
95 | $unread = db_fetch_result($result, 0, "unread"); | |
96 | return $unread; | |
97 | } | |
98 | ||
8143ae1f AD |
99 | /* FIXME this needs reworking */ |
100 | ||
fc69e641 | 101 | function getGlobalCounters($link) { |
4c193675 AD |
102 | $result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries |
103 | WHERE unread = true AND | |
104 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
105 | owner_uid = " . $_SESSION["uid"]); | |
fc69e641 AD |
106 | $c_id = db_fetch_result($result, 0, "c_id"); |
107 | print "<counter id='global-unread' counter='$c_id'/>"; | |
108 | } | |
109 | ||
bbc92e50 | 110 | function getTagCounters($link, $smart_mode = SMART_RPC_COUNTERS) { |
0477a326 AD |
111 | |
112 | if ($smart_mode) { | |
113 | if (!$_SESSION["tctr_last_value"]) { | |
114 | $_SESSION["tctr_last_value"] = array(); | |
115 | } | |
116 | } | |
117 | ||
118 | $old_counters = $_SESSION["tctr_last_value"]; | |
119 | ||
120 | $tctrs_modified = false; | |
121 | ||
8143ae1f | 122 | $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count |
4c193675 AD |
123 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE |
124 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
4356293a | 125 | ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND |
05732aa0 | 126 | post_int_id = ttrss_user_entries.int_id AND unread = true GROUP BY tag_name |
8143ae1f | 127 | UNION |
4356293a AD |
128 | select tag_name,0 as count FROM ttrss_tags |
129 | WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]); | |
8143ae1f AD |
130 | |
131 | $tags = array(); | |
132 | ||
133 | while ($line = db_fetch_assoc($result)) { | |
134 | $tags[$line["tag_name"]] += $line["count"]; | |
135 | } | |
136 | ||
137 | foreach (array_keys($tags) as $tag) { | |
138 | $unread = $tags[$tag]; | |
139 | ||
140 | $tag = htmlspecialchars($tag); | |
0477a326 AD |
141 | |
142 | if (!$smart_mode || $old_counters[$tag] != $unread) { | |
143 | $old_counters[$tag] = $unread; | |
144 | $tctrs_modified = true; | |
145 | print "<tag id=\"$tag\" counter=\"$unread\"/>"; | |
146 | } | |
147 | ||
8143ae1f | 148 | } |
0477a326 AD |
149 | |
150 | if ($smart_mode && $tctrs_modified) { | |
151 | $_SESSION["tctr_last_value"] = $old_counters; | |
152 | } | |
153 | ||
8143ae1f AD |
154 | } |
155 | ||
bbc92e50 AD |
156 | function getLabelCounters($link, $smart_mode = SMART_RPC_COUNTERS) { |
157 | ||
158 | if ($smart_mode) { | |
159 | if (!$_SESSION["lctr_last_value"]) { | |
160 | $_SESSION["lctr_last_value"] = array(); | |
161 | } | |
162 | } | |
163 | ||
164 | $old_counters = $_SESSION["lctr_last_value"]; | |
165 | $lctrs_modified = false; | |
090e250b | 166 | |
4c193675 AD |
167 | $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries |
168 | WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND | |
169 | unread = true AND owner_uid = ".$_SESSION["uid"]); | |
090e250b | 170 | |
d61fd764 | 171 | $count = db_fetch_result($result, 0, "count"); |
090e250b AD |
172 | |
173 | print "<label id=\"-1\" counter=\"$count\"/>"; | |
174 | ||
4356293a AD |
175 | $result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM |
176 | ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description"); | |
090e250b AD |
177 | |
178 | while ($line = db_fetch_assoc($result)) { | |
179 | ||
180 | $id = -$line["id"] - 11; | |
181 | ||
182 | error_reporting (0); | |
d61fd764 | 183 | |
4c193675 | 184 | $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries |
655be073 | 185 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND |
4c193675 | 186 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
655be073 | 187 | owner_uid = ".$_SESSION["uid"]); |
090e250b | 188 | |
d61fd764 | 189 | $count = db_fetch_result($tmp_result, 0, "count"); |
090e250b | 190 | |
bbc92e50 AD |
191 | if (!$smart_mode || $old_counters[$id] != $count) { |
192 | $old_counters[$id] = $count; | |
193 | $lctrs_modified = true; | |
194 | print "<label id=\"$id\" counter=\"$count\"/>"; | |
195 | } | |
090e250b | 196 | |
cce28758 | 197 | error_reporting (DEFAULT_ERROR_LEVEL); |
bbc92e50 AD |
198 | } |
199 | ||
200 | if ($smart_mode && $lctrs_modified) { | |
201 | $_SESSION["lctr_last_value"] = $old_counters; | |
090e250b AD |
202 | } |
203 | } | |
204 | ||
8073cce7 AD |
205 | function getFeedCounter($link, $id) { |
206 | ||
207 | $result = db_query($link, "SELECT | |
4c193675 AD |
208 | count(id) as count FROM ttrss_entries,ttrss_user_entries |
209 | WHERE feed_id = '$id' AND unread = true | |
210 | AND ttrss_user_entries.ref_id = ttrss_entries.id"); | |
8073cce7 AD |
211 | |
212 | $count = db_fetch_result($result, 0, "count"); | |
213 | ||
214 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
215 | } | |
090e250b | 216 | |
bbc92e50 | 217 | function getFeedCounters($link, $smart_mode = SMART_RPC_COUNTERS) { |
0477a326 AD |
218 | |
219 | if ($smart_mode) { | |
220 | if (!$_SESSION["fctr_last_value"]) { | |
221 | $_SESSION["fctr_last_value"] = array(); | |
222 | } | |
223 | } | |
224 | ||
225 | $old_counters = $_SESSION["fctr_last_value"]; | |
226 | ||
090e250b | 227 | $result = db_query($link, "SELECT id, |
4c193675 AD |
228 | (SELECT count(id) |
229 | FROM ttrss_entries,ttrss_user_entries | |
230 | WHERE feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id | |
b88917af | 231 | AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count |
4356293a | 232 | FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]); |
0477a326 AD |
233 | |
234 | $fctrs_modified = false; | |
235 | ||
090e250b AD |
236 | while ($line = db_fetch_assoc($result)) { |
237 | ||
238 | $id = $line["id"]; | |
239 | $count = $line["count"]; | |
240 | ||
0477a326 AD |
241 | if (!$smart_mode || $old_counters[$id] != $count) { |
242 | $old_counters[$id] = $count; | |
243 | $fctrs_modified = true; | |
244 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
245 | } | |
246 | } | |
247 | ||
248 | if ($smart_mode && $fctrs_modified) { | |
249 | $_SESSION["fctr_last_value"] = $old_counters; | |
090e250b AD |
250 | } |
251 | } | |
252 | ||
8143ae1f | 253 | function outputFeedList($link, $tags = false) { |
175847de | 254 | |
1a66d16e AD |
255 | print "<html><head> |
256 | <title>Tiny Tiny RSS : Feedlist</title> | |
430bf183 AD |
257 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
258 | ||
503eb349 AD |
259 | $user_theme = $_SESSION["theme"]; |
260 | if ($user_theme) { | |
261 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
262 | href=\"themes/$user_theme/theme.css\">"; | |
263 | } | |
264 | ||
4769ddaf | 265 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
430bf183 AD |
266 | print "<link rel=\"stylesheet\" type=\"text/css\" |
267 | href=\"tt-rss_compact.css\"/>"; | |
268 | } else { | |
269 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
270 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
271 | } | |
272 | ||
273 | print "<script type=\"text/javascript\" src=\"functions.js\"></script> | |
1a66d16e AD |
274 | <script type=\"text/javascript\" src=\"feedlist.js\"></script> |
275 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
3745788e | 276 | </head><body onload=\"init()\">"; |
254e0e4b AD |
277 | |
278 | print "<ul class=\"feedList\" id=\"feedList\">"; | |
279 | ||
4356293a AD |
280 | $owner_uid = $_SESSION["uid"]; |
281 | ||
8143ae1f | 282 | if (!$tags) { |
254e0e4b | 283 | |
8143ae1f | 284 | /* virtual feeds */ |
254e0e4b | 285 | |
91ff844a AD |
286 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
287 | print "<li class=\"feedCat\">Special</li>"; | |
703b632e | 288 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
91ff844a AD |
289 | } |
290 | ||
8143ae1f | 291 | $result = db_query($link, "SELECT count(id) as num_starred |
4c193675 AD |
292 | FROM ttrss_entries,ttrss_user_entries |
293 | WHERE marked = true AND | |
294 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
295 | unread = true AND owner_uid = '$owner_uid'"); | |
8143ae1f | 296 | $num_starred = db_fetch_result($result, 0, "num_starred"); |
254e0e4b | 297 | |
3745788e | 298 | $class = "virt"; |
8add756a AD |
299 | |
300 | if ($num_starred > 0) $class .= "Unread"; | |
301 | ||
302 | printFeedEntry(-1, $class, "Starred articles", $num_starred, | |
4668523d | 303 | "images/mark_set.png", $link); |
48f0adb0 | 304 | |
91ff844a | 305 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
703b632e | 306 | print "</li></ul>"; |
91ff844a AD |
307 | } |
308 | ||
cfaba6df | 309 | if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) { |
8143ae1f AD |
310 | |
311 | $result = db_query($link, "SELECT id,sql_exp,description FROM | |
4356293a | 312 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); |
8143ae1f AD |
313 | |
314 | if (db_num_rows($result) > 0) { | |
91ff844a AD |
315 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
316 | print "<li class=\"feedCat\">Labels</li>"; | |
703b632e | 317 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
91ff844a AD |
318 | } else { |
319 | print "<li><hr></li>"; | |
320 | } | |
8143ae1f AD |
321 | } |
322 | ||
323 | while ($line = db_fetch_assoc($result)) { | |
48f0adb0 | 324 | |
8143ae1f AD |
325 | error_reporting (0); |
326 | ||
4c193675 AD |
327 | $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries |
328 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND | |
329 | ttrss_user_entries.ref_id = ttrss_entries.id | |
655be073 | 330 | AND owner_uid = '$owner_uid'"); |
8143ae1f AD |
331 | |
332 | $count = db_fetch_result($tmp_result, 0, "count"); | |
333 | ||
3745788e | 334 | $class = "label"; |
8143ae1f AD |
335 | |
336 | if ($count > 0) { | |
337 | $class .= "Unread"; | |
338 | } | |
339 | ||
cce28758 | 340 | error_reporting (DEFAULT_ERROR_LEVEL); |
8143ae1f AD |
341 | |
342 | printFeedEntry(-$line["id"]-11, | |
4668523d | 343 | $class, $line["description"], $count, "images/label.png", $link); |
8143ae1f AD |
344 | |
345 | } | |
91ff844a AD |
346 | |
347 | if (db_num_rows($result) > 0) { | |
348 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
703b632e | 349 | print "</li></ul>"; |
91ff844a AD |
350 | } |
351 | } | |
352 | ||
353 | } | |
354 | ||
355 | // if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
356 | print "<li><hr></li>"; | |
357 | // } | |
358 | ||
359 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
360 | $order_by_qpart = "category,title"; | |
361 | } else { | |
362 | $order_by_qpart = "title"; | |
48f0adb0 | 363 | } |
8143ae1f AD |
364 | |
365 | $result = db_query($link, "SELECT *, | |
4c193675 AD |
366 | (SELECT count(id) FROM ttrss_entries,ttrss_user_entries |
367 | WHERE feed_id = ttrss_feeds.id AND | |
368 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
369 | owner_uid = '$owner_uid') AS total, | |
370 | (SELECT count(id) FROM ttrss_entries,ttrss_user_entries | |
b88917af | 371 | WHERE feed_id = ttrss_feeds.id AND unread = true |
4c193675 | 372 | AND ttrss_user_entries.ref_id = ttrss_entries.id |
91ff844a AD |
373 | AND owner_uid = '$owner_uid') as unread, |
374 | (SELECT title FROM ttrss_feed_categories | |
375 | WHERE id = cat_id) AS category | |
376 | FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY $order_by_qpart"); | |
8143ae1f AD |
377 | |
378 | $actid = $_GET["actid"]; | |
379 | ||
380 | /* real feeds */ | |
381 | ||
382 | $lnum = 0; | |
383 | ||
384 | $total_unread = 0; | |
91ff844a AD |
385 | |
386 | $category = ""; | |
8143ae1f | 387 | |
48f0adb0 | 388 | while ($line = db_fetch_assoc($result)) { |
8143ae1f | 389 | |
69668465 | 390 | $feed = db_unescape_string($line["title"]); |
8143ae1f AD |
391 | $feed_id = $line["id"]; |
392 | ||
393 | $subop = $_GET["subop"]; | |
394 | ||
395 | $total = $line["total"]; | |
396 | $unread = $line["unread"]; | |
91ff844a AD |
397 | |
398 | $tmp_category = $line["category"]; | |
399 | ||
400 | if (!$tmp_category) { | |
401 | $tmp_category = "Uncategorized"; | |
402 | } | |
8143ae1f AD |
403 | |
404 | // $class = ($lnum % 2) ? "even" : "odd"; | |
48f0adb0 | 405 | |
3745788e | 406 | $class = "feed"; |
8143ae1f AD |
407 | |
408 | if ($unread > 0) $class .= "Unread"; | |
409 | ||
410 | if ($actid == $feed_id) { | |
411 | $class .= "Selected"; | |
392d4563 | 412 | } |
48f0adb0 | 413 | |
8143ae1f | 414 | $total_unread += $unread; |
91ff844a AD |
415 | |
416 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
417 | ||
418 | if ($category) { | |
419 | print "</li></ul></li>"; | |
420 | } | |
421 | ||
422 | $category = $tmp_category; | |
423 | ||
424 | print "<li class=\"feedCat\">$category</li>"; | |
703b632e | 425 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
91ff844a | 426 | } |
8143ae1f | 427 | |
91ff844a AD |
428 | printFeedEntry($feed_id, $class, $feed, $unread, |
429 | "icons/$feed_id.ico", $link); | |
8143ae1f AD |
430 | |
431 | ++$lnum; | |
48f0adb0 | 432 | } |
91ff844a | 433 | |
8143ae1f | 434 | } else { |
a1a8a2be | 435 | |
8143ae1f | 436 | // tags |
a1a8a2be | 437 | |
8143ae1f | 438 | $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count |
05732aa0 AD |
439 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE |
440 | post_int_id = ttrss_user_entries.int_id AND | |
441 | unread = true AND ref_id = ttrss_entries.id | |
3b0948c4 | 442 | AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name |
8143ae1f | 443 | UNION |
3b0948c4 AD |
444 | select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid' |
445 | ORDER BY tag_name"); | |
8143ae1f AD |
446 | |
447 | $tags = array(); | |
448 | ||
449 | while ($line = db_fetch_assoc($result)) { | |
450 | $tags[$line["tag_name"]] += $line["count"]; | |
1a66d16e | 451 | } |
8143ae1f AD |
452 | |
453 | foreach (array_keys($tags) as $tag) { | |
454 | ||
455 | $unread = $tags[$tag]; | |
456 | ||
83957936 | 457 | $class = "tag"; |
8143ae1f AD |
458 | |
459 | if ($unread > 0) { | |
460 | $class .= "Unread"; | |
461 | } | |
462 | ||
4668523d | 463 | printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link); |
8143ae1f AD |
464 | |
465 | } | |
1a66d16e | 466 | |
e828e31e | 467 | } |
82baad4a | 468 | |
dc33ec95 | 469 | if (db_num_rows($result) == 0) { |
8037c618 AD |
470 | if ($tags) { |
471 | $what = "tags"; | |
472 | } else { | |
473 | $what = "feeds"; | |
474 | } | |
475 | print "<li>No $what to display.</li>"; | |
dc33ec95 AD |
476 | } |
477 | ||
8143ae1f | 478 | print "</ul>"; |
1cd17194 | 479 | |
c3b81db0 AD |
480 | } |
481 | ||
482 | ||
483 | if ($op == "rpc") { | |
484 | ||
485 | $subop = $_GET["subop"]; | |
486 | ||
090e250b | 487 | if ($subop == "getLabelCounters") { |
8073cce7 | 488 | $aid = $_GET["aid"]; |
090e250b AD |
489 | print "<rpc-reply>"; |
490 | getLabelCounters($link); | |
8073cce7 AD |
491 | if ($aid) { |
492 | getFeedCounter($link, $aid); | |
493 | } | |
090e250b AD |
494 | print "</rpc-reply>"; |
495 | } | |
496 | ||
497 | if ($subop == "getFeedCounters") { | |
498 | print "<rpc-reply>"; | |
499 | getFeedCounters($link); | |
500 | print "</rpc-reply>"; | |
501 | } | |
502 | ||
503 | if ($subop == "getAllCounters") { | |
504 | print "<rpc-reply>"; | |
1572afe5 | 505 | getAllCounters($link); |
090e250b | 506 | print "</rpc-reply>"; |
090e250b AD |
507 | } |
508 | ||
f4c10d44 AD |
509 | if ($subop == "mark") { |
510 | $mark = $_GET["mark"]; | |
648472a7 | 511 | $id = db_escape_string($_GET["id"]); |
f4c10d44 AD |
512 | |
513 | if ($mark == "1") { | |
514 | $mark = "true"; | |
515 | } else { | |
516 | $mark = "false"; | |
517 | } | |
518 | ||
b5137506 AD |
519 | // FIXME this needs collision testing |
520 | ||
521 | $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark | |
522 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
f4c10d44 AD |
523 | } |
524 | ||
caa4e57f | 525 | if ($subop == "updateFeed") { |
648472a7 | 526 | $feed_id = db_escape_string($_GET["feed"]); |
9cfc649a | 527 | |
648472a7 | 528 | $result = db_query($link, |
a5873b2e AD |
529 | "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id' |
530 | AND owner_uid = " . $_SESSION["uid"]); | |
9cfc649a | 531 | |
648472a7 AD |
532 | if (db_num_rows($result) > 0) { |
533 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
a5873b2e | 534 | update_rss_feed($link, $feed_url, $feed_id); |
caa4e57f | 535 | } |
9cfc649a | 536 | |
a5873b2e AD |
537 | print "<rpc-reply>"; |
538 | getFeedCounter($link, $feed_id); | |
539 | print "</rpc-reply>"; | |
540 | ||
caa4e57f | 541 | return; |
9cfc649a AD |
542 | } |
543 | ||
090e250b | 544 | if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") { |
c5142cca | 545 | |
05732aa0 | 546 | update_all_feeds($link, $subop == "forceUpdateAllFeeds"); |
c3b81db0 | 547 | |
ab3f3f72 AD |
548 | $omode = $_GET["omode"]; |
549 | ||
550 | if (!$omode) $omode = "tfl"; | |
551 | ||
090e250b | 552 | print "<rpc-reply>"; |
ab3f3f72 AD |
553 | if (strchr($omode, "l")) getLabelCounters($link); |
554 | if (strchr($omode, "f")) getFeedCounters($link); | |
555 | if (strchr($omode, "t")) getTagCounters($link); | |
fc69e641 | 556 | getGlobalCounters($link); |
090e250b | 557 | print "</rpc-reply>"; |
c3b81db0 | 558 | } |
1572afe5 AD |
559 | |
560 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ | |
b018b49b | 561 | if ($subop == "catchupSelected") { |
c3b81db0 | 562 | |
f932bc9f | 563 | $ids = split(",", db_escape_string($_GET["ids"])); |
c3b81db0 | 564 | |
1572afe5 | 565 | $cmode = sprintf("%d", $_GET["cmode"]); |
c3b81db0 | 566 | |
1572afe5 | 567 | foreach ($ids as $id) { |
c3b81db0 | 568 | |
1572afe5 AD |
569 | if ($cmode == 0) { |
570 | db_query($link, "UPDATE ttrss_user_entries SET | |
571 | unread = false,last_read = NOW() | |
572 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
573 | } else if ($cmode == 1) { | |
574 | db_query($link, "UPDATE ttrss_user_entries SET | |
575 | unread = true | |
576 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
577 | } else { | |
578 | db_query($link, "UPDATE ttrss_user_entries SET | |
579 | unread = NOT unread,last_read = NOW() | |
580 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
581 | } | |
c3b81db0 | 582 | } |
1572afe5 AD |
583 | print "<rpc-reply>"; |
584 | getAllCounters($link); | |
585 | print "</rpc-reply>"; | |
586 | } | |
c3b81db0 | 587 | |
1572afe5 AD |
588 | if ($subop == "markSelected") { |
589 | ||
f932bc9f | 590 | $ids = split(",", db_escape_string($_GET["ids"])); |
1572afe5 AD |
591 | |
592 | $cmode = sprintf("%d", $_GET["cmode"]); | |
593 | ||
594 | foreach ($ids as $id) { | |
595 | ||
596 | if ($cmode == 0) { | |
597 | db_query($link, "UPDATE ttrss_user_entries SET | |
598 | marked = false | |
599 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
600 | } else if ($cmode == 1) { | |
601 | db_query($link, "UPDATE ttrss_user_entries SET | |
602 | marked = true | |
603 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
604 | } else { | |
605 | db_query($link, "UPDATE ttrss_user_entries SET | |
606 | marked = NOT marked | |
607 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
608 | } | |
609 | } | |
610 | print "<rpc-reply>"; | |
611 | getAllCounters($link); | |
612 | print "</rpc-reply>"; | |
c3b81db0 | 613 | } |
295f9b42 AD |
614 | |
615 | if ($subop == "sanityCheck") { | |
616 | ||
617 | $error_code = 0; | |
618 | ||
619 | $result = db_query($link, "SELECT schema_version FROM ttrss_version"); | |
620 | ||
621 | $schema_version = db_fetch_result($result, 0, "schema_version"); | |
622 | ||
623 | if ($schema_version != SCHEMA_VERSION) { | |
624 | $error_code = 5; | |
625 | } | |
626 | ||
262bd8ea | 627 | print "<error error-code='$error_code'/>"; |
295f9b42 | 628 | } |
fefa6ca3 AD |
629 | |
630 | if ($subop == "globalPurge") { | |
631 | ||
632 | print "<rpc-reply>"; | |
633 | global_purge_old_posts($link, true); | |
634 | print "</rpc-reply>"; | |
635 | ||
636 | } | |
637 | ||
c3b81db0 AD |
638 | } |
639 | ||
640 | if ($op == "feeds") { | |
641 | ||
8143ae1f AD |
642 | $tags = $_GET["tags"]; |
643 | ||
c3b81db0 AD |
644 | $subop = $_GET["subop"]; |
645 | ||
646 | if ($subop == "catchupAll") { | |
b018b49b | 647 | db_query($link, "UPDATE ttrss_user_entries SET |
6d15e1ef | 648 | last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]); |
c3b81db0 AD |
649 | } |
650 | ||
8143ae1f | 651 | outputFeedList($link, $tags); |
c3b81db0 | 652 | |
1cd17194 AD |
653 | } |
654 | ||
655 | if ($op == "view") { | |
656 | ||
d76a3b03 | 657 | $id = $_GET["id"]; |
8073cce7 | 658 | $feed_id = $_GET["feed"]; |
d76a3b03 | 659 | |
4c193675 AD |
660 | $result = db_query($link, "UPDATE ttrss_user_entries |
661 | SET unread = false,last_read = NOW() | |
662 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
a1a8a2be | 663 | |
70830c87 AD |
664 | $addheader = $_GET["addheader"]; |
665 | ||
21703604 | 666 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, |
9167e250 | 667 | SUBSTRING(updated,1,16) as updated, |
11b0dce2 AD |
668 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, |
669 | num_comments | |
4c193675 AD |
670 | FROM ttrss_entries,ttrss_user_entries |
671 | WHERE id = '$id' AND ref_id = id"); | |
1cd17194 | 672 | |
70830c87 | 673 | if ($addheader) { |
f0601b87 | 674 | print "<html><head> |
70830c87 | 675 | <title>Tiny Tiny RSS : Article $id</title> |
503eb349 AD |
676 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
677 | ||
678 | $user_theme = $_SESSION["theme"]; | |
679 | if ($user_theme) { | |
680 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
681 | href=\"themes/$user_theme/theme.css\">"; | |
682 | } | |
683 | ||
684 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { | |
685 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
686 | href=\"tt-rss_compact.css\"/>"; | |
687 | } else { | |
688 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
689 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
690 | } | |
691 | ||
692 | print "<script type=\"text/javascript\" src=\"functions.js\"></script> | |
70830c87 | 693 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
f0601b87 | 694 | </head><body>"; |
70830c87 AD |
695 | } |
696 | ||
d76a3b03 | 697 | if ($result) { |
1cd17194 | 698 | |
648472a7 | 699 | $line = db_fetch_assoc($result); |
1cd17194 | 700 | |
b7f4bda2 AD |
701 | if ($line["icon_url"]) { |
702 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
703 | } else { | |
704 | $feed_icon = " "; | |
705 | } | |
d76a3b03 | 706 | |
11b0dce2 | 707 | /* if ($line["comments"] && $line["link"] != $line["comments"]) { |
f7181e9b AD |
708 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; |
709 | } else { | |
710 | $entry_comments = ""; | |
11b0dce2 AD |
711 | } */ |
712 | ||
713 | $num_comments = $line["num_comments"]; | |
714 | $entry_comments = ""; | |
715 | ||
716 | if ($num_comments > 0) { | |
717 | if ($line["comments"]) { | |
718 | $comments_url = $line["comments"]; | |
719 | } else { | |
720 | $comments_url = $line["link"]; | |
721 | } | |
6a1ad084 | 722 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; |
11b0dce2 AD |
723 | } else { |
724 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
6a1ad084 | 725 | $entry_comments = "<a href=\"".$line["comments"]."\">Comments</a>"; |
11b0dce2 | 726 | } |
f7181e9b AD |
727 | } |
728 | ||
e828e31e AD |
729 | print "<div class=\"postReply\">"; |
730 | ||
21703604 AD |
731 | print "<div class=\"postHeader\"><table width=\"100%\">"; |
732 | ||
6a1ad084 | 733 | print "<tr><td><a href=\"" . $line["link"] . "\">" . $line["title"] . "</a></td>"; |
9167e250 AD |
734 | |
735 | $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
736 | strtotime($line["updated"])); | |
737 | ||
738 | print "<td class=\"postDate\">$parsed_updated</td>"; | |
739 | ||
740 | print "</tr>"; | |
21703604 AD |
741 | |
742 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM | |
743 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
744 | ORDER BY tag_name"); | |
745 | ||
746 | $tags_str = ""; | |
42918a07 AD |
747 | $f_tags_str = ""; |
748 | ||
749 | $num_tags = 0; | |
21703604 AD |
750 | |
751 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
42918a07 AD |
752 | $num_tags++; |
753 | $tag = $tmp_line["tag_name"]; | |
754 | $tag_str = "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, "; | |
755 | ||
756 | if ($num_tags == 5) { | |
757 | $tags_str .= "<a href=\"javascript:showBlockElement('allEntryTags')\">...</a>"; | |
758 | } else if ($num_tags < 5) { | |
759 | $tags_str .= $tag_str; | |
760 | } | |
761 | $f_tags_str .= $tag_str; | |
762 | } | |
21703604 | 763 | |
42918a07 AD |
764 | $tags_str = preg_replace("/, $/", "", $tags_str); |
765 | $f_tags_str = preg_replace("/, $/", "", $f_tags_str); | |
e828e31e | 766 | |
6a1ad084 | 767 | // $truncated_link = truncate_string($line["link"], 60); |
21703604 | 768 | |
6a1ad084 AD |
769 | if ($tags_str || $entry_comments) { |
770 | print "<tr><td width='50%'> | |
771 | $entry_comments</td> | |
772 | <td align=\"right\">$tags_str</td></tr>"; | |
773 | } | |
21703604 | 774 | |
e828e31e AD |
775 | print "</table></div>"; |
776 | ||
777 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
42918a07 AD |
778 | print "<div class=\"postContent\">"; |
779 | ||
780 | if (db_num_rows($tmp_result) > 5) { | |
781 | print "<div id=\"allEntryTags\">Tags: $f_tags_str</div>"; | |
782 | } | |
783 | ||
784 | print $line["content"] . "</div>"; | |
e828e31e AD |
785 | |
786 | print "</div>"; | |
787 | ||
090e250b | 788 | print "<script type=\"text/javascript\"> |
4f3a84f4 | 789 | update_all_counters('$feed_id'); |
090e250b | 790 | </script>"; |
d76a3b03 | 791 | } |
70830c87 AD |
792 | |
793 | if ($addheader) { | |
794 | print "</body></html>"; | |
795 | } | |
1cd17194 AD |
796 | } |
797 | ||
798 | if ($op == "viewfeed") { | |
799 | ||
800 | $feed = $_GET["feed"]; | |
d76a3b03 | 801 | $skip = $_GET["skip"]; |
476cac42 | 802 | $subop = $_GET["subop"]; |
f175937c | 803 | $view_mode = $_GET["view"]; |
f0601b87 | 804 | $addheader = $_GET["addheader"]; |
cb1083a1 | 805 | $limit = $_GET["limit"]; |
a1a8a2be | 806 | |
8d7008c7 | 807 | if (!$feed) { |
8d7008c7 AD |
808 | return; |
809 | } | |
810 | ||
ac53063a AD |
811 | if (!$skip) $skip = 0; |
812 | ||
476cac42 | 813 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 814 | |
f0601b87 AD |
815 | if ($addheader) { |
816 | print "<html><head> | |
ac43eba1 | 817 | <title>Tiny Tiny RSS : Feed $feed</title> |
430bf183 AD |
818 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
819 | ||
503eb349 AD |
820 | $user_theme = $_SESSION["theme"]; |
821 | if ($user_theme) { | |
822 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
823 | href=\"themes/$user_theme/theme.css\">"; | |
824 | } | |
825 | ||
4769ddaf | 826 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
430bf183 AD |
827 | print "<link rel=\"stylesheet\" |
828 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
829 | ||
830 | } else { | |
831 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
832 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
833 | } | |
503eb349 | 834 | |
430bf183 | 835 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
f0601b87 AD |
836 | <script type=\"text/javascript\" src=\"functions.js\"></script> |
837 | <script type=\"text/javascript\" src=\"viewfeed.js\"></script> | |
b623b3ed | 838 | </head><body onload='init()'>"; |
f0601b87 AD |
839 | } |
840 | ||
7a232fc6 | 841 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { |
dcee8f61 AD |
842 | |
843 | $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds | |
844 | WHERE id = '$feed'"); | |
845 | ||
846 | $feed_url = db_fetch_result($tmp_result, 0, "feed_url"); | |
847 | ||
848 | update_rss_feed($link, $feed_url, $feed); | |
849 | ||
850 | } | |
851 | ||
0e32076b | 852 | if ($subop == "MarkAllRead") { |
d76a3b03 | 853 | |
7a232fc6 | 854 | if (sprintf("%d", $feed) != 0) { |
0e32076b AD |
855 | |
856 | if ($feed > 0) { | |
f23a2177 | 857 | db_query($link, "UPDATE ttrss_user_entries |
0e32076b | 858 | SET unread = false,last_read = NOW() |
f23a2177 | 859 | WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]); |
0e32076b AD |
860 | |
861 | } else if ($feed < 0 && $feed > -10) { // special, like starred | |
862 | ||
863 | if ($feed == -1) { | |
f23a2177 | 864 | db_query($link, "UPDATE ttrss_user_entries |
0e32076b | 865 | SET unread = false,last_read = NOW() |
5859be02 | 866 | WHERE marked = true AND owner_uid = ".$_SESSION["uid"]); |
0e32076b AD |
867 | } |
868 | ||
869 | } else if ($feed < -10) { // label | |
870 | ||
f23a2177 AD |
871 | // TODO make this more efficient |
872 | ||
7db95187 | 873 | $label_id = -$feed - 11; |
0e32076b | 874 | |
7db95187 | 875 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels |
f23a2177 | 876 | WHERE id = '$label_id'"); |
7db95187 AD |
877 | |
878 | if ($tmp_result) { | |
879 | $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp"); | |
880 | ||
f23a2177 AD |
881 | db_query($link, "BEGIN"); |
882 | ||
883 | $tmp2_result = db_query($link, | |
884 | "SELECT | |
885 | int_id | |
886 | FROM | |
887 | ttrss_user_entries,ttrss_entries | |
888 | WHERE | |
889 | ref_id = id AND | |
890 | $sql_exp AND | |
891 | owner_uid = " . $_SESSION["uid"]); | |
892 | ||
893 | while ($tmp_line = db_fetch_assoc($tmp2_result)) { | |
894 | db_query($link, "UPDATE | |
895 | ttrss_user_entries | |
896 | SET | |
897 | unread = false, last_read = NOW() | |
898 | WHERE | |
899 | int_id = " . $tmp_line["int_id"]); | |
900 | } | |
901 | ||
902 | db_query($link, "COMMIT"); | |
903 | ||
904 | /* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries | |
7db95187 | 905 | SET unread = false,last_read = NOW() |
f23a2177 AD |
906 | WHERE $sql_exp |
907 | AND ref_id = id | |
908 | AND owner_uid = ".$_SESSION["uid"]); */ | |
7db95187 | 909 | } |
254e0e4b | 910 | } |
0e32076b | 911 | } else { // tag |
7eec90cf AD |
912 | db_query($link, "BEGIN"); |
913 | ||
914 | $tag_name = db_escape_string($feed); | |
915 | ||
916 | $result = db_query($link, "SELECT post_int_id FROM ttrss_tags | |
917 | WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]); | |
918 | ||
919 | while ($line = db_fetch_assoc($result)) { | |
920 | db_query($link, "UPDATE ttrss_user_entries SET | |
921 | unread = false, last_read = NOW() | |
922 | WHERE int_id = " . $line["post_int_id"]); | |
923 | } | |
924 | db_query($link, "COMMIT"); | |
a1a8a2be | 925 | } |
0e32076b | 926 | |
a1a8a2be | 927 | } |
d76a3b03 | 928 | |
f932bc9f AD |
929 | $search = db_escape_string($_GET["search"]); |
930 | $search_mode = db_escape_string($_GET["smode"]); | |
52b51244 | 931 | |
f175937c | 932 | if ($search) { |
ac53063a AD |
933 | $search_query_part = "(upper(title) LIKE upper('%$search%') |
934 | OR content LIKE '%$search%') AND"; | |
f175937c AD |
935 | } else { |
936 | $search_query_part = ""; | |
937 | } | |
938 | ||
939 | $view_query_part = ""; | |
940 | ||
0ee2d12f AD |
941 | if ($view_mode == "Adaptive") { |
942 | if ($feed != -1) { | |
943 | $unread = getFeedUnread($link, $feed); | |
944 | if ($unread > 0) { | |
945 | $view_query_part = " unread = true AND "; | |
946 | } | |
947 | } | |
948 | } | |
949 | ||
f175937c AD |
950 | if ($view_mode == "Starred") { |
951 | $view_query_part = " marked = true AND "; | |
ac53063a AD |
952 | } |
953 | ||
ac43eba1 AD |
954 | if ($view_mode == "Unread") { |
955 | $view_query_part = " unread = true AND "; | |
956 | } | |
957 | ||
0ee2d12f | 958 | /* if ($view_mode == "Unread or Starred") { |
b5aa95e7 AD |
959 | $view_query_part = " (unread = true OR marked = true) AND "; |
960 | } | |
961 | ||
bdd01d3f AD |
962 | if ($view_mode == "Unread or Updated") { |
963 | $view_query_part = " (unread = true OR last_read is NULL) AND "; | |
0ee2d12f | 964 | } */ |
bdd01d3f | 965 | |
254e0e4b | 966 | /* $result = db_query($link, "SELECT count(id) AS total_entries |
36bf7496 AD |
967 | FROM ttrss_entries WHERE |
968 | $search_query_part | |
969 | feed_id = '$feed'"); | |
e6d1c0a0 | 970 | |
254e0e4b | 971 | $total_entries = db_fetch_result($result, 0, "total_entries"); */ |
e6d1c0a0 | 972 | |
648472a7 | 973 | /* $result = db_query("SELECT count(id) AS unread_entries |
ac43eba1 AD |
974 | FROM ttrss_entries WHERE |
975 | $search_query_part | |
976 | unread = true AND | |
977 | feed_id = '$feed'"); | |
978 | ||
648472a7 | 979 | $unread_entries = db_fetch_result($result, 0, "unread_entries"); */ |
ac43eba1 | 980 | |
8d7008c7 | 981 | if ($limit && $limit != "All") { |
82c9223c | 982 | $limit_query_part = "LIMIT " . $limit; |
ad3cb710 | 983 | } |
f0601b87 | 984 | |
254e0e4b AD |
985 | $vfeed_query_part = ""; |
986 | ||
52b51244 | 987 | // override query strategy and enable feed display when searching globally |
d3416913 | 988 | if ($search && $search_mode == "All feeds") { |
52b51244 AD |
989 | $query_strategy_part = "id > 0"; |
990 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
991 | id = feed_id) as feed_title,"; | |
7a232fc6 | 992 | } else if (sprintf("%d", $feed) == 0) { |
8143ae1f AD |
993 | $query_strategy_part = "ttrss_entries.id > 0"; |
994 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
995 | id = feed_id) as feed_title,"; | |
996 | } else if ($feed >= 0) { | |
254e0e4b | 997 | $query_strategy_part = "feed_id = '$feed'"; |
48f0adb0 | 998 | } else if ($feed == -1) { // starred virtual feed |
254e0e4b | 999 | $query_strategy_part = "marked = true"; |
48f0adb0 AD |
1000 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
1001 | id = feed_id) as feed_title,"; | |
1002 | } else if ($feed <= -10) { // labels | |
1003 | $label_id = -$feed - 11; | |
1004 | ||
1005 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
1006 | WHERE id = '$label_id'"); | |
1007 | ||
1008 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
1009 | ||
254e0e4b AD |
1010 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
1011 | id = feed_id) as feed_title,"; | |
1012 | } else { | |
48f0adb0 | 1013 | $query_strategy_part = "id > 0"; // dumb |
254e0e4b AD |
1014 | } |
1015 | ||
f99321a3 AD |
1016 | $order_by = "updated DESC"; |
1017 | ||
1018 | // if ($feed < -10) { | |
1019 | // $order_by = "feed_id,updated DESC"; | |
1020 | // } | |
1021 | ||
1572afe5 AD |
1022 | $feed_title = ""; |
1023 | ||
1024 | if ($search && $search_mode == "All feeds") { | |
1025 | $feed_title = "Search results"; | |
7a232fc6 | 1026 | } else if (sprintf("%d", $feed) == 0) { |
1572afe5 AD |
1027 | $feed_title = $feed; |
1028 | } else if ($feed > 0) { | |
1029 | $result = db_query($link, "SELECT title,site_url FROM ttrss_feeds | |
1030 | WHERE id = '$feed'"); | |
1031 | ||
1032 | $feed_title = db_fetch_result($result, 0, "title"); | |
1033 | $feed_site_url = db_fetch_result($result, 0, "site_url"); | |
1034 | ||
1035 | } else if ($feed == -1) { | |
1036 | $feed_title = "Starred articles"; | |
1037 | } else if ($feed < -10) { | |
1038 | $label_id = -$feed - 11; | |
1039 | $result = db_query($link, "SELECT description FROM ttrss_labels | |
1040 | WHERE id = '$label_id'"); | |
1041 | $feed_title = db_fetch_result($result, 0, "description"); | |
1042 | } else { | |
1043 | $feed_title = "?"; | |
1044 | } | |
1045 | ||
48f0adb0 AD |
1046 | if ($feed < -10) error_reporting (0); |
1047 | ||
386cbf27 AD |
1048 | print "<div id=\"headlinesContainer\">"; |
1049 | ||
7a232fc6 | 1050 | if (sprintf("%d", $feed) != 0) { |
8143ae1f | 1051 | |
21703604 AD |
1052 | if ($feed > 0) { |
1053 | $feed_kind = "Feeds"; | |
1054 | } else { | |
1055 | $feed_kind = "Labels"; | |
1056 | } | |
1057 | ||
386cbf27 AD |
1058 | // if (!$vfeed_query_part) { |
1059 | $content_query_part = "content as content_preview,"; | |
1060 | // } else { | |
1061 | // $content_query_part = ""; | |
1062 | // } | |
bd34c528 | 1063 | |
8143ae1f | 1064 | $result = db_query($link, "SELECT |
1572afe5 AD |
1065 | id,title, |
1066 | SUBSTRING(updated,1,16) as updated, | |
1067 | unread,feed_id,marked,link,last_read, | |
8143ae1f AD |
1068 | SUBSTRING(last_read,1,19) as last_read_noms, |
1069 | $vfeed_query_part | |
bd34c528 AD |
1070 | $content_query_part |
1071 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 1072 | FROM |
4c193675 | 1073 | ttrss_entries,ttrss_user_entries |
8143ae1f | 1074 | WHERE |
4c193675 | 1075 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
aee86c2e | 1076 | owner_uid = '".$_SESSION["uid"]."' AND |
8143ae1f AD |
1077 | $search_query_part |
1078 | $view_query_part | |
1079 | $query_strategy_part ORDER BY $order_by | |
1080 | $limit_query_part"); | |
1081 | ||
1082 | } else { | |
1083 | // browsing by tag | |
1084 | ||
21703604 AD |
1085 | $feed_kind = "Tags"; |
1086 | ||
8143ae1f | 1087 | $result = db_query($link, "SELECT |
1572afe5 AD |
1088 | ttrss_entries.id as id,title, |
1089 | SUBSTRING(updated,1,16) as updated, | |
1090 | unread,feed_id, | |
8143ae1f | 1091 | marked,link,last_read, |
c05a19f3 | 1092 | SUBSTRING(last_read,1,19) as last_read_noms, |
254e0e4b | 1093 | $vfeed_query_part |
bd34c528 AD |
1094 | $content_query_part |
1095 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 1096 | FROM |
05732aa0 | 1097 | ttrss_entries,ttrss_user_entries,ttrss_tags |
8143ae1f | 1098 | WHERE |
05732aa0 AD |
1099 | ref_id = ttrss_entries.id AND |
1100 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
1101 | post_int_id = int_id AND tag_name = '$feed' AND | |
8143ae1f AD |
1102 | $view_query_part |
1103 | $search_query_part | |
1104 | $query_strategy_part ORDER BY $order_by | |
1105 | $limit_query_part"); | |
1106 | } | |
d76a3b03 | 1107 | |
48f0adb0 | 1108 | if (!$result) { |
386cbf27 AD |
1109 | print "<div align='center'> |
1110 | Could not display feed (query failed). Please check label match syntax or local configuration.</div>"; | |
1111 | return; | |
adccd201 AD |
1112 | } |
1113 | ||
f56ec297 AD |
1114 | if (db_num_rows($result) > 0) { |
1115 | ||
386cbf27 AD |
1116 | print "<table class=\"headlinesSubToolbar\" |
1117 | width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>"; | |
1118 | ||
1119 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { | |
adccd201 | 1120 | |
adccd201 AD |
1121 | print "<td class=\"headlineActions\"> |
1122 | Select: | |
386cbf27 AD |
1123 | <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', |
1124 | 'RROW-', 'RCHK-', true)\">All</a>, | |
1125 | <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', | |
1126 | 'RROW-', 'RCHK-', true, 'Unread')\">Unread</a>, | |
1127 | <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', | |
1128 | 'RROW-', 'RCHK-', false)\">None</a> | |
1129 | | |
1130 | Toggle: <a href=\"javascript:selectionToggleUnread()\">Unread</a>, | |
1131 | <a href=\"javascript:selectionToggleMarked()\">Starred</a>"; | |
1132 | ||
adccd201 | 1133 | print "</td>"; |
386cbf27 AD |
1134 | |
1135 | } else { | |
1136 | ||
1137 | print "<td class=\"headlineActions\"> | |
1138 | Select: | |
1139 | <a href=\"javascript:cdmSelectArticles('all')\">All</a>, | |
1140 | <a href=\"javascript:cdmSelectArticles('unread')\">Unread</a>, | |
1141 | <a href=\"javascript:cdmSelectArticles('none')\">None</a> | |
1142 | | |
1143 | Toggle: <a href=\"javascript:selectionToggleUnread(true)\">Unread</a>, | |
1144 | <a href=\"javascript:selectionToggleMarked(true)\">Starred</a>"; | |
1145 | ||
adccd201 | 1146 | print "</td>"; |
386cbf27 AD |
1147 | |
1148 | ||
1149 | } | |
1150 | ||
1151 | print "<td class=\"headlineTitle\">"; | |
adccd201 | 1152 | |
386cbf27 AD |
1153 | if ($feed_site_url) { |
1154 | print "<a target=\"_blank\" href=\"$feed_site_url\">$feed_title</a>"; | |
1155 | } else { | |
1156 | print $feed_title; | |
1157 | } | |
1158 | ||
1159 | print "</td>"; | |
1160 | print "</tr></table>"; | |
1161 | ||
1162 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { | |
adccd201 AD |
1163 | print "<table class=\"headlinesList\" id=\"headlinesList\" |
1164 | cellspacing=\"0\" width=\"100%\">"; | |
f4c10d44 | 1165 | } |
386cbf27 | 1166 | |
e5a99b88 AD |
1167 | $lnum = 0; |
1168 | ||
1169 | error_reporting (DEFAULT_ERROR_LEVEL); | |
1170 | ||
1171 | $num_unread = 0; | |
1172 | ||
1173 | while ($line = db_fetch_assoc($result)) { | |
adccd201 | 1174 | |
e5a99b88 AD |
1175 | $class = ($lnum % 2) ? "even" : "odd"; |
1176 | ||
1177 | $id = $line["id"]; | |
1178 | $feed_id = $line["feed_id"]; | |
1179 | ||
1180 | if ($line["last_read"] == "" && | |
1181 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
1182 | ||
1183 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
1184 | alt=\"Updated\">"; | |
1185 | } else { | |
1186 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
1187 | alt=\"Updated\">"; | |
1188 | } | |
1189 | ||
1190 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
1191 | $class .= "Unread"; | |
1192 | ++$num_unread; | |
386cbf27 | 1193 | $is_unread = true; |
adccd201 | 1194 | } else { |
386cbf27 | 1195 | $is_unread = false; |
e5a99b88 AD |
1196 | } |
1197 | ||
1198 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
1199 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" | |
9932fb06 | 1200 | alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
1201 | } else { |
1202 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
9932fb06 | 1203 | alt=\"Set mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
1204 | } |
1205 | ||
e454a889 | 1206 | $content_link = "<a href=\"javascript:view($id,$feed_id);\">" . |
e5a99b88 | 1207 | $line["title"] . "</a>"; |
adccd201 | 1208 | |
e5a99b88 AD |
1209 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
1210 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
1211 | } else { | |
1212 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1213 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
1214 | } | |
adccd201 AD |
1215 | |
1216 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
8fd0c717 | 1217 | $content_preview = truncate_string(strip_tags($line["content_preview"]), |
de244d27 | 1218 | 200); |
adccd201 AD |
1219 | } |
1220 | ||
386cbf27 | 1221 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 AD |
1222 | |
1223 | print "<tr class='$class' id='RROW-$id'>"; | |
adccd201 AD |
1224 | |
1225 | print "<td class='hlUpdatePic'>$update_pic</td>"; | |
1226 | ||
1227 | print "<td class='hlSelectRow'> | |
1228 | <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\" | |
1229 | class=\"feedCheckBox\" id=\"RCHK-$id\"> | |
1230 | </td>"; | |
1231 | ||
1232 | print "<td class='hlMarkedPic'>$marked_pic</td>"; | |
1233 | ||
1234 | if ($line["feed_title"]) { | |
1235 | print "<td class='hlContent'>$content_link</td>"; | |
1236 | print "<td class='hlFeed'> | |
42918a07 | 1237 | <a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a> </td>"; |
adccd201 | 1238 | } else { |
de244d27 | 1239 | print "<td class='hlContent' valign='middle'>"; |
adccd201 | 1240 | |
e454a889 | 1241 | print "<a href=\"javascript:view($id,$feed_id);\">" . |
adccd201 AD |
1242 | $line["title"]; |
1243 | ||
1244 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
1245 | ||
1246 | if ($content_preview) { | |
1247 | print "<span class=\"contentPreview\"> - $content_preview</span>"; | |
1248 | } | |
1249 | } | |
1250 | ||
1251 | print "</a>"; | |
1252 | print "</td>"; | |
1253 | } | |
1254 | ||
1255 | print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>"; | |
1256 | ||
1257 | print "</tr>"; | |
1258 | ||
1259 | } else { | |
386cbf27 AD |
1260 | |
1261 | if ($is_unread) { | |
1262 | $add_class = "Unread"; | |
1263 | } else { | |
1264 | $add_class = ""; | |
1265 | } | |
1266 | ||
1267 | print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">"; | |
1268 | ||
1269 | print "<div class=\"cdmHeader\">"; | |
adccd201 | 1270 | |
386cbf27 AD |
1271 | print "<div style=\"float : right\">$updated_fmt</div>"; |
1272 | ||
1273 | print "<a href=\"".$line["link"]."\">".$line["title"]."</a>"; | |
adccd201 | 1274 | |
386cbf27 AD |
1275 | if ($line["feed_title"]) { |
1276 | print " (<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)"; | |
adccd201 | 1277 | } |
adccd201 | 1278 | |
386cbf27 AD |
1279 | print "</div>"; |
1280 | ||
1281 | print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div>"; | |
1282 | ||
1283 | print "<div style=\"float : right\">$marked_pic</div> | |
1284 | <div class=\"cdmFooter\"> | |
1285 | <input type=\"checkbox\" onclick=\"toggleSelectRowById(this, | |
1286 | 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"></div>"; | |
1287 | ||
1288 | print "</div>"; | |
1289 | ||
1290 | } | |
e5a99b88 AD |
1291 | |
1292 | ++$lnum; | |
254e0e4b | 1293 | } |
adccd201 | 1294 | |
386cbf27 | 1295 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 1296 | print "</table>"; |
adccd201 | 1297 | } |
d76a3b03 | 1298 | |
e5a99b88 AD |
1299 | } else { |
1300 | print "<div width='100%' align='center'>No articles found.</div>"; | |
a1a8a2be | 1301 | } |
d76a3b03 | 1302 | |
386cbf27 | 1303 | print "</div>"; |
d76a3b03 | 1304 | |
386cbf27 AD |
1305 | print "<script type=\"text/javascript\"> |
1306 | document.onkeydown = hotkey_handler; | |
1307 | update_all_counters('$feed'); | |
1308 | </script>"; | |
adccd201 | 1309 | |
386cbf27 AD |
1310 | if ($addheader) { |
1311 | print "</body></html>"; | |
f0601b87 | 1312 | } |
1cd17194 AD |
1313 | } |
1314 | ||
0e091d38 | 1315 | if ($op == "pref-rpc") { |
331900c6 | 1316 | |
0e091d38 | 1317 | $subop = $_GET["subop"]; |
331900c6 | 1318 | |
83fe4d6d | 1319 | if ($subop == "unread") { |
f932bc9f | 1320 | $ids = split(",", db_escape_string($_GET["ids"])); |
83fe4d6d | 1321 | foreach ($ids as $id) { |
a5873b2e AD |
1322 | db_query($link, "UPDATE ttrss_user_entries SET unread = true |
1323 | WHERE feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
83fe4d6d | 1324 | } |
0e091d38 | 1325 | |
a5873b2e | 1326 | print "Marked selected feeds as unread."; |
83fe4d6d AD |
1327 | } |
1328 | ||
1329 | if ($subop == "read") { | |
f932bc9f | 1330 | $ids = split(",", db_escape_string($_GET["ids"])); |
83fe4d6d | 1331 | foreach ($ids as $id) { |
a5873b2e AD |
1332 | db_query($link, "UPDATE ttrss_user_entries |
1333 | SET unread = false,last_read = NOW() WHERE | |
1334 | feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
83fe4d6d | 1335 | } |
0e091d38 | 1336 | |
a5873b2e | 1337 | print "Marked selected feeds as read."; |
0e091d38 AD |
1338 | |
1339 | } | |
1340 | ||
1341 | } | |
1342 | ||
1343 | if ($op == "pref-feeds") { | |
1344 | ||
1345 | $subop = $_GET["subop"]; | |
a24f525c | 1346 | $quiet = $_GET["quiet"]; |
0e091d38 | 1347 | |
0ea4fb50 AD |
1348 | if ($subop == "editfeed") { |
1349 | $feed_id = db_escape_string($_GET["id"]); | |
1350 | ||
1351 | $result = db_query($link, | |
1352 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
1353 | owner_uid = " . $_SESSION["uid"]); | |
1354 | ||
1355 | $title = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1356 | 0, "title"))); | |
1357 | ||
1358 | print "<div class=\"infoBoxContents\">"; | |
1359 | ||
1360 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1361 | ||
1362 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1363 | $feed_icon = "<img width=\"16\" height=\"16\" | |
1364 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1365 | } else { | |
1366 | $feed_icon = ""; | |
1367 | } | |
1368 | ||
1369 | print "<h1>$feed_icon $title</h1>"; | |
1370 | ||
1371 | print "<table width='100%'>"; | |
1372 | ||
1373 | $row_class = "odd"; | |
1374 | ||
1375 | print "<tr class='$row_class'><td>Title:</td>"; | |
1376 | print "<td><input id=\"iedit_title\" value=\"$title\"></td></tr>"; | |
1377 | ||
1378 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1379 | $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1380 | 0, "feed_url"))); | |
1381 | $row_class = toggleEvenOdd($row_class); | |
1382 | ||
1383 | print "<tr class='$row_class'><td>Feed URL:</td>"; | |
1384 | print "<td><input id=\"iedit_link\" value=\"$feed_url\"></td></tr>"; | |
1385 | ||
1386 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1387 | ||
1388 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
1389 | ||
1390 | $row_class = toggleEvenOdd($row_class); | |
1391 | ||
1392 | print "<tr class='$row_class'><td>Category:</td>"; | |
1393 | print "<td>"; | |
1394 | print "<select id=\"iedit_fcat\">"; | |
1395 | print "<option id=\"0\">Uncategorized</option>"; | |
1396 | ||
1397 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories | |
1398 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
1399 | ||
1400 | if (db_num_rows($tmp_result) > 0) { | |
1401 | print "<option disabled>--------</option>"; | |
1402 | } | |
1403 | ||
1404 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1405 | if ($tmp_line["id"] == $cat_id) { | |
1406 | $is_selected = "selected"; | |
1407 | } else { | |
1408 | $is_selected = ""; | |
1409 | } | |
1410 | printf("<option $is_selected id='%d'>%s</option>", | |
1411 | $tmp_line["id"], $tmp_line["title"]); | |
1412 | } | |
1413 | ||
1414 | print "</select></td>"; | |
1415 | print "</td></tr>"; | |
1416 | ||
1417 | } | |
1418 | ||
1419 | $update_interval = db_fetch_result($result, 0, "update_interval"); | |
1420 | $row_class = toggleEvenOdd($row_class); | |
1421 | ||
1422 | print "<tr class='$row_class'><td>Update Interval:</td>"; | |
1423 | print "<td><input id=\"iedit_updintl\" | |
1424 | value=\"$update_interval\"></td></tr>"; | |
1425 | ||
1426 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); | |
1427 | $row_class = toggleEvenOdd($row_class); | |
1428 | ||
1429 | print "<tr class='$row_class'><td>Purge Days:</td>"; | |
1430 | print "<td><input id=\"iedit_purgintl\" | |
1431 | value=\"$purge_interval\"></td></tr>"; | |
1432 | ||
1433 | print "</table>"; | |
1434 | print "</div>"; | |
1435 | ||
1436 | print "<div align='center'> | |
1437 | <input type='submit' class='button' | |
327a3bbe | 1438 | onclick=\"feedEditCancel()\" value=\"Cancel\"> |
0ea4fb50 | 1439 | <input type=\"submit\" class=\"button\" |
327a3bbe | 1440 | onclick=\"feedEditSave()\" value=\"Save\"></div>"; |
0ea4fb50 AD |
1441 | return; |
1442 | } | |
1443 | ||
508a81e1 | 1444 | if ($subop == "editSave") { |
648472a7 AD |
1445 | $feed_title = db_escape_string($_GET["t"]); |
1446 | $feed_link = db_escape_string($_GET["l"]); | |
d148926e | 1447 | $upd_intl = db_escape_string($_GET["ui"]); |
5d73494a | 1448 | $purge_intl = db_escape_string($_GET["pi"]); |
91ff844a AD |
1449 | $feed_id = db_escape_string($_GET["id"]); |
1450 | $cat_id = db_escape_string($_GET["catid"]); | |
508a81e1 | 1451 | |
d148926e AD |
1452 | if (strtoupper($upd_intl) == "DEFAULT") |
1453 | $upd_intl = 0; | |
1454 | ||
a88c1f36 AD |
1455 | if (strtoupper($upd_intl) == "DISABLED") |
1456 | $upd_intl = -1; | |
1457 | ||
5d73494a AD |
1458 | if (strtoupper($purge_intl) == "DEFAULT") |
1459 | $purge_intl = 0; | |
1460 | ||
140aae81 AD |
1461 | if (strtoupper($purge_intl) == "DISABLED") |
1462 | $purge_intl = -1; | |
1463 | ||
91ff844a AD |
1464 | if ($cat_id != 0) { |
1465 | $category_qpart = "cat_id = '$cat_id'"; | |
1466 | } else { | |
1467 | $category_qpart = 'cat_id = NULL'; | |
1468 | } | |
1469 | ||
648472a7 | 1470 | $result = db_query($link, "UPDATE ttrss_feeds SET |
91ff844a | 1471 | $category_qpart, |
d148926e | 1472 | title = '$feed_title', feed_url = '$feed_link', |
5d73494a | 1473 | update_interval = '$upd_intl', |
91ff844a | 1474 | purge_interval = '$purge_intl' |
f72dbbde | 1475 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
5ddadb4c AD |
1476 | } |
1477 | ||
1478 | if ($subop == "saveCat") { | |
1479 | $cat_title = db_escape_string($_GET["title"]); | |
1480 | $cat_id = db_escape_string($_GET["id"]); | |
1481 | ||
1482 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
1483 | title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
508a81e1 | 1484 | |
83fe4d6d AD |
1485 | } |
1486 | ||
331900c6 | 1487 | if ($subop == "remove") { |
331900c6 | 1488 | |
b0b4abcf | 1489 | if (!WEB_DEMO_MODE) { |
331900c6 | 1490 | |
f932bc9f | 1491 | $ids = split(",", db_escape_string($_GET["ids"])); |
b0b4abcf AD |
1492 | |
1493 | foreach ($ids as $id) { | |
f72dbbde AD |
1494 | db_query($link, "DELETE FROM ttrss_feeds |
1495 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
4769ddaf | 1496 | |
273a2f6b | 1497 | $icons_dir = ICONS_DIR; |
d5caaae5 | 1498 | |
4769ddaf AD |
1499 | if (file_exists($icons_dir . "/$id.ico")) { |
1500 | unlink($icons_dir . "/$id.ico"); | |
d5caaae5 | 1501 | } |
b0b4abcf | 1502 | } |
331900c6 AD |
1503 | } |
1504 | } | |
1505 | ||
1506 | if ($subop == "add") { | |
b0b4abcf AD |
1507 | |
1508 | if (!WEB_DEMO_MODE) { | |
331900c6 | 1509 | |
b6b535ca | 1510 | $feed_link = db_escape_string(trim($_GET["link"])); |
331900c6 | 1511 | |
648472a7 | 1512 | $result = db_query($link, |
7e9a3986 AD |
1513 | "SELECT id FROM ttrss_feeds |
1514 | WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]); | |
1515 | ||
1516 | if (db_num_rows($result) == 0) { | |
1517 | ||
1518 | $result = db_query($link, | |
1519 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title) | |
1520 | VALUES ('".$_SESSION["uid"]."', '$feed_link', '')"); | |
331900c6 | 1521 | |
7e9a3986 AD |
1522 | $result = db_query($link, |
1523 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link' | |
1524 | AND owner_uid = " . $_SESSION["uid"]); | |
1525 | ||
1526 | $feed_id = db_fetch_result($result, 0, "id"); | |
1527 | ||
1528 | if ($feed_id) { | |
ddb68b81 | 1529 | update_rss_feed($link, $feed_link, $feed_id, true); |
7e9a3986 AD |
1530 | } |
1531 | } else { | |
331900c6 | 1532 | |
7e9a3986 AD |
1533 | print "<div class=\"warning\"> |
1534 | Feed <b>$feed_link</b> already exists in the database. | |
1535 | </div>"; | |
b0b4abcf AD |
1536 | } |
1537 | } | |
331900c6 | 1538 | } |
a0d53889 | 1539 | |
91ff844a AD |
1540 | if ($subop == "addCat") { |
1541 | ||
1542 | if (!WEB_DEMO_MODE) { | |
1543 | ||
1544 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
1545 | ||
1546 | $result = db_query($link, | |
1547 | "SELECT id FROM ttrss_feed_categories | |
1548 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
1549 | ||
1550 | if (db_num_rows($result) == 0) { | |
1551 | ||
1552 | $result = db_query($link, | |
1553 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
1554 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
1555 | ||
1556 | } else { | |
1557 | ||
1558 | print "<div class=\"warning\"> | |
1559 | Category <b>$feed_cat</b> already exists in the database. | |
1560 | </div>"; | |
1561 | } | |
1562 | ||
1563 | ||
1564 | } | |
1565 | } | |
1566 | ||
1567 | if ($subop == "removeCats") { | |
1568 | ||
1569 | if (!WEB_DEMO_MODE) { | |
1570 | ||
f932bc9f | 1571 | $ids = split(",", db_escape_string($_GET["ids"])); |
91ff844a AD |
1572 | |
1573 | foreach ($ids as $id) { | |
1574 | ||
1575 | db_query($link, "BEGIN"); | |
1576 | ||
1577 | $result = db_query($link, | |
1578 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
1579 | WHERE cat_id = '$id'"); | |
1580 | ||
1581 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
1582 | ||
1583 | if ($num_feeds == 0) { | |
1584 | db_query($link, "DELETE FROM ttrss_feed_categories | |
1585 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1586 | } else { | |
1587 | ||
1588 | print "<div class=\"warning\"> | |
1589 | Unable to delete non empty feed categories.</div>"; | |
1590 | ||
1591 | } | |
1592 | ||
1593 | db_query($link, "COMMIT"); | |
1594 | } | |
1595 | } | |
1596 | } | |
1597 | ||
f932bc9f AD |
1598 | if ($subop == "categorize") { |
1599 | ||
1600 | if (!WEB_DEMO_MODE) { | |
1601 | ||
1602 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1603 | ||
1604 | $cat_id = db_escape_string($_GET["cat_id"]); | |
1605 | ||
1606 | if ($cat_id == 0) { | |
1607 | $cat_id_qpart = 'NULL'; | |
1608 | } else { | |
1609 | $cat_id_qpart = "'$cat_id'"; | |
1610 | } | |
1611 | ||
1612 | db_query($link, "BEGIN"); | |
1613 | ||
1614 | foreach ($ids as $id) { | |
1615 | ||
1616 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
1617 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1618 | } | |
1619 | ||
1620 | db_query($link, "COMMIT"); | |
1621 | } | |
1622 | ||
1623 | } | |
1624 | ||
a24f525c AD |
1625 | if ($quiet) return; |
1626 | ||
c64d5b03 | 1627 | // print "<h3>Edit Feeds</h3>"; |
91ff844a | 1628 | |
4904f845 AD |
1629 | $result = db_query($link, "SELECT id,title,feed_url,last_error |
1630 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1631 | ||
1632 | if (db_num_rows($result) > 0) { | |
1633 | ||
1634 | print "<div class=\"warning\">"; | |
1635 | ||
36aab70f AD |
1636 | print "<a href=\"javascript:showBlockElement('feedUpdateErrors')\"> |
1637 | <b>Feeds with update errors</b> (click to expand)</a>"; | |
4904f845 | 1638 | |
36aab70f | 1639 | print "<ul id=\"feedUpdateErrors\" class=\"nomarks\">"; |
4904f845 AD |
1640 | |
1641 | while ($line = db_fetch_assoc($result)) { | |
1642 | print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " . | |
1643 | $line["last_error"]; | |
1644 | } | |
1645 | ||
1646 | print "</ul>"; | |
1647 | print "</div>"; | |
1648 | ||
1649 | } | |
1650 | ||
f932bc9f AD |
1651 | $feed_search = db_escape_string($_GET["search"]); |
1652 | ||
1653 | if (array_key_exists("search", $_GET)) { | |
1654 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1655 | } else { | |
1656 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1657 | } | |
1658 | ||
1659 | print "<table width='100%' class=\"prefGenericAddBox\" | |
1660 | cellspacing='0' cellpadding='0'><tr> | |
1661 | <td> | |
1662 | <input id=\"fadd_link\" | |
1663 | onchange=\"javascript:addFeed()\" | |
1664 | size=\"40\"> | |
1665 | <input type=\"submit\" class=\"button\" | |
1666 | onclick=\"javascript:addFeed()\" value=\"Add feed\"> | |
1667 | </td><td align='right'> | |
1668 | <input id=\"feed_search\" size=\"20\" | |
1669 | onchange=\"javascript:updateFeedList()\" | |
1670 | value=\"$feed_search\"> | |
1671 | <input type=\"submit\" class=\"button\" | |
1672 | onclick=\"javascript:updateFeedList()\" value=\"Search\"> | |
1673 | </td> | |
1674 | </tr></table>"; | |
a0d53889 | 1675 | |
b83c7545 AD |
1676 | $feeds_sort = db_escape_string($_GET["sort"]); |
1677 | ||
1678 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
1679 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
1680 | if (!$feeds_sort) $feeds_sort = "title"; | |
1681 | } | |
1682 | ||
1683 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
1684 | ||
f932bc9f | 1685 | if ($feed_search) { |
85af98a6 AD |
1686 | $search_qpart = "(UPPER(title) LIKE UPPER('%$feed_search%') OR |
1687 | UPPER(feed_url) LIKE UPPER('%$feed_search%')) AND"; | |
f932bc9f AD |
1688 | } else { |
1689 | $search_qpart = ""; | |
1690 | } | |
1691 | ||
648472a7 | 1692 | $result = db_query($link, "SELECT |
d148926e | 1693 | id,title,feed_url,substring(last_updated,1,16) as last_updated, |
76684fc7 | 1694 | update_interval,purge_interval,cat_id, |
91ff844a AD |
1695 | (SELECT title FROM ttrss_feed_categories |
1696 | WHERE id = cat_id) AS category | |
c0e5a40e | 1697 | FROM |
f932bc9f AD |
1698 | ttrss_feeds |
1699 | WHERE | |
1700 | $search_qpart owner_uid = '".$_SESSION["uid"]."' | |
0ea4fb50 | 1701 | ORDER by category,$feeds_sort,title"); |
1cd17194 | 1702 | |
3b0feb9b | 1703 | if (db_num_rows($result) != 0) { |
91ff844a | 1704 | |
3b0feb9b | 1705 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
35f3c923 | 1706 | |
f4fe2cde AD |
1707 | print "<p><table width=\"100%\" cellspacing=\"0\" |
1708 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
35f3c923 AD |
1709 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
1710 | Select: | |
1711 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', | |
3055bc41 | 1712 | 'FEEDR-', 'FRCHK-', true)\">All</a>, |
35f3c923 | 1713 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', |
3055bc41 | 1714 | 'FEEDR-', 'FRCHK-', false)\">None</a> |
35f3c923 AD |
1715 | </td</tr>"; |
1716 | ||
0ea4fb50 AD |
1717 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { |
1718 | print "<tr class=\"title\"> | |
e325c6e7 | 1719 | <td width='5%' align='center'> </td> |
62ac0cc8 | 1720 | <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> |
f42e9435 | 1721 | <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> |
62ac0cc8 AD |
1722 | <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td> |
1723 | <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a></td></tr>"; | |
603c27f8 | 1724 | } |
603c27f8 | 1725 | |
c64d5b03 | 1726 | $lnum = 0; |
0ea4fb50 AD |
1727 | |
1728 | $cur_cat_id = -1; | |
c64d5b03 AD |
1729 | |
1730 | while ($line = db_fetch_assoc($result)) { | |
1731 | ||
3b0feb9b | 1732 | $feed_id = $line["id"]; |
0ea4fb50 AD |
1733 | $cat_id = $line["cat_id"]; |
1734 | ||
1735 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
1736 | $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); | |
1737 | $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); | |
c64d5b03 | 1738 | |
0ea4fb50 AD |
1739 | if ($line["update_interval"] == "0") $line["update_interval"] = "Default"; |
1740 | if ($line["update_interval"] == "-1") $line["update_interval"] = "Disabled"; | |
1741 | if ($line["purge_interval"] == "0") $line["purge_interval"] = "Default"; | |
1742 | if ($line["purge_interval"] < 0) $line["purge_interval"] = "Disabled"; | |
1743 | ||
1744 | if (!$edit_cat) $edit_cat = "Uncategorized"; | |
1745 | ||
1746 | ||
1747 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { | |
cb58d0df AD |
1748 | $lnum = 0; |
1749 | ||
0ea4fb50 AD |
1750 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; |
1751 | ||
1752 | print "<tr class=\"title\"> | |
e325c6e7 | 1753 | <td width='5%' align='center'> </td> |
62ac0cc8 | 1754 | <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> |
f42e9435 | 1755 | <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> |
62ac0cc8 AD |
1756 | <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td> |
1757 | <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a></td></tr>"; | |
0ea4fb50 AD |
1758 | |
1759 | $cur_cat_id = $cat_id; | |
c64d5b03 | 1760 | } |
0ea4fb50 | 1761 | |
cb58d0df | 1762 | $class = ($lnum % 2) ? "even" : "odd"; |
0ea4fb50 AD |
1763 | $this_row_id = "id=\"FEEDR-$feed_id\""; |
1764 | ||
53226edc | 1765 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
1766 | |
1767 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1768 | ||
1769 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
327a3bbe | 1770 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; |
3b0feb9b | 1771 | } else { |
327a3bbe | 1772 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
3b0feb9b | 1773 | } |
327a3bbe | 1774 | // print "<td class='feedIcon'>$feed_icon</td>"; |
c64d5b03 | 1775 | |
62ac0cc8 | 1776 | print "<td class='feedSelect'><input onclick='toggleSelectRow(this);' |
0ea4fb50 | 1777 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
3547842a | 1778 | |
0ea4fb50 AD |
1779 | $edit_title = truncate_string($edit_title, 40); |
1780 | $edit_link = truncate_string($edit_link, 60); | |
a88c1f36 | 1781 | |
0ea4fb50 | 1782 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
327a3bbe | 1783 | "$feed_icon $edit_title" . "</a></td>"; |
0ea4fb50 AD |
1784 | |
1785 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1786 | $edit_link . "</a></td>"; | |
3547842a | 1787 | |
0ea4fb50 AD |
1788 | /* if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1789 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1790 | $edit_cat . "</a></td>"; | |
1791 | } */ | |
3547842a | 1792 | |
0ea4fb50 AD |
1793 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
1794 | $line["update_interval"] . "</a></td>"; | |
3b0feb9b | 1795 | |
0ea4fb50 AD |
1796 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
1797 | $line["purge_interval"] . "</a></td>"; | |
3b0feb9b | 1798 | |
c64d5b03 AD |
1799 | print "</tr>"; |
1800 | ||
1801 | ++$lnum; | |
1802 | } | |
1803 | ||
c64d5b03 | 1804 | print "</table>"; |
3b0feb9b | 1805 | |
c64d5b03 AD |
1806 | print "<p>"; |
1807 | ||
3b0feb9b AD |
1808 | if ($subop == "edit") { |
1809 | print "Edit feed: | |
c64d5b03 | 1810 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 1811 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> |
c64d5b03 | 1812 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
1813 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
1814 | } else { | |
c64d5b03 AD |
1815 | |
1816 | print " | |
1817 | Selection: | |
1818 | <input type=\"submit\" class=\"button\" | |
3b0feb9b | 1819 | onclick=\"javascript:selectedFeedDetails()\" value=\"Details\"> |
c64d5b03 | 1820 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
1821 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> |
1822 | <input type=\"submit\" class=\"button\" | |
1823 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
f932bc9f AD |
1824 | |
1825 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1826 | ||
1827 | print " "; | |
1828 | ||
1829 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
1830 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1831 | ORDER BY title"); | |
1832 | ||
1833 | print "<select id=\"sfeed_set_fcat\">"; | |
1834 | print "<option id=\"0\">Uncategorized</option>"; | |
1835 | ||
1836 | if (db_num_rows($result) != 0) { | |
1837 | ||
1838 | print "<option disabled>--------</option>"; | |
1839 | ||
1840 | while ($line = db_fetch_assoc($result)) { | |
1841 | printf("<option id='%d'>%s</option>", | |
1842 | $line["id"], $line["title"]); | |
1843 | } | |
1844 | } | |
1845 | ||
1846 | print "</select>"; | |
1847 | ||
1848 | print " <input type=\"submit\" class=\"button\" | |
1849 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Set category\">"; | |
1850 | ||
1851 | } | |
1852 | ||
3b0feb9b AD |
1853 | if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) { |
1854 | print " | |
1855 | <input type=\"submit\" class=\"button\" | |
4f3a84f4 | 1856 | onclick=\"javascript:readSelectedFeeds(true)\" value=\"Mark as read\"> |
3b0feb9b | 1857 | <input type=\"submit\" class=\"button\" |
4f3a84f4 | 1858 | onclick=\"javascript:readSelectedFeeds(false)\" |
3b0feb9b AD |
1859 | value=\"Mark as unread\"> "; |
1860 | } | |
1861 | ||
1862 | print " | |
f932bc9f | 1863 | All feeds: <input type=\"submit\" |
3b0feb9b AD |
1864 | class=\"button\" onclick=\"gotoExportOpml()\" |
1865 | value=\"Export OPML\">"; | |
1866 | } | |
1867 | } else { | |
1868 | ||
1869 | print "<p>No feeds defined.</p>"; | |
1870 | ||
1871 | } | |
1872 | ||
1873 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1874 | ||
1875 | print "<h3>Edit Categories</h3>"; | |
1876 | ||
1877 | // print "<h3>Categories</h3>"; | |
1878 | ||
1879 | print "<div class=\"prefGenericAddBox\"> | |
f932bc9f AD |
1880 | <input id=\"fadd_cat\" |
1881 | onchange=\"javascript:addFeedCat()\" | |
1882 | size=\"40\"> | |
1883 | <input | |
3b0feb9b AD |
1884 | type=\"submit\" class=\"button\" |
1885 | onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>"; | |
1886 | ||
1887 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
1888 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1889 | ORDER BY title"); | |
1890 | ||
1891 | if (db_num_rows($result) != 0) { | |
1892 | ||
35f3c923 | 1893 | print "<p><table width=\"100%\" class=\"prefFeedCatList\" |
f4fe2cde | 1894 | cellspacing=\"0\" id=\"prefFeedCatList\">"; |
35f3c923 AD |
1895 | |
1896 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
1897 | Select: | |
1898 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', | |
3055bc41 | 1899 | 'FCATR-', 'FCCHK-', true)\">All</a>, |
35f3c923 | 1900 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', |
3055bc41 | 1901 | 'FCATR-', 'FCCHK-', false)\">None</a> |
35f3c923 AD |
1902 | </td</tr>"; |
1903 | ||
3b0feb9b | 1904 | print "<tr class=\"title\"> |
a426e532 | 1905 | <td width=\"5%\"></td><td width=\"80%\">Title</td> |
3b0feb9b AD |
1906 | </tr>"; |
1907 | ||
1908 | $lnum = 0; | |
1909 | ||
1910 | while ($line = db_fetch_assoc($result)) { | |
1911 | ||
1912 | $class = ($lnum % 2) ? "even" : "odd"; | |
1913 | ||
1914 | $cat_id = $line["id"]; | |
1915 | ||
1916 | $edit_cat_id = $_GET["id"]; | |
1917 | ||
1918 | if ($subop == "editCat" && $cat_id != $edit_cat_id) { | |
1919 | $class .= "Grayed"; | |
53226edc AD |
1920 | $this_row_id = ""; |
1921 | } else { | |
1922 | $this_row_id = "id=\"FCATR-$cat_id\""; | |
3b0feb9b AD |
1923 | } |
1924 | ||
53226edc | 1925 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
1926 | |
1927 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
1928 | ||
1929 | if (!$edit_cat_id || $subop != "editCat") { | |
1930 | ||
a426e532 | 1931 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
1932 | type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>"; |
1933 | ||
1934 | print "<td><a href=\"javascript:editFeedCat($cat_id);\">" . | |
1935 | $edit_title . "</a></td>"; | |
1936 | ||
1937 | } else if ($cat_id != $edit_cat_id) { | |
1938 | ||
1939 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1940 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
1941 | ||
1942 | print "<td>$edit_title</td>"; | |
1943 | ||
1944 | } else { | |
1945 | ||
1946 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
1947 | ||
1948 | print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>"; | |
1949 | ||
1950 | } | |
1951 | ||
1952 | print "</tr>"; | |
1953 | ||
1954 | ++$lnum; | |
1955 | } | |
1956 | ||
1957 | print "</table>"; | |
1958 | ||
1959 | print "<p>"; | |
1960 | ||
1961 | if ($subop == "editCat") { | |
1962 | print "Edit category: | |
1963 | <input type=\"submit\" class=\"button\" | |
1964 | onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\"> | |
1965 | <input type=\"submit\" class=\"button\" | |
1966 | onclick=\"javascript:feedCatEditSave()\" value=\"Save\">"; | |
1967 | } else { | |
1968 | ||
1969 | print " | |
1970 | Selection: | |
1971 | <input type=\"submit\" class=\"button\" | |
1972 | onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\"> | |
1973 | <input type=\"submit\" class=\"button\" | |
1974 | onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">"; | |
1975 | ||
1976 | } | |
1977 | ||
1978 | } else { | |
1979 | print "<p>No feed categories defined.</p>"; | |
1980 | } | |
c64d5b03 AD |
1981 | } |
1982 | ||
1983 | print "<h3>Import OPML</h3> | |
f5a50b25 AD |
1984 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
1985 | File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
1986 | <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\" | |
1987 | type=\"submit\" value=\"Import\"> | |
1988 | </form>"; | |
1989 | ||
007bda35 AD |
1990 | } |
1991 | ||
a0d53889 AD |
1992 | if ($op == "pref-filters") { |
1993 | ||
1994 | $subop = $_GET["subop"]; | |
a24f525c | 1995 | $quiet = $_GET["quiet"]; |
a0d53889 AD |
1996 | |
1997 | if ($subop == "editSave") { | |
a0d53889 | 1998 | |
648472a7 AD |
1999 | $regexp = db_escape_string($_GET["r"]); |
2000 | $descr = db_escape_string($_GET["d"]); | |
2001 | $match = db_escape_string($_GET["m"]); | |
2002 | $filter_id = db_escape_string($_GET["id"]); | |
ead60402 | 2003 | $feed_id = db_escape_string($_GET["fid"]); |
19c9cb11 | 2004 | $action_id = db_escape_string($_GET["aid"]); |
ead60402 AD |
2005 | |
2006 | if (!$feed_id) { | |
2007 | $feed_id = 'NULL'; | |
2008 | } else { | |
2009 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2010 | } | |
0afbd851 | 2011 | |
648472a7 | 2012 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 2013 | reg_exp = '$regexp', |
0afbd851 | 2014 | description = '$descr', |
ead60402 | 2015 | feed_id = $feed_id, |
19c9cb11 | 2016 | action_id = '$action_id', |
0afbd851 AD |
2017 | filter_type = (SELECT id FROM ttrss_filter_types WHERE |
2018 | description = '$match') | |
2019 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
2020 | } |
2021 | ||
2022 | if ($subop == "remove") { | |
2023 | ||
2024 | if (!WEB_DEMO_MODE) { | |
2025 | ||
f932bc9f | 2026 | $ids = split(",", db_escape_string($_GET["ids"])); |
a0d53889 AD |
2027 | |
2028 | foreach ($ids as $id) { | |
648472a7 | 2029 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
2030 | |
2031 | } | |
2032 | } | |
2033 | } | |
2034 | ||
2035 | if ($subop == "add") { | |
2036 | ||
de435974 | 2037 | if (!WEB_DEMO_MODE) { |
a0d53889 | 2038 | |
b6b535ca AD |
2039 | $regexp = db_escape_string(trim($_GET["regexp"])); |
2040 | $match = db_escape_string(trim($_GET["match"])); | |
ead60402 | 2041 | $feed_id = db_escape_string($_GET["fid"]); |
19c9cb11 | 2042 | $action_id = db_escape_string($_GET["aid"]); |
ead60402 AD |
2043 | |
2044 | if (!$feed_id) { | |
2045 | $feed_id = 'NULL'; | |
2046 | } else { | |
2047 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2048 | } | |
4401bf04 | 2049 | |
648472a7 | 2050 | $result = db_query($link, |
19c9cb11 AD |
2051 | "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, |
2052 | action_id) | |
2053 | VALUES | |
de435974 | 2054 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
19c9cb11 AD |
2055 | description = '$match'),'".$_SESSION["uid"]."', |
2056 | $feed_id, '$action_id')"); | |
de435974 | 2057 | } |
a0d53889 AD |
2058 | } |
2059 | ||
a24f525c AD |
2060 | if ($quiet) return; |
2061 | ||
648472a7 | 2062 | $result = db_query($link, "SELECT description |
a0d53889 AD |
2063 | FROM ttrss_filter_types ORDER BY description"); |
2064 | ||
2065 | $filter_types = array(); | |
2066 | ||
648472a7 | 2067 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
2068 | array_push($filter_types, $line["description"]); |
2069 | } | |
2070 | ||
2c7070b5 | 2071 | print "<div class=\"prefGenericAddBox\"> |
7cc1e5d6 | 2072 | <input id=\"fadd_regexp\" size=\"40\"> "; |
2c7070b5 | 2073 | |
ead60402 AD |
2074 | print_select("fadd_match", "Title", $filter_types); |
2075 | ||
2076 | print " <select id=\"fadd_feed\">"; | |
2077 | ||
2078 | print "<option selected id=\"0\">All feeds</option>"; | |
2079 | ||
2080 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2081 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2082 | ||
2083 | if (db_num_rows($result) > 0) { | |
2084 | print "<option disabled>--------</option>"; | |
2085 | } | |
2086 | ||
2087 | while ($line = db_fetch_assoc($result)) { | |
2088 | printf("<option id='%d'>%s</option>", $line["id"], $line["title"]); | |
2089 | } | |
2090 | ||
2c7070b5 | 2091 | print "</select> "; |
19c9cb11 AD |
2092 | |
2093 | print " Action: "; | |
2094 | ||
2095 | print "<select id=\"fadd_action\">"; | |
2096 | ||
2097 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2098 | ORDER BY name"); | |
2099 | ||
2100 | while ($line = db_fetch_assoc($result)) { | |
2101 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
2102 | } | |
2103 | ||
2104 | print "</select> "; | |
2105 | ||
2c7070b5 AD |
2106 | print "<input type=\"submit\" |
2107 | class=\"button\" onclick=\"javascript:addFilter()\" | |
2108 | value=\"Add filter\">"; | |
a0d53889 | 2109 | |
19c9cb11 AD |
2110 | print "</div>"; |
2111 | ||
648472a7 | 2112 | $result = db_query($link, "SELECT |
ead60402 AD |
2113 | ttrss_filters.id AS id,reg_exp, |
2114 | ttrss_filters.description AS description, | |
2115 | ttrss_filter_types.name AS filter_type_name, | |
2116 | ttrss_filter_types.description AS filter_type_descr, | |
2117 | feed_id, | |
19c9cb11 | 2118 | ttrss_filter_actions.description AS action_description, |
ead60402 | 2119 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title |
a0d53889 | 2120 | FROM |
19c9cb11 | 2121 | ttrss_filters,ttrss_filter_types,ttrss_filter_actions |
4356293a | 2122 | WHERE |
ead60402 | 2123 | filter_type = ttrss_filter_types.id AND |
19c9cb11 | 2124 | ttrss_filter_actions.id = action_id AND |
ead60402 | 2125 | ttrss_filters.owner_uid = ".$_SESSION["uid"]." |
4356293a | 2126 | ORDER by reg_exp"); |
a0d53889 | 2127 | |
3b0feb9b | 2128 | if (db_num_rows($result) != 0) { |
a0d53889 | 2129 | |
f4fe2cde AD |
2130 | print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" |
2131 | id=\"prefFilterList\">"; | |
35f3c923 AD |
2132 | |
2133 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2134 | Select: | |
2135 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', | |
3055bc41 | 2136 | 'FILRR-', 'FICHK-', true)\">All</a>, |
35f3c923 | 2137 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', |
3055bc41 | 2138 | 'FILRR-', 'FICHK-', false)\">None</a> |
35f3c923 AD |
2139 | </td</tr>"; |
2140 | ||
3b0feb9b | 2141 | print "<tr class=\"title\"> |
e325c6e7 | 2142 | <td align='center' width=\"5%\"> </td> |
19c9cb11 AD |
2143 | <td width=\"20%\">Filter expression</td> |
2144 | <td width=\"20%\">Feed</td> | |
2145 | <td width=\"15%\">Match</td> | |
2146 | <td width=\"15%\">Action</td> | |
3b0feb9b | 2147 | <td width=\"30%\">Description</td></tr>"; |
a0d53889 | 2148 | |
3b0feb9b AD |
2149 | $lnum = 0; |
2150 | ||
2151 | while ($line = db_fetch_assoc($result)) { | |
2152 | ||
2153 | $class = ($lnum % 2) ? "even" : "odd"; | |
2154 | ||
2155 | $filter_id = $line["id"]; | |
2156 | $edit_filter_id = $_GET["id"]; | |
2157 | ||
2158 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
2159 | $class .= "Grayed"; | |
53226edc AD |
2160 | $this_row_id = ""; |
2161 | } else { | |
2162 | $this_row_id = "id=\"FILRR-$filter_id\""; | |
ead60402 | 2163 | } |
3b0feb9b | 2164 | |
53226edc | 2165 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2166 | |
2167 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); | |
2168 | $line["description"] = htmlspecialchars($line["description"]); | |
2169 | ||
2170 | if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; | |
2171 | ||
2172 | if (!$edit_filter_id || $subop != "edit") { | |
2173 | ||
2174 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2175 | ||
a426e532 | 2176 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
2177 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; |
2178 | ||
2179 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2180 | $line["reg_exp"] . "</td>"; | |
2181 | ||
2182 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2183 | $line["feed_title"] . "</td>"; | |
2184 | ||
2185 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2186 | $line["filter_type_descr"] . "</td>"; | |
19c9cb11 AD |
2187 | |
2188 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2189 | $line["action_description"] . "</td>"; | |
2190 | ||
3b0feb9b AD |
2191 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . |
2192 | $line["description"] . "</td>"; | |
2193 | ||
2194 | } else if ($filter_id != $edit_filter_id) { | |
2195 | ||
2196 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2197 | ||
2198 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2199 | id=\"FICHK-".$line["id"]."\"></td>"; | |
2200 | ||
2201 | print "<td>".$line["reg_exp"]."</td>"; | |
2202 | print "<td>".$line["feed_title"]."</td>"; | |
2203 | print "<td>".$line["filter_type_descr"]."</td>"; | |
19c9cb11 | 2204 | print "<td>".$line["action_description"]."</td>"; |
3b0feb9b | 2205 | print "<td>".$line["description"]."</td>"; |
19c9cb11 | 2206 | |
3b0feb9b AD |
2207 | } else { |
2208 | ||
2209 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2210 | ||
2211 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. | |
2212 | "\"></td>"; | |
2213 | ||
2214 | print "<td>"; | |
3b0feb9b | 2215 | print "<select id=\"iedit_feed\">"; |
3b0feb9b AD |
2216 | print "<option id=\"0\">All feeds</option>"; |
2217 | ||
3b0feb9b AD |
2218 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds |
2219 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
19c9cb11 AD |
2220 | |
2221 | if (db_num_rows($tmp_result) > 0) { | |
2222 | print "<option disabled>--------</option>"; | |
2223 | } | |
2224 | ||
3b0feb9b AD |
2225 | while ($tmp_line = db_fetch_assoc($tmp_result)) { |
2226 | if ($tmp_line["id"] == $line["feed_id"]) { | |
2227 | $is_selected = "selected"; | |
2228 | } else { | |
2229 | $is_selected = ""; | |
2230 | } | |
2231 | printf("<option $is_selected id='%d'>%s</option>", | |
2232 | $tmp_line["id"], $tmp_line["title"]); | |
ead60402 | 2233 | } |
3b0feb9b AD |
2234 | |
2235 | print "</select></td>"; | |
2236 | ||
2237 | print "<td>"; | |
2238 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
2239 | print "</td>"; | |
19c9cb11 AD |
2240 | |
2241 | print "<td>"; | |
2242 | print "<select id=\"iedit_filter_action\">"; | |
2243 | ||
2244 | $tmp_result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2245 | ORDER BY description"); | |
2246 | ||
2247 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
2248 | if ($tmp_line["description"] == $line["action_description"]) { | |
2249 | $is_selected = "selected"; | |
2250 | } else { | |
2251 | $is_selected = ""; | |
2252 | } | |
2253 | printf("<option $is_selected id='%d'>%s</option>", | |
2254 | $tmp_line["id"], $tmp_line["description"]); | |
2255 | } | |
3b0feb9b | 2256 | |
19c9cb11 AD |
2257 | print "</select></td>"; |
2258 | ||
2259 | ||
3b0feb9b AD |
2260 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. |
2261 | "\"></td>"; | |
2262 | ||
2263 | print "</td>"; | |
ead60402 | 2264 | } |
3b0feb9b AD |
2265 | |
2266 | print "</tr>"; | |
2267 | ||
2268 | ++$lnum; | |
a0d53889 | 2269 | } |
3b0feb9b AD |
2270 | |
2271 | if ($lnum == 0) { | |
2272 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
2273 | } | |
2274 | ||
2275 | print "</table>"; | |
2276 | ||
2277 | print "<p>"; | |
2278 | ||
2279 | if ($subop == "edit") { | |
2280 | print "Edit feed: | |
2281 | <input type=\"submit\" class=\"button\" | |
2282 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\"> | |
2283 | <input type=\"submit\" class=\"button\" | |
2284 | onclick=\"javascript:filterEditSave()\" value=\"Save\">"; | |
2285 | ||
2286 | } else { | |
2287 | ||
2288 | print " | |
2289 | Selection: | |
e828e31e | 2290 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2291 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> |
e828e31e | 2292 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2293 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; |
2294 | } | |
2295 | ||
a0d53889 AD |
2296 | } else { |
2297 | ||
3b0feb9b AD |
2298 | print "<p>No filters defined.</p>"; |
2299 | ||
a0d53889 AD |
2300 | } |
2301 | } | |
2302 | ||
80dce858 AD |
2303 | // We need to accept raw SQL data in label queries, so not everything is escaped |
2304 | // here, this is by design. If you don't like the whole idea, disable labels | |
2305 | // altogether with GLOBAL_ENABLE_LABELS = false | |
2306 | ||
48f0adb0 AD |
2307 | if ($op == "pref-labels") { |
2308 | ||
cfaba6df AD |
2309 | if (!GLOBAL_ENABLE_LABELS) { |
2310 | return; | |
2311 | } | |
2312 | ||
48f0adb0 AD |
2313 | $subop = $_GET["subop"]; |
2314 | ||
d9dde1d6 AD |
2315 | if ($subop == "test") { |
2316 | ||
2317 | $expr = $_GET["expr"]; | |
2318 | $descr = $_GET["descr"]; | |
2319 | ||
2320 | print "<div class='infoBoxContents'>"; | |
2321 | ||
2322 | print "<h1>Label «$descr»</h1>"; | |
2323 | ||
2324 | // print "<p><b>Expression</b>: $expr</p>"; | |
2325 | ||
2326 | $result = db_query($link, | |
2327 | "SELECT count(id) AS num_matches | |
2328 | FROM ttrss_entries,ttrss_user_entries | |
2329 | WHERE ($expr) AND | |
2330 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
2331 | owner_uid = " . $_SESSION["uid"]); | |
2332 | ||
2333 | $num_matches = db_fetch_result($result, 0, "num_matches");; | |
2334 | ||
2335 | if ($num_matches > 0) { | |
2336 | ||
a31a7b39 | 2337 | print "<p>Query returned <b>$num_matches</b> matches, first 5 follow:</p>"; |
d9dde1d6 AD |
2338 | |
2339 | $result = db_query($link, | |
2340 | "SELECT title, | |
2341 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title | |
2342 | FROM ttrss_entries,ttrss_user_entries | |
2343 | WHERE ($expr) AND | |
2344 | ttrss_user_entries.ref_id = ttrss_entries.id | |
2345 | AND owner_uid = " . $_SESSION["uid"] . " | |
2346 | ORDER BY date_entered DESC LIMIT 5"); | |
2347 | ||
2348 | print "<ul class=\"nomarks\">"; | |
2349 | while ($line = db_fetch_assoc($result)) { | |
2350 | print "<li>".$line["title"]. | |
2351 | " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>"; | |
2352 | } | |
2353 | print "</ul>"; | |
2354 | ||
2355 | } else { | |
2356 | print "<p>Query didn't return any matches.</p>"; | |
2357 | } | |
2358 | ||
2359 | print "</div>"; | |
2360 | ||
2361 | print "<div align='center'> | |
2362 | <input type='submit' class='button' | |
2363 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
2364 | return; | |
2365 | } | |
2366 | ||
48f0adb0 AD |
2367 | if ($subop == "editSave") { |
2368 | ||
2369 | $sql_exp = $_GET["s"]; | |
2370 | $descr = $_GET["d"]; | |
2371 | $label_id = db_escape_string($_GET["id"]); | |
2372 | ||
2373 | // print "$sql_exp : $descr : $label_id"; | |
2374 | ||
2375 | $result = db_query($link, "UPDATE ttrss_labels SET | |
2376 | sql_exp = '$sql_exp', | |
2377 | description = '$descr' | |
2378 | WHERE id = '$label_id'"); | |
2379 | } | |
2380 | ||
2381 | if ($subop == "remove") { | |
2382 | ||
2383 | if (!WEB_DEMO_MODE) { | |
2384 | ||
f932bc9f | 2385 | $ids = split(",", db_escape_string($_GET["ids"])); |
48f0adb0 AD |
2386 | |
2387 | foreach ($ids as $id) { | |
2388 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
2389 | ||
2390 | } | |
2391 | } | |
2392 | } | |
2393 | ||
2394 | if ($subop == "add") { | |
2395 | ||
2396 | if (!WEB_DEMO_MODE) { | |
2397 | ||
4401bf04 AD |
2398 | // no escaping is done here on purpose |
2399 | $exp = trim($_GET["exp"]); | |
48f0adb0 AD |
2400 | |
2401 | $result = db_query($link, | |
4356293a AD |
2402 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) |
2403 | VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); | |
48f0adb0 AD |
2404 | } |
2405 | } | |
2406 | ||
2c7070b5 AD |
2407 | print "<div class=\"prefGenericAddBox\"> |
2408 | <input size=\"40\" id=\"ladd_expr\"> "; | |
48f0adb0 | 2409 | |
2c7070b5 AD |
2410 | print"<input type=\"submit\" class=\"button\" |
2411 | onclick=\"javascript:addLabel()\" value=\"Add label\"></div>"; | |
48f0adb0 AD |
2412 | |
2413 | $result = db_query($link, "SELECT | |
2414 | id,sql_exp,description | |
2415 | FROM | |
4356293a AD |
2416 | ttrss_labels |
2417 | WHERE | |
2418 | owner_uid = ".$_SESSION["uid"]." | |
2419 | ORDER by description"); | |
48f0adb0 | 2420 | |
d9dde1d6 AD |
2421 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
2422 | ||
3b0feb9b | 2423 | if (db_num_rows($result) != 0) { |
48f0adb0 | 2424 | |
f4fe2cde AD |
2425 | print "<p><table width=\"100%\" cellspacing=\"0\" |
2426 | class=\"prefLabelList\" id=\"prefLabelList\">"; | |
35f3c923 AD |
2427 | |
2428 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2429 | Select: | |
2430 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', | |
3055bc41 | 2431 | 'LILRR-', 'LICHK-', true)\">All</a>, |
35f3c923 | 2432 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', |
3055bc41 | 2433 | 'LILRR-', 'LICHK-', false)\">None</a> |
35f3c923 AD |
2434 | </td</tr>"; |
2435 | ||
3b0feb9b | 2436 | print "<tr class=\"title\"> |
e325c6e7 AD |
2437 | <td align='center' width=\"5%\"> </td> |
2438 | <td width=\"40%\">SQL expression | |
01c9c74a | 2439 | <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a> |
3b0feb9b AD |
2440 | </td> |
2441 | <td width=\"40%\">Caption</td></tr>"; | |
2442 | ||
2443 | $lnum = 0; | |
2444 | ||
2445 | while ($line = db_fetch_assoc($result)) { | |
2446 | ||
2447 | $class = ($lnum % 2) ? "even" : "odd"; | |
2448 | ||
2449 | $label_id = $line["id"]; | |
2450 | $edit_label_id = $_GET["id"]; | |
2451 | ||
2452 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
2453 | $class .= "Grayed"; | |
53226edc AD |
2454 | $this_row_id = ""; |
2455 | } else { | |
2456 | $this_row_id = "id=\"LILRR-$label_id\""; | |
3b0feb9b AD |
2457 | } |
2458 | ||
53226edc | 2459 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2460 | |
2461 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
2462 | $line["description"] = htmlspecialchars($line["description"]); | |
2463 | ||
2464 | if (!$edit_label_id || $subop != "edit") { | |
2465 | ||
2466 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
2467 | ||
a426e532 | 2468 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
2469 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; |
2470 | ||
2471 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
2472 | $line["sql_exp"] . "</td>"; | |
48f0adb0 | 2473 | |
3b0feb9b AD |
2474 | print "<td><a href=\"javascript:editLabel($label_id);\">" . |
2475 | $line["description"] . "</td>"; | |
2476 | ||
2477 | } else if ($label_id != $edit_label_id) { | |
2478 | ||
2479 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2480 | ||
2481 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2482 | id=\"LICHK-".$line["id"]."\"></td>"; | |
2483 | ||
2484 | print "<td>".$line["sql_exp"]."</td>"; | |
2485 | print "<td>".$line["description"]."</td>"; | |
2486 | ||
2487 | } else { | |
2488 | ||
2489 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2490 | ||
2491 | print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. | |
2492 | "\"></td>"; | |
2493 | ||
2494 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
2495 | "\"></td>"; | |
2496 | ||
2497 | } | |
2498 | ||
48f0adb0 | 2499 | |
3b0feb9b AD |
2500 | print "</tr>"; |
2501 | ||
2502 | ++$lnum; | |
2503 | } | |
2504 | ||
2505 | if ($lnum == 0) { | |
2506 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
2507 | } | |
2508 | ||
2509 | print "</table>"; | |
2510 | ||
2511 | print "<p>"; | |
2512 | ||
2513 | if ($subop == "edit") { | |
2514 | print "Edit label: | |
d9dde1d6 AD |
2515 | <input type=\"submit\" class=\"button\" |
2516 | onclick=\"javascript:labelTest()\" value=\"Test\"> | |
3b0feb9b AD |
2517 | <input type=\"submit\" class=\"button\" |
2518 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\"> | |
2519 | <input type=\"submit\" class=\"button\" | |
2520 | onclick=\"javascript:labelEditSave()\" value=\"Save\">"; | |
2521 | ||
2522 | } else { | |
2523 | ||
2524 | print " | |
2525 | Selection: | |
48f0adb0 | 2526 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2527 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> |
48f0adb0 | 2528 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2529 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; |
2530 | } | |
48f0adb0 | 2531 | } else { |
3b0feb9b | 2532 | print "<p>No labels defined.</p>"; |
48f0adb0 AD |
2533 | } |
2534 | } | |
2535 | ||
e828e31e AD |
2536 | if ($op == "error") { |
2537 | print "<div width=\"100%\" align='center'>"; | |
2538 | $msg = $_GET["msg"]; | |
2539 | print $msg; | |
2540 | print "</div>"; | |
2541 | } | |
2542 | ||
7dc66a61 | 2543 | if ($op == "help") { |
01c9c74a AD |
2544 | if (!$_GET["noheaders"]) { |
2545 | print "<html><head> | |
2546 | <title>Tiny Tiny RSS : Help</title> | |
2547 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
2548 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
2549 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
2550 | </head><body>"; | |
2551 | } | |
7dc66a61 AD |
2552 | |
2553 | $tid = sprintf("%d", $_GET["tid"]); | |
2554 | ||
01c9c74a | 2555 | print "<div class='infoBoxContents'>"; |
7dc66a61 | 2556 | |
01c9c74a AD |
2557 | if (file_exists("help/$tid.php")) { |
2558 | include("help/$tid.php"); | |
2559 | } else { | |
2560 | print "<p>Help topic not found.</p>"; | |
2561 | } | |
7dc66a61 | 2562 | |
01c9c74a | 2563 | print "</div>"; |
7dc66a61 AD |
2564 | |
2565 | print "<div align='center'> | |
01c9c74a AD |
2566 | <input type='submit' class='button' |
2567 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
7dc66a61 | 2568 | |
01c9c74a AD |
2569 | if (!$_GET["noheaders"]) { |
2570 | print "</body></html>"; | |
2571 | } | |
7dc66a61 AD |
2572 | |
2573 | } | |
2574 | ||
f84a97a3 AD |
2575 | if ($op == "dlg") { |
2576 | $id = $_GET["id"]; | |
6de5d056 | 2577 | $param = $_GET["param"]; |
f84a97a3 AD |
2578 | |
2579 | if ($id == "quickAddFeed") { | |
76332f3c AD |
2580 | print " |
2581 | Feed URL: <input | |
033e47e0 AD |
2582 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" |
2583 | id=\"qafInput\"> | |
f84a97a3 AD |
2584 | <input class=\"button\" |
2585 | type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\"> | |
2586 | <input class=\"button\" | |
2587 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2588 | value=\"Cancel\">"; | |
2589 | } | |
6de5d056 AD |
2590 | |
2591 | if ($id == "quickDelFeed") { | |
2592 | ||
2593 | $param = db_escape_string($param); | |
2594 | ||
2595 | $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'"); | |
2596 | ||
2597 | if ($result) { | |
2598 | ||
2599 | $f_title = db_fetch_result($result, 0, "title"); | |
2600 | ||
76332f3c | 2601 | print "Remove current feed (<b>$f_title</b>)? |
6de5d056 AD |
2602 | <input class=\"button\" |
2603 | type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\"> | |
2604 | <input class=\"button\" | |
2605 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2606 | value=\"Cancel\">"; | |
2607 | } else { | |
2608 | print "Error: Feed $param not found. | |
2609 | <input class=\"button\" | |
2610 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2611 | value=\"Cancel\">"; | |
2612 | } | |
2613 | } | |
2614 | ||
033e47e0 AD |
2615 | if ($id == "search") { |
2616 | ||
2617 | print "<input id=\"searchbox\" class=\"extSearch\" | |
2618 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
2619 | onchange=\"javascript:search()\"> | |
2620 | <select id=\"searchmodebox\"> | |
2621 | <option selected>All feeds</option> | |
2622 | <option>This feed</option> | |
2623 | </select> | |
2624 | <input type=\"submit\" | |
2625 | class=\"button\" onclick=\"javascript:search()\" value=\"Search\"> | |
2626 | <input class=\"button\" | |
2627 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2628 | value=\"Close\">"; | |
2629 | ||
2630 | } | |
2631 | ||
a24f525c AD |
2632 | if ($id == "quickAddFilter") { |
2633 | ||
2634 | $result = db_query($link, "SELECT description | |
2635 | FROM ttrss_filter_types ORDER BY description"); | |
2636 | ||
2637 | $filter_types = array(); | |
2638 | ||
2639 | while ($line = db_fetch_assoc($result)) { | |
2640 | array_push($filter_types, $line["description"]); | |
2641 | } | |
2642 | ||
2643 | print "<table>"; | |
2644 | ||
2645 | print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"40\"> "; | |
2646 | ||
2647 | print_select("fadd_match", "Title", $filter_types); | |
2648 | ||
2649 | print "</td></tr>"; | |
2650 | print "<tr><td>Feed:</td><td><select id=\"fadd_feed\">"; | |
2651 | ||
2652 | print "<option selected id=\"0\">All feeds</option>"; | |
2653 | ||
2654 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2655 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2656 | ||
2657 | if (db_num_rows($result) > 0) { | |
2658 | print "<option disabled>--------</option>"; | |
2659 | } | |
2660 | ||
2661 | while ($line = db_fetch_assoc($result)) { | |
2662 | if ($param == $line["id"]) { | |
2663 | $selected = "selected"; | |
2664 | } else { | |
2665 | $selected = ""; | |
2666 | } | |
2667 | printf("<option id='%d' %s>%s</option>", $line["id"], $selected, $line["title"]); | |
2668 | } | |
2669 | ||
2670 | print "</select></td></tr>"; | |
2671 | ||
2672 | print "<tr><td>Action:</td>"; | |
2673 | ||
2674 | print "<td><select id=\"fadd_action\">"; | |
2675 | ||
2676 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2677 | ORDER BY name"); | |
2678 | ||
2679 | while ($line = db_fetch_assoc($result)) { | |
2680 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
2681 | } | |
2682 | ||
2683 | print "</select>"; | |
2684 | ||
2685 | print "</td></tr><tr><td colspan=\"2\" align=\"right\">"; | |
2686 | ||
2687 | print "<input type=\"submit\" | |
2688 | class=\"button\" onclick=\"javascript:qaddFilter()\" | |
2689 | value=\"Add filter\"> "; | |
2690 | ||
2691 | print "<input class=\"button\" | |
2692 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2693 | value=\"Close\">"; | |
2694 | ||
2695 | print "</td></tr></table>"; | |
2696 | } | |
f84a97a3 AD |
2697 | } |
2698 | ||
a2770077 AD |
2699 | // update feeds of all users, may be used anonymously |
2700 | if ($op == "globalUpdateFeeds") { | |
2701 | ||
2702 | $result = db_query($link, "SELECT id FROM ttrss_users"); | |
2703 | ||
2704 | while ($line = db_fetch_assoc($result)) { | |
2705 | $user_id = $line["id"]; | |
2706 | // print "<!-- updating feeds of uid $user_id -->"; | |
2707 | update_all_feeds($link, false, $user_id); | |
2708 | } | |
e65af9c1 | 2709 | |
a2770077 AD |
2710 | print "<rpc-reply> |
2711 | <message msg=\"All feeds updated\"/> | |
2712 | </rpc-reply>"; | |
e65af9c1 AD |
2713 | |
2714 | } | |
2715 | ||
77e96719 AD |
2716 | if ($op == "pref-prefs") { |
2717 | ||
b1895692 | 2718 | $subop = $_REQUEST["subop"]; |
77e96719 AD |
2719 | |
2720 | if ($subop == "Save configuration") { | |
2721 | ||
d2892032 AD |
2722 | if (WEB_DEMO_MODE) { |
2723 | header("Location: prefs.php"); | |
2724 | return; | |
2725 | } | |
01d68cf9 | 2726 | |
93cb4442 AD |
2727 | $_SESSION["prefs_op_result"] = "save-config"; |
2728 | ||
77e96719 AD |
2729 | foreach (array_keys($_POST) as $pref_name) { |
2730 | ||
2731 | $pref_name = db_escape_string($pref_name); | |
2732 | $value = db_escape_string($_POST[$pref_name]); | |
2733 | ||
2734 | $result = db_query($link, "SELECT type_name | |
2735 | FROM ttrss_prefs,ttrss_prefs_types | |
2736 | WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id"); | |
2737 | ||
2738 | if (db_num_rows($result) > 0) { | |
2739 | ||
2740 | $type_name = db_fetch_result($result, 0, "type_name"); | |
2741 | ||
5da169d9 AD |
2742 | // print "$pref_name : $type_name : $value<br>"; |
2743 | ||
77e96719 | 2744 | if ($type_name == "bool") { |
5da169d9 | 2745 | if ($value == "1") { |
77e96719 AD |
2746 | $value = "true"; |
2747 | } else { | |
2748 | $value = "false"; | |
2749 | } | |
2750 | } else if ($type_name == "integer") { | |
2751 | $value = sprintf("%d", $value); | |
2752 | } | |
2753 | ||
2754 | // print "$pref_name : $type_name : $value<br>"; | |
2755 | ||
ff485f1d AD |
2756 | db_query($link, "UPDATE ttrss_user_prefs SET value = '$value' |
2757 | WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]); | |
77e96719 AD |
2758 | |
2759 | } | |
2760 | ||
2761 | header("Location: prefs.php"); | |
2762 | ||
2763 | } | |
2764 | ||
b1895692 AD |
2765 | } else if ($subop == "getHelp") { |
2766 | ||
2767 | $pref_name = db_escape_string($_GET["pn"]); | |
2768 | ||
2769 | $result = db_query($link, "SELECT help_text FROM ttrss_prefs | |
2770 | WHERE pref_name = '$pref_name'"); | |
2771 | ||
2772 | if (db_num_rows($result) > 0) { | |
2773 | $help_text = db_fetch_result($result, 0, "help_text"); | |
2774 | print $help_text; | |
2775 | } else { | |
2776 | print "Unknown option: $pref_name"; | |
2777 | } | |
2778 | ||
1c7f75ed AD |
2779 | } else if ($subop == "Change password") { |
2780 | ||
d2892032 AD |
2781 | if (WEB_DEMO_MODE) { |
2782 | header("Location: prefs.php"); | |
2783 | return; | |
2784 | } | |
1c7f75ed AD |
2785 | |
2786 | $old_pw = $_POST["OLD_PASSWORD"]; | |
2787 | $new_pw = $_POST["OLD_PASSWORD"]; | |
2788 | ||
2789 | $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]); | |
2790 | $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]); | |
2791 | ||
2792 | $active_uid = $_SESSION["uid"]; | |
2793 | ||
2794 | if ($old_pw && $new_pw) { | |
2795 | ||
2796 | $login = db_escape_string($_SERVER['PHP_AUTH_USER']); | |
2797 | ||
2798 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
2799 | id = '$active_uid' AND (pwd_hash = '$old_pw' OR | |
2800 | pwd_hash = '$old_pw_hash')"); | |
2801 | ||
2802 | if (db_num_rows($result) == 1) { | |
2803 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash' | |
2804 | WHERE id = '$active_uid'"); | |
b791095d AD |
2805 | |
2806 | $_SESSION["pwd_change_result"] = "ok"; | |
2807 | } else { | |
2808 | $_SESSION["pwd_change_result"] = "failed"; | |
1c7f75ed AD |
2809 | } |
2810 | } | |
2811 | ||
2812 | header("Location: prefs.php"); | |
b791095d | 2813 | |
77e96719 AD |
2814 | } else if ($subop == "Reset to defaults") { |
2815 | ||
d2892032 AD |
2816 | if (WEB_DEMO_MODE) { |
2817 | header("Location: prefs.php"); | |
2818 | return; | |
2819 | } | |
01d68cf9 | 2820 | |
93cb4442 AD |
2821 | $_SESSION["prefs_op_result"] = "reset-to-defaults"; |
2822 | ||
e1aa0559 AD |
2823 | if (DB_TYPE == "pgsql") { |
2824 | db_query($link,"UPDATE ttrss_user_prefs | |
2825 | SET value = ttrss_prefs.def_value | |
2826 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
2827 | ttrss_prefs.pref_name = ttrss_user_prefs.pref_name"); | |
2828 | } else { | |
2829 | db_query($link, "DELETE FROM ttrss_user_prefs | |
2830 | WHERE owner_uid = ".$_SESSION["uid"]); | |
2831 | initialize_user_prefs($link, $_SESSION["uid"]); | |
2832 | } | |
5da169d9 | 2833 | |
77e96719 AD |
2834 | header("Location: prefs.php"); |
2835 | ||
58f8ad54 AD |
2836 | } else if ($subop == "Change theme") { |
2837 | ||
2838 | $theme = db_escape_string($_POST["theme"]); | |
2839 | ||
2840 | if ($theme == "Default") { | |
2841 | $theme_qpart = 'NULL'; | |
2842 | } else { | |
2843 | $theme_qpart = "'$theme'"; | |
2844 | } | |
2845 | ||
6752e330 AD |
2846 | $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes |
2847 | WHERE theme_name = '$theme'"); | |
2848 | ||
2849 | if (db_num_rows($result) == 1) { | |
2850 | $theme_id = db_fetch_result($result, 0, "id"); | |
2851 | $theme_path = db_fetch_result($result, 0, "theme_path"); | |
2852 | } else { | |
2853 | $theme_id = "NULL"; | |
2854 | $theme_path = ""; | |
2855 | } | |
2856 | ||
58f8ad54 | 2857 | db_query($link, "UPDATE ttrss_users SET |
6752e330 | 2858 | theme_id = $theme_id WHERE id = " . $_SESSION["uid"]); |
58f8ad54 | 2859 | |
6752e330 | 2860 | $_SESSION["theme"] = $theme_path; |
503eb349 | 2861 | |
58f8ad54 AD |
2862 | header("Location: prefs.php"); |
2863 | ||
77e96719 AD |
2864 | } else { |
2865 | ||
7d4c898a | 2866 | if (!SINGLE_USER_MODE) { |
1c7f75ed | 2867 | |
a029d530 AD |
2868 | $result = db_query($link, "SELECT id FROM ttrss_users |
2869 | WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR | |
2870 | pwd_hash = 'SHA1:".sha1("password")."')"); | |
2871 | ||
2872 | if (db_num_rows($result) != 0) { | |
b791095d | 2873 | print "<div class=\"warning\"> |
a029d530 AD |
2874 | Your password is at default value, please change it. |
2875 | </div>"; | |
2876 | } | |
2877 | ||
b791095d AD |
2878 | if ($_SESSION["pwd_change_result"] == "failed") { |
2879 | print "<div class=\"warning\"> | |
2880 | There was an error while changing your password. | |
2881 | </div>"; | |
2882 | } | |
2883 | ||
2884 | if ($_SESSION["pwd_change_result"] == "ok") { | |
2885 | print "<div class=\"notice\"> | |
2886 | Password changed successfully. | |
2887 | </div>"; | |
2888 | } | |
2889 | ||
2890 | $_SESSION["pwd_change_result"] = ""; | |
2891 | ||
93cb4442 AD |
2892 | if ($_SESSION["prefs_op_result"] == "reset-to-defaults") { |
2893 | print "<div class=\"notice\"> | |
2894 | Your configuration was reset to defaults. | |
2895 | </div>"; | |
2896 | } | |
2897 | ||
2898 | if ($_SESSION["prefs_op_result"] == "save-config") { | |
2899 | print "<div class=\"notice\"> | |
2900 | Your configuration was saved successfully. | |
2901 | </div>"; | |
2902 | } | |
2903 | ||
2904 | $_SESSION["prefs_op_result"] = ""; | |
2905 | ||
7d4c898a AD |
2906 | print "<form action=\"backend.php\" method=\"POST\">"; |
2907 | ||
2908 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
2909 | print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>"; | |
2910 | ||
2911 | print "<tr><td width=\"40%\">Old password</td>"; | |
2912 | print "<td><input class=\"editbox\" type=\"password\" | |
2913 | name=\"OLD_PASSWORD\"></td></tr>"; | |
2914 | ||
2915 | print "<tr><td width=\"40%\">New password</td>"; | |
2916 | ||
2917 | print "<td><input class=\"editbox\" type=\"password\" | |
2918 | name=\"NEW_PASSWORD\"></td></tr>"; | |
2919 | ||
2920 | print "</table>"; | |
2921 | ||
2922 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
2923 | ||
2924 | print "<p><input class=\"button\" type=\"submit\" | |
2925 | value=\"Change password\" name=\"subop\">"; | |
2926 | ||
2927 | print "</form>"; | |
1c7f75ed | 2928 | |
7d4c898a | 2929 | } |
1c7f75ed | 2930 | |
58f8ad54 AD |
2931 | $result = db_query($link, "SELECT |
2932 | theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]); | |
2933 | ||
2934 | $user_theme_id = db_fetch_result($result, 0, "theme_id"); | |
2935 | ||
2936 | $result = db_query($link, "SELECT | |
2937 | id,theme_name FROM ttrss_themes ORDER BY theme_name"); | |
2938 | ||
2939 | if (db_num_rows($result) > 0) { | |
6752e330 AD |
2940 | |
2941 | print "<form action=\"backend.php\" method=\"POST\">"; | |
2942 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
2943 | print "<tr><td colspan='3'><h3>Themes</h3></tr></td>"; | |
2944 | print "<tr><td width=\"40%\">Select theme</td>"; | |
2945 | print "<td><select name=\"theme\">"; | |
2946 | print "<option>Default</option>"; | |
58f8ad54 | 2947 | print "<option disabled>--------</option>"; |
6752e330 | 2948 | |
58f8ad54 AD |
2949 | while ($line = db_fetch_assoc($result)) { |
2950 | if ($line["id"] == $user_theme_id) { | |
2951 | $selected = "selected"; | |
2952 | } else { | |
2953 | $selected = ""; | |
2954 | } | |
2955 | print "<option $selected>" . $line["theme_name"] . "</option>"; | |
2956 | } | |
6752e330 AD |
2957 | print "</select></td></tr>"; |
2958 | print "</table>"; | |
2959 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
2960 | print "<p><input class=\"button\" type=\"submit\" | |
2961 | value=\"Change theme\" name=\"subop\">"; | |
2962 | print "</form>"; | |
58f8ad54 AD |
2963 | } |
2964 | ||
77e96719 | 2965 | $result = db_query($link, "SELECT |
ff485f1d | 2966 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, |
77e96719 | 2967 | section_name,def_value |
ff485f1d | 2968 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs |
77e96719 | 2969 | WHERE type_id = ttrss_prefs_types.id AND |
ff485f1d | 2970 | section_id = ttrss_prefs_sections.id AND |
a2411bd9 AD |
2971 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND |
2972 | owner_uid = ".$_SESSION["uid"]." | |
650bc435 | 2973 | ORDER BY section_id,short_desc"); |
77e96719 AD |
2974 | |
2975 | print "<form action=\"backend.php\" method=\"POST\">"; | |
2976 | ||
77e96719 AD |
2977 | $lnum = 0; |
2978 | ||
2979 | $active_section = ""; | |
2980 | ||
2981 | while ($line = db_fetch_assoc($result)) { | |
2982 | ||
2983 | if ($active_section != $line["section_name"]) { | |
59a654ba AD |
2984 | |
2985 | if ($active_section != "") { | |
1c7f75ed | 2986 | print "</table>"; |
59a654ba | 2987 | } |
1c7f75ed AD |
2988 | |
2989 | print "<p><table width=\"100%\" class=\"prefPrefsList\">"; | |
59a654ba AD |
2990 | |
2991 | $active_section = $line["section_name"]; | |
2992 | ||
77e96719 | 2993 | print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>"; |
59a654ba AD |
2994 | // print "<tr class=\"title\"> |
2995 | // <td width=\"25%\">Option</td><td>Value</td></tr>"; | |
7268adf7 AD |
2996 | |
2997 | $lnum = 0; | |
77e96719 AD |
2998 | } |
2999 | ||
650bc435 | 3000 | // $class = ($lnum % 2) ? "even" : "odd"; |
77e96719 | 3001 | |
650bc435 | 3002 | print "<tr>"; |
77e96719 | 3003 | |
77e96719 AD |
3004 | $type_name = $line["type_name"]; |
3005 | $pref_name = $line["pref_name"]; | |
3006 | $value = $line["value"]; | |
3007 | $def_value = $line["def_value"]; | |
b1895692 AD |
3008 | $help_text = $line["help_text"]; |
3009 | ||
3010 | print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"]; | |
3011 | ||
3012 | if ($help_text) print "<div class=\"prefHelp\">$help_text</div>"; | |
3013 | ||
3014 | print "</td>"; | |
77e96719 AD |
3015 | |
3016 | print "<td>"; | |
3017 | ||
3018 | if ($type_name == "bool") { | |
3019 | // print_select($pref_name, $value, array("true", "false")); | |
3020 | ||
3021 | if ($value == "true") { | |
3022 | $value = "Yes"; | |
3023 | } else { | |
3024 | $value = "No"; | |
3025 | } | |
3026 | ||
3027 | print_radio($pref_name, $value, array("Yes", "No")); | |
3028 | ||
3029 | } else { | |
3030 | print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">"; | |
3031 | } | |
3032 | ||
3033 | print "</td>"; | |
3034 | ||
3035 | print "</tr>"; | |
3036 | ||
3037 | $lnum++; | |
3038 | } | |
3039 | ||
3040 | print "</table>"; | |
3041 | ||
3042 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3043 | ||
3044 | print "<p><input class=\"button\" type=\"submit\" | |
3045 | name=\"subop\" value=\"Save configuration\">"; | |
3046 | ||
3047 | print " <input class=\"button\" type=\"submit\" | |
69668465 AD |
3048 | name=\"subop\" onclick=\"return validatePrefsReset()\" |
3049 | value=\"Reset to defaults\"></p>"; | |
77e96719 AD |
3050 | |
3051 | print "</form>"; | |
3052 | ||
3053 | } | |
3054 | ||
3055 | } | |
3056 | ||
e6cb77a0 AD |
3057 | if ($op == "pref-users") { |
3058 | ||
3059 | $subop = $_GET["subop"]; | |
3060 | ||
3061 | if ($subop == "editSave") { | |
3062 | ||
3063 | if (!WEB_DEMO_MODE) { | |
3064 | ||
3065 | $login = db_escape_string($_GET["l"]); | |
3066 | $uid = db_escape_string($_GET["id"]); | |
3067 | $access_level = sprintf("%d", $_GET["al"]); | |
3068 | ||
3069 | db_query($link, "UPDATE ttrss_users SET login = '$login', access_level = '$access_level' WHERE id = '$uid'"); | |
3070 | ||
3071 | } | |
3072 | } else if ($subop == "remove") { | |
3073 | ||
3074 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3075 | ||
f932bc9f | 3076 | $ids = split(",", db_escape_string($_GET["ids"])); |
e6cb77a0 AD |
3077 | |
3078 | foreach ($ids as $id) { | |
3079 | db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]); | |
3080 | ||
3081 | } | |
3082 | } | |
3083 | } else if ($subop == "add") { | |
3084 | ||
3085 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3086 | ||
b6b535ca | 3087 | $login = db_escape_string(trim($_GET["login"])); |
e6cb77a0 AD |
3088 | $tmp_user_pwd = make_password(8); |
3089 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3090 | ||
3091 | db_query($link, "INSERT INTO ttrss_users (login,pwd_hash,access_level) | |
3092 | VALUES ('$login', '$pwd_hash', 0)"); | |
3093 | ||
3094 | ||
3095 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3096 | login = '$login' AND pwd_hash = '$pwd_hash'"); | |
3097 | ||
3098 | if (db_num_rows($result) == 1) { | |
3099 | ||
3100 | $new_uid = db_fetch_result($result, 0, "id"); | |
3101 | ||
3102 | print "<div class=\"notice\">Added user <b>".$_GET["login"]. | |
3103 | "</b> with password <b>$tmp_user_pwd</b>.</div>"; | |
3104 | ||
3105 | initialize_user($link, $new_uid); | |
3106 | ||
3107 | } else { | |
3108 | ||
3109 | print "<div class=\"warning\">Error while adding user <b>". | |
3110 | $_GET["login"].".</b></div>"; | |
3111 | ||
3112 | } | |
3113 | } | |
3114 | } else if ($subop == "resetPass") { | |
3115 | ||
3116 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3117 | ||
3118 | $uid = db_escape_string($_GET["id"]); | |
3119 | ||
3120 | $result = db_query($link, "SELECT login FROM ttrss_users WHERE id = '$uid'"); | |
3121 | ||
3122 | $login = db_fetch_result($result, 0, "login"); | |
3123 | $tmp_user_pwd = make_password(8); | |
3124 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3125 | ||
3126 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash' | |
3127 | WHERE id = '$uid'"); | |
3128 | ||
3129 | print "<div class=\"notice\">Changed password of | |
3130 | user <b>$login</b> to <b>$tmp_user_pwd</b>.</div>"; | |
3131 | ||
3132 | } | |
3133 | } | |
3134 | ||
2c7070b5 | 3135 | print "<div class=\"prefGenericAddBox\"> |
f932bc9f | 3136 | <input id=\"uadd_box\" onchange=\"javascript:addUser()\" size=\"40\"> "; |
e6cb77a0 | 3137 | |
2c7070b5 AD |
3138 | print"<input type=\"submit\" class=\"button\" |
3139 | onclick=\"javascript:addUser()\" value=\"Add user\"></div>"; | |
e6cb77a0 AD |
3140 | |
3141 | $result = db_query($link, "SELECT | |
fe99ab12 AD |
3142 | id,login,access_level, |
3143 | SUBSTRING(last_login,1,16) as last_login | |
e6cb77a0 AD |
3144 | FROM |
3145 | ttrss_users | |
3146 | ORDER by login"); | |
3147 | ||
2317ffaa | 3148 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
1a7572cb | 3149 | |
f4fe2cde AD |
3150 | print "<p><table width=\"100%\" cellspacing=\"0\" |
3151 | class=\"prefUserList\" id=\"prefUserList\">"; | |
e6cb77a0 | 3152 | |
35f3c923 AD |
3153 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
3154 | Select: | |
3155 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', | |
3055bc41 | 3156 | 'UMRR-', 'UMCHK-', true)\">All</a>, |
35f3c923 | 3157 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', |
3055bc41 | 3158 | 'UMRR-', 'UMCHK-', false)\">None</a> |
35f3c923 AD |
3159 | </td</tr>"; |
3160 | ||
e6cb77a0 | 3161 | print "<tr class=\"title\"> |
e325c6e7 | 3162 | <td align='center' width=\"5%\"> </td> |
f6f32198 AD |
3163 | <td width='30%'>Username</td> |
3164 | <td width='30%'>Access Level</td> | |
3165 | <td width='30%'>Last login</td></tr>"; | |
e6cb77a0 AD |
3166 | |
3167 | $lnum = 0; | |
3168 | ||
3169 | while ($line = db_fetch_assoc($result)) { | |
3170 | ||
3171 | $class = ($lnum % 2) ? "even" : "odd"; | |
3172 | ||
3173 | $uid = $line["id"]; | |
3174 | $edit_uid = $_GET["id"]; | |
3175 | ||
3176 | if ($uid == $_SESSION["uid"] || ($subop == "edit" && $uid != $edit_uid)) { | |
3177 | $class .= "Grayed"; | |
53226edc AD |
3178 | $this_row_id = ""; |
3179 | } else { | |
3180 | $this_row_id = "id=\"UMRR-$uid\""; | |
3181 | } | |
3182 | ||
3183 | print "<tr class=\"$class\" $this_row_id>"; | |
e6cb77a0 AD |
3184 | |
3185 | $line["login"] = htmlspecialchars($line["login"]); | |
3186 | ||
6be6bc03 AD |
3187 | $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'), |
3188 | strtotime($line["last_login"])); | |
3189 | ||
e6cb77a0 AD |
3190 | if ($uid == $_SESSION["uid"]) { |
3191 | ||
a426e532 | 3192 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
e6cb77a0 AD |
3193 | id=\"UMCHK-".$line["id"]."\"></td>"; |
3194 | ||
3195 | print "<td>".$line["login"]."</td>"; | |
3196 | print "<td>".$line["access_level"]."</td>"; | |
e6cb77a0 AD |
3197 | |
3198 | } else if (!$edit_uid || $subop != "edit") { | |
3199 | ||
a426e532 | 3200 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
1a7572cb | 3201 | type=\"checkbox\" id=\"UMCHK-$uid\"></td>"; |
e6cb77a0 AD |
3202 | |
3203 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3204 | $line["login"] . "</td>"; | |
3205 | ||
3206 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3207 | $line["access_level"] . "</td>"; | |
3208 | ||
3209 | } else if ($uid != $edit_uid) { | |
3210 | ||
3211 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
3212 | id=\"UMCHK-".$line["id"]."\"></td>"; | |
3213 | ||
3214 | print "<td>".$line["login"]."</td>"; | |
3215 | print "<td>".$line["access_level"]."</td>"; | |
3216 | ||
3217 | } else { | |
3218 | ||
3219 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
3220 | ||
3221 | print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"]. | |
3222 | "\"></td>"; | |
3223 | ||
3224 | print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"]. | |
3225 | "\"></td>"; | |
3226 | ||
3227 | } | |
3228 | ||
f6f32198 AD |
3229 | print "<td>".$line["last_login"]."</td>"; |
3230 | ||
e6cb77a0 AD |
3231 | print "</tr>"; |
3232 | ||
3233 | ++$lnum; | |
3234 | } | |
3235 | ||
3236 | print "</table>"; | |
3237 | ||
3238 | print "<p>"; | |
3239 | ||
3240 | if ($subop == "edit") { | |
3241 | print "Edit label: | |
3242 | <input type=\"submit\" class=\"button\" | |
3243 | onclick=\"javascript:userEditCancel()\" value=\"Cancel\"> | |
3244 | <input type=\"submit\" class=\"button\" | |
3245 | onclick=\"javascript:userEditSave()\" value=\"Save\">"; | |
3246 | ||
3247 | } else { | |
3248 | ||
3249 | print " | |
3250 | Selection: | |
3251 | <input type=\"submit\" class=\"button\" | |
717f5e64 | 3252 | onclick=\"javascript:selectedUserDetails()\" value=\"User details\"> |
e6cb77a0 AD |
3253 | <input type=\"submit\" class=\"button\" |
3254 | onclick=\"javascript:editSelectedUser()\" value=\"Edit\"> | |
3255 | <input type=\"submit\" class=\"button\" | |
717f5e64 AD |
3256 | onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\"> |
3257 | <input type=\"submit\" class=\"button\" | |
3258 | onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">"; | |
3259 | ||
3260 | } | |
3261 | } | |
3262 | ||
3263 | if ($op == "user-details") { | |
3264 | ||
3265 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { | |
3266 | return; | |
3267 | } | |
3268 | ||
1a7572cb | 3269 | /* print "<html><head> |
717f5e64 AD |
3270 | <title>Tiny Tiny RSS : User Details</title> |
3271 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
3272 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
1a7572cb | 3273 | </head><body>"; */ |
717f5e64 AD |
3274 | |
3275 | $uid = sprintf("%d", $_GET["id"]); | |
3276 | ||
c6c3a07f | 3277 | print "<div class='infoBoxContents'>"; |
717f5e64 | 3278 | |
fe99ab12 AD |
3279 | $result = db_query($link, "SELECT login, |
3280 | SUBSTRING(last_login,1,16) AS last_login, | |
3281 | access_level, | |
c6c3a07f AD |
3282 | (SELECT COUNT(int_id) FROM ttrss_user_entries |
3283 | WHERE owner_uid = id) AS stored_articles | |
717f5e64 AD |
3284 | FROM ttrss_users |
3285 | WHERE id = '$uid'"); | |
3286 | ||
3287 | if (db_num_rows($result) == 0) { | |
3288 | print "<h1>User not found</h1>"; | |
3289 | return; | |
3290 | } | |
3291 | ||
3292 | print "<h1>User Details</h1>"; | |
3293 | ||
3294 | print "<table width='100%'>"; | |
3295 | ||
3296 | $login = db_fetch_result($result, 0, "login"); | |
6be6bc03 AD |
3297 | $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), |
3298 | strtotime(db_fetch_result($result, 0, "last_login"))); | |
717f5e64 | 3299 | $access_level = db_fetch_result($result, 0, "access_level"); |
c6c3a07f | 3300 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); |
717f5e64 AD |
3301 | |
3302 | print "<tr><td>Username</td><td>$login</td></tr>"; | |
3303 | print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
3304 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
c6c3a07f | 3305 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; |
717f5e64 AD |
3306 | |
3307 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds | |
3308 | WHERE owner_uid = '$uid'"); | |
3309 | ||
3310 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
3311 | ||
3312 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; | |
3313 | ||
5d15d3ea | 3314 | /* $result = db_query($link, "SELECT |
717f5e64 | 3315 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size |
c6c3a07f AD |
3316 | FROM ttrss_user_entries,ttrss_entries |
3317 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
717f5e64 | 3318 | |
d9f115c3 | 3319 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
717f5e64 | 3320 | |
c6c3a07f | 3321 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ |
717f5e64 AD |
3322 | |
3323 | print "</table>"; | |
3324 | ||
3325 | print "<h1>Subscribed feeds</h1>"; | |
3326 | ||
e94645ca | 3327 | $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds |
a88c1f36 | 3328 | WHERE owner_uid = '$uid' ORDER BY title LIMIT 20"); |
717f5e64 AD |
3329 | |
3330 | print "<ul class=\"nomarks\">"; | |
3331 | ||
3332 | while ($line = db_fetch_assoc($result)) { | |
3333 | ||
3334 | $icon_file = ICONS_URL."/".$line["id"].".ico"; | |
3335 | ||
3336 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
6c56687e | 3337 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; |
717f5e64 | 3338 | } else { |
5951ded1 | 3339 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
717f5e64 AD |
3340 | } |
3341 | ||
e94645ca | 3342 | print "<li>$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>"; |
e6cb77a0 | 3343 | } |
717f5e64 | 3344 | |
a88c1f36 AD |
3345 | if (db_num_rows($result) < $num_feeds) { |
3346 | // FIXME - add link to show ALL subscribed feeds here somewhere | |
3347 | print "<li><img | |
3348 | class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>"; | |
3349 | } | |
3350 | ||
717f5e64 AD |
3351 | print "</ul>"; |
3352 | ||
717f5e64 AD |
3353 | print "</div>"; |
3354 | ||
1a7572cb AD |
3355 | print "<div align='center'> |
3356 | <input type='submit' class='button' | |
c6c3a07f | 3357 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; |
1a7572cb AD |
3358 | |
3359 | // print "</body></html>"; | |
717f5e64 | 3360 | |
e6cb77a0 AD |
3361 | } |
3362 | ||
c6c3a07f AD |
3363 | if ($op == "feed-details") { |
3364 | ||
df268d47 | 3365 | // $feed_id = $_GET["id"]; |
4fec9fd7 | 3366 | |
df268d47 | 3367 | $feed_ids = split(",", db_escape_string($_GET["id"])); |
c6c3a07f | 3368 | |
df268d47 | 3369 | print "<div class=\"infoBoxContents\">"; |
bca02305 | 3370 | |
df268d47 | 3371 | foreach ($feed_ids as $feed_id) { |
c6c3a07f | 3372 | |
df268d47 AD |
3373 | $result = db_query($link, |
3374 | "SELECT | |
3375 | title,feed_url, | |
3376 | SUBSTRING(last_updated,1,16) as last_updated, | |
3377 | icon_url,site_url, | |
3378 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3379 | WHERE feed_id = id) AS total, | |
3380 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3381 | WHERE feed_id = id AND unread = true) AS unread, | |
3382 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3383 | WHERE feed_id = id AND marked = true) AS marked | |
3384 | FROM ttrss_feeds | |
3385 | WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]); | |
3386 | ||
3387 | if (db_num_rows($result) == 0) return; | |
3388 | ||
3389 | $title = db_unescape_string(db_fetch_result($result, 0, "title")); | |
3390 | $last_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
3391 | strtotime(db_fetch_result($result, 0, "last_updated"))); | |
3392 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
3393 | $icon_url = db_fetch_result($result, 0, "icon_url"); | |
3394 | $total = db_fetch_result($result, 0, "total"); | |
3395 | $unread = db_fetch_result($result, 0, "unread"); | |
3396 | $marked = db_fetch_result($result, 0, "marked"); | |
3397 | $site_url = db_fetch_result($result, 0, "site_url"); | |
bca02305 | 3398 | |
df268d47 AD |
3399 | $result = db_query($link, "SELECT COUNT(id) AS subscribed |
3400 | FROM ttrss_feeds WHERE feed_url = '$feed_url'"); | |
3401 | ||
3402 | $subscribed = db_fetch_result($result, 0, "subscribed"); | |
3403 | ||
3404 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
3405 | ||
3406 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
3407 | $feed_icon = "<img width=\"16\" height=\"16\" | |
3408 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
3409 | } else { | |
3410 | $feed_icon = ""; | |
bca02305 AD |
3411 | } |
3412 | ||
df268d47 | 3413 | print "<h1>$feed_icon $title</h1>"; |
bca02305 | 3414 | |
df268d47 | 3415 | print "<table width='100%'>"; |
bca02305 | 3416 | |
df268d47 AD |
3417 | if ($site_url) { |
3418 | print "<tr><td width='30%'>Link</td> | |
3419 | <td><a href=\"$site_url\">$site_url</a> | |
3420 | <a href=\"$feed_url\">(feed)</a></td> | |
3421 | </td></tr>"; | |
3422 | } else { | |
3423 | print "<tr><td width='30%'>Feed URL</td> | |
3424 | <td><a href=\"$feed_url\">$feed_url</a></td></tr>"; | |
3425 | } | |
3426 | print "<tr><td>Last updated</td><td>$last_updated</td></tr>"; | |
3427 | print "<tr><td>Total articles</td><td>$total</td></tr>"; | |
3428 | print "<tr><td>Unread articles</td><td>$unread</td></tr>"; | |
3429 | print "<tr><td>Starred articles</td><td>$marked</td></tr>"; | |
3430 | print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>"; | |
3431 | ||
3432 | print "</table>"; | |
3433 | ||
3434 | /* $result = db_query($link, "SELECT title, | |
3435 | SUBSTRING(updated,1,16) AS updated,unread | |
3436 | FROM ttrss_entries,ttrss_user_entries | |
3437 | WHERE ref_id = id AND feed_id = '$feed_id' | |
3438 | ORDER BY date_entered DESC LIMIT 5"); | |
3439 | ||
3440 | if (db_num_rows($result) > 0) { | |
3441 | ||
3442 | print "<h1>Latest headlines</h1>"; | |
3443 | ||
3444 | print "<ul class=\"nomarks\">"; | |
3445 | ||
3446 | while ($line = db_fetch_assoc($result)) { | |
3447 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
3448 | $line["title"] = "<b>" . $line["title"] . "</b>"; | |
3449 | } | |
3450 | print "<li>" . $line["title"]. | |
3451 | " <span class=\"insensitive\">(" . | |
3452 | date(get_pref($link, 'SHORT_DATE_FORMAT'), | |
3453 | strtotime($line["updated"])). | |
3454 | ")</span></li>"; | |
3455 | } | |
3456 | ||
3457 | print "</ul>"; | |
3458 | ||
3459 | } */ | |
bca02305 | 3460 | } |
df268d47 AD |
3461 | |
3462 | print "</div>"; | |
3463 | ||
3464 | print "<div align='center'> | |
3465 | <input type='submit' class='button' | |
3466 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
3467 | } | |
c6c3a07f | 3468 | |
4b3dff6e | 3469 | db_close($link); |
1cd17194 | 3470 | ?> |
406d9489 AD |
3471 | |
3472 | <!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> | |
3473 |