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