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