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