]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | <? |
36bfab86 AD |
2 | require_once "sessions.php"; |
3 | ||
59b8192f | 4 | header("Cache-Control: no-cache, must-revalidate"); |
ce0619bb AD |
5 | header("Pragma: no-cache"); |
6 | header("Expires: -1"); | |
de696427 | 7 | |
cce28758 AD |
8 | if ($_GET["debug"]) { |
9 | define('DEFAULT_ERROR_LEVEL', E_ALL); | |
10 | } else { | |
11 | define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); | |
12 | } | |
13 | ||
14 | error_reporting(DEFAULT_ERROR_LEVEL); | |
15 | ||
262bd8ea AD |
16 | $op = $_REQUEST["op"]; |
17 | ||
a2770077 | 18 | if ((!$op || $op == "rpc" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { |
262bd8ea AD |
19 | header("Content-Type: application/xml"); |
20 | } | |
21 | ||
a2770077 | 22 | if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") { |
262bd8ea | 23 | |
a2770077 | 24 | if ($op == "rpc") { |
262bd8ea | 25 | print "<error error-code=\"6\"/>"; |
04269460 AD |
26 | } else { |
27 | print " | |
28 | <html><body> | |
29 | <p>Error: Not logged in.</p> | |
30 | <script type=\"text/javascript\"> | |
31 | if (parent.window != 'undefined') { | |
32 | parent.window.location = \"login.php\"; | |
33 | } else { | |
34 | window.location = \"login.php\"; | |
35 | } | |
36 | </script> | |
37 | </body></html> | |
38 | "; | |
262bd8ea AD |
39 | } |
40 | exit; | |
41 | } | |
1c7f75ed | 42 | |
a2770077 AD |
43 | if (!$op) { |
44 | print "<error error-code=\"7\"/>"; | |
45 | exit; | |
46 | } | |
47 | ||
bc8a9512 | 48 | define('SCHEMA_VERSION', 6); |
1cd17194 | 49 | |
66581886 | 50 | require_once "sanity_check.php"; |
82baad4a | 51 | require_once "config.php"; |
648472a7 | 52 | require_once "db.php"; |
3bac89ad | 53 | require_once "db-prefs.php"; |
82baad4a AD |
54 | require_once "functions.php"; |
55 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 56 | |
406d9489 AD |
57 | $script_started = getmicrotime(); |
58 | ||
648472a7 | 59 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
d76a3b03 | 60 | |
5136011e AD |
61 | if (!$link) { |
62 | if (DB_TYPE == "mysql") { | |
63 | print mysql_error(); | |
64 | } | |
65 | // PG seems to display its own errors just fine by default. | |
66 | return; | |
67 | } | |
68 | ||
648472a7 AD |
69 | if (DB_TYPE == "pgsql") { |
70 | pg_query("set client_encoding = 'utf-8'"); | |
71 | } | |
7ec2a838 | 72 | |
4053b540 AD |
73 | if ($_SESSION["uid"]) { |
74 | if (get_pref($link, "HIDE_READ_FEEDS") == "true") { | |
75 | setcookie("ttrss_vf_hreadf", 1); | |
76 | } else { | |
77 | setcookie("ttrss_vf_hreadf", 0); | |
78 | } | |
f5de0d8d AD |
79 | |
80 | setcookie('ttrss_vf_refresh', FEEDS_FRAME_REFRESH); | |
c6784aea | 81 | setcookie('ttrss_vf_daemon', ENABLE_UPDATE_DAEMON); |
4053b540 | 82 | } |
7f123cda | 83 | |
331900c6 | 84 | $fetch = $_GET["fetch"]; |
175847de | 85 | |
023fe037 | 86 | setcookie("ttrss_icons_url", ICONS_URL); |
b2804af7 AD |
87 | |
88 | if (!sanity_check($link)) { return; } | |
023fe037 | 89 | |
1572afe5 AD |
90 | function getAllCounters($link) { |
91 | getLabelCounters($link); | |
92 | getFeedCounters($link); | |
93 | getTagCounters($link); | |
94 | getGlobalCounters($link); | |
280ee9a3 AD |
95 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
96 | getCategoryCounters($link); | |
97 | } | |
1572afe5 AD |
98 | } |
99 | ||
280ee9a3 | 100 | function getCategoryCounters($link) { |
987170e6 AD |
101 | $result = db_query($link, "SELECT cat_id,SUM((SELECT COUNT(int_id) |
102 | FROM ttrss_user_entries WHERE feed_id = ttrss_feeds.id | |
103 | AND unread = true)) AS unread FROM ttrss_feeds | |
60103089 AD |
104 | WHERE |
105 | owner_uid = ".$_SESSION["uid"]." GROUP BY cat_id"); | |
280ee9a3 AD |
106 | |
107 | while ($line = db_fetch_assoc($result)) { | |
108 | $line["cat_id"] = sprintf("%d", $line["cat_id"]); | |
109 | print "<counter type=\"category\" id=\"".$line["cat_id"]."\" counter=\"". | |
110 | $line["unread"]."\"/>"; | |
111 | } | |
112 | } | |
113 | ||
0ee2d12f AD |
114 | function getFeedUnread($link, $feed) { |
115 | $n_feed = sprintf("%d", $feed); | |
116 | ||
117 | if ($n_feed == -1) { | |
118 | $match_part = "marked = true"; | |
119 | } else if ($feed > 0) { | |
120 | $match_part = "feed_id = '$n_feed'"; | |
121 | } else if ($feed < -10) { | |
122 | $label_id = -$feed - 11; | |
123 | ||
124 | $result = db_query($link, "SELECT sql_exp FROM ttrss_labels WHERE | |
125 | id = '$label_id' AND owner_uid = " . $_SESSION["uid"]); | |
126 | ||
127 | $match_part = db_fetch_result($result, 0, "sql_exp"); | |
128 | } | |
129 | ||
130 | if ($match_part) { | |
131 | ||
132 | $result = db_query($link, "SELECT count(int_id) AS unread | |
133 | FROM ttrss_user_entries | |
134 | WHERE unread = true AND $match_part AND owner_uid = " . $_SESSION["uid"]); | |
135 | ||
136 | } else { | |
137 | ||
138 | $result = db_query($link, "SELECT COUNT(post_int_id) AS unread | |
139 | FROM ttrss_tags,ttrss_user_entries | |
140 | WHERE tag_name = '$feed' AND post_int_id = int_id AND unread = true AND | |
141 | ttrss_tags.owner_uid = " . $_SESSION["uid"]); | |
142 | } | |
143 | ||
144 | $unread = db_fetch_result($result, 0, "unread"); | |
145 | return $unread; | |
146 | } | |
147 | ||
8143ae1f AD |
148 | /* FIXME this needs reworking */ |
149 | ||
78ea1de0 | 150 | function getGlobalUnread($link) { |
4c193675 AD |
151 | $result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries |
152 | WHERE unread = true AND | |
153 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
154 | owner_uid = " . $_SESSION["uid"]); | |
fc69e641 | 155 | $c_id = db_fetch_result($result, 0, "c_id"); |
78ea1de0 AD |
156 | return $c_id; |
157 | } | |
158 | ||
159 | function getGlobalCounters($link, $global_unread = -1) { | |
160 | if ($global_unread == -1) { | |
161 | $global_unread = getGlobalUnread($link); | |
162 | } | |
163 | print "<counter type=\"global\" id='global-unread' counter='$global_unread'/>"; | |
fc69e641 AD |
164 | } |
165 | ||
bbc92e50 | 166 | function getTagCounters($link, $smart_mode = SMART_RPC_COUNTERS) { |
0477a326 AD |
167 | |
168 | if ($smart_mode) { | |
169 | if (!$_SESSION["tctr_last_value"]) { | |
170 | $_SESSION["tctr_last_value"] = array(); | |
171 | } | |
172 | } | |
173 | ||
174 | $old_counters = $_SESSION["tctr_last_value"]; | |
175 | ||
176 | $tctrs_modified = false; | |
177 | ||
987170e6 | 178 | /* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count |
4c193675 AD |
179 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE |
180 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
4356293a | 181 | ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND |
05732aa0 | 182 | post_int_id = ttrss_user_entries.int_id AND unread = true GROUP BY tag_name |
8143ae1f | 183 | UNION |
4356293a | 184 | select tag_name,0 as count FROM ttrss_tags |
987170e6 | 185 | WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]); */ |
8143ae1f | 186 | |
987170e6 AD |
187 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) |
188 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
189 | AND unread = true)) AS count FROM ttrss_tags | |
190 | WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name"); | |
191 | ||
8143ae1f AD |
192 | $tags = array(); |
193 | ||
194 | while ($line = db_fetch_assoc($result)) { | |
195 | $tags[$line["tag_name"]] += $line["count"]; | |
196 | } | |
197 | ||
198 | foreach (array_keys($tags) as $tag) { | |
199 | $unread = $tags[$tag]; | |
200 | ||
201 | $tag = htmlspecialchars($tag); | |
0477a326 AD |
202 | |
203 | if (!$smart_mode || $old_counters[$tag] != $unread) { | |
204 | $old_counters[$tag] = $unread; | |
205 | $tctrs_modified = true; | |
280ee9a3 | 206 | print "<counter type=\"tag\" id=\"$tag\" counter=\"$unread\"/>"; |
0477a326 AD |
207 | } |
208 | ||
8143ae1f | 209 | } |
0477a326 AD |
210 | |
211 | if ($smart_mode && $tctrs_modified) { | |
212 | $_SESSION["tctr_last_value"] = $old_counters; | |
213 | } | |
214 | ||
8143ae1f AD |
215 | } |
216 | ||
bbc92e50 AD |
217 | function getLabelCounters($link, $smart_mode = SMART_RPC_COUNTERS) { |
218 | ||
219 | if ($smart_mode) { | |
220 | if (!$_SESSION["lctr_last_value"]) { | |
221 | $_SESSION["lctr_last_value"] = array(); | |
222 | } | |
223 | } | |
224 | ||
225 | $old_counters = $_SESSION["lctr_last_value"]; | |
226 | $lctrs_modified = false; | |
090e250b | 227 | |
4c193675 AD |
228 | $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries |
229 | WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND | |
230 | unread = true AND owner_uid = ".$_SESSION["uid"]); | |
090e250b | 231 | |
d61fd764 | 232 | $count = db_fetch_result($result, 0, "count"); |
090e250b | 233 | |
280ee9a3 | 234 | print "<counter type=\"label\" id=\"-1\" counter=\"$count\"/>"; |
090e250b | 235 | |
4356293a AD |
236 | $result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM |
237 | ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description"); | |
090e250b AD |
238 | |
239 | while ($line = db_fetch_assoc($result)) { | |
240 | ||
241 | $id = -$line["id"] - 11; | |
242 | ||
243 | error_reporting (0); | |
d61fd764 | 244 | |
4c193675 | 245 | $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries |
655be073 | 246 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND |
4c193675 | 247 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
655be073 | 248 | owner_uid = ".$_SESSION["uid"]); |
090e250b | 249 | |
d61fd764 | 250 | $count = db_fetch_result($tmp_result, 0, "count"); |
090e250b | 251 | |
bbc92e50 AD |
252 | if (!$smart_mode || $old_counters[$id] != $count) { |
253 | $old_counters[$id] = $count; | |
254 | $lctrs_modified = true; | |
280ee9a3 | 255 | print "<counter type=\"label\" id=\"$id\" counter=\"$count\"/>"; |
bbc92e50 | 256 | } |
090e250b | 257 | |
cce28758 | 258 | error_reporting (DEFAULT_ERROR_LEVEL); |
bbc92e50 AD |
259 | } |
260 | ||
261 | if ($smart_mode && $lctrs_modified) { | |
262 | $_SESSION["lctr_last_value"] = $old_counters; | |
090e250b AD |
263 | } |
264 | } | |
265 | ||
db42b934 | 266 | /* function getFeedCounter($link, $id) { |
8073cce7 AD |
267 | |
268 | $result = db_query($link, "SELECT | |
d246bc99 AD |
269 | count(id) as count,last_error |
270 | FROM ttrss_entries,ttrss_user_entries,ttrss_feeds | |
4c193675 | 271 | WHERE feed_id = '$id' AND unread = true |
d246bc99 | 272 | AND ttrss_user_entries.feed_id = ttrss_feeds.id |
4c193675 | 273 | AND ttrss_user_entries.ref_id = ttrss_entries.id"); |
8073cce7 AD |
274 | |
275 | $count = db_fetch_result($result, 0, "count"); | |
dd0e3728 | 276 | $last_error = htmlspecialchars(db_fetch_result($result, 0, "last_error")); |
8073cce7 | 277 | |
d246bc99 | 278 | print "<counter type=\"feed\" id=\"$id\" counter=\"$count\" error=\"$last_error\"/>"; |
db42b934 | 279 | } */ |
090e250b | 280 | |
bbc92e50 | 281 | function getFeedCounters($link, $smart_mode = SMART_RPC_COUNTERS) { |
0477a326 AD |
282 | |
283 | if ($smart_mode) { | |
284 | if (!$_SESSION["fctr_last_value"]) { | |
285 | $_SESSION["fctr_last_value"] = array(); | |
286 | } | |
287 | } | |
288 | ||
289 | $old_counters = $_SESSION["fctr_last_value"]; | |
290 | ||
db42b934 | 291 | $result = db_query($link, "SELECT id,last_error,parent_feed, |
4c193675 AD |
292 | (SELECT count(id) |
293 | FROM ttrss_entries,ttrss_user_entries | |
d246bc99 AD |
294 | WHERE feed_id = ttrss_feeds.id AND |
295 | ttrss_user_entries.ref_id = ttrss_entries.id | |
b88917af | 296 | AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count |
db42b934 AD |
297 | FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"] . " |
298 | AND parent_feed IS NULL"); | |
0477a326 AD |
299 | |
300 | $fctrs_modified = false; | |
301 | ||
090e250b AD |
302 | while ($line = db_fetch_assoc($result)) { |
303 | ||
304 | $id = $line["id"]; | |
305 | $count = $line["count"]; | |
db42b934 AD |
306 | $last_error = htmlspecialchars($line["last_error"]); |
307 | ||
023fe037 AD |
308 | $has_img = is_file(ICONS_DIR . "/$id.ico"); |
309 | ||
db42b934 AD |
310 | $tmp_result = db_query($link, |
311 | "SELECT id,COUNT(unread) AS unread | |
312 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
313 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
314 | WHERE parent_feed = '$id' AND unread = true GROUP BY ttrss_feeds.id"); | |
315 | ||
316 | if (db_num_rows($tmp_result) > 0) { | |
317 | while ($l = db_fetch_assoc($tmp_result)) { | |
318 | $count += $l["unread"]; | |
319 | } | |
320 | } | |
321 | ||
0477a326 AD |
322 | if (!$smart_mode || $old_counters[$id] != $count) { |
323 | $old_counters[$id] = $count; | |
324 | $fctrs_modified = true; | |
d246bc99 AD |
325 | |
326 | if ($last_error) { | |
327 | $error_part = "error=\"$last_error\""; | |
328 | } else { | |
329 | $error_part = ""; | |
330 | } | |
023fe037 AD |
331 | |
332 | if ($has_img) { | |
333 | $has_img_part = "hi=\"$has_img\""; | |
334 | } else { | |
335 | $has_img_part = ""; | |
336 | } | |
337 | ||
338 | print "<counter type=\"feed\" id=\"$id\" counter=\"$count\" $has_img_part $error_part/>"; | |
0477a326 AD |
339 | } |
340 | } | |
341 | ||
342 | if ($smart_mode && $fctrs_modified) { | |
343 | $_SESSION["fctr_last_value"] = $old_counters; | |
090e250b AD |
344 | } |
345 | } | |
346 | ||
8143ae1f | 347 | function outputFeedList($link, $tags = false) { |
175847de | 348 | |
1a66d16e AD |
349 | print "<html><head> |
350 | <title>Tiny Tiny RSS : Feedlist</title> | |
430bf183 AD |
351 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
352 | ||
503eb349 AD |
353 | $user_theme = $_SESSION["theme"]; |
354 | if ($user_theme) { | |
355 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
356 | href=\"themes/$user_theme/theme.css\">"; | |
357 | } | |
358 | ||
4769ddaf | 359 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
430bf183 AD |
360 | print "<link rel=\"stylesheet\" type=\"text/css\" |
361 | href=\"tt-rss_compact.css\"/>"; | |
362 | } else { | |
363 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
364 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
365 | } | |
366 | ||
367 | print "<script type=\"text/javascript\" src=\"functions.js\"></script> | |
1a66d16e AD |
368 | <script type=\"text/javascript\" src=\"feedlist.js\"></script> |
369 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
beac550b AD |
370 | <!--[if gte IE 5.5000]> |
371 | <script type=\"text/javascript\" src=\"pngfix.js\"></script> | |
2f52ca1b | 372 | <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\"> |
beac550b | 373 | <![endif]--> |
97dcd654 AD |
374 | </head><body> |
375 | <script type=\"text/javascript\"> | |
376 | if (document.addEventListener) { | |
377 | document.addEventListener(\"DOMContentLoaded\", init, null); | |
378 | } | |
379 | window.onload = init; | |
380 | </script>"; | |
254e0e4b | 381 | |
140ff9db | 382 | print "<ul class=\"feedList\" id=\"feedList\">\n"; |
254e0e4b | 383 | |
4356293a AD |
384 | $owner_uid = $_SESSION["uid"]; |
385 | ||
8143ae1f | 386 | if (!$tags) { |
254e0e4b | 387 | |
8143ae1f | 388 | /* virtual feeds */ |
254e0e4b | 389 | |
91ff844a | 390 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
937881b5 AD |
391 | print "<li class=\"feedCat\">Special</li>"; |
392 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; | |
91ff844a AD |
393 | } |
394 | ||
8143ae1f | 395 | $result = db_query($link, "SELECT count(id) as num_starred |
4c193675 AD |
396 | FROM ttrss_entries,ttrss_user_entries |
397 | WHERE marked = true AND | |
398 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
399 | unread = true AND owner_uid = '$owner_uid'"); | |
8143ae1f | 400 | $num_starred = db_fetch_result($result, 0, "num_starred"); |
254e0e4b | 401 | |
3745788e | 402 | $class = "virt"; |
8add756a AD |
403 | |
404 | if ($num_starred > 0) $class .= "Unread"; | |
405 | ||
406 | printFeedEntry(-1, $class, "Starred articles", $num_starred, | |
4668523d | 407 | "images/mark_set.png", $link); |
48f0adb0 | 408 | |
91ff844a | 409 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
140ff9db | 410 | print "</ul>\n"; |
91ff844a AD |
411 | } |
412 | ||
cfaba6df | 413 | if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) { |
8143ae1f AD |
414 | |
415 | $result = db_query($link, "SELECT id,sql_exp,description FROM | |
4356293a | 416 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); |
8143ae1f AD |
417 | |
418 | if (db_num_rows($result) > 0) { | |
91ff844a | 419 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
937881b5 AD |
420 | print "<li class=\"feedCat\">Labels</li>"; |
421 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; | |
91ff844a | 422 | } else { |
937881b5 | 423 | print "<li><hr></li>"; |
91ff844a | 424 | } |
8143ae1f AD |
425 | } |
426 | ||
427 | while ($line = db_fetch_assoc($result)) { | |
48f0adb0 | 428 | |
8143ae1f AD |
429 | error_reporting (0); |
430 | ||
280ee9a3 AD |
431 | $tmp_result = db_query($link, "SELECT count(id) as count |
432 | FROM ttrss_entries,ttrss_user_entries | |
4c193675 AD |
433 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND |
434 | ttrss_user_entries.ref_id = ttrss_entries.id | |
655be073 | 435 | AND owner_uid = '$owner_uid'"); |
8143ae1f AD |
436 | |
437 | $count = db_fetch_result($tmp_result, 0, "count"); | |
438 | ||
3745788e | 439 | $class = "label"; |
8143ae1f AD |
440 | |
441 | if ($count > 0) { | |
442 | $class .= "Unread"; | |
443 | } | |
444 | ||
cce28758 | 445 | error_reporting (DEFAULT_ERROR_LEVEL); |
8143ae1f AD |
446 | |
447 | printFeedEntry(-$line["id"]-11, | |
4668523d | 448 | $class, $line["description"], $count, "images/label.png", $link); |
8143ae1f AD |
449 | |
450 | } | |
91ff844a AD |
451 | |
452 | if (db_num_rows($result) > 0) { | |
453 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
140ff9db | 454 | print "</ul>"; |
91ff844a AD |
455 | } |
456 | } | |
457 | ||
458 | } | |
459 | ||
460 | // if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
461 | print "<li><hr></li>"; | |
462 | // } | |
463 | ||
464 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
465 | $order_by_qpart = "category,title"; | |
466 | } else { | |
467 | $order_by_qpart = "title"; | |
48f0adb0 | 468 | } |
8143ae1f | 469 | |
db42b934 AD |
470 | $result = db_query($link, "SELECT ttrss_feeds.*, |
471 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
4c193675 AD |
472 | WHERE feed_id = ttrss_feeds.id AND |
473 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
474 | owner_uid = '$owner_uid') AS total, | |
db42b934 | 475 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries |
b88917af | 476 | WHERE feed_id = ttrss_feeds.id AND unread = true |
4c193675 | 477 | AND ttrss_user_entries.ref_id = ttrss_entries.id |
91ff844a | 478 | AND owner_uid = '$owner_uid') as unread, |
023fe037 | 479 | cat_id,last_error, |
db42b934 AD |
480 | ttrss_feed_categories.title AS category, |
481 | ttrss_feed_categories.collapsed | |
482 | FROM ttrss_feeds LEFT JOIN ttrss_feed_categories | |
483 | ON (ttrss_feed_categories.id = cat_id) | |
484 | WHERE | |
485 | ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL | |
486 | ORDER BY $order_by_qpart"); | |
487 | ||
8143ae1f AD |
488 | $actid = $_GET["actid"]; |
489 | ||
490 | /* real feeds */ | |
491 | ||
492 | $lnum = 0; | |
493 | ||
494 | $total_unread = 0; | |
91ff844a AD |
495 | |
496 | $category = ""; | |
8143ae1f | 497 | |
48f0adb0 | 498 | while ($line = db_fetch_assoc($result)) { |
8143ae1f | 499 | |
69668465 | 500 | $feed = db_unescape_string($line["title"]); |
8143ae1f AD |
501 | $feed_id = $line["id"]; |
502 | ||
503 | $subop = $_GET["subop"]; | |
504 | ||
505 | $total = $line["total"]; | |
506 | $unread = $line["unread"]; | |
91ff844a | 507 | |
db42b934 AD |
508 | $tmp_result = db_query($link, |
509 | "SELECT id,COUNT(unread) AS unread | |
510 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
511 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
512 | WHERE parent_feed = '$feed_id' AND unread = true | |
513 | GROUP BY ttrss_feeds.id"); | |
514 | ||
515 | if (db_num_rows($tmp_result) > 0) { | |
516 | while ($l = db_fetch_assoc($tmp_result)) { | |
517 | $unread += $l["unread"]; | |
518 | } | |
519 | } | |
520 | ||
fe14aeb8 AD |
521 | $cat_id = $line["cat_id"]; |
522 | ||
91ff844a AD |
523 | $tmp_category = $line["category"]; |
524 | ||
525 | if (!$tmp_category) { | |
526 | $tmp_category = "Uncategorized"; | |
527 | } | |
8143ae1f AD |
528 | |
529 | // $class = ($lnum % 2) ? "even" : "odd"; | |
023fe037 AD |
530 | |
531 | if ($line["last_error"]) { | |
532 | $class = "error"; | |
533 | } else { | |
534 | $class = "feed"; | |
535 | } | |
8143ae1f AD |
536 | |
537 | if ($unread > 0) $class .= "Unread"; | |
538 | ||
539 | if ($actid == $feed_id) { | |
540 | $class .= "Selected"; | |
392d4563 | 541 | } |
48f0adb0 | 542 | |
8143ae1f | 543 | $total_unread += $unread; |
91ff844a AD |
544 | |
545 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
546 | ||
547 | if ($category) { | |
140ff9db | 548 | print "</ul></li>"; |
91ff844a AD |
549 | } |
550 | ||
551 | $category = $tmp_category; | |
fe14aeb8 AD |
552 | |
553 | $collapsed = $line["collapsed"]; | |
554 | ||
65f85814 AD |
555 | // workaround for NULL category |
556 | if ($category == "Uncategorized") { | |
557 | if ($_COOKIE["ttrss_vf_uclps"] == 1) { | |
558 | $collapsed = "t"; | |
559 | } | |
560 | } | |
561 | ||
fe14aeb8 AD |
562 | if ($collapsed == "t" || $collapsed == "1") { |
563 | $holder_class = "invisible"; | |
65f85814 | 564 | $ellipsis = "..."; |
fe14aeb8 AD |
565 | } else { |
566 | $holder_class = ""; | |
65f85814 | 567 | $ellipsis = ""; |
280ee9a3 AD |
568 | } |
569 | ||
570 | if ($cat_id) { | |
571 | $cat_id_qpart = "cat_id = '$cat_id'"; | |
572 | } else { | |
573 | $cat_id_qpart = "cat_id IS NULL"; | |
574 | } | |
575 | ||
576 | $tmp_result = db_query($link, "SELECT count(int_id) AS unread | |
577 | FROM ttrss_user_entries,ttrss_feeds WHERE | |
578 | unread = true AND | |
579 | feed_id = ttrss_feeds.id AND $cat_id_qpart AND | |
580 | ttrss_user_entries.owner_uid = " . $_SESSION["uid"]); | |
581 | ||
582 | $cat_unread = db_fetch_result($tmp_result, 0, "unread"); | |
583 | ||
584 | $cat_id = sprintf("%d", $cat_id); | |
91ff844a | 585 | |
fe14aeb8 | 586 | print "<li class=\"feedCat\" id=\"FCAT-$cat_id\"> |
ff2c6e6a | 587 | <a href=\"javascript:toggleCollapseCat($cat_id)\">$tmp_category</a> |
99ff73f4 | 588 | <a href=\"javascript:viewCategory($cat_id)\" id=\"FCAP-$cat_id\"> |
280ee9a3 | 589 | <span id=\"FCATCTR-$cat_id\" |
ff2c6e6a AD |
590 | class=\"$catctr_class\">($cat_unread unread)$ellipsis</span></a> |
591 | <!-- <div style=\"float : right\"> | |
592 | <a href=\"javascript:viewCategory($cat_id)\">[view]</a> | |
593 | </div> --> | |
594 | </li>"; | |
c3f348c2 AD |
595 | |
596 | // !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function | |
597 | // -> keyboard navigation, etc. | |
96737ce9 | 598 | print "<li id=\"feedCatHolder\" class=\"$holder_class\"><ul class=\"feedCatList\" id=\"FCATLIST-$cat_id\">"; |
91ff844a | 599 | } |
8143ae1f | 600 | |
91ff844a AD |
601 | printFeedEntry($feed_id, $class, $feed, $unread, |
602 | "icons/$feed_id.ico", $link); | |
8143ae1f AD |
603 | |
604 | ++$lnum; | |
48f0adb0 | 605 | } |
91ff844a | 606 | |
8143ae1f | 607 | } else { |
a1a8a2be | 608 | |
8143ae1f | 609 | // tags |
a1a8a2be | 610 | |
987170e6 | 611 | /* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count |
05732aa0 AD |
612 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE |
613 | post_int_id = ttrss_user_entries.int_id AND | |
614 | unread = true AND ref_id = ttrss_entries.id | |
3b0948c4 | 615 | AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name |
8143ae1f | 616 | UNION |
3b0948c4 | 617 | select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid' |
987170e6 AD |
618 | ORDER BY tag_name"); */ |
619 | ||
620 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) | |
621 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
622 | AND unread = true)) AS count FROM ttrss_tags | |
623 | WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name"); | |
624 | ||
8143ae1f AD |
625 | $tags = array(); |
626 | ||
627 | while ($line = db_fetch_assoc($result)) { | |
628 | $tags[$line["tag_name"]] += $line["count"]; | |
1a66d16e | 629 | } |
8143ae1f AD |
630 | |
631 | foreach (array_keys($tags) as $tag) { | |
632 | ||
633 | $unread = $tags[$tag]; | |
634 | ||
83957936 | 635 | $class = "tag"; |
8143ae1f AD |
636 | |
637 | if ($unread > 0) { | |
638 | $class .= "Unread"; | |
639 | } | |
640 | ||
4668523d | 641 | printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link); |
8143ae1f AD |
642 | |
643 | } | |
1a66d16e | 644 | |
e828e31e | 645 | } |
82baad4a | 646 | |
dc33ec95 | 647 | if (db_num_rows($result) == 0) { |
8037c618 AD |
648 | if ($tags) { |
649 | $what = "tags"; | |
650 | } else { | |
651 | $what = "feeds"; | |
652 | } | |
653 | print "<li>No $what to display.</li>"; | |
dc33ec95 AD |
654 | } |
655 | ||
8143ae1f | 656 | print "</ul>"; |
1cd17194 | 657 | |
97dcd654 AD |
658 | print ' |
659 | <script type="text/javascript"> | |
660 | /* for IE */ | |
661 | function statechange() { | |
662 | if (document.readyState == "interactive") init(); | |
663 | } | |
664 | ||
665 | if (document.readyState) { | |
666 | if (document.readyState == "interactive" || document.readyState == "complete") { | |
667 | init(); | |
668 | } else { | |
669 | document.onreadystatechange = statechange; | |
670 | } | |
671 | } | |
672 | </script></body></html>'; | |
c3b81db0 AD |
673 | } |
674 | ||
675 | ||
676 | if ($op == "rpc") { | |
677 | ||
678 | $subop = $_GET["subop"]; | |
679 | ||
7f123cda AD |
680 | if ($subop == "setpref") { |
681 | if (WEB_DEMO_MODE) { | |
682 | return; | |
683 | } | |
684 | ||
685 | print "<rpc-reply>"; | |
686 | ||
687 | $key = db_escape_string($_GET["key"]); | |
688 | $value = db_escape_string($_GET["value"]); | |
689 | ||
690 | set_pref($link, $key, $value); | |
691 | ||
692 | print "<param-set key=\"$key\" value=\"$value\"/>"; | |
693 | ||
694 | print "</rpc-reply>"; | |
695 | ||
696 | } | |
697 | ||
090e250b | 698 | if ($subop == "getLabelCounters") { |
8073cce7 | 699 | $aid = $_GET["aid"]; |
090e250b AD |
700 | print "<rpc-reply>"; |
701 | getLabelCounters($link); | |
8073cce7 AD |
702 | if ($aid) { |
703 | getFeedCounter($link, $aid); | |
704 | } | |
090e250b AD |
705 | print "</rpc-reply>"; |
706 | } | |
707 | ||
708 | if ($subop == "getFeedCounters") { | |
709 | print "<rpc-reply>"; | |
710 | getFeedCounters($link); | |
711 | print "</rpc-reply>"; | |
712 | } | |
713 | ||
714 | if ($subop == "getAllCounters") { | |
715 | print "<rpc-reply>"; | |
1572afe5 | 716 | getAllCounters($link); |
090e250b | 717 | print "</rpc-reply>"; |
090e250b AD |
718 | } |
719 | ||
f4c10d44 AD |
720 | if ($subop == "mark") { |
721 | $mark = $_GET["mark"]; | |
648472a7 | 722 | $id = db_escape_string($_GET["id"]); |
f4c10d44 AD |
723 | |
724 | if ($mark == "1") { | |
725 | $mark = "true"; | |
726 | } else { | |
727 | $mark = "false"; | |
728 | } | |
729 | ||
b5137506 AD |
730 | // FIXME this needs collision testing |
731 | ||
732 | $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark | |
733 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
f4c10d44 AD |
734 | } |
735 | ||
caa4e57f | 736 | if ($subop == "updateFeed") { |
648472a7 | 737 | $feed_id = db_escape_string($_GET["feed"]); |
9cfc649a | 738 | |
648472a7 | 739 | $result = db_query($link, |
a5873b2e AD |
740 | "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id' |
741 | AND owner_uid = " . $_SESSION["uid"]); | |
9cfc649a | 742 | |
648472a7 AD |
743 | if (db_num_rows($result) > 0) { |
744 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
a5873b2e | 745 | update_rss_feed($link, $feed_url, $feed_id); |
caa4e57f | 746 | } |
9cfc649a | 747 | |
a5873b2e AD |
748 | print "<rpc-reply>"; |
749 | getFeedCounter($link, $feed_id); | |
750 | print "</rpc-reply>"; | |
751 | ||
caa4e57f | 752 | return; |
9cfc649a AD |
753 | } |
754 | ||
090e250b | 755 | if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") { |
9d1ef64e | 756 | |
085a5a74 | 757 | if (ENABLE_UPDATE_DAEMON) { |
c3b81db0 | 758 | |
b8a6ff30 | 759 | if ($subop == "forceUpdateAllFeeds") { |
8b911251 | 760 | |
b8a6ff30 AD |
761 | $result = db_query($link, "SELECT count(id) AS cid FROM |
762 | ttrss_scheduled_updates WHERE feed_id IS NULL AND | |
763 | owner_uid = " . $_SESSION["uid"]); | |
764 | ||
765 | $cid = db_fetch_result($result, 0, "cid"); | |
766 | ||
767 | # print "<rpc-reply>"; | |
768 | ||
769 | if ($cid == 0) { | |
770 | ||
771 | db_query($link, "INSERT INTO ttrss_scheduled_updates | |
772 | (owner_uid, feed_id, entered) VALUES | |
773 | (".$_SESSION["uid"].", NULL, NOW())"); | |
774 | ||
36cf32bc | 775 | // print "<!-- ScheduledOK -->"; |
8b911251 | 776 | |
b8a6ff30 | 777 | } else { |
36cf32bc | 778 | // print "<!-- RequestAlreadyInQueue -->"; |
b8a6ff30 AD |
779 | } |
780 | ||
781 | # print "</rpc-reply>"; | |
8b911251 | 782 | } |
1f4ad53c | 783 | |
cd907b7c | 784 | } else { |
1f4ad53c AD |
785 | update_all_feeds($link, $subop == "forceUpdateAllFeeds"); |
786 | } | |
787 | ||
78ea1de0 AD |
788 | $global_unread_caller = sprintf("%d", $_GET["uctr"]); |
789 | $global_unread = getGlobalUnread($link); | |
cd907b7c | 790 | |
085a5a74 | 791 | print "<rpc-reply>"; |
78ea1de0 AD |
792 | |
793 | if ($global_unread_caller != $global_unread) { | |
794 | ||
795 | $omode = $_GET["omode"]; | |
796 | ||
2bf6e0a8 | 797 | if (!$omode) $omode = "tflc"; |
78ea1de0 AD |
798 | |
799 | if (strchr($omode, "l")) getLabelCounters($link); | |
800 | if (strchr($omode, "f")) getFeedCounters($link); | |
801 | if (strchr($omode, "t")) getTagCounters($link); | |
2bf6e0a8 AD |
802 | if (strchr($omode, "c")) { |
803 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
804 | getCategoryCounters($link); | |
805 | } | |
806 | } | |
601a5e04 | 807 | } |
e50d3212 AD |
808 | |
809 | getGlobalCounters($link, $global_unread); | |
810 | ||
085a5a74 AD |
811 | print "</rpc-reply>"; |
812 | ||
c3b81db0 | 813 | } |
1572afe5 AD |
814 | |
815 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ | |
b018b49b | 816 | if ($subop == "catchupSelected") { |
c3b81db0 | 817 | |
f932bc9f | 818 | $ids = split(",", db_escape_string($_GET["ids"])); |
c3b81db0 | 819 | |
1572afe5 | 820 | $cmode = sprintf("%d", $_GET["cmode"]); |
c3b81db0 | 821 | |
1572afe5 | 822 | foreach ($ids as $id) { |
c3b81db0 | 823 | |
1572afe5 AD |
824 | if ($cmode == 0) { |
825 | db_query($link, "UPDATE ttrss_user_entries SET | |
826 | unread = false,last_read = NOW() | |
827 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
828 | } else if ($cmode == 1) { | |
829 | db_query($link, "UPDATE ttrss_user_entries SET | |
830 | unread = true | |
831 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
832 | } else { | |
833 | db_query($link, "UPDATE ttrss_user_entries SET | |
834 | unread = NOT unread,last_read = NOW() | |
835 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
836 | } | |
c3b81db0 | 837 | } |
1572afe5 AD |
838 | print "<rpc-reply>"; |
839 | getAllCounters($link); | |
840 | print "</rpc-reply>"; | |
841 | } | |
c3b81db0 | 842 | |
1572afe5 AD |
843 | if ($subop == "markSelected") { |
844 | ||
f932bc9f | 845 | $ids = split(",", db_escape_string($_GET["ids"])); |
1572afe5 AD |
846 | |
847 | $cmode = sprintf("%d", $_GET["cmode"]); | |
848 | ||
849 | foreach ($ids as $id) { | |
850 | ||
851 | if ($cmode == 0) { | |
852 | db_query($link, "UPDATE ttrss_user_entries SET | |
853 | marked = false | |
854 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
855 | } else if ($cmode == 1) { | |
856 | db_query($link, "UPDATE ttrss_user_entries SET | |
857 | marked = true | |
858 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
859 | } else { | |
860 | db_query($link, "UPDATE ttrss_user_entries SET | |
861 | marked = NOT marked | |
862 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
863 | } | |
864 | } | |
865 | print "<rpc-reply>"; | |
866 | getAllCounters($link); | |
867 | print "</rpc-reply>"; | |
c3b81db0 | 868 | } |
295f9b42 AD |
869 | |
870 | if ($subop == "sanityCheck") { | |
bc236938 AD |
871 | if (sanity_check($link)) { |
872 | print "<error error-code=\"0\"/>"; | |
873 | } | |
295f9b42 | 874 | } |
fefa6ca3 AD |
875 | |
876 | if ($subop == "globalPurge") { | |
877 | ||
878 | print "<rpc-reply>"; | |
879 | global_purge_old_posts($link, true); | |
880 | print "</rpc-reply>"; | |
881 | ||
882 | } | |
883 | ||
c3b81db0 AD |
884 | } |
885 | ||
886 | if ($op == "feeds") { | |
887 | ||
8143ae1f AD |
888 | $tags = $_GET["tags"]; |
889 | ||
c3b81db0 AD |
890 | $subop = $_GET["subop"]; |
891 | ||
892 | if ($subop == "catchupAll") { | |
b018b49b | 893 | db_query($link, "UPDATE ttrss_user_entries SET |
6d15e1ef | 894 | last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]); |
c3b81db0 AD |
895 | } |
896 | ||
fe14aeb8 AD |
897 | if ($subop == "collapse") { |
898 | $cat_id = db_escape_string($_GET["cid"]); | |
280ee9a3 | 899 | |
fe14aeb8 AD |
900 | db_query($link, "UPDATE ttrss_feed_categories SET |
901 | collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . | |
902 | $_SESSION["uid"]); | |
903 | return; | |
904 | } | |
905 | ||
8143ae1f | 906 | outputFeedList($link, $tags); |
c3b81db0 | 907 | |
1cd17194 AD |
908 | } |
909 | ||
910 | if ($op == "view") { | |
911 | ||
d76a3b03 | 912 | $id = $_GET["id"]; |
8073cce7 | 913 | $feed_id = $_GET["feed"]; |
d76a3b03 | 914 | |
4c193675 AD |
915 | $result = db_query($link, "UPDATE ttrss_user_entries |
916 | SET unread = false,last_read = NOW() | |
917 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
a1a8a2be | 918 | |
21703604 | 919 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, |
9167e250 | 920 | SUBSTRING(updated,1,16) as updated, |
11b0dce2 | 921 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, |
a545b564 AD |
922 | num_comments, |
923 | author | |
4c193675 AD |
924 | FROM ttrss_entries,ttrss_user_entries |
925 | WHERE id = '$id' AND ref_id = id"); | |
1cd17194 | 926 | |
59b8192f AD |
927 | print "<html><head> |
928 | <title>Tiny Tiny RSS : Article $id</title> | |
929 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; | |
503eb349 | 930 | |
59b8192f AD |
931 | $user_theme = $_SESSION["theme"]; |
932 | if ($user_theme) { | |
933 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
934 | href=\"themes/$user_theme/theme.css\">"; | |
935 | } | |
503eb349 | 936 | |
59b8192f AD |
937 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
938 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
939 | href=\"tt-rss_compact.css\"/>"; | |
940 | } else { | |
941 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
942 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
70830c87 AD |
943 | } |
944 | ||
59b8192f AD |
945 | print "<script type=\"text/javascript\" src=\"functions.js\"></script> |
946 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
947 | </head><body>"; | |
948 | ||
d76a3b03 | 949 | if ($result) { |
1cd17194 | 950 | |
648472a7 | 951 | $line = db_fetch_assoc($result); |
1cd17194 | 952 | |
b7f4bda2 AD |
953 | if ($line["icon_url"]) { |
954 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
955 | } else { | |
956 | $feed_icon = " "; | |
957 | } | |
d76a3b03 | 958 | |
11b0dce2 | 959 | /* if ($line["comments"] && $line["link"] != $line["comments"]) { |
f7181e9b AD |
960 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; |
961 | } else { | |
962 | $entry_comments = ""; | |
11b0dce2 AD |
963 | } */ |
964 | ||
965 | $num_comments = $line["num_comments"]; | |
966 | $entry_comments = ""; | |
967 | ||
968 | if ($num_comments > 0) { | |
969 | if ($line["comments"]) { | |
970 | $comments_url = $line["comments"]; | |
971 | } else { | |
972 | $comments_url = $line["link"]; | |
973 | } | |
6a1ad084 | 974 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; |
11b0dce2 AD |
975 | } else { |
976 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
672366bd | 977 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; |
11b0dce2 | 978 | } |
f7181e9b AD |
979 | } |
980 | ||
e828e31e AD |
981 | print "<div class=\"postReply\">"; |
982 | ||
21703604 AD |
983 | print "<div class=\"postHeader\"><table width=\"100%\">"; |
984 | ||
a545b564 AD |
985 | $entry_author = $line["author"]; |
986 | ||
987 | if ($entry_author) { | |
988 | $entry_author = " - by $entry_author"; | |
989 | } | |
990 | ||
991 | print "<tr><td><a href=\"" . $line["link"] . "\">" . $line["title"] . | |
992 | "</a>$entry_author</td>"; | |
9167e250 AD |
993 | |
994 | $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
995 | strtotime($line["updated"])); | |
996 | ||
997 | print "<td class=\"postDate\">$parsed_updated</td>"; | |
998 | ||
999 | print "</tr>"; | |
21703604 AD |
1000 | |
1001 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM | |
1002 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
1003 | ORDER BY tag_name"); | |
1004 | ||
1005 | $tags_str = ""; | |
42918a07 AD |
1006 | $f_tags_str = ""; |
1007 | ||
1008 | $num_tags = 0; | |
21703604 AD |
1009 | |
1010 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
42918a07 AD |
1011 | $num_tags++; |
1012 | $tag = $tmp_line["tag_name"]; | |
1013 | $tag_str = "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, "; | |
1014 | ||
1015 | if ($num_tags == 5) { | |
1016 | $tags_str .= "<a href=\"javascript:showBlockElement('allEntryTags')\">...</a>"; | |
1017 | } else if ($num_tags < 5) { | |
1018 | $tags_str .= $tag_str; | |
1019 | } | |
1020 | $f_tags_str .= $tag_str; | |
1021 | } | |
21703604 | 1022 | |
42918a07 AD |
1023 | $tags_str = preg_replace("/, $/", "", $tags_str); |
1024 | $f_tags_str = preg_replace("/, $/", "", $f_tags_str); | |
e828e31e | 1025 | |
6a1ad084 | 1026 | // $truncated_link = truncate_string($line["link"], 60); |
21703604 | 1027 | |
6a1ad084 AD |
1028 | if ($tags_str || $entry_comments) { |
1029 | print "<tr><td width='50%'> | |
1030 | $entry_comments</td> | |
1031 | <td align=\"right\">$tags_str</td></tr>"; | |
1032 | } | |
21703604 | 1033 | |
e828e31e AD |
1034 | print "</table></div>"; |
1035 | ||
1036 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
42918a07 AD |
1037 | print "<div class=\"postContent\">"; |
1038 | ||
1039 | if (db_num_rows($tmp_result) > 5) { | |
1040 | print "<div id=\"allEntryTags\">Tags: $f_tags_str</div>"; | |
1041 | } | |
1042 | ||
1043 | print $line["content"] . "</div>"; | |
e828e31e AD |
1044 | |
1045 | print "</div>"; | |
1046 | ||
090e250b | 1047 | print "<script type=\"text/javascript\"> |
4f3a84f4 | 1048 | update_all_counters('$feed_id'); |
090e250b | 1049 | </script>"; |
d76a3b03 | 1050 | } |
70830c87 | 1051 | |
59b8192f | 1052 | print "</body></html>"; |
1cd17194 AD |
1053 | } |
1054 | ||
1055 | if ($op == "viewfeed") { | |
1056 | ||
1057 | $feed = $_GET["feed"]; | |
d76a3b03 | 1058 | $skip = $_GET["skip"]; |
476cac42 | 1059 | $subop = $_GET["subop"]; |
f175937c | 1060 | $view_mode = $_GET["view"]; |
cb1083a1 | 1061 | $limit = $_GET["limit"]; |
ff2c6e6a | 1062 | $cat_view = $_GET["cat"]; |
a1a8a2be | 1063 | |
ac53063a AD |
1064 | if (!$skip) $skip = 0; |
1065 | ||
476cac42 | 1066 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 1067 | |
59b8192f AD |
1068 | print "<html><head> |
1069 | <title>Tiny Tiny RSS : Feed $feed</title> | |
1070 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; | |
503eb349 | 1071 | |
59b8192f AD |
1072 | $user_theme = $_SESSION["theme"]; |
1073 | if ($user_theme) { | |
1074 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
1075 | href=\"themes/$user_theme/theme.css\">"; | |
1076 | } | |
430bf183 | 1077 | |
59b8192f AD |
1078 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
1079 | print "<link rel=\"stylesheet\" | |
1080 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
503eb349 | 1081 | |
59b8192f AD |
1082 | } else { |
1083 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
1084 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
f0601b87 AD |
1085 | } |
1086 | ||
59b8192f AD |
1087 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
1088 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
1089 | <script type=\"text/javascript\" src=\"viewfeed.js\"></script> | |
1090 | <!--[if gte IE 5.5000]> | |
1091 | <script type=\"text/javascript\" src=\"pngfix.js\"></script> | |
1092 | <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\"> | |
1093 | <![endif]--> | |
1094 | </head><body> | |
1095 | <script type=\"text/javascript\"> | |
1096 | if (document.addEventListener) { | |
1097 | document.addEventListener(\"DOMContentLoaded\", init, null); | |
1098 | } | |
1099 | window.onload = init; | |
1100 | </script>"; | |
1101 | ||
7a232fc6 | 1102 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { |
dcee8f61 | 1103 | |
085a5a74 | 1104 | /* if (ENABLE_UPDATE_DAEMON) { |
8b911251 AD |
1105 | |
1106 | if ($cid == 0) { | |
1107 | ||
1108 | db_query($link, "INSERT INTO ttrss_scheduled_updates | |
1109 | (owner_uid, feed_id, entered) VALUES | |
1110 | (".$_SESSION["uid"].", '$feed', NOW())"); | |
1111 | } | |
dcee8f61 | 1112 | |
633d263b AD |
1113 | } else { |
1114 | // fixme update_rss_feed... | |
1115 | } */ | |
1116 | ||
ff2c6e6a | 1117 | if ($cat_view) { |
99ff73f4 AD |
1118 | |
1119 | if ($feed > 0) { | |
1120 | $cat_qpart = "cat_id = '$feed'"; | |
1121 | } else { | |
1122 | $cat_qpart = "cat_id IS NULL"; | |
1123 | } | |
1124 | ||
ff2c6e6a | 1125 | $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds |
99ff73f4 | 1126 | WHERE $cat_qpart AND owner_uid = " . $_SESSION["uid"]); |
ff2c6e6a AD |
1127 | |
1128 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1129 | $feed_url = $tmp_line["feed_url"]; | |
1130 | update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON); | |
1131 | } | |
1132 | ||
1133 | } else { | |
1134 | $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds | |
1135 | WHERE id = '$feed'"); | |
1136 | $feed_url = db_fetch_result($tmp_result, 0, "feed_url"); | |
1137 | update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON); | |
1138 | } | |
dcee8f61 AD |
1139 | } |
1140 | ||
0e32076b | 1141 | if ($subop == "MarkAllRead") { |
d76a3b03 | 1142 | |
d0bb308e | 1143 | if (preg_match("/^[0-9][0-9]*$/", $feed) != false && $feed >= 0) { |
0e32076b | 1144 | |
ff2c6e6a AD |
1145 | if ($cat_view) { |
1146 | ||
99ff73f4 AD |
1147 | if ($feed > 0) { |
1148 | $cat_qpart = "cat_id = '$feed'"; | |
1149 | } else { | |
1150 | $cat_qpart = "cat_id IS NULL"; | |
1151 | } | |
1152 | ||
ff2c6e6a | 1153 | $tmp_result = db_query($link, "SELECT id |
99ff73f4 | 1154 | FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = " . |
ff2c6e6a AD |
1155 | $_SESSION["uid"]); |
1156 | ||
1157 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1158 | ||
1159 | $tmp_feed = $tmp_line["id"]; | |
1160 | ||
1161 | db_query($link, "UPDATE ttrss_user_entries | |
1162 | SET unread = false,last_read = NOW() | |
1163 | WHERE feed_id = '$tmp_feed' AND owner_uid = " . $_SESSION["uid"]); | |
1164 | } | |
1165 | ||
1166 | } else if ($feed > 0) { | |
f33371c0 AD |
1167 | |
1168 | $tmp_result = db_query($link, "SELECT id | |
1169 | FROM ttrss_feeds WHERE parent_feed = '$feed' | |
1170 | ORDER BY cat_id,title"); | |
1171 | ||
1172 | $parent_ids = array(); | |
1173 | ||
1174 | if (db_num_rows($tmp_result) > 0) { | |
1175 | while ($p = db_fetch_assoc($tmp_result)) { | |
1176 | array_push($parent_ids, "feed_id = " . $p["id"]); | |
1177 | } | |
1178 | ||
1179 | $children_qpart = implode(" OR ", $parent_ids); | |
1180 | ||
1181 | db_query($link, "UPDATE ttrss_user_entries | |
1182 | SET unread = false,last_read = NOW() | |
1183 | WHERE (feed_id = '$feed' OR $children_qpart) | |
1184 | AND owner_uid = " . $_SESSION["uid"]); | |
1185 | ||
1186 | } else { | |
1187 | db_query($link, "UPDATE ttrss_user_entries | |
1188 | SET unread = false,last_read = NOW() | |
1189 | WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
1190 | } | |
0e32076b AD |
1191 | |
1192 | } else if ($feed < 0 && $feed > -10) { // special, like starred | |
1193 | ||
1194 | if ($feed == -1) { | |
f23a2177 | 1195 | db_query($link, "UPDATE ttrss_user_entries |
0e32076b | 1196 | SET unread = false,last_read = NOW() |
5859be02 | 1197 | WHERE marked = true AND owner_uid = ".$_SESSION["uid"]); |
0e32076b AD |
1198 | } |
1199 | ||
1200 | } else if ($feed < -10) { // label | |
1201 | ||
f23a2177 AD |
1202 | // TODO make this more efficient |
1203 | ||
7db95187 | 1204 | $label_id = -$feed - 11; |
0e32076b | 1205 | |
7db95187 | 1206 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels |
f23a2177 | 1207 | WHERE id = '$label_id'"); |
7db95187 AD |
1208 | |
1209 | if ($tmp_result) { | |
1210 | $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp"); | |
1211 | ||
f23a2177 AD |
1212 | db_query($link, "BEGIN"); |
1213 | ||
1214 | $tmp2_result = db_query($link, | |
1215 | "SELECT | |
1216 | int_id | |
1217 | FROM | |
1218 | ttrss_user_entries,ttrss_entries | |
1219 | WHERE | |
1220 | ref_id = id AND | |
1221 | $sql_exp AND | |
1222 | owner_uid = " . $_SESSION["uid"]); | |
1223 | ||
1224 | while ($tmp_line = db_fetch_assoc($tmp2_result)) { | |
1225 | db_query($link, "UPDATE | |
1226 | ttrss_user_entries | |
1227 | SET | |
1228 | unread = false, last_read = NOW() | |
1229 | WHERE | |
1230 | int_id = " . $tmp_line["int_id"]); | |
1231 | } | |
1232 | ||
1233 | db_query($link, "COMMIT"); | |
1234 | ||
1235 | /* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries | |
7db95187 | 1236 | SET unread = false,last_read = NOW() |
f23a2177 AD |
1237 | WHERE $sql_exp |
1238 | AND ref_id = id | |
1239 | AND owner_uid = ".$_SESSION["uid"]); */ | |
7db95187 | 1240 | } |
254e0e4b | 1241 | } |
0e32076b | 1242 | } else { // tag |
7eec90cf AD |
1243 | db_query($link, "BEGIN"); |
1244 | ||
1245 | $tag_name = db_escape_string($feed); | |
1246 | ||
1247 | $result = db_query($link, "SELECT post_int_id FROM ttrss_tags | |
1248 | WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]); | |
1249 | ||
1250 | while ($line = db_fetch_assoc($result)) { | |
1251 | db_query($link, "UPDATE ttrss_user_entries SET | |
1252 | unread = false, last_read = NOW() | |
1253 | WHERE int_id = " . $line["post_int_id"]); | |
1254 | } | |
1255 | db_query($link, "COMMIT"); | |
a1a8a2be | 1256 | } |
0e32076b | 1257 | |
a1a8a2be | 1258 | } |
d76a3b03 | 1259 | |
f932bc9f AD |
1260 | $search = db_escape_string($_GET["search"]); |
1261 | $search_mode = db_escape_string($_GET["smode"]); | |
52b51244 | 1262 | |
f175937c | 1263 | if ($search) { |
8e84993b AD |
1264 | $search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%') |
1265 | OR ttrss_entries.content LIKE '%$search%') AND"; | |
f175937c AD |
1266 | } else { |
1267 | $search_query_part = ""; | |
1268 | } | |
1269 | ||
1270 | $view_query_part = ""; | |
1271 | ||
0ee2d12f | 1272 | if ($view_mode == "Adaptive") { |
f18d0d94 AD |
1273 | if ($search) { |
1274 | $view_query_part = " "; | |
1275 | } else if ($feed != -1) { | |
0ee2d12f AD |
1276 | $unread = getFeedUnread($link, $feed); |
1277 | if ($unread > 0) { | |
1278 | $view_query_part = " unread = true AND "; | |
1279 | } | |
1280 | } | |
1281 | } | |
1282 | ||
f175937c AD |
1283 | if ($view_mode == "Starred") { |
1284 | $view_query_part = " marked = true AND "; | |
ac53063a AD |
1285 | } |
1286 | ||
ac43eba1 AD |
1287 | if ($view_mode == "Unread") { |
1288 | $view_query_part = " unread = true AND "; | |
1289 | } | |
1290 | ||
8d7008c7 | 1291 | if ($limit && $limit != "All") { |
82c9223c | 1292 | $limit_query_part = "LIMIT " . $limit; |
ad3cb710 | 1293 | } |
f0601b87 | 1294 | |
254e0e4b AD |
1295 | $vfeed_query_part = ""; |
1296 | ||
52b51244 | 1297 | // override query strategy and enable feed display when searching globally |
d3416913 | 1298 | if ($search && $search_mode == "All feeds") { |
8e84993b | 1299 | $query_strategy_part = "ttrss_entries.id > 0"; |
b0005823 | 1300 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
d0bb308e | 1301 | } else if (preg_match("/^-?[0-9][0-9]*$/", $feed) == false) { |
8143ae1f AD |
1302 | $query_strategy_part = "ttrss_entries.id > 0"; |
1303 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
1304 | id = feed_id) as feed_title,"; | |
b0005823 AD |
1305 | } else if ($feed >= 0 && $search && $search_mode == "This category") { |
1306 | ||
1307 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
1308 | ||
1309 | $tmp_result = db_query($link, "SELECT id | |
1310 | FROM ttrss_feeds WHERE cat_id = | |
1311 | (SELECT cat_id FROM ttrss_feeds WHERE id = '$feed') AND id != '$feed'"); | |
1312 | ||
1313 | $cat_siblings = array(); | |
1314 | ||
1315 | if (db_num_rows($tmp_result) > 0) { | |
1316 | while ($p = db_fetch_assoc($tmp_result)) { | |
1317 | array_push($cat_siblings, "feed_id = " . $p["id"]); | |
1318 | } | |
1319 | ||
1320 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
1321 | $feed, implode(" OR ", $cat_siblings)); | |
1322 | ||
1323 | } else { | |
1324 | $query_strategy_part = "ttrss_entries.id > 0"; | |
1325 | } | |
ff2c6e6a | 1326 | |
8143ae1f | 1327 | } else if ($feed >= 0) { |
60103089 | 1328 | |
ff2c6e6a | 1329 | if ($cat_view) { |
b0005823 | 1330 | |
99ff73f4 AD |
1331 | if ($feed > 0) { |
1332 | $query_strategy_part = "cat_id = '$feed'"; | |
1333 | } else { | |
1334 | $query_strategy_part = "cat_id IS NULL"; | |
1335 | } | |
1336 | ||
60103089 | 1337 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
ff2c6e6a AD |
1338 | |
1339 | } else { | |
1340 | $tmp_result = db_query($link, "SELECT id | |
1341 | FROM ttrss_feeds WHERE parent_feed = '$feed' | |
1342 | ORDER BY cat_id,title"); | |
1343 | ||
1344 | $parent_ids = array(); | |
1345 | ||
1346 | if (db_num_rows($tmp_result) > 0) { | |
1347 | while ($p = db_fetch_assoc($tmp_result)) { | |
1348 | array_push($parent_ids, "feed_id = " . $p["id"]); | |
1349 | } | |
1350 | ||
1351 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
1352 | $feed, implode(" OR ", $parent_ids)); | |
1353 | ||
1354 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
1355 | } else { | |
1356 | $query_strategy_part = "feed_id = '$feed'"; | |
1357 | } | |
60103089 | 1358 | } |
48f0adb0 | 1359 | } else if ($feed == -1) { // starred virtual feed |
254e0e4b | 1360 | $query_strategy_part = "marked = true"; |
60103089 | 1361 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
48f0adb0 AD |
1362 | } else if ($feed <= -10) { // labels |
1363 | $label_id = -$feed - 11; | |
1364 | ||
1365 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
1366 | WHERE id = '$label_id'"); | |
1367 | ||
1368 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
1369 | ||
60103089 | 1370 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
254e0e4b | 1371 | } else { |
48f0adb0 | 1372 | $query_strategy_part = "id > 0"; // dumb |
254e0e4b AD |
1373 | } |
1374 | ||
f99321a3 AD |
1375 | $order_by = "updated DESC"; |
1376 | ||
1377 | // if ($feed < -10) { | |
1378 | // $order_by = "feed_id,updated DESC"; | |
1379 | // } | |
1380 | ||
1572afe5 AD |
1381 | $feed_title = ""; |
1382 | ||
1383 | if ($search && $search_mode == "All feeds") { | |
49b7cbd3 | 1384 | $feed_title = "Global search results ($search)"; |
d0bb308e | 1385 | } else if ($search && preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { |
49b7cbd3 | 1386 | $feed_title = "Feed search results ($search, $feed)"; |
d0bb308e AD |
1387 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { |
1388 | $feed_title = $feed; | |
1389 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) != false && $feed >= 0) { | |
1572afe5 | 1390 | |
ff2c6e6a | 1391 | if ($cat_view) { |
ff2c6e6a | 1392 | |
019ce9f3 AD |
1393 | if ($feed != 0) { |
1394 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
1395 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
1396 | $feed_title = db_fetch_result($result, 0, "title"); | |
1397 | } else { | |
1398 | $feed_title = "Uncategorized"; | |
1399 | } | |
ff2c6e6a AD |
1400 | } else { |
1401 | ||
1402 | $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds | |
1403 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
1404 | ||
1405 | $feed_title = db_fetch_result($result, 0, "title"); | |
1406 | $feed_site_url = db_fetch_result($result, 0, "site_url"); | |
1407 | $last_error = db_fetch_result($result, 0, "last_error"); | |
1408 | ||
1409 | } | |
1572afe5 AD |
1410 | |
1411 | } else if ($feed == -1) { | |
1412 | $feed_title = "Starred articles"; | |
1413 | } else if ($feed < -10) { | |
1414 | $label_id = -$feed - 11; | |
1415 | $result = db_query($link, "SELECT description FROM ttrss_labels | |
1416 | WHERE id = '$label_id'"); | |
1417 | $feed_title = db_fetch_result($result, 0, "description"); | |
1418 | } else { | |
1419 | $feed_title = "?"; | |
1420 | } | |
1421 | ||
48f0adb0 AD |
1422 | if ($feed < -10) error_reporting (0); |
1423 | ||
386cbf27 AD |
1424 | print "<div id=\"headlinesContainer\">"; |
1425 | ||
d0bb308e | 1426 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
8143ae1f | 1427 | |
99ff73f4 | 1428 | if ($feed >= 0) { |
21703604 AD |
1429 | $feed_kind = "Feeds"; |
1430 | } else { | |
1431 | $feed_kind = "Labels"; | |
1432 | } | |
1433 | ||
386cbf27 AD |
1434 | // if (!$vfeed_query_part) { |
1435 | $content_query_part = "content as content_preview,"; | |
1436 | // } else { | |
1437 | // $content_query_part = ""; | |
1438 | // } | |
bd34c528 | 1439 | |
8143ae1f | 1440 | $result = db_query($link, "SELECT |
60103089 | 1441 | ttrss_entries.id,ttrss_entries.title, |
1572afe5 AD |
1442 | SUBSTRING(updated,1,16) as updated, |
1443 | unread,feed_id,marked,link,last_read, | |
8143ae1f AD |
1444 | SUBSTRING(last_read,1,19) as last_read_noms, |
1445 | $vfeed_query_part | |
bd34c528 AD |
1446 | $content_query_part |
1447 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 1448 | FROM |
60103089 | 1449 | ttrss_entries,ttrss_user_entries,ttrss_feeds |
8143ae1f | 1450 | WHERE |
60103089 | 1451 | ttrss_user_entries.feed_id = ttrss_feeds.id AND |
4c193675 | 1452 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
60103089 | 1453 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND |
8143ae1f AD |
1454 | $search_query_part |
1455 | $view_query_part | |
1456 | $query_strategy_part ORDER BY $order_by | |
1457 | $limit_query_part"); | |
1458 | ||
1459 | } else { | |
1460 | // browsing by tag | |
1461 | ||
21703604 AD |
1462 | $feed_kind = "Tags"; |
1463 | ||
8143ae1f | 1464 | $result = db_query($link, "SELECT |
1572afe5 AD |
1465 | ttrss_entries.id as id,title, |
1466 | SUBSTRING(updated,1,16) as updated, | |
1467 | unread,feed_id, | |
1e471f3b | 1468 | marked,link,last_read, |
c05a19f3 | 1469 | SUBSTRING(last_read,1,19) as last_read_noms, |
254e0e4b | 1470 | $vfeed_query_part |
bd34c528 AD |
1471 | $content_query_part |
1472 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 1473 | FROM |
05732aa0 | 1474 | ttrss_entries,ttrss_user_entries,ttrss_tags |
8143ae1f | 1475 | WHERE |
05732aa0 AD |
1476 | ref_id = ttrss_entries.id AND |
1477 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
1478 | post_int_id = int_id AND tag_name = '$feed' AND | |
8143ae1f AD |
1479 | $view_query_part |
1480 | $search_query_part | |
1481 | $query_strategy_part ORDER BY $order_by | |
1482 | $limit_query_part"); | |
1483 | } | |
d76a3b03 | 1484 | |
48f0adb0 | 1485 | if (!$result) { |
386cbf27 AD |
1486 | print "<div align='center'> |
1487 | Could not display feed (query failed). Please check label match syntax or local configuration.</div>"; | |
1488 | return; | |
adccd201 | 1489 | } |
98bea1b1 | 1490 | |
e0a7121b AD |
1491 | function print_headline_subtoolbar($link, $feed_site_url, $feed_title, |
1492 | $bottom = false) { | |
f56ec297 | 1493 | |
e0a7121b AD |
1494 | if (!$bottom) { |
1495 | $class = "headlinesSubToolbar"; | |
1496 | $tid = "headlineActionsTop"; | |
1497 | } else { | |
1498 | $class = "invisible"; | |
1499 | $tid = "headlineActionsBottom"; | |
1500 | } | |
1501 | ||
1502 | print "<table class=\"$class\" id=\"$tid\" | |
386cbf27 AD |
1503 | width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>"; |
1504 | ||
1505 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { | |
adccd201 | 1506 | |
adccd201 AD |
1507 | print "<td class=\"headlineActions\"> |
1508 | Select: | |
e7811ea5 AD |
1509 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, '', true)\">All</a>, |
1510 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true)\">Unread</a>, | |
1511 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false)\">None</a> | |
386cbf27 | 1512 | |
e7811ea5 AD |
1513 | Toggle: <a href='#' onclick=\"javascript:selectionToggleUnread()\">Unread</a>, |
1514 | <a href='#' onclick=\"javascript:selectionToggleMarked()\">Starred</a>"; | |
adccd201 | 1515 | print "</td>"; |
386cbf27 AD |
1516 | |
1517 | } else { | |
1518 | ||
1519 | print "<td class=\"headlineActions\"> | |
1520 | Select: | |
e7811ea5 AD |
1521 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('all')\">All</a>, |
1522 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('unread')\">Unread</a>, | |
1523 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('none')\">None</a> | |
386cbf27 | 1524 | |
e7811ea5 AD |
1525 | Toggle: <a href=\"#\" onclick=\"javascript:selectionToggleUnread(true)\">Unread</a>, |
1526 | <a href=\"#\" onclick=\"javascript:selectionToggleMarked(true)\">Starred</a>"; | |
386cbf27 | 1527 | |
adccd201 | 1528 | print "</td>"; |
386cbf27 | 1529 | |
386cbf27 AD |
1530 | } |
1531 | ||
078cb996 AD |
1532 | if ($last_error) { |
1533 | print "<td align='center' class='small'> | |
1534 | <a class=\"warning\" href=\"javascript:alert('TT-RSS encountered an error while trying to update this feed.\\n\\n$last_error')\">Could not update this feed.</a></td>"; | |
98bea1b1 | 1535 | } |
078cb996 | 1536 | |
386cbf27 | 1537 | print "<td class=\"headlineTitle\">"; |
adccd201 | 1538 | |
386cbf27 | 1539 | if ($feed_site_url) { |
c7a8abe6 AD |
1540 | if (!$bottom) { |
1541 | $target = "target=\"_blank\""; | |
1542 | } | |
1543 | print "<a $target href=\"$feed_site_url\">$feed_title</a>"; | |
386cbf27 AD |
1544 | } else { |
1545 | print $feed_title; | |
1546 | } | |
1547 | ||
1548 | print "</td>"; | |
1549 | print "</tr></table>"; | |
1550 | ||
98bea1b1 AD |
1551 | } |
1552 | ||
1553 | if (db_num_rows($result) > 0) { | |
1554 | ||
1555 | print_headline_subtoolbar($link, $feed_site_url, $feed_title); | |
1556 | ||
386cbf27 | 1557 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 AD |
1558 | print "<table class=\"headlinesList\" id=\"headlinesList\" |
1559 | cellspacing=\"0\" width=\"100%\">"; | |
f4c10d44 | 1560 | } |
386cbf27 | 1561 | |
e5a99b88 AD |
1562 | $lnum = 0; |
1563 | ||
1564 | error_reporting (DEFAULT_ERROR_LEVEL); | |
1565 | ||
1566 | $num_unread = 0; | |
1567 | ||
1568 | while ($line = db_fetch_assoc($result)) { | |
adccd201 | 1569 | |
e5a99b88 AD |
1570 | $class = ($lnum % 2) ? "even" : "odd"; |
1571 | ||
1572 | $id = $line["id"]; | |
1573 | $feed_id = $line["feed_id"]; | |
1574 | ||
1575 | if ($line["last_read"] == "" && | |
1576 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
1577 | ||
1578 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
1579 | alt=\"Updated\">"; | |
1580 | } else { | |
1581 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
1582 | alt=\"Updated\">"; | |
1583 | } | |
1584 | ||
1585 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
1586 | $class .= "Unread"; | |
1587 | ++$num_unread; | |
386cbf27 | 1588 | $is_unread = true; |
adccd201 | 1589 | } else { |
386cbf27 | 1590 | $is_unread = false; |
e5a99b88 AD |
1591 | } |
1592 | ||
1593 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
1594 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" | |
9932fb06 | 1595 | alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
1596 | } else { |
1597 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
9932fb06 | 1598 | alt=\"Set mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
1599 | } |
1600 | ||
e454a889 | 1601 | $content_link = "<a href=\"javascript:view($id,$feed_id);\">" . |
e5a99b88 | 1602 | $line["title"] . "</a>"; |
adccd201 | 1603 | |
e5a99b88 AD |
1604 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
1605 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
1606 | } else { | |
1607 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1608 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
1609 | } | |
adccd201 AD |
1610 | |
1611 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
8fd0c717 | 1612 | $content_preview = truncate_string(strip_tags($line["content_preview"]), |
070d0d2a | 1613 | 100); |
adccd201 AD |
1614 | } |
1615 | ||
386cbf27 | 1616 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 AD |
1617 | |
1618 | print "<tr class='$class' id='RROW-$id'>"; | |
adccd201 AD |
1619 | |
1620 | print "<td class='hlUpdatePic'>$update_pic</td>"; | |
1621 | ||
1622 | print "<td class='hlSelectRow'> | |
1623 | <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\" | |
1624 | class=\"feedCheckBox\" id=\"RCHK-$id\"> | |
1625 | </td>"; | |
1626 | ||
1627 | print "<td class='hlMarkedPic'>$marked_pic</td>"; | |
1628 | ||
1629 | if ($line["feed_title"]) { | |
1630 | print "<td class='hlContent'>$content_link</td>"; | |
1631 | print "<td class='hlFeed'> | |
9b1424fe AD |
1632 | <a href='javascript:viewfeed($feed_id)'>". |
1633 | $line["feed_title"]."</a> </td>"; | |
adccd201 | 1634 | } else { |
de244d27 | 1635 | print "<td class='hlContent' valign='middle'>"; |
adccd201 | 1636 | |
e454a889 | 1637 | print "<a href=\"javascript:view($id,$feed_id);\">" . |
adccd201 AD |
1638 | $line["title"]; |
1639 | ||
1640 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
1641 | ||
1642 | if ($content_preview) { | |
1643 | print "<span class=\"contentPreview\"> - $content_preview</span>"; | |
1644 | } | |
1645 | } | |
1646 | ||
1647 | print "</a>"; | |
1648 | print "</td>"; | |
1649 | } | |
1650 | ||
1651 | print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>"; | |
1652 | ||
1653 | print "</tr>"; | |
1654 | ||
1655 | } else { | |
386cbf27 AD |
1656 | |
1657 | if ($is_unread) { | |
1658 | $add_class = "Unread"; | |
1659 | } else { | |
1660 | $add_class = ""; | |
1661 | } | |
1662 | ||
1663 | print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">"; | |
1664 | ||
1665 | print "<div class=\"cdmHeader\">"; | |
adccd201 | 1666 | |
386cbf27 AD |
1667 | print "<div style=\"float : right\">$updated_fmt</div>"; |
1668 | ||
86383df6 | 1669 | print "<a target=\"new\" href=\"".$line["link"]."\">".$line["title"]."</a>"; |
adccd201 | 1670 | |
386cbf27 AD |
1671 | if ($line["feed_title"]) { |
1672 | print " (<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)"; | |
adccd201 | 1673 | } |
adccd201 | 1674 | |
386cbf27 AD |
1675 | print "</div>"; |
1676 | ||
1677 | print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div>"; | |
1678 | ||
1679 | print "<div style=\"float : right\">$marked_pic</div> | |
1680 | <div class=\"cdmFooter\"> | |
1681 | <input type=\"checkbox\" onclick=\"toggleSelectRowById(this, | |
1682 | 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"></div>"; | |
1683 | ||
1684 | print "</div>"; | |
1685 | ||
1686 | } | |
e5a99b88 AD |
1687 | |
1688 | ++$lnum; | |
254e0e4b | 1689 | } |
adccd201 | 1690 | |
386cbf27 | 1691 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 1692 | print "</table>"; |
adccd201 | 1693 | } |
d76a3b03 | 1694 | |
e0a7121b AD |
1695 | print_headline_subtoolbar($link, |
1696 | "javascript:catchupPage()", "Mark page as read", true); | |
98bea1b1 AD |
1697 | |
1698 | ||
e5a99b88 AD |
1699 | } else { |
1700 | print "<div width='100%' align='center'>No articles found.</div>"; | |
a1a8a2be | 1701 | } |
d76a3b03 | 1702 | |
386cbf27 | 1703 | print "</div>"; |
d76a3b03 | 1704 | |
386cbf27 AD |
1705 | print "<script type=\"text/javascript\"> |
1706 | document.onkeydown = hotkey_handler; | |
5a494a0b | 1707 | // if (parent.daemon_enabled) parent.updateTitle('$feed_title'); |
386cbf27 AD |
1708 | update_all_counters('$feed'); |
1709 | </script>"; | |
adccd201 | 1710 | |
97dcd654 AD |
1711 | print ' |
1712 | <script type="text/javascript"> | |
1713 | /* for IE */ | |
1714 | function statechange() { | |
1715 | if (document.readyState == "interactive") init(); | |
1716 | } | |
1717 | ||
1718 | if (document.readyState) { | |
1719 | if (document.readyState == "interactive" || document.readyState == "complete") { | |
1720 | init(); | |
1721 | } else { | |
1722 | document.onreadystatechange = statechange; | |
1723 | } | |
1724 | } | |
1725 | </script>'; | |
1726 | ||
59b8192f | 1727 | print "</body></html>"; |
1cd17194 AD |
1728 | } |
1729 | ||
0e091d38 | 1730 | if ($op == "pref-rpc") { |
331900c6 | 1731 | |
0e091d38 | 1732 | $subop = $_GET["subop"]; |
331900c6 | 1733 | |
83fe4d6d | 1734 | if ($subop == "unread") { |
f932bc9f | 1735 | $ids = split(",", db_escape_string($_GET["ids"])); |
83fe4d6d | 1736 | foreach ($ids as $id) { |
a5873b2e AD |
1737 | db_query($link, "UPDATE ttrss_user_entries SET unread = true |
1738 | WHERE feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
83fe4d6d | 1739 | } |
0e091d38 | 1740 | |
a5873b2e | 1741 | print "Marked selected feeds as unread."; |
83fe4d6d AD |
1742 | } |
1743 | ||
1744 | if ($subop == "read") { | |
f932bc9f | 1745 | $ids = split(",", db_escape_string($_GET["ids"])); |
83fe4d6d | 1746 | foreach ($ids as $id) { |
a5873b2e AD |
1747 | db_query($link, "UPDATE ttrss_user_entries |
1748 | SET unread = false,last_read = NOW() WHERE | |
1749 | feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
83fe4d6d | 1750 | } |
0e091d38 | 1751 | |
a5873b2e | 1752 | print "Marked selected feeds as read."; |
0e091d38 AD |
1753 | |
1754 | } | |
1755 | ||
1756 | } | |
1757 | ||
1758 | if ($op == "pref-feeds") { | |
1759 | ||
47c6c988 AD |
1760 | $subop = $_REQUEST["subop"]; |
1761 | $quiet = $_REQUEST["quiet"]; | |
0e091d38 | 1762 | |
a0476535 AD |
1763 | if ($subop == "massSubscribe") { |
1764 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1765 | ||
a7f22b70 AD |
1766 | $subscribed = array(); |
1767 | ||
a0476535 AD |
1768 | foreach ($ids as $id) { |
1769 | $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds | |
1770 | WHERE id = '$id'"); | |
1771 | ||
1772 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1773 | $title = db_fetch_result($result, 0, "title"); | |
1774 | ||
1775 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
1776 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
1777 | ||
1778 | if (db_num_rows($result) == 0) { | |
1779 | $result = db_query($link, | |
1780 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) | |
1781 | VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); | |
a7f22b70 AD |
1782 | |
1783 | array_push($subscribed, $title); | |
1784 | } | |
1785 | } | |
1786 | ||
1787 | if (count($subscribed) > 0) { | |
1788 | print "<div class=\"notice\">"; | |
1789 | print "<b>Subscribed to feeds:</b>"; | |
1790 | print "<ul class=\"nomarks\">"; | |
1791 | foreach ($subscribed as $title) { | |
1792 | print "<li>$title</li>"; | |
a0476535 | 1793 | } |
a7f22b70 AD |
1794 | print "</ul>"; |
1795 | print "</div>"; | |
a0476535 AD |
1796 | } |
1797 | } | |
1798 | ||
f9cb39ac | 1799 | if ($subop == "browse") { |
e2f728be AD |
1800 | |
1801 | if (!ENABLE_FEED_BROWSER) { | |
1802 | print "Feed browser is administratively disabled."; | |
1803 | return; | |
1804 | } | |
f9cb39ac AD |
1805 | |
1806 | print "<div class=\"infoBoxContents\">"; | |
1807 | ||
1808 | print "<h1>Feed browser</h1>"; | |
1809 | ||
1810 | print "<p>Showing top 50 registered feeds, sorted by popularity:</p>"; | |
1811 | ||
1812 | $result = db_query($link, "SELECT feed_url,count(id) AS subscribers | |
e3c99f3b AD |
1813 | FROM ttrss_feeds |
1814 | WHERE auth_login = '' AND auth_pass = '' AND private = false | |
24b18114 | 1815 | GROUP BY feed_url ORDER BY subscribers DESC LIMIT 50"); |
f9cb39ac AD |
1816 | |
1817 | print "<ul class='browseFeedList' id='browseFeedList'>"; | |
dc932d0a AD |
1818 | |
1819 | $feedctr = 0; | |
f9cb39ac AD |
1820 | |
1821 | while ($line = db_fetch_assoc($result)) { | |
1822 | $feed_url = $line["feed_url"]; | |
1823 | $subscribers = $line["subscribers"]; | |
dc932d0a AD |
1824 | |
1825 | $sub_result = db_query($link, "SELECT id | |
1826 | FROM ttrss_feeds WHERE feed_url = '$feed_url' AND owner_uid =" . | |
1827 | $_SESSION["uid"]); | |
1828 | ||
1829 | if (db_num_rows($sub_result) > 0) { | |
1830 | continue; // already subscribed | |
1831 | } | |
f9cb39ac AD |
1832 | |
1833 | $det_result = db_query($link, "SELECT site_url,title,id | |
1834 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
1835 | ||
1836 | $details = db_fetch_assoc($det_result); | |
1837 | ||
1838 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
1839 | ||
1840 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1841 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
1842 | "/".$details["id"].".ico\">"; | |
1843 | } else { | |
1844 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1845 | } | |
1846 | ||
b92e6209 AD |
1847 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' |
1848 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
f9cb39ac | 1849 | |
b92e6209 AD |
1850 | $class = ($feedctr % 2) ? "even" : "odd"; |
1851 | ||
1852 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
1853 | "$feed_icon " . db_unescape_string($details["title"]) . | |
f9cb39ac | 1854 | " <span class='subscribers'>($subscribers)</span></li>"; |
dc932d0a AD |
1855 | |
1856 | ++$feedctr; | |
1857 | } | |
1858 | ||
1859 | if ($feedctr == 0) { | |
1860 | print "<li>No feeds found to subscribe.</li>"; | |
1861 | } | |
f9cb39ac AD |
1862 | |
1863 | print "</ul>"; | |
1864 | ||
1865 | print "<div align='center'> | |
f9cb39ac | 1866 | <input type=\"submit\" class=\"button\" |
d10fabe4 AD |
1867 | onclick=\"feedBrowserSubscribe()\" value=\"Subscribe\"> |
1868 | <input type='submit' class='button' | |
1869 | onclick=\"closeInfoBox()\" value=\"Cancel\"></div>"; | |
f9cb39ac AD |
1870 | |
1871 | print "</div>"; | |
1872 | return; | |
1873 | } | |
1874 | ||
0ea4fb50 AD |
1875 | if ($subop == "editfeed") { |
1876 | $feed_id = db_escape_string($_GET["id"]); | |
1877 | ||
1878 | $result = db_query($link, | |
1879 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
1880 | owner_uid = " . $_SESSION["uid"]); | |
1881 | ||
1882 | $title = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1883 | 0, "title"))); | |
1884 | ||
1885 | print "<div class=\"infoBoxContents\">"; | |
1886 | ||
1887 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1888 | ||
1889 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1890 | $feed_icon = "<img width=\"16\" height=\"16\" | |
1891 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1892 | } else { | |
1893 | $feed_icon = ""; | |
1894 | } | |
1895 | ||
1896 | print "<h1>$feed_icon $title</h1>"; | |
1897 | ||
1898 | print "<table width='100%'>"; | |
1899 | ||
1900 | $row_class = "odd"; | |
1901 | ||
1902 | print "<tr class='$row_class'><td>Title:</td>"; | |
1903 | print "<td><input id=\"iedit_title\" value=\"$title\"></td></tr>"; | |
1904 | ||
1905 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1906 | $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1907 | 0, "feed_url"))); | |
1908 | $row_class = toggleEvenOdd($row_class); | |
1909 | ||
1910 | print "<tr class='$row_class'><td>Feed URL:</td>"; | |
1911 | print "<td><input id=\"iedit_link\" value=\"$feed_url\"></td></tr>"; | |
1912 | ||
1913 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1914 | ||
1915 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
1916 | ||
1917 | $row_class = toggleEvenOdd($row_class); | |
1918 | ||
1919 | print "<tr class='$row_class'><td>Category:</td>"; | |
1920 | print "<td>"; | |
1921 | print "<select id=\"iedit_fcat\">"; | |
1922 | print "<option id=\"0\">Uncategorized</option>"; | |
1923 | ||
1924 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories | |
1925 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
1926 | ||
1927 | if (db_num_rows($tmp_result) > 0) { | |
1928 | print "<option disabled>--------</option>"; | |
1929 | } | |
1930 | ||
1931 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1932 | if ($tmp_line["id"] == $cat_id) { | |
1933 | $is_selected = "selected"; | |
1934 | } else { | |
1935 | $is_selected = ""; | |
1936 | } | |
1937 | printf("<option $is_selected id='%d'>%s</option>", | |
1938 | $tmp_line["id"], $tmp_line["title"]); | |
1939 | } | |
1940 | ||
1941 | print "</select></td>"; | |
1942 | print "</td></tr>"; | |
1943 | ||
1944 | } | |
1945 | ||
1946 | $update_interval = db_fetch_result($result, 0, "update_interval"); | |
1947 | $row_class = toggleEvenOdd($row_class); | |
1948 | ||
1949 | print "<tr class='$row_class'><td>Update Interval:</td>"; | |
1950 | print "<td><input id=\"iedit_updintl\" | |
1951 | value=\"$update_interval\"></td></tr>"; | |
1952 | ||
1da7e457 AD |
1953 | $row_class = toggleEvenOdd($row_class); |
1954 | print "<tr class='$row_class'><td>Link to:</td>"; | |
1955 | ||
3b0027a4 AD |
1956 | $tmp_result = db_query($link, "SELECT COUNT(id) AS count |
1957 | FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); | |
1958 | ||
1959 | $linked_count = db_fetch_result($tmp_result, 0, "count"); | |
1960 | ||
1da7e457 | 1961 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); |
3b0027a4 AD |
1962 | |
1963 | if ($linked_count > 0) { | |
1964 | $disabled = "disabled"; | |
1965 | } | |
1966 | ||
1967 | print "<select $disabled id=\"iedit_parent_feed\">"; | |
1968 | ||
eac46afb | 1969 | print "<option id=\"0\">Not linked</option>"; |
1da7e457 | 1970 | |
8a53e029 AD |
1971 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1972 | if ($cat_id) { | |
1973 | $cat_qpart = "AND cat_id = '$cat_id'"; | |
1974 | } else { | |
1975 | $cat_qpart = "AND cat_id IS NULL"; | |
1976 | } | |
1977 | } | |
1978 | ||
1da7e457 | 1979 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds |
262c2426 AD |
1980 | WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." |
1981 | $cat_qpart ORDER BY title"); | |
1da7e457 AD |
1982 | |
1983 | if (db_num_rows($tmp_result) > 0) { | |
1984 | print "<option disabled>--------</option>"; | |
1985 | } | |
1986 | ||
1987 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1988 | if ($tmp_line["id"] == $parent_feed) { | |
1989 | $is_selected = "selected"; | |
1990 | } else { | |
1991 | $is_selected = ""; | |
1992 | } | |
1993 | printf("<option $is_selected id='%d'>%s</option>", | |
1994 | $tmp_line["id"], $tmp_line["title"]); | |
1995 | } | |
1996 | ||
1997 | print "</select></td>"; | |
1998 | print "</td></tr>"; | |
1999 | ||
0ea4fb50 AD |
2000 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); |
2001 | $row_class = toggleEvenOdd($row_class); | |
2002 | ||
2003 | print "<tr class='$row_class'><td>Purge Days:</td>"; | |
2004 | print "<td><input id=\"iedit_purgintl\" | |
2005 | value=\"$purge_interval\"></td></tr>"; | |
2006 | ||
47c6c988 AD |
2007 | // print "<tr><td colspan=\"2\"><b>Authentication</b></td></tr>"; |
2008 | ||
2009 | $row_class = toggleEvenOdd($row_class); | |
2010 | $auth_login = db_fetch_result($result, 0, "auth_login"); | |
2011 | ||
2012 | print "<tr class='$row_class'><td>Login:</td>"; | |
2013 | print "<td><input id=\"iedit_login\" | |
2014 | value=\"$auth_login\"></td></tr>"; | |
2015 | ||
2016 | $row_class = toggleEvenOdd($row_class); | |
2017 | $auth_pass = db_fetch_result($result, 0, "auth_pass"); | |
2018 | ||
2019 | print "<tr class='$row_class'><td>Password:</td>"; | |
2020 | print "<td><input type=\"password\" id=\"iedit_pass\" | |
2021 | value=\"$auth_pass\"></td></tr>"; | |
2022 | ||
e3c99f3b AD |
2023 | $row_class = toggleEvenOdd($row_class); |
2024 | $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); | |
2025 | ||
2026 | if ($private) { | |
2027 | $checked = "checked"; | |
2028 | } else { | |
2029 | $checked = ""; | |
2030 | } | |
2031 | ||
2032 | print "<tr class='$row_class'><td>Options:</td>"; | |
2033 | print "<td><input type=\"checkbox\" id=\"iedit_private\" | |
88d9259a AD |
2034 | $checked><label for=\"iedit_private\">Hide from feed browser</label> |
2035 | </td></tr>"; | |
e3c99f3b | 2036 | |
0ea4fb50 AD |
2037 | print "</table>"; |
2038 | print "</div>"; | |
2039 | ||
2040 | print "<div align='center'> | |
0ea4fb50 | 2041 | <input type=\"submit\" class=\"button\" |
d10fabe4 AD |
2042 | onclick=\"feedEditSave()\" value=\"Save\"> |
2043 | <input type='submit' class='button' | |
2044 | onclick=\"feedEditCancel()\" value=\"Cancel\"></div>"; | |
0ea4fb50 AD |
2045 | return; |
2046 | } | |
2047 | ||
508a81e1 | 2048 | if ($subop == "editSave") { |
47c6c988 AD |
2049 | $feed_title = db_escape_string($_POST["t"]); |
2050 | $feed_link = db_escape_string($_POST["l"]); | |
2051 | $upd_intl = db_escape_string($_POST["ui"]); | |
2052 | $purge_intl = db_escape_string($_POST["pi"]); | |
2053 | $feed_id = db_escape_string($_POST["id"]); | |
2054 | $cat_id = db_escape_string($_POST["catid"]); | |
2055 | $auth_login = db_escape_string($_POST["login"]); | |
2056 | $auth_pass = db_escape_string($_POST["pass"]); | |
1da7e457 | 2057 | $parent_feed = db_escape_string($_POST["pfeed"]); |
19ded366 | 2058 | $private = db_escape_string($_POST["is_pvt"]); |
508a81e1 | 2059 | |
d148926e AD |
2060 | if (strtoupper($upd_intl) == "DEFAULT") |
2061 | $upd_intl = 0; | |
2062 | ||
a88c1f36 AD |
2063 | if (strtoupper($upd_intl) == "DISABLED") |
2064 | $upd_intl = -1; | |
2065 | ||
5d73494a AD |
2066 | if (strtoupper($purge_intl) == "DEFAULT") |
2067 | $purge_intl = 0; | |
2068 | ||
140aae81 AD |
2069 | if (strtoupper($purge_intl) == "DISABLED") |
2070 | $purge_intl = -1; | |
2071 | ||
91ff844a AD |
2072 | if ($cat_id != 0) { |
2073 | $category_qpart = "cat_id = '$cat_id'"; | |
2074 | } else { | |
2075 | $category_qpart = 'cat_id = NULL'; | |
2076 | } | |
2077 | ||
1da7e457 AD |
2078 | if ($parent_feed != 0) { |
2079 | $parent_qpart = "parent_feed = '$parent_feed'"; | |
2080 | } else { | |
2081 | $parent_qpart = 'parent_feed = NULL'; | |
2082 | } | |
2083 | ||
648472a7 | 2084 | $result = db_query($link, "UPDATE ttrss_feeds SET |
91ff844a | 2085 | $category_qpart, |
1da7e457 | 2086 | $parent_qpart, |
d148926e | 2087 | title = '$feed_title', feed_url = '$feed_link', |
5d73494a | 2088 | update_interval = '$upd_intl', |
47c6c988 AD |
2089 | purge_interval = '$purge_intl', |
2090 | auth_login = '$auth_login', | |
e3c99f3b AD |
2091 | auth_pass = '$auth_pass', |
2092 | private = '$private' | |
f72dbbde | 2093 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
5ddadb4c AD |
2094 | } |
2095 | ||
2096 | if ($subop == "saveCat") { | |
2097 | $cat_title = db_escape_string($_GET["title"]); | |
2098 | $cat_id = db_escape_string($_GET["id"]); | |
2099 | ||
2100 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
2101 | title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
508a81e1 | 2102 | |
83fe4d6d AD |
2103 | } |
2104 | ||
331900c6 | 2105 | if ($subop == "remove") { |
331900c6 | 2106 | |
b0b4abcf | 2107 | if (!WEB_DEMO_MODE) { |
331900c6 | 2108 | |
f932bc9f | 2109 | $ids = split(",", db_escape_string($_GET["ids"])); |
b0b4abcf AD |
2110 | |
2111 | foreach ($ids as $id) { | |
f72dbbde AD |
2112 | db_query($link, "DELETE FROM ttrss_feeds |
2113 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
4769ddaf | 2114 | |
273a2f6b | 2115 | $icons_dir = ICONS_DIR; |
d5caaae5 | 2116 | |
4769ddaf AD |
2117 | if (file_exists($icons_dir . "/$id.ico")) { |
2118 | unlink($icons_dir . "/$id.ico"); | |
d5caaae5 | 2119 | } |
b0b4abcf | 2120 | } |
331900c6 AD |
2121 | } |
2122 | } | |
2123 | ||
2124 | if ($subop == "add") { | |
b0b4abcf AD |
2125 | |
2126 | if (!WEB_DEMO_MODE) { | |
331900c6 | 2127 | |
b6b535ca | 2128 | $feed_link = db_escape_string(trim($_GET["link"])); |
15da5cc1 AD |
2129 | $cat_id = db_escape_string($_GET["cid"]); |
2130 | ||
5edfe303 | 2131 | if ($cat_id == "0" || !$cat_id) { |
15da5cc1 AD |
2132 | $cat_qpart = "NULL"; |
2133 | } else { | |
2134 | $cat_qpart = "'$cat_id'"; | |
2135 | } | |
331900c6 | 2136 | |
648472a7 | 2137 | $result = db_query($link, |
7e9a3986 AD |
2138 | "SELECT id FROM ttrss_feeds |
2139 | WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]); | |
2140 | ||
2141 | if (db_num_rows($result) == 0) { | |
2142 | ||
2143 | $result = db_query($link, | |
15da5cc1 | 2144 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) |
746b249f AD |
2145 | VALUES ('".$_SESSION["uid"]."', '$feed_link', |
2146 | '[Unknown]', $cat_qpart)"); | |
331900c6 | 2147 | |
7e9a3986 | 2148 | $result = db_query($link, |
746b249f | 2149 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link' |
7e9a3986 AD |
2150 | AND owner_uid = " . $_SESSION["uid"]); |
2151 | ||
2152 | $feed_id = db_fetch_result($result, 0, "id"); | |
2153 | ||
2154 | if ($feed_id) { | |
ddb68b81 | 2155 | update_rss_feed($link, $feed_link, $feed_id, true); |
7e9a3986 AD |
2156 | } |
2157 | } else { | |
331900c6 | 2158 | |
7e9a3986 AD |
2159 | print "<div class=\"warning\"> |
2160 | Feed <b>$feed_link</b> already exists in the database. | |
2161 | </div>"; | |
b0b4abcf AD |
2162 | } |
2163 | } | |
331900c6 | 2164 | } |
a0d53889 | 2165 | |
91ff844a AD |
2166 | if ($subop == "addCat") { |
2167 | ||
2168 | if (!WEB_DEMO_MODE) { | |
2169 | ||
2170 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
2171 | ||
2172 | $result = db_query($link, | |
2173 | "SELECT id FROM ttrss_feed_categories | |
2174 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
2175 | ||
2176 | if (db_num_rows($result) == 0) { | |
2177 | ||
2178 | $result = db_query($link, | |
2179 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
2180 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
2181 | ||
2182 | } else { | |
2183 | ||
2184 | print "<div class=\"warning\"> | |
2185 | Category <b>$feed_cat</b> already exists in the database. | |
2186 | </div>"; | |
2187 | } | |
2188 | ||
2189 | ||
2190 | } | |
2191 | } | |
2192 | ||
2193 | if ($subop == "removeCats") { | |
2194 | ||
2195 | if (!WEB_DEMO_MODE) { | |
2196 | ||
f932bc9f | 2197 | $ids = split(",", db_escape_string($_GET["ids"])); |
91ff844a AD |
2198 | |
2199 | foreach ($ids as $id) { | |
2200 | ||
2201 | db_query($link, "BEGIN"); | |
2202 | ||
2203 | $result = db_query($link, | |
2204 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
2205 | WHERE cat_id = '$id'"); | |
2206 | ||
2207 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
2208 | ||
2209 | if ($num_feeds == 0) { | |
2210 | db_query($link, "DELETE FROM ttrss_feed_categories | |
2211 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
2212 | } else { | |
2213 | ||
2214 | print "<div class=\"warning\"> | |
2215 | Unable to delete non empty feed categories.</div>"; | |
2216 | ||
2217 | } | |
2218 | ||
2219 | db_query($link, "COMMIT"); | |
2220 | } | |
2221 | } | |
2222 | } | |
2223 | ||
f932bc9f AD |
2224 | if ($subop == "categorize") { |
2225 | ||
2226 | if (!WEB_DEMO_MODE) { | |
2227 | ||
2228 | $ids = split(",", db_escape_string($_GET["ids"])); | |
2229 | ||
2230 | $cat_id = db_escape_string($_GET["cat_id"]); | |
2231 | ||
2232 | if ($cat_id == 0) { | |
2233 | $cat_id_qpart = 'NULL'; | |
2234 | } else { | |
2235 | $cat_id_qpart = "'$cat_id'"; | |
2236 | } | |
2237 | ||
2238 | db_query($link, "BEGIN"); | |
2239 | ||
2240 | foreach ($ids as $id) { | |
2241 | ||
2242 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
2243 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
2244 | } | |
2245 | ||
2246 | db_query($link, "COMMIT"); | |
2247 | } | |
2248 | ||
2249 | } | |
2250 | ||
a24f525c AD |
2251 | if ($quiet) return; |
2252 | ||
c64d5b03 | 2253 | // print "<h3>Edit Feeds</h3>"; |
91ff844a | 2254 | |
4904f845 AD |
2255 | $result = db_query($link, "SELECT id,title,feed_url,last_error |
2256 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
2257 | ||
2258 | if (db_num_rows($result) > 0) { | |
2259 | ||
2260 | print "<div class=\"warning\">"; | |
a9b0bfd5 AD |
2261 | |
2262 | // print"<img class=\"closeButton\" | |
2263 | // onclick=\"javascript:hideParentElement(this);\" src=\"images/close.png\">"; | |
2264 | ||
36aab70f AD |
2265 | print "<a href=\"javascript:showBlockElement('feedUpdateErrors')\"> |
2266 | <b>Feeds with update errors</b> (click to expand)</a>"; | |
4904f845 | 2267 | |
36aab70f | 2268 | print "<ul id=\"feedUpdateErrors\" class=\"nomarks\">"; |
4904f845 AD |
2269 | |
2270 | while ($line = db_fetch_assoc($result)) { | |
2271 | print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " . | |
2272 | $line["last_error"]; | |
2273 | } | |
2274 | ||
2275 | print "</ul>"; | |
2276 | print "</div>"; | |
2277 | ||
2278 | } | |
2279 | ||
f932bc9f AD |
2280 | $feed_search = db_escape_string($_GET["search"]); |
2281 | ||
2282 | if (array_key_exists("search", $_GET)) { | |
2283 | $_SESSION["prefs_feed_search"] = $feed_search; | |
2284 | } else { | |
2285 | $feed_search = $_SESSION["prefs_feed_search"]; | |
2286 | } | |
2287 | ||
2288 | print "<table width='100%' class=\"prefGenericAddBox\" | |
2289 | cellspacing='0' cellpadding='0'><tr> | |
2290 | <td> | |
2291 | <input id=\"fadd_link\" | |
2292 | onchange=\"javascript:addFeed()\" | |
2293 | size=\"40\"> | |
2294 | <input type=\"submit\" class=\"button\" | |
e2f728be AD |
2295 | onclick=\"javascript:addFeed()\" value=\"Add feed\">"; |
2296 | ||
2297 | if (ENABLE_FEED_BROWSER) { | |
2298 | print " (<a href='javascript:browseFeeds()'>Top 50</a>)"; | |
2299 | } | |
2300 | ||
2301 | print "</td><td align='right'> | |
f932bc9f AD |
2302 | <input id=\"feed_search\" size=\"20\" |
2303 | onchange=\"javascript:updateFeedList()\" | |
2304 | value=\"$feed_search\"> | |
2305 | <input type=\"submit\" class=\"button\" | |
2306 | onclick=\"javascript:updateFeedList()\" value=\"Search\"> | |
2307 | </td> | |
2308 | </tr></table>"; | |
a0d53889 | 2309 | |
b83c7545 AD |
2310 | $feeds_sort = db_escape_string($_GET["sort"]); |
2311 | ||
2312 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
2313 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
2314 | if (!$feeds_sort) $feeds_sort = "title"; | |
2315 | } | |
2316 | ||
2317 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
2318 | ||
f932bc9f | 2319 | if ($feed_search) { |
11de82c3 AD |
2320 | $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR |
2321 | UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND"; | |
f932bc9f AD |
2322 | } else { |
2323 | $search_qpart = ""; | |
2324 | } | |
2325 | ||
648472a7 | 2326 | $result = db_query($link, "SELECT |
db42b934 AD |
2327 | F1.id, |
2328 | F1.title, | |
2329 | F1.feed_url, | |
2330 | substring(F1.last_updated,1,16) AS last_updated, | |
2331 | F1.parent_feed, | |
2332 | F1.update_interval, | |
2333 | F1.purge_interval, | |
2334 | F1.cat_id, | |
2335 | F2.title AS parent_title, | |
2336 | C1.title AS category | |
c0e5a40e | 2337 | FROM |
db42b934 AD |
2338 | ttrss_feeds AS F1 |
2339 | LEFT JOIN ttrss_feeds AS F2 | |
2340 | ON (F1.parent_feed = F2.id) | |
2341 | LEFT JOIN ttrss_feed_categories AS C1 | |
2342 | ON (F1.cat_id = C1.id) | |
f932bc9f | 2343 | WHERE |
db42b934 | 2344 | $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' |
0ea4fb50 | 2345 | ORDER by category,$feeds_sort,title"); |
1cd17194 | 2346 | |
3b0feb9b | 2347 | if (db_num_rows($result) != 0) { |
91ff844a | 2348 | |
3b0feb9b | 2349 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
35f3c923 | 2350 | |
f4fe2cde AD |
2351 | print "<p><table width=\"100%\" cellspacing=\"0\" |
2352 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
35f3c923 AD |
2353 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
2354 | Select: | |
2355 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', | |
3055bc41 | 2356 | 'FEEDR-', 'FRCHK-', true)\">All</a>, |
35f3c923 | 2357 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', |
3055bc41 | 2358 | 'FEEDR-', 'FRCHK-', false)\">None</a> |
35f3c923 AD |
2359 | </td</tr>"; |
2360 | ||
0ea4fb50 AD |
2361 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { |
2362 | print "<tr class=\"title\"> | |
e325c6e7 | 2363 | <td width='5%' align='center'> </td> |
62ac0cc8 | 2364 | <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> |
f42e9435 | 2365 | <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> |
62ac0cc8 AD |
2366 | <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td> |
2367 | <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a></td></tr>"; | |
603c27f8 | 2368 | } |
603c27f8 | 2369 | |
c64d5b03 | 2370 | $lnum = 0; |
0ea4fb50 AD |
2371 | |
2372 | $cur_cat_id = -1; | |
c64d5b03 AD |
2373 | |
2374 | while ($line = db_fetch_assoc($result)) { | |
2375 | ||
3b0feb9b | 2376 | $feed_id = $line["id"]; |
0ea4fb50 AD |
2377 | $cat_id = $line["cat_id"]; |
2378 | ||
2379 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
2380 | $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); | |
2381 | $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); | |
c64d5b03 | 2382 | |
0ea4fb50 AD |
2383 | if ($line["update_interval"] == "0") $line["update_interval"] = "Default"; |
2384 | if ($line["update_interval"] == "-1") $line["update_interval"] = "Disabled"; | |
2385 | if ($line["purge_interval"] == "0") $line["purge_interval"] = "Default"; | |
2386 | if ($line["purge_interval"] < 0) $line["purge_interval"] = "Disabled"; | |
2387 | ||
2388 | if (!$edit_cat) $edit_cat = "Uncategorized"; | |
2389 | ||
2390 | ||
2391 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { | |
cb58d0df AD |
2392 | $lnum = 0; |
2393 | ||
0ea4fb50 AD |
2394 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; |
2395 | ||
2396 | print "<tr class=\"title\"> | |
e325c6e7 | 2397 | <td width='5%' align='center'> </td> |
62ac0cc8 | 2398 | <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> |
f42e9435 | 2399 | <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> |
62ac0cc8 AD |
2400 | <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td> |
2401 | <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a></td></tr>"; | |
0ea4fb50 AD |
2402 | |
2403 | $cur_cat_id = $cat_id; | |
c64d5b03 | 2404 | } |
0ea4fb50 | 2405 | |
cb58d0df | 2406 | $class = ($lnum % 2) ? "even" : "odd"; |
0ea4fb50 AD |
2407 | $this_row_id = "id=\"FEEDR-$feed_id\""; |
2408 | ||
53226edc | 2409 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2410 | |
2411 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
2412 | ||
2413 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
327a3bbe | 2414 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; |
3b0feb9b | 2415 | } else { |
327a3bbe | 2416 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
3b0feb9b | 2417 | } |
327a3bbe | 2418 | // print "<td class='feedIcon'>$feed_icon</td>"; |
c64d5b03 | 2419 | |
62ac0cc8 | 2420 | print "<td class='feedSelect'><input onclick='toggleSelectRow(this);' |
0ea4fb50 | 2421 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
3547842a | 2422 | |
0ea4fb50 AD |
2423 | $edit_title = truncate_string($edit_title, 40); |
2424 | $edit_link = truncate_string($edit_link, 60); | |
a88c1f36 | 2425 | |
1da7e457 AD |
2426 | $parent_title = $line["parent_title"]; |
2427 | if ($parent_title) { | |
2428 | $parent_title = "<span class='groupPrompt'>(linked to | |
2429 | $parent_title)</span>"; | |
2430 | } | |
2431 | ||
0ea4fb50 | 2432 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
1da7e457 | 2433 | "$feed_icon $edit_title $parent_title" . "</a></td>"; |
0ea4fb50 AD |
2434 | |
2435 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
2436 | $edit_link . "</a></td>"; | |
3547842a | 2437 | |
0ea4fb50 AD |
2438 | /* if (get_pref($link, 'ENABLE_FEED_CATS')) { |
2439 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
2440 | $edit_cat . "</a></td>"; | |
2441 | } */ | |
3547842a | 2442 | |
0ea4fb50 AD |
2443 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
2444 | $line["update_interval"] . "</a></td>"; | |
3b0feb9b | 2445 | |
0ea4fb50 AD |
2446 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
2447 | $line["purge_interval"] . "</a></td>"; | |
3b0feb9b | 2448 | |
c64d5b03 AD |
2449 | print "</tr>"; |
2450 | ||
2451 | ++$lnum; | |
2452 | } | |
2453 | ||
c64d5b03 | 2454 | print "</table>"; |
3b0feb9b | 2455 | |
c64d5b03 AD |
2456 | print "<p>"; |
2457 | ||
3b0feb9b AD |
2458 | if ($subop == "edit") { |
2459 | print "Edit feed: | |
c64d5b03 | 2460 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2461 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> |
c64d5b03 | 2462 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2463 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
2464 | } else { | |
c64d5b03 AD |
2465 | |
2466 | print " | |
2467 | Selection: | |
2468 | <input type=\"submit\" class=\"button\" | |
3b0feb9b | 2469 | onclick=\"javascript:selectedFeedDetails()\" value=\"Details\"> |
c64d5b03 | 2470 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2471 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> |
2472 | <input type=\"submit\" class=\"button\" | |
2473 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
f932bc9f AD |
2474 | |
2475 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2476 | ||
2477 | print " "; | |
2478 | ||
2479 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2480 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2481 | ORDER BY title"); | |
2482 | ||
2483 | print "<select id=\"sfeed_set_fcat\">"; | |
2484 | print "<option id=\"0\">Uncategorized</option>"; | |
2485 | ||
2486 | if (db_num_rows($result) != 0) { | |
2487 | ||
2488 | print "<option disabled>--------</option>"; | |
2489 | ||
2490 | while ($line = db_fetch_assoc($result)) { | |
2491 | printf("<option id='%d'>%s</option>", | |
2492 | $line["id"], $line["title"]); | |
2493 | } | |
2494 | } | |
2495 | ||
2496 | print "</select>"; | |
2497 | ||
2498 | print " <input type=\"submit\" class=\"button\" | |
2499 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Set category\">"; | |
2500 | ||
2501 | } | |
2502 | ||
3b0feb9b AD |
2503 | if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) { |
2504 | print " | |
2505 | <input type=\"submit\" class=\"button\" | |
4f3a84f4 | 2506 | onclick=\"javascript:readSelectedFeeds(true)\" value=\"Mark as read\"> |
3b0feb9b | 2507 | <input type=\"submit\" class=\"button\" |
4f3a84f4 | 2508 | onclick=\"javascript:readSelectedFeeds(false)\" |
3b0feb9b AD |
2509 | value=\"Mark as unread\"> "; |
2510 | } | |
2511 | ||
2512 | print " | |
f932bc9f | 2513 | All feeds: <input type=\"submit\" |
3b0feb9b AD |
2514 | class=\"button\" onclick=\"gotoExportOpml()\" |
2515 | value=\"Export OPML\">"; | |
2516 | } | |
2517 | } else { | |
2518 | ||
2519 | print "<p>No feeds defined.</p>"; | |
2520 | ||
2521 | } | |
2522 | ||
2523 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2524 | ||
2525 | print "<h3>Edit Categories</h3>"; | |
2526 | ||
2527 | // print "<h3>Categories</h3>"; | |
2528 | ||
2529 | print "<div class=\"prefGenericAddBox\"> | |
f932bc9f AD |
2530 | <input id=\"fadd_cat\" |
2531 | onchange=\"javascript:addFeedCat()\" | |
2532 | size=\"40\"> | |
2533 | <input | |
3b0feb9b AD |
2534 | type=\"submit\" class=\"button\" |
2535 | onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>"; | |
2536 | ||
2537 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2538 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2539 | ORDER BY title"); | |
2540 | ||
2541 | if (db_num_rows($result) != 0) { | |
2542 | ||
35f3c923 | 2543 | print "<p><table width=\"100%\" class=\"prefFeedCatList\" |
f4fe2cde | 2544 | cellspacing=\"0\" id=\"prefFeedCatList\">"; |
35f3c923 AD |
2545 | |
2546 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2547 | Select: | |
2548 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', | |
3055bc41 | 2549 | 'FCATR-', 'FCCHK-', true)\">All</a>, |
35f3c923 | 2550 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', |
3055bc41 | 2551 | 'FCATR-', 'FCCHK-', false)\">None</a> |
35f3c923 AD |
2552 | </td</tr>"; |
2553 | ||
3b0feb9b | 2554 | print "<tr class=\"title\"> |
a426e532 | 2555 | <td width=\"5%\"></td><td width=\"80%\">Title</td> |
3b0feb9b AD |
2556 | </tr>"; |
2557 | ||
2558 | $lnum = 0; | |
2559 | ||
2560 | while ($line = db_fetch_assoc($result)) { | |
2561 | ||
2562 | $class = ($lnum % 2) ? "even" : "odd"; | |
2563 | ||
2564 | $cat_id = $line["id"]; | |
2565 | ||
2566 | $edit_cat_id = $_GET["id"]; | |
2567 | ||
2568 | if ($subop == "editCat" && $cat_id != $edit_cat_id) { | |
2569 | $class .= "Grayed"; | |
53226edc AD |
2570 | $this_row_id = ""; |
2571 | } else { | |
2572 | $this_row_id = "id=\"FCATR-$cat_id\""; | |
3b0feb9b AD |
2573 | } |
2574 | ||
53226edc | 2575 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2576 | |
2577 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
2578 | ||
2579 | if (!$edit_cat_id || $subop != "editCat") { | |
2580 | ||
a426e532 | 2581 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
2582 | type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>"; |
2583 | ||
2584 | print "<td><a href=\"javascript:editFeedCat($cat_id);\">" . | |
2585 | $edit_title . "</a></td>"; | |
2586 | ||
2587 | } else if ($cat_id != $edit_cat_id) { | |
2588 | ||
2589 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2590 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
2591 | ||
2592 | print "<td>$edit_title</td>"; | |
2593 | ||
2594 | } else { | |
2595 | ||
2596 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2597 | ||
2598 | print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>"; | |
2599 | ||
2600 | } | |
2601 | ||
2602 | print "</tr>"; | |
2603 | ||
2604 | ++$lnum; | |
2605 | } | |
2606 | ||
2607 | print "</table>"; | |
2608 | ||
2609 | print "<p>"; | |
2610 | ||
2611 | if ($subop == "editCat") { | |
2612 | print "Edit category: | |
2613 | <input type=\"submit\" class=\"button\" | |
2614 | onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\"> | |
2615 | <input type=\"submit\" class=\"button\" | |
2616 | onclick=\"javascript:feedCatEditSave()\" value=\"Save\">"; | |
2617 | } else { | |
2618 | ||
2619 | print " | |
2620 | Selection: | |
2621 | <input type=\"submit\" class=\"button\" | |
2622 | onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\"> | |
2623 | <input type=\"submit\" class=\"button\" | |
2624 | onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">"; | |
2625 | ||
2626 | } | |
2627 | ||
2628 | } else { | |
2629 | print "<p>No feed categories defined.</p>"; | |
2630 | } | |
c64d5b03 AD |
2631 | } |
2632 | ||
2633 | print "<h3>Import OPML</h3> | |
f5a50b25 AD |
2634 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
2635 | File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
2636 | <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\" | |
2637 | type=\"submit\" value=\"Import\"> | |
2638 | </form>"; | |
2639 | ||
007bda35 AD |
2640 | } |
2641 | ||
a0d53889 AD |
2642 | if ($op == "pref-filters") { |
2643 | ||
2644 | $subop = $_GET["subop"]; | |
a24f525c | 2645 | $quiet = $_GET["quiet"]; |
a0d53889 AD |
2646 | |
2647 | if ($subop == "editSave") { | |
a0d53889 | 2648 | |
648472a7 AD |
2649 | $regexp = db_escape_string($_GET["r"]); |
2650 | $descr = db_escape_string($_GET["d"]); | |
2651 | $match = db_escape_string($_GET["m"]); | |
2652 | $filter_id = db_escape_string($_GET["id"]); | |
ead60402 | 2653 | $feed_id = db_escape_string($_GET["fid"]); |
19c9cb11 | 2654 | $action_id = db_escape_string($_GET["aid"]); |
ead60402 AD |
2655 | |
2656 | if (!$feed_id) { | |
2657 | $feed_id = 'NULL'; | |
2658 | } else { | |
2659 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2660 | } | |
0afbd851 | 2661 | |
648472a7 | 2662 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 2663 | reg_exp = '$regexp', |
0afbd851 | 2664 | description = '$descr', |
ead60402 | 2665 | feed_id = $feed_id, |
19c9cb11 | 2666 | action_id = '$action_id', |
0afbd851 AD |
2667 | filter_type = (SELECT id FROM ttrss_filter_types WHERE |
2668 | description = '$match') | |
2669 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
2670 | } |
2671 | ||
2672 | if ($subop == "remove") { | |
2673 | ||
2674 | if (!WEB_DEMO_MODE) { | |
2675 | ||
f932bc9f | 2676 | $ids = split(",", db_escape_string($_GET["ids"])); |
a0d53889 AD |
2677 | |
2678 | foreach ($ids as $id) { | |
648472a7 | 2679 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
2680 | |
2681 | } | |
2682 | } | |
2683 | } | |
2684 | ||
2685 | if ($subop == "add") { | |
2686 | ||
de435974 | 2687 | if (!WEB_DEMO_MODE) { |
a0d53889 | 2688 | |
b6b535ca AD |
2689 | $regexp = db_escape_string(trim($_GET["regexp"])); |
2690 | $match = db_escape_string(trim($_GET["match"])); | |
ead60402 | 2691 | $feed_id = db_escape_string($_GET["fid"]); |
19c9cb11 | 2692 | $action_id = db_escape_string($_GET["aid"]); |
ead60402 AD |
2693 | |
2694 | if (!$feed_id) { | |
2695 | $feed_id = 'NULL'; | |
2696 | } else { | |
2697 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2698 | } | |
4401bf04 | 2699 | |
648472a7 | 2700 | $result = db_query($link, |
19c9cb11 AD |
2701 | "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, |
2702 | action_id) | |
2703 | VALUES | |
de435974 | 2704 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
19c9cb11 AD |
2705 | description = '$match'),'".$_SESSION["uid"]."', |
2706 | $feed_id, '$action_id')"); | |
de435974 | 2707 | } |
a0d53889 AD |
2708 | } |
2709 | ||
a24f525c AD |
2710 | if ($quiet) return; |
2711 | ||
648472a7 | 2712 | $result = db_query($link, "SELECT description |
a0d53889 AD |
2713 | FROM ttrss_filter_types ORDER BY description"); |
2714 | ||
2715 | $filter_types = array(); | |
2716 | ||
648472a7 | 2717 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
2718 | array_push($filter_types, $line["description"]); |
2719 | } | |
2720 | ||
2c7070b5 | 2721 | print "<div class=\"prefGenericAddBox\"> |
7cc1e5d6 | 2722 | <input id=\"fadd_regexp\" size=\"40\"> "; |
2c7070b5 | 2723 | |
ead60402 AD |
2724 | print_select("fadd_match", "Title", $filter_types); |
2725 | ||
2726 | print " <select id=\"fadd_feed\">"; | |
2727 | ||
2728 | print "<option selected id=\"0\">All feeds</option>"; | |
2729 | ||
2730 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2731 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2732 | ||
2733 | if (db_num_rows($result) > 0) { | |
2734 | print "<option disabled>--------</option>"; | |
2735 | } | |
2736 | ||
2737 | while ($line = db_fetch_assoc($result)) { | |
2738 | printf("<option id='%d'>%s</option>", $line["id"], $line["title"]); | |
2739 | } | |
2740 | ||
2c7070b5 | 2741 | print "</select> "; |
19c9cb11 AD |
2742 | |
2743 | print " Action: "; | |
2744 | ||
2745 | print "<select id=\"fadd_action\">"; | |
2746 | ||
2747 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2748 | ORDER BY name"); | |
2749 | ||
2750 | while ($line = db_fetch_assoc($result)) { | |
2751 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
2752 | } | |
2753 | ||
2754 | print "</select> "; | |
2755 | ||
2c7070b5 AD |
2756 | print "<input type=\"submit\" |
2757 | class=\"button\" onclick=\"javascript:addFilter()\" | |
2758 | value=\"Add filter\">"; | |
a0d53889 | 2759 | |
19c9cb11 AD |
2760 | print "</div>"; |
2761 | ||
648472a7 | 2762 | $result = db_query($link, "SELECT |
ead60402 AD |
2763 | ttrss_filters.id AS id,reg_exp, |
2764 | ttrss_filters.description AS description, | |
2765 | ttrss_filter_types.name AS filter_type_name, | |
2766 | ttrss_filter_types.description AS filter_type_descr, | |
2767 | feed_id, | |
19c9cb11 | 2768 | ttrss_filter_actions.description AS action_description, |
11de82c3 | 2769 | ttrss_feeds.title AS feed_title |
a0d53889 | 2770 | FROM |
5890c3f4 AD |
2771 | ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN |
2772 | ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id) | |
4356293a | 2773 | WHERE |
ead60402 | 2774 | filter_type = ttrss_filter_types.id AND |
19c9cb11 | 2775 | ttrss_filter_actions.id = action_id AND |
ead60402 | 2776 | ttrss_filters.owner_uid = ".$_SESSION["uid"]." |
4356293a | 2777 | ORDER by reg_exp"); |
a0d53889 | 2778 | |
3b0feb9b | 2779 | if (db_num_rows($result) != 0) { |
a0d53889 | 2780 | |
f4fe2cde AD |
2781 | print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" |
2782 | id=\"prefFilterList\">"; | |
35f3c923 AD |
2783 | |
2784 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2785 | Select: | |
2786 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', | |
3055bc41 | 2787 | 'FILRR-', 'FICHK-', true)\">All</a>, |
35f3c923 | 2788 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', |
3055bc41 | 2789 | 'FILRR-', 'FICHK-', false)\">None</a> |
35f3c923 AD |
2790 | </td</tr>"; |
2791 | ||
3b0feb9b | 2792 | print "<tr class=\"title\"> |
e325c6e7 | 2793 | <td align='center' width=\"5%\"> </td> |
19c9cb11 AD |
2794 | <td width=\"20%\">Filter expression</td> |
2795 | <td width=\"20%\">Feed</td> | |
2796 | <td width=\"15%\">Match</td> | |
2797 | <td width=\"15%\">Action</td> | |
3b0feb9b | 2798 | <td width=\"30%\">Description</td></tr>"; |
a0d53889 | 2799 | |
3b0feb9b AD |
2800 | $lnum = 0; |
2801 | ||
2802 | while ($line = db_fetch_assoc($result)) { | |
2803 | ||
2804 | $class = ($lnum % 2) ? "even" : "odd"; | |
2805 | ||
2806 | $filter_id = $line["id"]; | |
2807 | $edit_filter_id = $_GET["id"]; | |
2808 | ||
2809 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
2810 | $class .= "Grayed"; | |
53226edc AD |
2811 | $this_row_id = ""; |
2812 | } else { | |
2813 | $this_row_id = "id=\"FILRR-$filter_id\""; | |
ead60402 | 2814 | } |
3b0feb9b | 2815 | |
53226edc | 2816 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2817 | |
2818 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); | |
2819 | $line["description"] = htmlspecialchars($line["description"]); | |
2820 | ||
2821 | if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; | |
2822 | ||
2823 | if (!$edit_filter_id || $subop != "edit") { | |
2824 | ||
2825 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2826 | ||
a426e532 | 2827 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
2828 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; |
2829 | ||
2830 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2831 | $line["reg_exp"] . "</td>"; | |
2832 | ||
2833 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2834 | $line["feed_title"] . "</td>"; | |
2835 | ||
2836 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2837 | $line["filter_type_descr"] . "</td>"; | |
19c9cb11 AD |
2838 | |
2839 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2840 | $line["action_description"] . "</td>"; | |
2841 | ||
3b0feb9b AD |
2842 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . |
2843 | $line["description"] . "</td>"; | |
2844 | ||
2845 | } else if ($filter_id != $edit_filter_id) { | |
2846 | ||
2847 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2848 | ||
2849 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2850 | id=\"FICHK-".$line["id"]."\"></td>"; | |
2851 | ||
2852 | print "<td>".$line["reg_exp"]."</td>"; | |
2853 | print "<td>".$line["feed_title"]."</td>"; | |
2854 | print "<td>".$line["filter_type_descr"]."</td>"; | |
19c9cb11 | 2855 | print "<td>".$line["action_description"]."</td>"; |
3b0feb9b | 2856 | print "<td>".$line["description"]."</td>"; |
19c9cb11 | 2857 | |
3b0feb9b AD |
2858 | } else { |
2859 | ||
2860 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2861 | ||
2862 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. | |
2863 | "\"></td>"; | |
2864 | ||
2865 | print "<td>"; | |
3b0feb9b | 2866 | print "<select id=\"iedit_feed\">"; |
3b0feb9b AD |
2867 | print "<option id=\"0\">All feeds</option>"; |
2868 | ||
3b0feb9b AD |
2869 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds |
2870 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
19c9cb11 AD |
2871 | |
2872 | if (db_num_rows($tmp_result) > 0) { | |
2873 | print "<option disabled>--------</option>"; | |
2874 | } | |
2875 | ||
3b0feb9b AD |
2876 | while ($tmp_line = db_fetch_assoc($tmp_result)) { |
2877 | if ($tmp_line["id"] == $line["feed_id"]) { | |
2878 | $is_selected = "selected"; | |
2879 | } else { | |
2880 | $is_selected = ""; | |
2881 | } | |
2882 | printf("<option $is_selected id='%d'>%s</option>", | |
2883 | $tmp_line["id"], $tmp_line["title"]); | |
ead60402 | 2884 | } |
3b0feb9b AD |
2885 | |
2886 | print "</select></td>"; | |
2887 | ||
2888 | print "<td>"; | |
2889 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
2890 | print "</td>"; | |
19c9cb11 AD |
2891 | |
2892 | print "<td>"; | |
2893 | print "<select id=\"iedit_filter_action\">"; | |
2894 | ||
2895 | $tmp_result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2896 | ORDER BY description"); | |
2897 | ||
2898 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
2899 | if ($tmp_line["description"] == $line["action_description"]) { | |
2900 | $is_selected = "selected"; | |
2901 | } else { | |
2902 | $is_selected = ""; | |
2903 | } | |
2904 | printf("<option $is_selected id='%d'>%s</option>", | |
2905 | $tmp_line["id"], $tmp_line["description"]); | |
2906 | } | |
3b0feb9b | 2907 | |
19c9cb11 AD |
2908 | print "</select></td>"; |
2909 | ||
2910 | ||
3b0feb9b AD |
2911 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. |
2912 | "\"></td>"; | |
2913 | ||
2914 | print "</td>"; | |
ead60402 | 2915 | } |
3b0feb9b AD |
2916 | |
2917 | print "</tr>"; | |
2918 | ||
2919 | ++$lnum; | |
a0d53889 | 2920 | } |
3b0feb9b AD |
2921 | |
2922 | if ($lnum == 0) { | |
2923 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
2924 | } | |
2925 | ||
2926 | print "</table>"; | |
2927 | ||
2928 | print "<p>"; | |
2929 | ||
2930 | if ($subop == "edit") { | |
d10fabe4 | 2931 | print "Edit filter: |
3b0feb9b | 2932 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2933 | onclick=\"javascript:filterEditSave()\" value=\"Save\"> |
3b0feb9b | 2934 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2935 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">"; |
3b0feb9b AD |
2936 | |
2937 | } else { | |
2938 | ||
2939 | print " | |
2940 | Selection: | |
e828e31e | 2941 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2942 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> |
e828e31e | 2943 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2944 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; |
2945 | } | |
2946 | ||
a0d53889 AD |
2947 | } else { |
2948 | ||
3b0feb9b AD |
2949 | print "<p>No filters defined.</p>"; |
2950 | ||
a0d53889 AD |
2951 | } |
2952 | } | |
2953 | ||
80dce858 AD |
2954 | // We need to accept raw SQL data in label queries, so not everything is escaped |
2955 | // here, this is by design. If you don't like the whole idea, disable labels | |
2956 | // altogether with GLOBAL_ENABLE_LABELS = false | |
2957 | ||
48f0adb0 AD |
2958 | if ($op == "pref-labels") { |
2959 | ||
cfaba6df AD |
2960 | if (!GLOBAL_ENABLE_LABELS) { |
2961 | return; | |
2962 | } | |
2963 | ||
48f0adb0 AD |
2964 | $subop = $_GET["subop"]; |
2965 | ||
d9dde1d6 AD |
2966 | if ($subop == "test") { |
2967 | ||
2968 | $expr = $_GET["expr"]; | |
2969 | $descr = $_GET["descr"]; | |
2970 | ||
2971 | print "<div class='infoBoxContents'>"; | |
2972 | ||
2973 | print "<h1>Label «$descr»</h1>"; | |
2974 | ||
2975 | // print "<p><b>Expression</b>: $expr</p>"; | |
2976 | ||
2977 | $result = db_query($link, | |
2978 | "SELECT count(id) AS num_matches | |
2979 | FROM ttrss_entries,ttrss_user_entries | |
2980 | WHERE ($expr) AND | |
2981 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
2982 | owner_uid = " . $_SESSION["uid"]); | |
2983 | ||
2984 | $num_matches = db_fetch_result($result, 0, "num_matches");; | |
2985 | ||
2986 | if ($num_matches > 0) { | |
2987 | ||
a31a7b39 | 2988 | print "<p>Query returned <b>$num_matches</b> matches, first 5 follow:</p>"; |
d9dde1d6 AD |
2989 | |
2990 | $result = db_query($link, | |
2991 | "SELECT title, | |
2992 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title | |
2993 | FROM ttrss_entries,ttrss_user_entries | |
2994 | WHERE ($expr) AND | |
2995 | ttrss_user_entries.ref_id = ttrss_entries.id | |
2996 | AND owner_uid = " . $_SESSION["uid"] . " | |
2997 | ORDER BY date_entered DESC LIMIT 5"); | |
2998 | ||
2999 | print "<ul class=\"nomarks\">"; | |
3000 | while ($line = db_fetch_assoc($result)) { | |
3001 | print "<li>".$line["title"]. | |
3002 | " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>"; | |
3003 | } | |
3004 | print "</ul>"; | |
3005 | ||
3006 | } else { | |
3007 | print "<p>Query didn't return any matches.</p>"; | |
3008 | } | |
3009 | ||
3010 | print "</div>"; | |
3011 | ||
3012 | print "<div align='center'> | |
3013 | <input type='submit' class='button' | |
3014 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
3015 | return; | |
3016 | } | |
3017 | ||
48f0adb0 AD |
3018 | if ($subop == "editSave") { |
3019 | ||
3020 | $sql_exp = $_GET["s"]; | |
3021 | $descr = $_GET["d"]; | |
3022 | $label_id = db_escape_string($_GET["id"]); | |
3023 | ||
3024 | // print "$sql_exp : $descr : $label_id"; | |
3025 | ||
3026 | $result = db_query($link, "UPDATE ttrss_labels SET | |
3027 | sql_exp = '$sql_exp', | |
3028 | description = '$descr' | |
3029 | WHERE id = '$label_id'"); | |
3030 | } | |
3031 | ||
3032 | if ($subop == "remove") { | |
3033 | ||
3034 | if (!WEB_DEMO_MODE) { | |
3035 | ||
f932bc9f | 3036 | $ids = split(",", db_escape_string($_GET["ids"])); |
48f0adb0 AD |
3037 | |
3038 | foreach ($ids as $id) { | |
3039 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
3040 | ||
3041 | } | |
3042 | } | |
3043 | } | |
3044 | ||
3045 | if ($subop == "add") { | |
3046 | ||
3047 | if (!WEB_DEMO_MODE) { | |
3048 | ||
4401bf04 AD |
3049 | // no escaping is done here on purpose |
3050 | $exp = trim($_GET["exp"]); | |
48f0adb0 AD |
3051 | |
3052 | $result = db_query($link, | |
4356293a AD |
3053 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) |
3054 | VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); | |
48f0adb0 AD |
3055 | } |
3056 | } | |
3057 | ||
2c7070b5 AD |
3058 | print "<div class=\"prefGenericAddBox\"> |
3059 | <input size=\"40\" id=\"ladd_expr\"> "; | |
48f0adb0 | 3060 | |
2c7070b5 AD |
3061 | print"<input type=\"submit\" class=\"button\" |
3062 | onclick=\"javascript:addLabel()\" value=\"Add label\"></div>"; | |
48f0adb0 AD |
3063 | |
3064 | $result = db_query($link, "SELECT | |
3065 | id,sql_exp,description | |
3066 | FROM | |
4356293a AD |
3067 | ttrss_labels |
3068 | WHERE | |
3069 | owner_uid = ".$_SESSION["uid"]." | |
3070 | ORDER by description"); | |
48f0adb0 | 3071 | |
d9dde1d6 AD |
3072 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
3073 | ||
3b0feb9b | 3074 | if (db_num_rows($result) != 0) { |
48f0adb0 | 3075 | |
f4fe2cde AD |
3076 | print "<p><table width=\"100%\" cellspacing=\"0\" |
3077 | class=\"prefLabelList\" id=\"prefLabelList\">"; | |
35f3c923 AD |
3078 | |
3079 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
3080 | Select: | |
3081 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', | |
3055bc41 | 3082 | 'LILRR-', 'LICHK-', true)\">All</a>, |
35f3c923 | 3083 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', |
3055bc41 | 3084 | 'LILRR-', 'LICHK-', false)\">None</a> |
35f3c923 AD |
3085 | </td</tr>"; |
3086 | ||
3b0feb9b | 3087 | print "<tr class=\"title\"> |
e325c6e7 AD |
3088 | <td align='center' width=\"5%\"> </td> |
3089 | <td width=\"40%\">SQL expression | |
01c9c74a | 3090 | <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a> |
3b0feb9b AD |
3091 | </td> |
3092 | <td width=\"40%\">Caption</td></tr>"; | |
3093 | ||
3094 | $lnum = 0; | |
3095 | ||
3096 | while ($line = db_fetch_assoc($result)) { | |
3097 | ||
3098 | $class = ($lnum % 2) ? "even" : "odd"; | |
3099 | ||
3100 | $label_id = $line["id"]; | |
3101 | $edit_label_id = $_GET["id"]; | |
3102 | ||
3103 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
3104 | $class .= "Grayed"; | |
53226edc AD |
3105 | $this_row_id = ""; |
3106 | } else { | |
3107 | $this_row_id = "id=\"LILRR-$label_id\""; | |
3b0feb9b AD |
3108 | } |
3109 | ||
53226edc | 3110 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
3111 | |
3112 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
3113 | $line["description"] = htmlspecialchars($line["description"]); | |
3114 | ||
3115 | if (!$edit_label_id || $subop != "edit") { | |
3116 | ||
3117 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
3118 | ||
a426e532 | 3119 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
3120 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; |
3121 | ||
3122 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
3123 | $line["sql_exp"] . "</td>"; | |
48f0adb0 | 3124 | |
3b0feb9b AD |
3125 | print "<td><a href=\"javascript:editLabel($label_id);\">" . |
3126 | $line["description"] . "</td>"; | |
3127 | ||
3128 | } else if ($label_id != $edit_label_id) { | |
3129 | ||
3130 | if (!$line["description"]) $line["description"] = "[No description]"; | |
3131 | ||
3132 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
3133 | id=\"LICHK-".$line["id"]."\"></td>"; | |
3134 | ||
3135 | print "<td>".$line["sql_exp"]."</td>"; | |
3136 | print "<td>".$line["description"]."</td>"; | |
3137 | ||
3138 | } else { | |
3139 | ||
3140 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
3141 | ||
3142 | print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. | |
3143 | "\"></td>"; | |
3144 | ||
3145 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
3146 | "\"></td>"; | |
3147 | ||
3148 | } | |
3149 | ||
48f0adb0 | 3150 | |
3b0feb9b AD |
3151 | print "</tr>"; |
3152 | ||
3153 | ++$lnum; | |
3154 | } | |
3155 | ||
3156 | if ($lnum == 0) { | |
3157 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
3158 | } | |
3159 | ||
3160 | print "</table>"; | |
3161 | ||
3162 | print "<p>"; | |
3163 | ||
3164 | if ($subop == "edit") { | |
3165 | print "Edit label: | |
d9dde1d6 AD |
3166 | <input type=\"submit\" class=\"button\" |
3167 | onclick=\"javascript:labelTest()\" value=\"Test\"> | |
3b0feb9b | 3168 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 3169 | onclick=\"javascript:labelEditSave()\" value=\"Save\"> |
3b0feb9b | 3170 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 3171 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">"; |
3b0feb9b AD |
3172 | |
3173 | } else { | |
3174 | ||
3175 | print " | |
3176 | Selection: | |
48f0adb0 | 3177 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 3178 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> |
48f0adb0 | 3179 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
3180 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; |
3181 | } | |
48f0adb0 | 3182 | } else { |
3b0feb9b | 3183 | print "<p>No labels defined.</p>"; |
48f0adb0 AD |
3184 | } |
3185 | } | |
3186 | ||
e828e31e AD |
3187 | if ($op == "error") { |
3188 | print "<div width=\"100%\" align='center'>"; | |
3189 | $msg = $_GET["msg"]; | |
3190 | print $msg; | |
3191 | print "</div>"; | |
3192 | } | |
3193 | ||
7dc66a61 | 3194 | if ($op == "help") { |
01c9c74a AD |
3195 | if (!$_GET["noheaders"]) { |
3196 | print "<html><head> | |
3197 | <title>Tiny Tiny RSS : Help</title> | |
3198 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
3199 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
3200 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
3201 | </head><body>"; | |
3202 | } | |
7dc66a61 AD |
3203 | |
3204 | $tid = sprintf("%d", $_GET["tid"]); | |
3205 | ||
01c9c74a | 3206 | print "<div class='infoBoxContents'>"; |
7dc66a61 | 3207 | |
01c9c74a AD |
3208 | if (file_exists("help/$tid.php")) { |
3209 | include("help/$tid.php"); | |
3210 | } else { | |
3211 | print "<p>Help topic not found.</p>"; | |
3212 | } | |
7dc66a61 | 3213 | |
01c9c74a | 3214 | print "</div>"; |
7dc66a61 AD |
3215 | |
3216 | print "<div align='center'> | |
01c9c74a AD |
3217 | <input type='submit' class='button' |
3218 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
7dc66a61 | 3219 | |
01c9c74a AD |
3220 | if (!$_GET["noheaders"]) { |
3221 | print "</body></html>"; | |
3222 | } | |
7dc66a61 AD |
3223 | |
3224 | } | |
3225 | ||
f84a97a3 AD |
3226 | if ($op == "dlg") { |
3227 | $id = $_GET["id"]; | |
6de5d056 | 3228 | $param = $_GET["param"]; |
f84a97a3 AD |
3229 | |
3230 | if ($id == "quickAddFeed") { | |
76332f3c AD |
3231 | print " |
3232 | Feed URL: <input | |
033e47e0 | 3233 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" |
15da5cc1 AD |
3234 | id=\"qafInput\">"; |
3235 | ||
3236 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
3237 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
3238 | WHERE owner_uid = ".$_SESSION["uid"]." | |
3239 | ORDER BY title"); | |
3240 | ||
3241 | print " <select id=\"qafCat\">"; | |
3242 | print "<option id=\"0\">Uncategorized</option>"; | |
3243 | ||
3244 | if (db_num_rows($result) != 0) { | |
3245 | ||
3246 | print "<option disabled>--------</option>"; | |
3247 | ||
3248 | while ($line = db_fetch_assoc($result)) { | |
3249 | printf("<option id='%d'>%s</option>", | |
3250 | $line["id"], $line["title"]); | |
3251 | } | |
3252 | } | |
3253 | ||
3254 | print "</select>"; | |
3255 | } | |
3256 | ||
3257 | print " <input class=\"button\" | |
f84a97a3 AD |
3258 | type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\"> |
3259 | <input class=\"button\" | |
3260 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
3261 | value=\"Cancel\">"; | |
3262 | } | |
6de5d056 AD |
3263 | |
3264 | if ($id == "quickDelFeed") { | |
3265 | ||
3266 | $param = db_escape_string($param); | |
3267 | ||
3268 | $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'"); | |
3269 | ||
3270 | if ($result) { | |
3271 | ||
3272 | $f_title = db_fetch_result($result, 0, "title"); | |
3273 | ||
76332f3c | 3274 | print "Remove current feed (<b>$f_title</b>)? |
6de5d056 AD |
3275 | <input class=\"button\" |
3276 | type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\"> | |
3277 | <input class=\"button\" | |
3278 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
3279 | value=\"Cancel\">"; | |
3280 | } else { | |
3281 | print "Error: Feed $param not found. | |
3282 | <input class=\"button\" | |
3283 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
3284 | value=\"Cancel\">"; | |
3285 | } | |
3286 | } | |
3287 | ||
033e47e0 AD |
3288 | if ($id == "search") { |
3289 | ||
49b7cbd3 AD |
3290 | $active_feed_id = db_escape_string($_GET["param"]); |
3291 | ||
033e47e0 AD |
3292 | print "<input id=\"searchbox\" class=\"extSearch\" |
3293 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
3294 | onchange=\"javascript:search()\"> | |
3295 | <select id=\"searchmodebox\"> | |
49b7cbd3 AD |
3296 | <option selected>All feeds</option>"; |
3297 | ||
3298 | if ($active_feed_id) { | |
3299 | print "<option>This feed</option>"; | |
3300 | } else { | |
3301 | print "<option disabled>This feed</option>"; | |
3302 | } | |
b0005823 AD |
3303 | |
3304 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
3305 | print "<option>This category</option>"; | |
3306 | } | |
3307 | ||
49b7cbd3 | 3308 | print "</select> |
033e47e0 AD |
3309 | <input type=\"submit\" |
3310 | class=\"button\" onclick=\"javascript:search()\" value=\"Search\"> | |
3311 | <input class=\"button\" | |
3312 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
3313 | value=\"Close\">"; | |
3314 | ||
3315 | } | |
3316 | ||
a24f525c AD |
3317 | if ($id == "quickAddFilter") { |
3318 | ||
3319 | $result = db_query($link, "SELECT description | |
3320 | FROM ttrss_filter_types ORDER BY description"); | |
3321 | ||
3322 | $filter_types = array(); | |
3323 | ||
3324 | while ($line = db_fetch_assoc($result)) { | |
3325 | array_push($filter_types, $line["description"]); | |
3326 | } | |
3327 | ||
3328 | print "<table>"; | |
3329 | ||
3330 | print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"40\"> "; | |
3331 | ||
3332 | print_select("fadd_match", "Title", $filter_types); | |
3333 | ||
3334 | print "</td></tr>"; | |
3335 | print "<tr><td>Feed:</td><td><select id=\"fadd_feed\">"; | |
3336 | ||
3337 | print "<option selected id=\"0\">All feeds</option>"; | |
3338 | ||
3339 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
3340 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
3341 | ||
3342 | if (db_num_rows($result) > 0) { | |
3343 | print "<option disabled>--------</option>"; | |
3344 | } | |
3345 | ||
3346 | while ($line = db_fetch_assoc($result)) { | |
3347 | if ($param == $line["id"]) { | |
3348 | $selected = "selected"; | |
3349 | } else { | |
3350 | $selected = ""; | |
3351 | } | |
3352 | printf("<option id='%d' %s>%s</option>", $line["id"], $selected, $line["title"]); | |
3353 | } | |
3354 | ||
3355 | print "</select></td></tr>"; | |
3356 | ||
3357 | print "<tr><td>Action:</td>"; | |
3358 | ||
3359 | print "<td><select id=\"fadd_action\">"; | |
3360 | ||
3361 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
3362 | ORDER BY name"); | |
3363 | ||
3364 | while ($line = db_fetch_assoc($result)) { | |
3365 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
3366 | } | |
3367 | ||
3368 | print "</select>"; | |
3369 | ||
3370 | print "</td></tr><tr><td colspan=\"2\" align=\"right\">"; | |
3371 | ||
3372 | print "<input type=\"submit\" | |
3373 | class=\"button\" onclick=\"javascript:qaddFilter()\" | |
3374 | value=\"Add filter\"> "; | |
3375 | ||
3376 | print "<input class=\"button\" | |
3377 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
3378 | value=\"Close\">"; | |
3379 | ||
3380 | print "</td></tr></table>"; | |
3381 | } | |
f84a97a3 AD |
3382 | } |
3383 | ||
a2770077 AD |
3384 | // update feeds of all users, may be used anonymously |
3385 | if ($op == "globalUpdateFeeds") { | |
3386 | ||
3387 | $result = db_query($link, "SELECT id FROM ttrss_users"); | |
3388 | ||
3389 | while ($line = db_fetch_assoc($result)) { | |
3390 | $user_id = $line["id"]; | |
3391 | // print "<!-- updating feeds of uid $user_id -->"; | |
3392 | update_all_feeds($link, false, $user_id); | |
3393 | } | |
e65af9c1 | 3394 | |
a2770077 AD |
3395 | print "<rpc-reply> |
3396 | <message msg=\"All feeds updated\"/> | |
3397 | </rpc-reply>"; | |
e65af9c1 AD |
3398 | |
3399 | } | |
3400 | ||
77e96719 AD |
3401 | if ($op == "pref-prefs") { |
3402 | ||
b1895692 | 3403 | $subop = $_REQUEST["subop"]; |
77e96719 AD |
3404 | |
3405 | if ($subop == "Save configuration") { | |
3406 | ||
d2892032 AD |
3407 | if (WEB_DEMO_MODE) { |
3408 | header("Location: prefs.php"); | |
3409 | return; | |
3410 | } | |
01d68cf9 | 3411 | |
93cb4442 AD |
3412 | $_SESSION["prefs_op_result"] = "save-config"; |
3413 | ||
11de82c3 AD |
3414 | $_SESSION["prefs_cache"] = false; |
3415 | ||
77e96719 AD |
3416 | foreach (array_keys($_POST) as $pref_name) { |
3417 | ||
3418 | $pref_name = db_escape_string($pref_name); | |
3419 | $value = db_escape_string($_POST[$pref_name]); | |
3420 | ||
3421 | $result = db_query($link, "SELECT type_name | |
3422 | FROM ttrss_prefs,ttrss_prefs_types | |
3423 | WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id"); | |
3424 | ||
3425 | if (db_num_rows($result) > 0) { | |
3426 | ||
3427 | $type_name = db_fetch_result($result, 0, "type_name"); | |
3428 | ||
5da169d9 AD |
3429 | // print "$pref_name : $type_name : $value<br>"; |
3430 | ||
77e96719 | 3431 | if ($type_name == "bool") { |
5da169d9 | 3432 | if ($value == "1") { |
77e96719 AD |
3433 | $value = "true"; |
3434 | } else { | |
3435 | $value = "false"; | |
3436 | } | |
3437 | } else if ($type_name == "integer") { | |
3438 | $value = sprintf("%d", $value); | |
3439 | } | |
3440 | ||
3441 | // print "$pref_name : $type_name : $value<br>"; | |
3442 | ||
ff485f1d AD |
3443 | db_query($link, "UPDATE ttrss_user_prefs SET value = '$value' |
3444 | WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]); | |
77e96719 AD |
3445 | |
3446 | } | |
3447 | ||
3448 | header("Location: prefs.php"); | |
3449 | ||
3450 | } | |
3451 | ||
b1895692 AD |
3452 | } else if ($subop == "getHelp") { |
3453 | ||
3454 | $pref_name = db_escape_string($_GET["pn"]); | |
3455 | ||
3456 | $result = db_query($link, "SELECT help_text FROM ttrss_prefs | |
3457 | WHERE pref_name = '$pref_name'"); | |
3458 | ||
3459 | if (db_num_rows($result) > 0) { | |
3460 | $help_text = db_fetch_result($result, 0, "help_text"); | |
3461 | print $help_text; | |
3462 | } else { | |
3463 | print "Unknown option: $pref_name"; | |
3464 | } | |
3465 | ||
cbb01696 AD |
3466 | } else if ($subop == "Change e-mail") { |
3467 | ||
3468 | if (WEB_DEMO_MODE) { | |
3469 | header("Location: prefs.php"); | |
3470 | return; | |
3471 | } | |
3472 | ||
3473 | $email = db_escape_string($_GET["email"]); | |
3474 | $active_uid = $_SESSION["uid"]; | |
3475 | ||
3476 | if ($email) { | |
3477 | db_query($link, "UPDATE ttrss_users SET email = '$email' | |
3478 | WHERE id = '$active_uid'"); | |
3479 | } | |
3480 | ||
3481 | header("Location: prefs.php"); | |
3482 | ||
1c7f75ed AD |
3483 | } else if ($subop == "Change password") { |
3484 | ||
d2892032 AD |
3485 | if (WEB_DEMO_MODE) { |
3486 | header("Location: prefs.php"); | |
3487 | return; | |
3488 | } | |
1c7f75ed AD |
3489 | |
3490 | $old_pw = $_POST["OLD_PASSWORD"]; | |
3491 | $new_pw = $_POST["OLD_PASSWORD"]; | |
3492 | ||
3493 | $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]); | |
3494 | $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]); | |
3495 | ||
3496 | $active_uid = $_SESSION["uid"]; | |
3497 | ||
3498 | if ($old_pw && $new_pw) { | |
3499 | ||
3500 | $login = db_escape_string($_SERVER['PHP_AUTH_USER']); | |
3501 | ||
3502 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3503 | id = '$active_uid' AND (pwd_hash = '$old_pw' OR | |
3504 | pwd_hash = '$old_pw_hash')"); | |
3505 | ||
3506 | if (db_num_rows($result) == 1) { | |
3507 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash' | |
3508 | WHERE id = '$active_uid'"); | |
b791095d AD |
3509 | |
3510 | $_SESSION["pwd_change_result"] = "ok"; | |
3511 | } else { | |
3512 | $_SESSION["pwd_change_result"] = "failed"; | |
1c7f75ed AD |
3513 | } |
3514 | } | |
3515 | ||
3516 | header("Location: prefs.php"); | |
b791095d | 3517 | |
77e96719 AD |
3518 | } else if ($subop == "Reset to defaults") { |
3519 | ||
d2892032 AD |
3520 | if (WEB_DEMO_MODE) { |
3521 | header("Location: prefs.php"); | |
3522 | return; | |
3523 | } | |
01d68cf9 | 3524 | |
93cb4442 AD |
3525 | $_SESSION["prefs_op_result"] = "reset-to-defaults"; |
3526 | ||
e1aa0559 AD |
3527 | if (DB_TYPE == "pgsql") { |
3528 | db_query($link,"UPDATE ttrss_user_prefs | |
3529 | SET value = ttrss_prefs.def_value | |
3530 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
3531 | ttrss_prefs.pref_name = ttrss_user_prefs.pref_name"); | |
3532 | } else { | |
3533 | db_query($link, "DELETE FROM ttrss_user_prefs | |
3534 | WHERE owner_uid = ".$_SESSION["uid"]); | |
3535 | initialize_user_prefs($link, $_SESSION["uid"]); | |
3536 | } | |
5da169d9 | 3537 | |
77e96719 AD |
3538 | header("Location: prefs.php"); |
3539 | ||
58f8ad54 AD |
3540 | } else if ($subop == "Change theme") { |
3541 | ||
3542 | $theme = db_escape_string($_POST["theme"]); | |
3543 | ||
3544 | if ($theme == "Default") { | |
3545 | $theme_qpart = 'NULL'; | |
3546 | } else { | |
3547 | $theme_qpart = "'$theme'"; | |
3548 | } | |
3549 | ||
6752e330 AD |
3550 | $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes |
3551 | WHERE theme_name = '$theme'"); | |
3552 | ||
3553 | if (db_num_rows($result) == 1) { | |
3554 | $theme_id = db_fetch_result($result, 0, "id"); | |
3555 | $theme_path = db_fetch_result($result, 0, "theme_path"); | |
3556 | } else { | |
3557 | $theme_id = "NULL"; | |
3558 | $theme_path = ""; | |
3559 | } | |
3560 | ||
58f8ad54 | 3561 | db_query($link, "UPDATE ttrss_users SET |
6752e330 | 3562 | theme_id = $theme_id WHERE id = " . $_SESSION["uid"]); |
58f8ad54 | 3563 | |
6752e330 | 3564 | $_SESSION["theme"] = $theme_path; |
503eb349 | 3565 | |
58f8ad54 AD |
3566 | header("Location: prefs.php"); |
3567 | ||
77e96719 AD |
3568 | } else { |
3569 | ||
7d4c898a | 3570 | if (!SINGLE_USER_MODE) { |
1c7f75ed | 3571 | |
cbb01696 | 3572 | $result = db_query($link, "SELECT id,email FROM ttrss_users |
a029d530 AD |
3573 | WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR |
3574 | pwd_hash = 'SHA1:".sha1("password")."')"); | |
3575 | ||
3576 | if (db_num_rows($result) != 0) { | |
b791095d | 3577 | print "<div class=\"warning\"> |
a029d530 AD |
3578 | Your password is at default value, please change it. |
3579 | </div>"; | |
3580 | } | |
3581 | ||
b791095d AD |
3582 | if ($_SESSION["pwd_change_result"] == "failed") { |
3583 | print "<div class=\"warning\"> | |
3584 | There was an error while changing your password. | |
3585 | </div>"; | |
3586 | } | |
3587 | ||
3588 | if ($_SESSION["pwd_change_result"] == "ok") { | |
3589 | print "<div class=\"notice\"> | |
3590 | Password changed successfully. | |
3591 | </div>"; | |
3592 | } | |
3593 | ||
3594 | $_SESSION["pwd_change_result"] = ""; | |
3595 | ||
93cb4442 AD |
3596 | if ($_SESSION["prefs_op_result"] == "reset-to-defaults") { |
3597 | print "<div class=\"notice\"> | |
3598 | Your configuration was reset to defaults. | |
3599 | </div>"; | |
3600 | } | |
3601 | ||
3602 | if ($_SESSION["prefs_op_result"] == "save-config") { | |
3603 | print "<div class=\"notice\"> | |
3604 | Your configuration was saved successfully. | |
3605 | </div>"; | |
3606 | } | |
3607 | ||
3608 | $_SESSION["prefs_op_result"] = ""; | |
3609 | ||
cbb01696 AD |
3610 | print "<form action=\"backend.php\" method=\"GET\">"; |
3611 | ||
3612 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3613 | print "<tr><td colspan='3'><h3>Personal data</h3></tr></td>"; | |
3614 | ||
3615 | $result = db_query($link, "SELECT email FROM ttrss_users | |
3616 | WHERE id = ".$_SESSION["uid"]); | |
3617 | ||
3618 | $email = db_fetch_result($result, 0, "email"); | |
3619 | ||
3620 | print "<tr><td width=\"40%\">E-mail</td>"; | |
3621 | print "<td><input class=\"editbox\" name=\"email\" | |
3622 | value=\"$email\"></td></tr>"; | |
3623 | ||
3624 | print "</table>"; | |
3625 | ||
3626 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3627 | ||
3628 | print "<p><input class=\"button\" type=\"submit\" | |
3629 | value=\"Change e-mail\" name=\"subop\">"; | |
3630 | ||
a132b8b1 AD |
3631 | print "</form>"; |
3632 | ||
7d4c898a AD |
3633 | print "<form action=\"backend.php\" method=\"POST\">"; |
3634 | ||
3635 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3636 | print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>"; | |
3637 | ||
3638 | print "<tr><td width=\"40%\">Old password</td>"; | |
3639 | print "<td><input class=\"editbox\" type=\"password\" | |
3640 | name=\"OLD_PASSWORD\"></td></tr>"; | |
3641 | ||
3642 | print "<tr><td width=\"40%\">New password</td>"; | |
3643 | ||
3644 | print "<td><input class=\"editbox\" type=\"password\" | |
3645 | name=\"NEW_PASSWORD\"></td></tr>"; | |
3646 | ||
3647 | print "</table>"; | |
3648 | ||
3649 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3650 | ||
3651 | print "<p><input class=\"button\" type=\"submit\" | |
3652 | value=\"Change password\" name=\"subop\">"; | |
3653 | ||
3654 | print "</form>"; | |
1c7f75ed | 3655 | |
7d4c898a | 3656 | } |
1c7f75ed | 3657 | |
58f8ad54 AD |
3658 | $result = db_query($link, "SELECT |
3659 | theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]); | |
3660 | ||
3661 | $user_theme_id = db_fetch_result($result, 0, "theme_id"); | |
3662 | ||
3663 | $result = db_query($link, "SELECT | |
3664 | id,theme_name FROM ttrss_themes ORDER BY theme_name"); | |
3665 | ||
3666 | if (db_num_rows($result) > 0) { | |
6752e330 AD |
3667 | |
3668 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3669 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3670 | print "<tr><td colspan='3'><h3>Themes</h3></tr></td>"; | |
3671 | print "<tr><td width=\"40%\">Select theme</td>"; | |
3672 | print "<td><select name=\"theme\">"; | |
3673 | print "<option>Default</option>"; | |
58f8ad54 | 3674 | print "<option disabled>--------</option>"; |
6752e330 | 3675 | |
58f8ad54 AD |
3676 | while ($line = db_fetch_assoc($result)) { |
3677 | if ($line["id"] == $user_theme_id) { | |
3678 | $selected = "selected"; | |
3679 | } else { | |
3680 | $selected = ""; | |
3681 | } | |
3682 | print "<option $selected>" . $line["theme_name"] . "</option>"; | |
3683 | } | |
6752e330 AD |
3684 | print "</select></td></tr>"; |
3685 | print "</table>"; | |
3686 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3687 | print "<p><input class=\"button\" type=\"submit\" | |
3688 | value=\"Change theme\" name=\"subop\">"; | |
3689 | print "</form>"; | |
58f8ad54 AD |
3690 | } |
3691 | ||
77e96719 | 3692 | $result = db_query($link, "SELECT |
ff485f1d | 3693 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, |
77e96719 | 3694 | section_name,def_value |
ff485f1d | 3695 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs |
77e96719 | 3696 | WHERE type_id = ttrss_prefs_types.id AND |
ff485f1d | 3697 | section_id = ttrss_prefs_sections.id AND |
a2411bd9 AD |
3698 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND |
3699 | owner_uid = ".$_SESSION["uid"]." | |
650bc435 | 3700 | ORDER BY section_id,short_desc"); |
77e96719 AD |
3701 | |
3702 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3703 | ||
77e96719 AD |
3704 | $lnum = 0; |
3705 | ||
3706 | $active_section = ""; | |
3707 | ||
3708 | while ($line = db_fetch_assoc($result)) { | |
3709 | ||
3710 | if ($active_section != $line["section_name"]) { | |
59a654ba AD |
3711 | |
3712 | if ($active_section != "") { | |
1c7f75ed | 3713 | print "</table>"; |
59a654ba | 3714 | } |
1c7f75ed AD |
3715 | |
3716 | print "<p><table width=\"100%\" class=\"prefPrefsList\">"; | |
59a654ba AD |
3717 | |
3718 | $active_section = $line["section_name"]; | |
3719 | ||
77e96719 | 3720 | print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>"; |
59a654ba AD |
3721 | // print "<tr class=\"title\"> |
3722 | // <td width=\"25%\">Option</td><td>Value</td></tr>"; | |
7268adf7 AD |
3723 | |
3724 | $lnum = 0; | |
77e96719 AD |
3725 | } |
3726 | ||
650bc435 | 3727 | // $class = ($lnum % 2) ? "even" : "odd"; |
77e96719 | 3728 | |
650bc435 | 3729 | print "<tr>"; |
77e96719 | 3730 | |
77e96719 AD |
3731 | $type_name = $line["type_name"]; |
3732 | $pref_name = $line["pref_name"]; | |
3733 | $value = $line["value"]; | |
3734 | $def_value = $line["def_value"]; | |
b1895692 AD |
3735 | $help_text = $line["help_text"]; |
3736 | ||
3737 | print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"]; | |
3738 | ||
3739 | if ($help_text) print "<div class=\"prefHelp\">$help_text</div>"; | |
3740 | ||
3741 | print "</td>"; | |
77e96719 AD |
3742 | |
3743 | print "<td>"; | |
3744 | ||
3745 | if ($type_name == "bool") { | |
3746 | // print_select($pref_name, $value, array("true", "false")); | |
3747 | ||
3748 | if ($value == "true") { | |
3749 | $value = "Yes"; | |
3750 | } else { | |
3751 | $value = "No"; | |
3752 | } | |
3753 | ||
3754 | print_radio($pref_name, $value, array("Yes", "No")); | |
3755 | ||
3756 | } else { | |
3757 | print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">"; | |
3758 | } | |
3759 | ||
3760 | print "</td>"; | |
3761 | ||
3762 | print "</tr>"; | |
3763 | ||
3764 | $lnum++; | |
3765 | } | |
3766 | ||
3767 | print "</table>"; | |
3768 | ||
3769 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3770 | ||
3771 | print "<p><input class=\"button\" type=\"submit\" | |
3772 | name=\"subop\" value=\"Save configuration\">"; | |
3773 | ||
3774 | print " <input class=\"button\" type=\"submit\" | |
69668465 AD |
3775 | name=\"subop\" onclick=\"return validatePrefsReset()\" |
3776 | value=\"Reset to defaults\"></p>"; | |
77e96719 AD |
3777 | |
3778 | print "</form>"; | |
3779 | ||
3780 | } | |
3781 | ||
3782 | } | |
3783 | ||
e6cb77a0 AD |
3784 | if ($op == "pref-users") { |
3785 | ||
3786 | $subop = $_GET["subop"]; | |
3787 | ||
3788 | if ($subop == "editSave") { | |
3789 | ||
3790 | if (!WEB_DEMO_MODE) { | |
3791 | ||
3792 | $login = db_escape_string($_GET["l"]); | |
3793 | $uid = db_escape_string($_GET["id"]); | |
3794 | $access_level = sprintf("%d", $_GET["al"]); | |
72932a75 | 3795 | $email = db_escape_string($_GET["e"]); |
e6cb77a0 | 3796 | |
72932a75 AD |
3797 | db_query($link, "UPDATE ttrss_users SET login = '$login', |
3798 | access_level = '$access_level', email = '$email' WHERE id = '$uid'"); | |
e6cb77a0 AD |
3799 | |
3800 | } | |
3801 | } else if ($subop == "remove") { | |
3802 | ||
3803 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3804 | ||
f932bc9f | 3805 | $ids = split(",", db_escape_string($_GET["ids"])); |
e6cb77a0 AD |
3806 | |
3807 | foreach ($ids as $id) { | |
3808 | db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]); | |
3809 | ||
3810 | } | |
3811 | } | |
3812 | } else if ($subop == "add") { | |
3813 | ||
3814 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3815 | ||
b6b535ca | 3816 | $login = db_escape_string(trim($_GET["login"])); |
e6cb77a0 AD |
3817 | $tmp_user_pwd = make_password(8); |
3818 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3819 | ||
69c0d759 AD |
3820 | db_query($link, "INSERT INTO ttrss_users |
3821 | (login,pwd_hash,access_level,last_login) | |
3822 | VALUES ('$login', '$pwd_hash', 0, NOW())"); | |
e6cb77a0 AD |
3823 | |
3824 | ||
3825 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3826 | login = '$login' AND pwd_hash = '$pwd_hash'"); | |
3827 | ||
3828 | if (db_num_rows($result) == 1) { | |
3829 | ||
3830 | $new_uid = db_fetch_result($result, 0, "id"); | |
3831 | ||
3832 | print "<div class=\"notice\">Added user <b>".$_GET["login"]. | |
3833 | "</b> with password <b>$tmp_user_pwd</b>.</div>"; | |
3834 | ||
3835 | initialize_user($link, $new_uid); | |
3836 | ||
3837 | } else { | |
3838 | ||
3839 | print "<div class=\"warning\">Error while adding user <b>". | |
3840 | $_GET["login"].".</b></div>"; | |
3841 | ||
3842 | } | |
3843 | } | |
3844 | } else if ($subop == "resetPass") { | |
3845 | ||
3846 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3847 | ||
3848 | $uid = db_escape_string($_GET["id"]); | |
3849 | ||
72932a75 AD |
3850 | $result = db_query($link, "SELECT login,email |
3851 | FROM ttrss_users WHERE id = '$uid'"); | |
e6cb77a0 AD |
3852 | |
3853 | $login = db_fetch_result($result, 0, "login"); | |
72932a75 | 3854 | $email = db_fetch_result($result, 0, "email"); |
e6cb77a0 AD |
3855 | $tmp_user_pwd = make_password(8); |
3856 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3857 | ||
3858 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash' | |
3859 | WHERE id = '$uid'"); | |
3860 | ||
3861 | print "<div class=\"notice\">Changed password of | |
72932a75 AD |
3862 | user <b>$login</b> to <b>$tmp_user_pwd</b>."; |
3863 | ||
3864 | if (MAIL_RESET_PASS && $email) { | |
3865 | print " Notifying <b>$email</b>."; | |
3866 | ||
3867 | mail("$login <$email>", "Password reset notification", | |
3868 | "Hi, $login.\n". | |
3869 | "\n". | |
3870 | "Your password for this TT-RSS installation was reset by". | |
3871 | " an administrator.\n". | |
3872 | "\n". | |
3873 | "Your new password is $tmp_user_pwd, please remember". | |
3874 | " it for later reference.\n". | |
3875 | "\n". | |
3876 | "Sincerely, TT-RSS Mail Daemon.", "From: " . MAIL_FROM); | |
3877 | } | |
3878 | ||
3879 | print "</div>"; | |
e6cb77a0 AD |
3880 | |
3881 | } | |
3882 | } | |
3883 | ||
2c7070b5 | 3884 | print "<div class=\"prefGenericAddBox\"> |
f932bc9f | 3885 | <input id=\"uadd_box\" onchange=\"javascript:addUser()\" size=\"40\"> "; |
e6cb77a0 | 3886 | |
2c7070b5 AD |
3887 | print"<input type=\"submit\" class=\"button\" |
3888 | onclick=\"javascript:addUser()\" value=\"Add user\"></div>"; | |
e6cb77a0 AD |
3889 | |
3890 | $result = db_query($link, "SELECT | |
72932a75 | 3891 | id,login,access_level,email, |
fe99ab12 | 3892 | SUBSTRING(last_login,1,16) as last_login |
e6cb77a0 AD |
3893 | FROM |
3894 | ttrss_users | |
3895 | ORDER by login"); | |
3896 | ||
2317ffaa | 3897 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
1a7572cb | 3898 | |
f4fe2cde AD |
3899 | print "<p><table width=\"100%\" cellspacing=\"0\" |
3900 | class=\"prefUserList\" id=\"prefUserList\">"; | |
e6cb77a0 | 3901 | |
35f3c923 AD |
3902 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
3903 | Select: | |
3904 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', | |
3055bc41 | 3905 | 'UMRR-', 'UMCHK-', true)\">All</a>, |
35f3c923 | 3906 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', |
3055bc41 | 3907 | 'UMRR-', 'UMCHK-', false)\">None</a> |
35f3c923 AD |
3908 | </td</tr>"; |
3909 | ||
e6cb77a0 | 3910 | print "<tr class=\"title\"> |
e325c6e7 | 3911 | <td align='center' width=\"5%\"> </td> |
72932a75 AD |
3912 | <td width='20%'>Username</td> |
3913 | <td width='20%'>E-mail</td> | |
3914 | <td width='20%'>Access Level</td> | |
3915 | <td width='20%'>Last login</td></tr>"; | |
e6cb77a0 AD |
3916 | |
3917 | $lnum = 0; | |
3918 | ||
3919 | while ($line = db_fetch_assoc($result)) { | |
3920 | ||
3921 | $class = ($lnum % 2) ? "even" : "odd"; | |
3922 | ||
3923 | $uid = $line["id"]; | |
3924 | $edit_uid = $_GET["id"]; | |
3925 | ||
4154a415 | 3926 | if ($subop == "edit" && $uid != $edit_uid) { |
e6cb77a0 | 3927 | $class .= "Grayed"; |
53226edc AD |
3928 | $this_row_id = ""; |
3929 | } else { | |
3930 | $this_row_id = "id=\"UMRR-$uid\""; | |
3931 | } | |
3932 | ||
3933 | print "<tr class=\"$class\" $this_row_id>"; | |
e6cb77a0 AD |
3934 | |
3935 | $line["login"] = htmlspecialchars($line["login"]); | |
3936 | ||
6be6bc03 AD |
3937 | $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'), |
3938 | strtotime($line["last_login"])); | |
3939 | ||
72932a75 | 3940 | /* if ($uid == $_SESSION["uid"]) { |
e6cb77a0 | 3941 | |
a426e532 | 3942 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
e6cb77a0 AD |
3943 | id=\"UMCHK-".$line["id"]."\"></td>"; |
3944 | ||
72932a75 AD |
3945 | print "<td>".$line["login"]."</td>"; |
3946 | print "<td>".$line["email"]."</td>"; | |
3947 | print "<td>".$line["access_level"]."</td>"; | |
e6cb77a0 | 3948 | |
72932a75 | 3949 | } else */ if (!$edit_uid || $subop != "edit") { |
e6cb77a0 | 3950 | |
a426e532 | 3951 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
1a7572cb | 3952 | type=\"checkbox\" id=\"UMCHK-$uid\"></td>"; |
e6cb77a0 AD |
3953 | |
3954 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3955 | $line["login"] . "</td>"; | |
72932a75 AD |
3956 | |
3957 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3958 | $line["email"] . "</td>"; | |
3959 | ||
e6cb77a0 AD |
3960 | print "<td><a href=\"javascript:editUser($uid);\">" . |
3961 | $line["access_level"] . "</td>"; | |
3962 | ||
3963 | } else if ($uid != $edit_uid) { | |
3964 | ||
72932a75 | 3965 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
e6cb77a0 AD |
3966 | id=\"UMCHK-".$line["id"]."\"></td>"; |
3967 | ||
3968 | print "<td>".$line["login"]."</td>"; | |
72932a75 | 3969 | print "<td>".$line["email"]."</td>"; |
e6cb77a0 AD |
3970 | print "<td>".$line["access_level"]."</td>"; |
3971 | ||
3972 | } else { | |
3973 | ||
72932a75 AD |
3974 | print "<td align='center'> |
3975 | <input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
e6cb77a0 AD |
3976 | |
3977 | print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"]. | |
3978 | "\"></td>"; | |
3979 | ||
72932a75 AD |
3980 | print "<td><input id=\"iedit_email\" value=\"".$line["email"]. |
3981 | "\"></td>"; | |
3982 | ||
e6cb77a0 AD |
3983 | print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"]. |
3984 | "\"></td>"; | |
3985 | ||
3986 | } | |
3987 | ||
f6f32198 AD |
3988 | print "<td>".$line["last_login"]."</td>"; |
3989 | ||
e6cb77a0 AD |
3990 | print "</tr>"; |
3991 | ||
3992 | ++$lnum; | |
3993 | } | |
3994 | ||
3995 | print "</table>"; | |
3996 | ||
3997 | print "<p>"; | |
3998 | ||
3999 | if ($subop == "edit") { | |
d10fabe4 | 4000 | print "Edit user: |
e6cb77a0 | 4001 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 4002 | onclick=\"javascript:userEditSave()\" value=\"Save\"> |
e6cb77a0 | 4003 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 4004 | onclick=\"javascript:userEditCancel()\" value=\"Cancel\">"; |
e6cb77a0 AD |
4005 | |
4006 | } else { | |
4007 | ||
4008 | print " | |
4009 | Selection: | |
4010 | <input type=\"submit\" class=\"button\" | |
717f5e64 | 4011 | onclick=\"javascript:selectedUserDetails()\" value=\"User details\"> |
e6cb77a0 AD |
4012 | <input type=\"submit\" class=\"button\" |
4013 | onclick=\"javascript:editSelectedUser()\" value=\"Edit\"> | |
4014 | <input type=\"submit\" class=\"button\" | |
717f5e64 AD |
4015 | onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\"> |
4016 | <input type=\"submit\" class=\"button\" | |
4017 | onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">"; | |
4018 | ||
4019 | } | |
4020 | } | |
4021 | ||
4022 | if ($op == "user-details") { | |
4023 | ||
4024 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { | |
4025 | return; | |
4026 | } | |
4027 | ||
1a7572cb | 4028 | /* print "<html><head> |
717f5e64 AD |
4029 | <title>Tiny Tiny RSS : User Details</title> |
4030 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
4031 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
1a7572cb | 4032 | </head><body>"; */ |
717f5e64 AD |
4033 | |
4034 | $uid = sprintf("%d", $_GET["id"]); | |
4035 | ||
c6c3a07f | 4036 | print "<div class='infoBoxContents'>"; |
717f5e64 | 4037 | |
fe99ab12 AD |
4038 | $result = db_query($link, "SELECT login, |
4039 | SUBSTRING(last_login,1,16) AS last_login, | |
4040 | access_level, | |
c6c3a07f AD |
4041 | (SELECT COUNT(int_id) FROM ttrss_user_entries |
4042 | WHERE owner_uid = id) AS stored_articles | |
717f5e64 AD |
4043 | FROM ttrss_users |
4044 | WHERE id = '$uid'"); | |
4045 | ||
4046 | if (db_num_rows($result) == 0) { | |
4047 | print "<h1>User not found</h1>"; | |
4048 | return; | |
4049 | } | |
4050 | ||
4051 | print "<h1>User Details</h1>"; | |
4052 | ||
4053 | print "<table width='100%'>"; | |
4054 | ||
4055 | $login = db_fetch_result($result, 0, "login"); | |
6be6bc03 AD |
4056 | $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), |
4057 | strtotime(db_fetch_result($result, 0, "last_login"))); | |
717f5e64 | 4058 | $access_level = db_fetch_result($result, 0, "access_level"); |
c6c3a07f | 4059 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); |
717f5e64 AD |
4060 | |
4061 | print "<tr><td>Username</td><td>$login</td></tr>"; | |
4062 | print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
4063 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
c6c3a07f | 4064 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; |
717f5e64 AD |
4065 | |
4066 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds | |
4067 | WHERE owner_uid = '$uid'"); | |
4068 | ||
4069 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
4070 | ||
4071 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; | |
4072 | ||
5d15d3ea | 4073 | /* $result = db_query($link, "SELECT |
717f5e64 | 4074 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size |
c6c3a07f AD |
4075 | FROM ttrss_user_entries,ttrss_entries |
4076 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
717f5e64 | 4077 | |
d9f115c3 | 4078 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
717f5e64 | 4079 | |
c6c3a07f | 4080 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ |
717f5e64 AD |
4081 | |
4082 | print "</table>"; | |
4083 | ||
4084 | print "<h1>Subscribed feeds</h1>"; | |
4085 | ||
e94645ca | 4086 | $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds |
9b3e2cc7 | 4087 | WHERE owner_uid = '$uid' ORDER BY title"); |
717f5e64 | 4088 | |
9b3e2cc7 | 4089 | print "<ul class=\"userFeedList\">"; |
717f5e64 AD |
4090 | |
4091 | while ($line = db_fetch_assoc($result)) { | |
4092 | ||
4093 | $icon_file = ICONS_URL."/".$line["id"].".ico"; | |
4094 | ||
4095 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
6c56687e | 4096 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; |
717f5e64 | 4097 | } else { |
5951ded1 | 4098 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
717f5e64 AD |
4099 | } |
4100 | ||
e94645ca | 4101 | print "<li>$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>"; |
e6cb77a0 | 4102 | } |
717f5e64 | 4103 | |
a88c1f36 AD |
4104 | if (db_num_rows($result) < $num_feeds) { |
4105 | // FIXME - add link to show ALL subscribed feeds here somewhere | |
4106 | print "<li><img | |
4107 | class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>"; | |
4108 | } | |
4109 | ||
717f5e64 AD |
4110 | print "</ul>"; |
4111 | ||
717f5e64 AD |
4112 | print "</div>"; |
4113 | ||
1a7572cb AD |
4114 | print "<div align='center'> |
4115 | <input type='submit' class='button' | |
c6c3a07f | 4116 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; |
1a7572cb AD |
4117 | |
4118 | // print "</body></html>"; | |
717f5e64 | 4119 | |
e6cb77a0 AD |
4120 | } |
4121 | ||
c6c3a07f AD |
4122 | if ($op == "feed-details") { |
4123 | ||
df268d47 | 4124 | // $feed_id = $_GET["id"]; |
4fec9fd7 | 4125 | |
df268d47 | 4126 | $feed_ids = split(",", db_escape_string($_GET["id"])); |
c6c3a07f | 4127 | |
df268d47 | 4128 | print "<div class=\"infoBoxContents\">"; |
bca02305 | 4129 | |
df268d47 | 4130 | foreach ($feed_ids as $feed_id) { |
c6c3a07f | 4131 | |
df268d47 AD |
4132 | $result = db_query($link, |
4133 | "SELECT | |
4134 | title,feed_url, | |
4135 | SUBSTRING(last_updated,1,16) as last_updated, | |
4136 | icon_url,site_url, | |
4137 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
4138 | WHERE feed_id = id) AS total, | |
4139 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
4140 | WHERE feed_id = id AND unread = true) AS unread, | |
4141 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
4142 | WHERE feed_id = id AND marked = true) AS marked | |
4143 | FROM ttrss_feeds | |
4144 | WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]); | |
4145 | ||
4146 | if (db_num_rows($result) == 0) return; | |
4147 | ||
4148 | $title = db_unescape_string(db_fetch_result($result, 0, "title")); | |
4149 | $last_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
4150 | strtotime(db_fetch_result($result, 0, "last_updated"))); | |
4151 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
4152 | $icon_url = db_fetch_result($result, 0, "icon_url"); | |
4153 | $total = db_fetch_result($result, 0, "total"); | |
4154 | $unread = db_fetch_result($result, 0, "unread"); | |
4155 | $marked = db_fetch_result($result, 0, "marked"); | |
4156 | $site_url = db_fetch_result($result, 0, "site_url"); | |
bca02305 | 4157 | |
df268d47 | 4158 | $result = db_query($link, "SELECT COUNT(id) AS subscribed |
3803fa6a | 4159 | FROM ttrss_feeds WHERE feed_url = '$feed_url' AND private = false"); |
df268d47 AD |
4160 | |
4161 | $subscribed = db_fetch_result($result, 0, "subscribed"); | |
4162 | ||
4163 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
4164 | ||
4165 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
4166 | $feed_icon = "<img width=\"16\" height=\"16\" | |
4167 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
4168 | } else { | |
4169 | $feed_icon = ""; | |
bca02305 AD |
4170 | } |
4171 | ||
df268d47 | 4172 | print "<h1>$feed_icon $title</h1>"; |
bca02305 | 4173 | |
df268d47 | 4174 | print "<table width='100%'>"; |
bca02305 | 4175 | |
df268d47 AD |
4176 | if ($site_url) { |
4177 | print "<tr><td width='30%'>Link</td> | |
4178 | <td><a href=\"$site_url\">$site_url</a> | |
4179 | <a href=\"$feed_url\">(feed)</a></td> | |
4180 | </td></tr>"; | |
4181 | } else { | |
4182 | print "<tr><td width='30%'>Feed URL</td> | |
4183 | <td><a href=\"$feed_url\">$feed_url</a></td></tr>"; | |
4184 | } | |
4185 | print "<tr><td>Last updated</td><td>$last_updated</td></tr>"; | |
4186 | print "<tr><td>Total articles</td><td>$total</td></tr>"; | |
4187 | print "<tr><td>Unread articles</td><td>$unread</td></tr>"; | |
4188 | print "<tr><td>Starred articles</td><td>$marked</td></tr>"; | |
4189 | print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>"; | |
4190 | ||
4191 | print "</table>"; | |
4192 | ||
4193 | /* $result = db_query($link, "SELECT title, | |
4194 | SUBSTRING(updated,1,16) AS updated,unread | |
4195 | FROM ttrss_entries,ttrss_user_entries | |
4196 | WHERE ref_id = id AND feed_id = '$feed_id' | |
4197 | ORDER BY date_entered DESC LIMIT 5"); | |
4198 | ||
4199 | if (db_num_rows($result) > 0) { | |
4200 | ||
4201 | print "<h1>Latest headlines</h1>"; | |
4202 | ||
4203 | print "<ul class=\"nomarks\">"; | |
4204 | ||
4205 | while ($line = db_fetch_assoc($result)) { | |
4206 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
4207 | $line["title"] = "<b>" . $line["title"] . "</b>"; | |
4208 | } | |
4209 | print "<li>" . $line["title"]. | |
4210 | " <span class=\"insensitive\">(" . | |
4211 | date(get_pref($link, 'SHORT_DATE_FORMAT'), | |
4212 | strtotime($line["updated"])). | |
4213 | ")</span></li>"; | |
4214 | } | |
4215 | ||
4216 | print "</ul>"; | |
4217 | ||
4218 | } */ | |
bca02305 | 4219 | } |
df268d47 AD |
4220 | |
4221 | print "</div>"; | |
4222 | ||
4223 | print "<div align='center'> | |
4224 | <input type='submit' class='button' | |
4225 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
4226 | } | |
c6c3a07f | 4227 | |
c6232e43 AD |
4228 | if ($op == "pref-feed-browser") { |
4229 | ||
e2f728be AD |
4230 | if (!ENABLE_FEED_BROWSER) { |
4231 | print "Feed browser is administratively disabled."; | |
4232 | return; | |
4233 | } | |
4234 | ||
c6232e43 AD |
4235 | $subop = $_REQUEST["subop"]; |
4236 | ||
4237 | if ($subop == "details") { | |
4238 | $id = db_escape_string($_GET["id"]); | |
c2b2aee0 | 4239 | |
072f1ee2 AD |
4240 | print "<div class=\"browserFeedInfo\">"; |
4241 | print "<b>Feed information:</b>"; | |
4242 | print "<div class=\"detailsPart\">"; | |
4243 | ||
4244 | $result = db_query($link, "SELECT | |
4245 | feed_url,site_url, | |
4246 | SUBSTRING(last_updated,1,19) AS last_updated | |
4247 | FROM ttrss_feeds WHERE id = '$id'"); | |
4248 | ||
4249 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
4250 | $site_url = db_fetch_result($result, 0, "site_url"); | |
4251 | $last_updated = db_fetch_result($result, 0, "last_updated"); | |
4252 | ||
4253 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
4254 | $last_updated = smart_date_time(strtotime($last_updated)); | |
4255 | } else { | |
4256 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
4257 | $last_updated = date($short_date, strtotime($last_updated)); | |
4258 | } | |
4259 | ||
4260 | print "Site: <a href='$site_url'>$site_url</a> ". | |
4261 | "(<a href='$feed_url'>feed</a>), ". | |
4262 | "Last updated: $last_updated"; | |
4263 | ||
4264 | print "</div>"; | |
4265 | ||
4266 | $result = db_query($link, "SELECT | |
4267 | ttrss_entries.title, | |
4268 | content, | |
c2b2aee0 AD |
4269 | substring(date_entered,1,19) as date_entered, |
4270 | substring(updated,1,19) as updated | |
072f1ee2 AD |
4271 | FROM ttrss_entries,ttrss_user_entries |
4272 | WHERE ttrss_entries.id = ref_id AND feed_id = '$id' | |
c2b2aee0 AD |
4273 | ORDER BY updated DESC LIMIT 5"); |
4274 | ||
4275 | if (db_num_rows($result) > 0) { | |
c2b2aee0 AD |
4276 | |
4277 | print "<b>Last headlines:</b><br>"; | |
4278 | ||
4279 | print "<div class=\"detailsPart\">"; | |
4280 | print "<ul class=\"compact\">"; | |
4281 | while ($line = db_fetch_assoc($result)) { | |
4282 | ||
4283 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
4284 | $entry_dt = smart_date_time(strtotime($line["updated"])); | |
4285 | } else { | |
4286 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
4287 | $entry_dt = date($short_date, strtotime($line["updated"])); | |
4288 | } | |
4289 | ||
4290 | print "<li>" . $line["title"] . | |
4291 | " <span class=\"insensitive\">($entry_dt)</span></li>"; | |
4292 | } | |
4293 | print "</ul></div>"; | |
4294 | } | |
072f1ee2 AD |
4295 | |
4296 | print "</div>"; | |
c2b2aee0 | 4297 | |
c6232e43 AD |
4298 | return; |
4299 | } | |
65f28a40 | 4300 | |
c6232e43 AD |
4301 | $result = db_query($link, "SELECT feed_url,count(id) AS subscribers |
4302 | FROM ttrss_feeds | |
4303 | WHERE auth_login = '' AND auth_pass = '' AND private = false | |
65f28a40 | 4304 | GROUP BY feed_url ORDER BY subscribers DESC LIMIT 100"); |
c6232e43 | 4305 | |
0fefdacc | 4306 | print "<ul class='nomarks' id='browseBigFeedList'>"; |
c6232e43 AD |
4307 | |
4308 | $feedctr = 0; | |
4309 | ||
4310 | while ($line = db_fetch_assoc($result)) { | |
4311 | $feed_url = $line["feed_url"]; | |
4312 | $subscribers = $line["subscribers"]; | |
4313 | ||
4314 | $sub_result = db_query($link, "SELECT id | |
4315 | FROM ttrss_feeds WHERE feed_url = '$feed_url' AND owner_uid =" . | |
4316 | $_SESSION["uid"]); | |
4317 | ||
4318 | if (db_num_rows($sub_result) > 0) { | |
4319 | continue; // already subscribed | |
4320 | } | |
4321 | ||
4322 | $det_result = db_query($link, "SELECT site_url,title,id | |
4323 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
4324 | ||
4325 | $details = db_fetch_assoc($det_result); | |
4326 | ||
4327 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
4328 | ||
4329 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
4330 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
4331 | "/".$details["id"].".ico\">"; | |
4332 | } else { | |
4333 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
4334 | } | |
4335 | ||
4336 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' | |
4337 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
4338 | ||
4339 | $class = ($feedctr % 2) ? "even" : "odd"; | |
4340 | ||
4341 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
4342 | "$feed_icon "; | |
4343 | ||
c2b2aee0 | 4344 | print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" . |
c6232e43 AD |
4345 | $details["title"] ."</a> " . |
4346 | "<span class='subscribers'>($subscribers)</span>"; | |
4347 | ||
4348 | print "<div class=\"browserDetails\" id=\"BRDET-" . $details["id"] . "\">"; | |
4349 | print "</div>"; | |
4350 | ||
4351 | print "</li>"; | |
4352 | ||
4353 | ++$feedctr; | |
4354 | } | |
4355 | ||
4356 | if ($feedctr == 0) { | |
4357 | print "<li>No feeds found to subscribe.</li>"; | |
4358 | } | |
4359 | ||
4360 | print "</ul>"; | |
4361 | ||
0010d872 AD |
4362 | print "<p>Selection: |
4363 | <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\" | |
4364 | value=\"Subscribe\"></p>"; | |
c6232e43 AD |
4365 | |
4366 | print "</div>"; | |
4367 | ||
4368 | } | |
4369 | ||
4b3dff6e | 4370 | db_close($link); |
1cd17194 | 4371 | ?> |
406d9489 AD |
4372 | |
4373 | <!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> | |
4374 |