]>
Commit | Line | Data |
---|---|---|
ef8be8ea | 1 | <?php |
d20f3544 | 2 | |
758e1c4a | 3 | function batch_edit_cbox($elem, $label = false) { |
cd935c42 | 4 | print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\" |
05acc0d6 | 5 | onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">"; |
758e1c4a AD |
6 | } |
7 | ||
ef8be8ea AD |
8 | function module_pref_feeds($link) { |
9 | ||
d20f3544 AD |
10 | global $update_intervals; |
11 | global $purge_intervals; | |
16211ddb | 12 | global $update_methods; |
d20f3544 | 13 | |
ef8be8ea AD |
14 | $subop = $_REQUEST["subop"]; |
15 | $quiet = $_REQUEST["quiet"]; | |
082ae95b | 16 | $mode = $_REQUEST["mode"]; |
ef8be8ea | 17 | |
7b8a143f AD |
18 | if ($subop == "renamecat") { |
19 | $title = db_escape_string($_REQUEST['title']); | |
20 | $id = db_escape_string($_REQUEST['id']); | |
21 | ||
22 | if ($title) { | |
23 | db_query($link, "UPDATE ttrss_feed_categories SET | |
24 | title = '$title' WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
25 | } | |
26 | return; | |
27 | } | |
28 | ||
57e24c82 AD |
29 | if ($subop == "remtwitterinfo") { |
30 | ||
31 | db_query($link, "UPDATE ttrss_users SET twitter_oauth = NULL | |
32 | WHERE id = " . $_SESSION['uid']); | |
33 | ||
34 | return; | |
35 | } | |
36 | ||
7b8a143f AD |
37 | if ($subop == "getfeedtree") { |
38 | ||
39 | $root = array(); | |
40 | $root['id'] = 'root'; | |
41 | $root['name'] = __('Feeds'); | |
42 | $root['items'] = array(); | |
e8c20f92 | 43 | $root['type'] = 'category'; |
7b8a143f AD |
44 | |
45 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
46 | ||
47 | $result = db_query($link, "SELECT id, title FROM ttrss_feed_categories | |
48 | WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY order_id, title"); | |
8ffd2011 | 49 | |
7b8a143f AD |
50 | while ($line = db_fetch_assoc($result)) { |
51 | $cat = array(); | |
52 | $cat['id'] = 'CAT:' . $line['id']; | |
53 | $cat['bare_id'] = $feed_id; | |
54 | $cat['name'] = $line['title']; | |
55 | $cat['items'] = array(); | |
e8c20f92 | 56 | $cat['type'] = 'category'; |
8ffd2011 | 57 | |
1644304f AD |
58 | $feed_result = db_query($link, "SELECT id, title, last_error, |
59 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated | |
82aea978 | 60 | FROM ttrss_feeds |
7b8a143f AD |
61 | WHERE cat_id = '".$line['id']."' AND owner_uid = ".$_SESSION["uid"]. |
62 | " ORDER BY order_id, title"); | |
8ffd2011 | 63 | |
7b8a143f AD |
64 | while ($feed_line = db_fetch_assoc($feed_result)) { |
65 | $feed = array(); | |
66 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
67 | $feed['bare_id'] = $feed_line['id']; | |
68 | $feed['name'] = $feed_line['title']; | |
69 | $feed['checkbox'] = false; | |
82aea978 AD |
70 | $feed['error'] = $feed_line['last_error']; |
71 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
8ffd2011 | 72 | $feed['param'] = make_local_datetime($link, |
1644304f | 73 | $feed_line['last_updated'], true); |
82aea978 | 74 | |
7b8a143f AD |
75 | array_push($cat['items'], $feed); |
76 | } | |
8ffd2011 | 77 | |
7b8a143f AD |
78 | array_push($root['items'], $cat); |
79 | } | |
8ffd2011 | 80 | |
7b8a143f | 81 | /* Uncategorized is a special case */ |
8ffd2011 | 82 | |
7b8a143f AD |
83 | $cat = array(); |
84 | $cat['id'] = 'CAT:0'; | |
85 | $cat['bare_id'] = 0; | |
86 | $cat['name'] = __("Uncategorized"); | |
87 | $cat['items'] = array(); | |
a4d76498 AD |
88 | $cat['type'] = 'category'; |
89 | ||
1644304f AD |
90 | $feed_result = db_query($link, "SELECT id, title,last_error, |
91 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated | |
82aea978 | 92 | FROM ttrss_feeds |
7b8a143f AD |
93 | WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"]. |
94 | " ORDER BY order_id, title"); | |
8ffd2011 | 95 | |
7b8a143f AD |
96 | while ($feed_line = db_fetch_assoc($feed_result)) { |
97 | $feed = array(); | |
98 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
99 | $feed['bare_id'] = $feed_line['id']; | |
100 | $feed['name'] = $feed_line['title']; | |
101 | $feed['checkbox'] = false; | |
82aea978 AD |
102 | $feed['error'] = $feed_line['last_error']; |
103 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
8ffd2011 | 104 | $feed['param'] = make_local_datetime($link, |
1644304f | 105 | $feed_line['last_updated'], true); |
82aea978 | 106 | |
7b8a143f AD |
107 | array_push($cat['items'], $feed); |
108 | } | |
8ffd2011 | 109 | |
7b8a143f AD |
110 | array_push($root['items'], $cat); |
111 | } else { | |
1644304f AD |
112 | $feed_result = db_query($link, "SELECT id, title, last_error, |
113 | ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated | |
82aea978 | 114 | FROM ttrss_feeds |
7b8a143f AD |
115 | WHERE owner_uid = ".$_SESSION["uid"]. |
116 | " ORDER BY order_id, title"); | |
8ffd2011 | 117 | |
7b8a143f AD |
118 | while ($feed_line = db_fetch_assoc($feed_result)) { |
119 | $feed = array(); | |
120 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
121 | $feed['bare_id'] = $feed_line['id']; | |
122 | $feed['name'] = $feed_line['title']; | |
123 | $feed['checkbox'] = false; | |
82aea978 AD |
124 | $feed['error'] = $feed_line['last_error']; |
125 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
8ffd2011 | 126 | $feed['param'] = make_local_datetime($link, |
1644304f | 127 | $feed_line['last_updated'], true); |
82aea978 | 128 | |
7b8a143f AD |
129 | array_push($root['items'], $feed); |
130 | } | |
131 | } | |
132 | ||
133 | $fl = array(); | |
134 | $fl['identifier'] = 'id'; | |
135 | $fl['label'] = 'name'; | |
136 | $fl['items'] = array($root); | |
137 | ||
138 | print json_encode($fl); | |
139 | return; | |
140 | } | |
141 | ||
142 | if ($subop == "catsortreset") { | |
8ffd2011 | 143 | db_query($link, "UPDATE ttrss_feed_categories |
7b8a143f AD |
144 | SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); |
145 | return; | |
8ffd2011 | 146 | } |
7b8a143f AD |
147 | |
148 | if ($subop == "feedsortreset") { | |
8ffd2011 | 149 | db_query($link, "UPDATE ttrss_feeds |
7b8a143f AD |
150 | SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); |
151 | return; | |
8ffd2011 | 152 | } |
7b8a143f AD |
153 | |
154 | if ($subop == "savefeedorder") { | |
e8c20f92 AD |
155 | # if ($_POST['payload']) { |
156 | # file_put_contents("/tmp/blahblah.txt", $_POST['payload']); | |
8ffd2011 | 157 | # $data = json_decode($_POST['payload'], true); |
e8c20f92 AD |
158 | # } else { |
159 | # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true); | |
160 | # } | |
7b8a143f | 161 | |
e8c20f92 | 162 | $data = json_decode($_POST['payload'], true); |
7b8a143f AD |
163 | |
164 | if (is_array($data) && is_array($data['items'])) { | |
165 | $cat_order_id = 0; | |
166 | ||
167 | $data_map = array(); | |
168 | ||
169 | foreach ($data['items'] as $item) { | |
e8c20f92 AD |
170 | |
171 | if ($item['id'] != 'root') { | |
172 | if (is_array($item['items'])) { | |
173 | if (isset($item['items']['_reference'])) { | |
174 | $data_map[$item['id']] = array($item['items']); | |
175 | } else { | |
176 | $data_map[$item['id']] =& $item['items']; | |
177 | } | |
178 | } | |
179 | } | |
7b8a143f AD |
180 | } |
181 | ||
182 | foreach ($data['items'][0]['items'] as $item) { | |
183 | $id = $item['_reference']; | |
184 | $bare_id = substr($id, strpos($id, ':')+1); | |
185 | ||
186 | ++$cat_order_id; | |
187 | ||
188 | if ($bare_id > 0) { | |
8ffd2011 | 189 | db_query($link, "UPDATE ttrss_feed_categories |
7b8a143f AD |
190 | SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND |
191 | owner_uid = " . $_SESSION["uid"]); | |
192 | } | |
193 | ||
194 | $feed_order_id = 0; | |
195 | ||
196 | if (is_array($data_map[$id])) { | |
197 | foreach ($data_map[$id] as $feed) { | |
198 | $id = $feed['_reference']; | |
e8c20f92 AD |
199 | $feed_id = substr($id, strpos($id, ':')+1); |
200 | ||
8ffd2011 | 201 | if ($bare_id != 0) |
e8c20f92 AD |
202 | $cat_query = "cat_id = '$bare_id'"; |
203 | else | |
204 | $cat_query = "cat_id = NULL"; | |
205 | ||
7b8a143f | 206 | db_query($link, "UPDATE ttrss_feeds |
e8c20f92 AD |
207 | SET order_id = '$feed_order_id', |
208 | $cat_query | |
209 | WHERE id = '$feed_id' AND | |
210 | owner_uid = " . $_SESSION["uid"]); | |
8ffd2011 | 211 | |
7b8a143f | 212 | ++$feed_order_id; |
8ffd2011 | 213 | } |
7b8a143f AD |
214 | } |
215 | } | |
216 | } | |
217 | ||
218 | return; | |
219 | } | |
220 | ||
8ffd2011 | 221 | if ($subop == "removeicon") { |
7abf159d AD |
222 | $feed_id = db_escape_string($_REQUEST["feed_id"]); |
223 | ||
224 | $result = db_query($link, "SELECT id FROM ttrss_feeds | |
225 | WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]); | |
226 | ||
227 | if (db_num_rows($result) != 0) { | |
228 | unlink(ICONS_DIR . "/$feed_id.ico"); | |
229 | } | |
230 | ||
231 | return; | |
232 | } | |
233 | ||
c3b7b797 | 234 | if ($subop == "uploadicon") { |
7abf159d AD |
235 | $icon_file = $_FILES['icon_file']['tmp_name']; |
236 | $feed_id = db_escape_string($_REQUEST["feed_id"]); | |
237 | ||
238 | if (is_file($icon_file) && $feed_id) { | |
e258bceb | 239 | if (filesize($icon_file) < 20000) { |
8ffd2011 | 240 | |
7abf159d AD |
241 | $result = db_query($link, "SELECT id FROM ttrss_feeds |
242 | WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]); | |
243 | ||
244 | if (db_num_rows($result) != 0) { | |
245 | unlink(ICONS_DIR . "/$feed_id.ico"); | |
246 | move_uploaded_file($icon_file, ICONS_DIR . "/$feed_id.ico"); | |
247 | $rc = 0; | |
248 | } else { | |
249 | $rc = 2; | |
250 | } | |
251 | } else { | |
252 | $rc = 1; | |
253 | } | |
254 | } else { | |
255 | $rc = 2; | |
256 | } | |
257 | ||
c3b7b797 | 258 | print "<script type=\"text/javascript\">"; |
7abf159d | 259 | print "parent.uploadIconHandler($rc);"; |
c3b7b797 AD |
260 | print "</script>"; |
261 | return; | |
262 | } | |
263 | ||
951906dc | 264 | if ($subop == "editfeed") { |
ef8be8ea | 265 | |
ef8be8ea AD |
266 | $feed_id = db_escape_string($_REQUEST["id"]); |
267 | ||
8ffd2011 | 268 | $result = db_query($link, |
ef8be8ea AD |
269 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND |
270 | owner_uid = " . $_SESSION["uid"]); | |
271 | ||
47439031 AD |
272 | $title = htmlspecialchars(db_fetch_result($result, |
273 | 0, "title")); | |
ef8be8ea | 274 | |
f9c388f5 AD |
275 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$feed_id\">"; |
276 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">"; | |
277 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"editSave\">"; | |
ef8be8ea | 278 | |
ecace165 AD |
279 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; |
280 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 281 | |
ecace165 AD |
282 | /* Title */ |
283 | ||
f9c388f5 | 284 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" |
11b9d0be | 285 | placeHolder=\"".__("Feed Title")."\" |
f9c388f5 | 286 | style=\"font-size : 16px; width: 20em\" name=\"title\" value=\"$title\">"; |
ecace165 AD |
287 | |
288 | /* Feed URL */ | |
ef8be8ea AD |
289 | |
290 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
47439031 AD |
291 | $feed_url = htmlspecialchars(db_fetch_result($result, |
292 | 0, "feed_url")); | |
ecace165 | 293 | |
bcf5ed46 | 294 | print "<hr/>"; |
ecace165 AD |
295 | |
296 | print __('URL:') . " "; | |
f9c388f5 | 297 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" |
11b9d0be | 298 | placeHolder=\"".__("Feed URL")."\" |
f9c388f5 | 299 | regExp='^(http|https)://.*' style=\"width : 20em\" |
ecace165 AD |
300 | name=\"feed_url\" value=\"$feed_url\">"; |
301 | ||
50b284b1 AD |
302 | $last_error = db_fetch_result($result, 0, "last_error"); |
303 | ||
304 | if ($last_error) { | |
305 | print " <span title=\"".htmlspecialchars($last_error)."\" | |
306 | class=\"feed_error\">(error)</span>"; | |
307 | ||
308 | } | |
309 | ||
ecace165 | 310 | /* Category */ |
ef8be8ea AD |
311 | |
312 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
313 | ||
314 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
315 | ||
bcf5ed46 | 316 | print "<hr/>"; |
ecace165 AD |
317 | |
318 | print __('Place in category:') . " "; | |
ef8be8ea | 319 | |
8ffd2011 | 320 | print_feed_cat_select($link, "cat_id", $cat_id, |
f9c388f5 | 321 | 'dojoType="dijit.form.Select"'); |
ef8be8ea AD |
322 | } |
323 | ||
ecace165 | 324 | print "</div>"; |
ef8be8ea | 325 | |
e6bf0f4b | 326 | print "<div class=\"dlgSec\">".__("Update")."</div>"; |
ecace165 | 327 | print "<div class=\"dlgSecCont\">"; |
ef8be8ea | 328 | |
ecace165 | 329 | /* Update Interval */ |
ef8be8ea | 330 | |
ecace165 AD |
331 | $update_interval = db_fetch_result($result, 0, "update_interval"); |
332 | ||
8ffd2011 | 333 | print_select_hash("update_interval", $update_interval, $update_intervals, |
f9c388f5 | 334 | 'dojoType="dijit.form.Select"'); |
16211ddb | 335 | |
ecace165 AD |
336 | /* Update method */ |
337 | ||
8ffd2011 | 338 | $update_method = db_fetch_result($result, 0, "update_method", |
f9c388f5 | 339 | 'dojoType="dijit.form.Select"'); |
ecace165 | 340 | |
34f29d78 | 341 | print " " . __('using') . " "; |
f9c388f5 | 342 | print_select_hash("update_method", $update_method, $update_methods, |
8ffd2011 | 343 | 'dojoType="dijit.form.Select"'); |
16211ddb | 344 | |
22c1bc60 AD |
345 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); |
346 | ||
3907ef71 | 347 | if (FORCE_ARTICLE_PURGE == 0) { |
ecace165 | 348 | |
3907ef71 AD |
349 | /* Purge intl */ |
350 | ||
bcf5ed46 | 351 | print "<hr/>"; |
3907ef71 | 352 | |
3907ef71 | 353 | print __('Article purging:') . " "; |
ecace165 | 354 | |
8ffd2011 | 355 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, |
f9c388f5 | 356 | 'dojoType="dijit.form.Select"'); |
ecace165 | 357 | |
22c1bc60 | 358 | } else { |
8ffd2011 | 359 | print "<input style=\"display : none\" name='purge_interval' |
7d8eca88 | 360 | dojoType=\"dijit.form.TextBox\" value='$purge_interval'>"; |
22c1bc60 | 361 | |
3907ef71 | 362 | } |
ecace165 AD |
363 | |
364 | print "</div>"; | |
365 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
366 | print "<div class=\"dlgSecCont\">"; | |
367 | ||
47439031 | 368 | $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login")); |
ef8be8ea | 369 | |
11b9d0be | 370 | # print "<table>"; |
d616904c | 371 | |
11b9d0be | 372 | # print "<tr><td>" . __('Login:') . "</td><td>"; |
d616904c | 373 | |
57e24c82 | 374 | print "<input dojoType=\"dijit.form.TextBox\" id=\"feedEditDlg_login\" |
11b9d0be | 375 | placeHolder=\"".__("Login")."\" |
bcf5ed46 | 376 | name=\"auth_login\" value=\"$auth_login\"><hr/>"; |
ecace165 | 377 | |
11b9d0be | 378 | # print "</tr><tr><td>" . __("Password:") . "</td><td>"; |
ef8be8ea | 379 | |
47439031 | 380 | $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass")); |
ef8be8ea | 381 | |
8ffd2011 | 382 | print "<input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" |
11b9d0be | 383 | placeHolder=\"".__("Password")."\" |
ecace165 | 384 | value=\"$auth_pass\">"; |
ef8be8ea | 385 | |
57e24c82 AD |
386 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedEditDlg_login\" position=\"below\"> |
387 | ".__('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.')." | |
388 | </div>"; | |
389 | ||
11b9d0be | 390 | # print "</td></tr></table>"; |
d616904c | 391 | |
ecace165 AD |
392 | print "</div>"; |
393 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
394 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 395 | |
f9c388f5 | 396 | # print "<div style=\"line-height : 100%\">"; |
ef8be8ea | 397 | |
886d4bce AD |
398 | $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); |
399 | ||
400 | if ($private) { | |
f9c388f5 | 401 | $checked = "checked=\"1\""; |
886d4bce AD |
402 | } else { |
403 | $checked = ""; | |
404 | } | |
405 | ||
8ffd2011 | 406 | print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\" |
117335bf | 407 | $checked> <label for=\"private\">".__('Hide from Popular feeds')."</label>"; |
ef8be8ea AD |
408 | |
409 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
410 | ||
411 | if ($rtl_content) { | |
f9c388f5 | 412 | $checked = "checked=\"1\""; |
ef8be8ea AD |
413 | } else { |
414 | $checked = ""; | |
415 | } | |
416 | ||
bcf5ed46 | 417 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" |
ecace165 | 418 | $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>"; |
ef8be8ea | 419 | |
ef8be8ea AD |
420 | $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest")); |
421 | ||
422 | if ($include_in_digest) { | |
f9c388f5 | 423 | $checked = "checked=\"1\""; |
ef8be8ea AD |
424 | } else { |
425 | $checked = ""; | |
426 | } | |
427 | ||
8ffd2011 | 428 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\" |
ef8be8ea | 429 | name=\"include_in_digest\" |
ecace165 | 430 | $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; |
ef8be8ea | 431 | |
54e61a68 AD |
432 | |
433 | $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures")); | |
434 | ||
435 | if ($always_display_enclosures) { | |
436 | $checked = "checked"; | |
437 | } else { | |
438 | $checked = ""; | |
439 | } | |
440 | ||
8ffd2011 | 441 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\" |
54e61a68 AD |
442 | name=\"always_display_enclosures\" |
443 | $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
444 | ||
445 | ||
bc0f0785 AD |
446 | $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); |
447 | ||
448 | if ($cache_images) { | |
f9c388f5 | 449 | $checked = "checked=\"1\""; |
bc0f0785 AD |
450 | } else { |
451 | $checked = ""; | |
452 | } | |
453 | ||
0900727a | 454 | if (SIMPLEPIE_CACHE_IMAGES) { |
8ffd2011 | 455 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\" |
6039f5ef AD |
456 | name=\"cache_images\" |
457 | $checked> <label for=\"cache_images\">". | |
458 | __('Cache images locally (SimplePie only)')."</label>"; | |
0900727a | 459 | } |
ef8be8ea | 460 | |
9382ca84 AD |
461 | $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update")); |
462 | ||
463 | if ($mark_unread_on_update) { | |
464 | $checked = "checked"; | |
465 | } else { | |
466 | $checked = ""; | |
467 | } | |
468 | ||
469 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\" | |
470 | name=\"mark_unread_on_update\" | |
471 | $checked> <label for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
472 | ||
74b046a1 AD |
473 | $update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change")); |
474 | ||
475 | if ($update_on_checksum_change) { | |
476 | $checked = "checked"; | |
477 | } else { | |
478 | $checked = ""; | |
479 | } | |
480 | ||
481 | print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"update_on_checksum_change\" | |
482 | name=\"update_on_checksum_change\" | |
483 | $checked> <label for=\"update_on_checksum_change\">".__('Mark posts as updated on content change')."</label>"; | |
484 | ||
f9c388f5 | 485 | # print "</div>"; |
ecace165 | 486 | print "</div>"; |
ef8be8ea | 487 | |
c3b7b797 AD |
488 | /* Icon */ |
489 | ||
7abf159d | 490 | print "<div class=\"dlgSec\">".__("Icon")."</div>"; |
c3b7b797 AD |
491 | print "<div class=\"dlgSecCont\">"; |
492 | ||
493 | print "<iframe name=\"icon_upload_iframe\" | |
494 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; | |
495 | ||
496 | print "<form style='display : block' target=\"icon_upload_iframe\" | |
8ffd2011 | 497 | enctype=\"multipart/form-data\" method=\"POST\" |
c3b7b797 | 498 | action=\"backend.php\"> |
7abf159d | 499 | <input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\"> |
c3b7b797 | 500 | <input type=\"hidden\" name=\"op\" value=\"pref-feeds\"> |
7abf159d | 501 | <input type=\"hidden\" name=\"feed_id\" value=\"$feed_id\"> |
c3b7b797 | 502 | <input type=\"hidden\" name=\"subop\" value=\"uploadicon\"> |
f9c388f5 | 503 | <button dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\" |
c3b7b797 | 504 | type=\"submit\">".__('Replace')."</button> |
f9c388f5 | 505 | <button dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon($feed_id);\" |
7abf159d | 506 | type=\"submit\">".__('Remove')."</button> |
c3b7b797 AD |
507 | </form>"; |
508 | ||
7abf159d | 509 | print "</div>"; |
c3b7b797 | 510 | |
ddb61e79 AD |
511 | $title = htmlspecialchars($title, ENT_QUOTES); |
512 | ||
ecace165 | 513 | print "<div class='dlgButtons'> |
143a4973 | 514 | <div style=\"float : left\"> |
f9c388f5 | 515 | <button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>". |
5de27114 AD |
516 | __('Unsubscribe')."</button>"; |
517 | ||
518 | $pubsub_state = db_fetch_result($result, 0, "pubsub_state"); | |
519 | ||
520 | $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\""; | |
521 | ||
522 | print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled | |
523 | onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates'). | |
524 | "</button>"; | |
525 | ||
526 | print "</div>"; | |
527 | ||
528 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">". | |
529 | __('Resets PubSubHubbub subscription status for push-enabled feeds.')."</div>"; | |
530 | ||
531 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button> | |
f9c388f5 AD |
532 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button> |
533 | </div>"; | |
951906dc | 534 | |
ef8be8ea AD |
535 | return; |
536 | } | |
537 | ||
758e1c4a AD |
538 | if ($subop == "editfeeds") { |
539 | ||
540 | $feed_ids = db_escape_string($_REQUEST["ids"]); | |
758e1c4a | 541 | |
05acc0d6 AD |
542 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"$feed_ids\">"; |
543 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">"; | |
544 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"batchEditSave\">"; | |
758e1c4a AD |
545 | |
546 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
547 | print "<div class=\"dlgSecCont\">"; | |
548 | ||
549 | /* Title */ | |
550 | ||
8ffd2011 | 551 | print "<input dojoType=\"dijit.form.ValidationTextBox\" |
05acc0d6 AD |
552 | disabled=\"1\" style=\"font-size : 16px; width : 20em;\" required=\"1\" |
553 | name=\"title\" value=\"$title\">"; | |
758e1c4a AD |
554 | |
555 | batch_edit_cbox("title"); | |
556 | ||
557 | /* Feed URL */ | |
558 | ||
559 | print "<br/>"; | |
560 | ||
561 | print __('URL:') . " "; | |
05acc0d6 AD |
562 | print "<input dojoType=\"dijit.form.ValidationTextBox\" disabled=\"1\" |
563 | required=\"1\" regExp='^(http|https)://.*' style=\"width : 20em\" | |
758e1c4a AD |
564 | name=\"feed_url\" value=\"$feed_url\">"; |
565 | ||
566 | batch_edit_cbox("feed_url"); | |
567 | ||
568 | /* Category */ | |
569 | ||
570 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
571 | ||
572 | print "<br/>"; | |
573 | ||
574 | print __('Place in category:') . " "; | |
575 | ||
8ffd2011 | 576 | print_feed_cat_select($link, "cat_id", $cat_id, |
05acc0d6 | 577 | 'disabled="1" dojoType="dijit.form.Select"'); |
758e1c4a AD |
578 | |
579 | batch_edit_cbox("cat_id"); | |
580 | ||
581 | } | |
582 | ||
583 | print "</div>"; | |
584 | ||
585 | print "<div class=\"dlgSec\">".__("Update")."</div>"; | |
586 | print "<div class=\"dlgSecCont\">"; | |
587 | ||
588 | /* Update Interval */ | |
589 | ||
8ffd2011 | 590 | print_select_hash("update_interval", $update_interval, $update_intervals, |
05acc0d6 | 591 | 'disabled="1" dojoType="dijit.form.Select"'); |
758e1c4a AD |
592 | |
593 | batch_edit_cbox("update_interval"); | |
594 | ||
595 | /* Update method */ | |
596 | ||
34f29d78 | 597 | print " " . __('using') . " "; |
8ffd2011 AD |
598 | print_select_hash("update_method", $update_method, $update_methods, |
599 | 'disabled="1" dojoType="dijit.form.Select"'); | |
34f29d78 | 600 | batch_edit_cbox("update_method"); |
758e1c4a AD |
601 | |
602 | /* Purge intl */ | |
603 | ||
05acc0d6 | 604 | if (FORCE_ARTICLE_PURGE == 0) { |
758e1c4a | 605 | |
3907ef71 | 606 | print "<br/>"; |
758e1c4a | 607 | |
3907ef71 | 608 | print __('Article purging:') . " "; |
758e1c4a | 609 | |
3907ef71 | 610 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, |
05acc0d6 | 611 | 'disabled="1" dojoType="dijit.form.Select"'); |
3907ef71 AD |
612 | |
613 | batch_edit_cbox("purge_interval"); | |
614 | } | |
758e1c4a AD |
615 | |
616 | print "</div>"; | |
617 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
618 | print "<div class=\"dlgSecCont\">"; | |
619 | ||
8ffd2011 | 620 | print "<input dojoType=\"dijit.form.TextBox\" |
05acc0d6 | 621 | placeHolder=\"".__("Login")."\" disabled=\"1\" |
758e1c4a AD |
622 | name=\"auth_login\" value=\"$auth_login\">"; |
623 | ||
624 | batch_edit_cbox("auth_login"); | |
625 | ||
8ffd2011 | 626 | print "<br/><input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" |
05acc0d6 | 627 | placeHolder=\"".__("Password")."\" disabled=\"1\" |
758e1c4a AD |
628 | value=\"$auth_pass\">"; |
629 | ||
630 | batch_edit_cbox("auth_pass"); | |
631 | ||
632 | print "</div>"; | |
633 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
634 | print "<div class=\"dlgSecCont\">"; | |
635 | ||
8ffd2011 | 636 | print "<input disabled=\"1\" type=\"checkbox\" name=\"private\" id=\"private\" |
05acc0d6 | 637 | dojoType=\"dijit.form.CheckBox\"> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>"; |
758e1c4a AD |
638 | |
639 | print " "; batch_edit_cbox("private", "private_l"); | |
640 | ||
05acc0d6 AD |
641 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" |
642 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
758e1c4a AD |
643 | |
644 | print " "; batch_edit_cbox("rtl_content", "rtl_content_l"); | |
645 | ||
8ffd2011 AD |
646 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"include_in_digest\" |
647 | name=\"include_in_digest\" | |
05acc0d6 | 648 | dojoType=\"dijit.form.CheckBox\"> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; |
758e1c4a AD |
649 | |
650 | print " "; batch_edit_cbox("include_in_digest", "include_in_digest_l"); | |
651 | ||
8ffd2011 AD |
652 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"always_display_enclosures\" |
653 | name=\"always_display_enclosures\" | |
05acc0d6 | 654 | dojoType=\"dijit.form.CheckBox\"> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; |
c9f185bd AD |
655 | |
656 | print " "; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l"); | |
657 | ||
0900727a | 658 | if (SIMPLEPIE_CACHE_IMAGES) { |
8ffd2011 AD |
659 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\" |
660 | name=\"cache_images\" | |
661 | dojoType=\"dijit.form.CheckBox\"> <label class='insensitive' id=\"cache_images_l\" | |
758e1c4a AD |
662 | for=\"cache_images\">". |
663 | __('Cache images locally')."</label>"; | |
8ffd2011 | 664 | |
758e1c4a | 665 | |
0900727a AD |
666 | print " "; batch_edit_cbox("cache_images", "cache_images_l"); |
667 | } | |
758e1c4a | 668 | |
9382ca84 AD |
669 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"mark_unread_on_update\" |
670 | name=\"mark_unread_on_update\" | |
671 | dojoType=\"dijit.form.CheckBox\"> <label id=\"mark_unread_on_update_l\" class='insensitive' for=\"mark_unread_on_update\">".__('Mark updated articles as unread')."</label>"; | |
672 | ||
673 | print " "; batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l"); | |
674 | ||
74b046a1 AD |
675 | print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"update_on_checksum_change\" |
676 | name=\"update_on_checksum_change\" | |
677 | dojoType=\"dijit.form.CheckBox\"> <label id=\"update_on_checksum_change_l\" class='insensitive' for=\"update_on_checksum_change\">".__('Mark posts as updated on content change')."</label>"; | |
678 | ||
679 | print " "; batch_edit_cbox("update_on_checksum_change", "update_on_checksum_change_l"); | |
9382ca84 | 680 | |
758e1c4a AD |
681 | print "</div>"; |
682 | ||
758e1c4a | 683 | print "<div class='dlgButtons'> |
8ffd2011 | 684 | <button dojoType=\"dijit.form.Button\" |
e1218480 AD |
685 | onclick=\"return dijit.byId('feedEditDlg').execute()\">". |
686 | __('Save')."</button> | |
687 | <button dojoType=\"dijit.form.Button\" | |
688 | onclick=\"return dijit.byId('feedEditDlg').hide()\">". | |
689 | __('Cancel')."</button> | |
758e1c4a | 690 | </div>"; |
8ffd2011 | 691 | |
758e1c4a AD |
692 | return; |
693 | } | |
694 | ||
b0f015a2 | 695 | if ($subop == "editSave" || $subop == "batchEditSave") { |
ef8be8ea AD |
696 | |
697 | $feed_title = db_escape_string(trim($_POST["title"])); | |
698 | $feed_link = db_escape_string(trim($_POST["feed_url"])); | |
699 | $upd_intl = db_escape_string($_POST["update_interval"]); | |
700 | $purge_intl = db_escape_string($_POST["purge_interval"]); | |
b0f015a2 AD |
701 | $feed_id = db_escape_string($_POST["id"]); /* editSave */ |
702 | $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */ | |
ef8be8ea AD |
703 | $cat_id = db_escape_string($_POST["cat_id"]); |
704 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
705 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
ef8be8ea AD |
706 | $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); |
707 | $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); | |
ef8be8ea AD |
708 | $include_in_digest = checkbox_to_sql_bool( |
709 | db_escape_string($_POST["include_in_digest"])); | |
bc0f0785 AD |
710 | $cache_images = checkbox_to_sql_bool( |
711 | db_escape_string($_POST["cache_images"])); | |
16211ddb | 712 | $update_method = (int) db_escape_string($_POST["update_method"]); |
ef8be8ea | 713 | |
54e61a68 AD |
714 | $always_display_enclosures = checkbox_to_sql_bool( |
715 | db_escape_string($_POST["always_display_enclosures"])); | |
716 | ||
9382ca84 AD |
717 | $mark_unread_on_update = checkbox_to_sql_bool( |
718 | db_escape_string($_POST["mark_unread_on_update"])); | |
719 | ||
74b046a1 AD |
720 | $update_on_checksum_change = checkbox_to_sql_bool( |
721 | db_escape_string($_POST["update_on_checksum_change"])); | |
722 | ||
8ffd2011 | 723 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
ef8be8ea AD |
724 | if ($cat_id && $cat_id != 0) { |
725 | $category_qpart = "cat_id = '$cat_id',"; | |
726 | $category_qpart_nocomma = "cat_id = '$cat_id'"; | |
727 | } else { | |
728 | $category_qpart = 'cat_id = NULL,'; | |
729 | $category_qpart_nocomma = 'cat_id = NULL'; | |
730 | } | |
731 | } else { | |
732 | $category_qpart = ""; | |
733 | $category_qpart_nocomma = ""; | |
734 | } | |
735 | ||
78a5c296 | 736 | if (SIMPLEPIE_CACHE_IMAGES) { |
bc0f0785 AD |
737 | $cache_images_qpart = "cache_images = $cache_images,"; |
738 | } else { | |
739 | $cache_images_qpart = ""; | |
740 | } | |
741 | ||
b0f015a2 AD |
742 | if ($subop == "editSave") { |
743 | ||
8ffd2011 | 744 | $result = db_query($link, "UPDATE ttrss_feeds SET |
6e63a7c3 | 745 | $category_qpart |
b0f015a2 AD |
746 | title = '$feed_title', feed_url = '$feed_link', |
747 | update_interval = '$upd_intl', | |
748 | purge_interval = '$purge_intl', | |
749 | auth_login = '$auth_login', | |
750 | auth_pass = '$auth_pass', | |
751 | private = $private, | |
752 | rtl_content = $rtl_content, | |
b0f015a2 AD |
753 | $cache_images_qpart |
754 | include_in_digest = $include_in_digest, | |
54e61a68 | 755 | always_display_enclosures = $always_display_enclosures, |
9382ca84 | 756 | mark_unread_on_update = $mark_unread_on_update, |
74b046a1 | 757 | update_on_checksum_change = $update_on_checksum_change, |
b0f015a2 | 758 | update_method = '$update_method' |
5ffd798d | 759 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
b0f015a2 | 760 | |
b0f015a2 AD |
761 | } else if ($subop == "batchEditSave") { |
762 | $feed_data = array(); | |
ef8be8ea | 763 | |
b0f015a2 AD |
764 | foreach (array_keys($_POST) as $k) { |
765 | if ($k != "op" && $k != "subop" && $k != "ids") { | |
766 | $feed_data[$k] = $_POST[$k]; | |
767 | } | |
768 | } | |
769 | ||
770 | db_query($link, "BEGIN"); | |
771 | ||
772 | foreach (array_keys($feed_data) as $k) { | |
773 | ||
774 | $qpart = ""; | |
775 | ||
776 | switch ($k) { | |
8ffd2011 | 777 | case "title": |
b0f015a2 AD |
778 | $qpart = "title = '$feed_title'"; |
779 | break; | |
780 | ||
781 | case "feed_url": | |
782 | $qpart = "feed_url = '$feed_link'"; | |
783 | break; | |
784 | ||
785 | case "update_interval": | |
786 | $qpart = "update_interval = '$upd_intl'"; | |
787 | break; | |
788 | ||
789 | case "purge_interval": | |
790 | $qpart = "purge_interval = '$purge_intl'"; | |
791 | break; | |
792 | ||
793 | case "auth_login": | |
794 | $qpart = "auth_login = '$auth_login'"; | |
795 | break; | |
796 | ||
797 | case "auth_pass": | |
798 | $qpart = "auth_pass = '$auth_pass'"; | |
799 | break; | |
800 | ||
801 | case "private": | |
802 | $qpart = "private = '$private'"; | |
803 | break; | |
804 | ||
b0f015a2 AD |
805 | case "include_in_digest": |
806 | $qpart = "include_in_digest = '$include_in_digest'"; | |
807 | break; | |
808 | ||
c9f185bd AD |
809 | case "always_display_enclosures": |
810 | $qpart = "always_display_enclosures = '$always_display_enclosures'"; | |
811 | break; | |
812 | ||
9382ca84 AD |
813 | case "mark_unread_on_update": |
814 | $qpart = "mark_unread_on_update = '$mark_unread_on_update'"; | |
815 | break; | |
816 | ||
74b046a1 AD |
817 | case "update_on_checksum_change": |
818 | $qpart = "update_on_checksum_change = '$update_on_checksum_change'"; | |
819 | break; | |
820 | ||
5d538f4f AD |
821 | case "cache_images": |
822 | $qpart = "cache_images = '$cache_images'"; | |
823 | break; | |
824 | ||
825 | case "rtl_content": | |
826 | $qpart = "rtl_content = '$rtl_content'"; | |
827 | break; | |
828 | ||
b0f015a2 AD |
829 | case "update_method": |
830 | $qpart = "update_method = '$update_method'"; | |
831 | break; | |
832 | ||
833 | case "cat_id": | |
834 | $qpart = $category_qpart_nocomma; | |
835 | break; | |
836 | ||
837 | } | |
838 | ||
839 | if ($qpart) { | |
cff7a3a2 | 840 | db_query($link, |
b0f015a2 | 841 | "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids) |
cd935c42 AD |
842 | AND owner_uid = " . $_SESSION["uid"]); |
843 | print "<br/>"; | |
b0f015a2 AD |
844 | } |
845 | } | |
846 | ||
847 | db_query($link, "COMMIT"); | |
ef8be8ea | 848 | } |
05acc0d6 | 849 | return; |
ef8be8ea AD |
850 | } |
851 | ||
5de27114 AD |
852 | if ($subop == "resetPubSub") { |
853 | ||
854 | $ids = db_escape_string($_REQUEST["ids"]); | |
855 | ||
856 | db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids) | |
857 | AND owner_uid = " . $_SESSION["uid"]); | |
858 | ||
859 | return; | |
860 | } | |
861 | ||
ef8be8ea AD |
862 | if ($subop == "remove") { |
863 | ||
b4e75b2a | 864 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea | 865 | |
810b1561 | 866 | foreach ($ids as $id) { |
7e329f13 | 867 | remove_feed($link, $id, $_SESSION["uid"]); |
ef8be8ea | 868 | } |
b6a6e262 AD |
869 | |
870 | return; | |
ef8be8ea AD |
871 | } |
872 | ||
d1f0c584 | 873 | if ($subop == "clear") { |
b4e75b2a | 874 | $id = db_escape_string($_REQUEST["id"]); |
d1f0c584 AD |
875 | clear_feed_articles($link, $id); |
876 | } | |
877 | ||
fee840fb | 878 | if ($subop == "rescore") { |
b4e75b2a | 879 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
fee840fb AD |
880 | |
881 | foreach ($ids as $id) { | |
882 | ||
883 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
884 | ||
8ffd2011 | 885 | $result = db_query($link, "SELECT |
38edb151 AD |
886 | title, content, link, ref_id, author,". |
887 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
888 | FROM | |
8ffd2011 AD |
889 | ttrss_user_entries, ttrss_entries |
890 | WHERE ref_id = id AND feed_id = '$id' AND | |
fee840fb | 891 | owner_uid = " .$_SESSION['uid']." |
ef1b0366 | 892 | "); |
fee840fb AD |
893 | |
894 | $scores = array(); | |
895 | ||
896 | while ($line = db_fetch_assoc($result)) { | |
897 | ||
38edb151 AD |
898 | $tags = get_article_tags($link, $line["ref_id"]); |
899 | ||
8ffd2011 AD |
900 | $article_filters = get_article_filters($filters, $line['title'], |
901 | $line['content'], $line['link'], strtotime($line['updated']), | |
38edb151 | 902 | $line['author'], $tags); |
8ffd2011 | 903 | |
fee840fb AD |
904 | $new_score = calculate_article_score($article_filters); |
905 | ||
906 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
907 | ||
908 | array_push($scores[$new_score], $line['ref_id']); | |
909 | } | |
910 | ||
911 | foreach (array_keys($scores) as $s) { | |
912 | if ($s > 1000) { | |
8ffd2011 | 913 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', |
fee840fb | 914 | marked = true WHERE |
95a948a5 | 915 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
1618a849 | 916 | } else if ($s < -500) { |
8ffd2011 | 917 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', |
1618a849 AD |
918 | unread = false WHERE |
919 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
95a948a5 AD |
920 | } else { |
921 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
922 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
923 | } | |
924 | } | |
925 | } | |
926 | ||
927 | print __("All done."); | |
928 | ||
929 | } | |
930 | ||
931 | if ($subop == "rescoreAll") { | |
932 | ||
8ffd2011 | 933 | $result = db_query($link, |
95a948a5 AD |
934 | "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); |
935 | ||
936 | while ($feed_line = db_fetch_assoc($result)) { | |
937 | ||
938 | $id = $feed_line["id"]; | |
939 | ||
940 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
941 | ||
8ffd2011 | 942 | $tmp_result = db_query($link, "SELECT |
38edb151 AD |
943 | title, content, link, ref_id, author,". |
944 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
945 | FROM | |
8ffd2011 AD |
946 | ttrss_user_entries, ttrss_entries |
947 | WHERE ref_id = id AND feed_id = '$id' AND | |
95a948a5 AD |
948 | owner_uid = " .$_SESSION['uid']." |
949 | "); | |
950 | ||
951 | $scores = array(); | |
952 | ||
953 | while ($line = db_fetch_assoc($tmp_result)) { | |
954 | ||
38edb151 AD |
955 | $tags = get_article_tags($link, $line["ref_id"]); |
956 | ||
8ffd2011 AD |
957 | $article_filters = get_article_filters($filters, $line['title'], |
958 | $line['content'], $line['link'], strtotime($line['updated']), | |
38edb151 AD |
959 | $line['author'], $tags); |
960 | ||
95a948a5 AD |
961 | $new_score = calculate_article_score($article_filters); |
962 | ||
963 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
964 | ||
965 | array_push($scores[$new_score], $line['ref_id']); | |
966 | } | |
967 | ||
968 | foreach (array_keys($scores) as $s) { | |
969 | if ($s > 1000) { | |
8ffd2011 | 970 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', |
95a948a5 | 971 | marked = true WHERE |
fee840fb AD |
972 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
973 | } else { | |
974 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
975 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
976 | } | |
977 | } | |
978 | } | |
979 | ||
980 | print __("All done."); | |
981 | ||
982 | } | |
983 | ||
ef8be8ea | 984 | if ($subop == "add") { |
ef8be8ea | 985 | |
a5819bb3 AD |
986 | $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); |
987 | $cat_id = db_escape_string($_REQUEST["cat_id"]); | |
988 | $p_from = db_escape_string($_REQUEST["from"]); | |
ef8be8ea | 989 | |
a5819bb3 | 990 | /* only read authentication information from POST */ |
aa2122d4 | 991 | |
a5819bb3 AD |
992 | $auth_login = db_escape_string(trim($_POST["auth_login"])); |
993 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
aa2122d4 | 994 | |
a5819bb3 | 995 | if ($p_from != 'tt-rss') { |
add81ec7 | 996 | header("Content-Type: text/html"); |
a5819bb3 AD |
997 | print "<html> |
998 | <head> | |
999 | <title>Tiny Tiny RSS</title> | |
1000 | <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\"> | |
1001 | </head> | |
1002 | <body> | |
1003 | <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\" | |
8ffd2011 | 1004 | alt=\"Tiny Tiny RSS\"/> |
a5819bb3 AD |
1005 | <h1>Subscribe to feed...</h1>"; |
1006 | } | |
d70c5ae4 | 1007 | |
a5819bb3 AD |
1008 | $rc = subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass); |
1009 | ||
1010 | switch ($rc) { | |
8ffd2011 | 1011 | case 1: |
a5819bb3 AD |
1012 | print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); |
1013 | break; | |
1014 | case 2: | |
1015 | print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url)); | |
1016 | break; | |
1017 | case 0: | |
1018 | print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); | |
1019 | break; | |
33d32a3c AD |
1020 | case 4: |
1021 | print_notice("Multiple feed URLs found."); | |
1022 | ||
1023 | $feed_urls = get_feeds_from_html($feed_url); | |
1024 | break; | |
08ac193a | 1025 | case 5: |
1026 | print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url)); | |
1027 | break; | |
a5819bb3 | 1028 | } |
e513a74a | 1029 | |
a5819bb3 | 1030 | if ($p_from != 'tt-rss') { |
e513a74a | 1031 | |
33d32a3c AD |
1032 | if ($feed_urls) { |
1033 | ||
1034 | print "<form action=\"backend.php\">"; | |
1035 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
1036 | print "<input type=\"hidden\" name=\"quiet\" value=\"1\">"; | |
1037 | print "<input type=\"hidden\" name=\"subop\" value=\"add\">"; | |
8ffd2011 | 1038 | |
33d32a3c AD |
1039 | print "<select name=\"feed_url\">"; |
1040 | ||
1041 | foreach ($feed_urls as $url => $name) { | |
1042 | $url = htmlspecialchars($url); | |
1043 | $name = htmlspecialchars($name); | |
1044 | ||
1045 | print "<option value=\"$url\">$name</option>"; | |
1046 | } | |
1047 | ||
1048 | print "<input type=\"submit\" value=\"".__("Subscribe to selected feed"). | |
1049 | "\">"; | |
1050 | ||
1051 | print "</form>"; | |
1052 | } | |
e513a74a | 1053 | |
33d32a3c AD |
1054 | $tp_uri = get_self_url_prefix() . "/prefs.php"; |
1055 | $tt_uri = get_self_url_prefix(); | |
6906f145 | 1056 | |
08ac193a | 1057 | if ($rc <= 2){ |
1058 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
1059 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
aa2122d4 | 1060 | |
08ac193a | 1061 | $feed_id = db_fetch_result($result, 0, "id"); |
1062 | } else { | |
1063 | $feed_id = 0; | |
1064 | } | |
a5819bb3 AD |
1065 | print "<p>"; |
1066 | ||
1067 | if ($feed_id) { | |
8ffd2011 | 1068 | print "<form method=\"GET\" style='display: inline' |
a5819bb3 AD |
1069 | action=\"$tp_uri\"> |
1070 | <input type=\"hidden\" name=\"tab\" value=\"feedConfig\"> | |
1071 | <input type=\"hidden\" name=\"subop\" value=\"editFeed\"> | |
1072 | <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\"> | |
1073 | <input type=\"submit\" value=\"".__("Edit subscription options")."\"> | |
1074 | </form>"; | |
aa2122d4 | 1075 | } |
442d77f1 | 1076 | |
a5819bb3 AD |
1077 | print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\"> |
1078 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
1079 | </form></p>"; | |
1080 | ||
1081 | print "</body></html>"; | |
1082 | return; | |
ef8be8ea AD |
1083 | } |
1084 | } | |
1085 | ||
ef8be8ea AD |
1086 | if ($subop == "categorize") { |
1087 | ||
ef8be8ea | 1088 | |
913f374b | 1089 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea | 1090 | |
913f374b | 1091 | $cat_id = db_escape_string($_REQUEST["cat_id"]); |
ef8be8ea | 1092 | |
913f374b AD |
1093 | if ($cat_id == 0) { |
1094 | $cat_id_qpart = 'NULL'; | |
1095 | } else { | |
1096 | $cat_id_qpart = "'$cat_id'"; | |
1097 | } | |
ef8be8ea | 1098 | |
913f374b | 1099 | db_query($link, "BEGIN"); |
ef8be8ea | 1100 | |
913f374b | 1101 | foreach ($ids as $id) { |
8ffd2011 | 1102 | |
913f374b | 1103 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart |
6e63a7c3 | 1104 | WHERE id = '$id' |
913f374b | 1105 | AND owner_uid = " . $_SESSION["uid"]); |
ef8be8ea | 1106 | |
ef8be8ea AD |
1107 | } |
1108 | ||
913f374b AD |
1109 | db_query($link, "COMMIT"); |
1110 | ||
ef8be8ea AD |
1111 | } |
1112 | ||
9c483746 AD |
1113 | if ($subop == "editCats") { |
1114 | ||
9c483746 AD |
1115 | $action = $_REQUEST["action"]; |
1116 | ||
1117 | if ($action == "save") { | |
1118 | ||
11f083e7 | 1119 | $cat_title = db_escape_string(trim($_REQUEST["value"])); |
b4e75b2a | 1120 | $cat_id = db_escape_string($_REQUEST["cid"]); |
11f083e7 | 1121 | |
8f708155 AD |
1122 | db_query($link, "BEGIN"); |
1123 | ||
1124 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
1125 | WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
1126 | ||
1127 | if (db_num_rows($result) == 1) { | |
1128 | ||
1129 | $old_title = db_fetch_result($result, 0, "title"); | |
8ffd2011 | 1130 | |
8f708155 AD |
1131 | if ($cat_title != "") { |
1132 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
8ffd2011 | 1133 | title = '$cat_title' WHERE id = '$cat_id' AND |
8f708155 AD |
1134 | owner_uid = ".$_SESSION["uid"]); |
1135 | ||
1136 | print $cat_title; | |
1137 | } else { | |
1138 | print $old_title; | |
1139 | } | |
1140 | } else { | |
1141 | print $_REQUEST["value"]; | |
1142 | } | |
1143 | ||
1144 | db_query($link, "COMMIT"); | |
11f083e7 AD |
1145 | |
1146 | return; | |
1147 | ||
9c483746 AD |
1148 | } |
1149 | ||
1150 | if ($action == "add") { | |
1151 | ||
913f374b AD |
1152 | $feed_cat = db_escape_string(trim($_REQUEST["cat"])); |
1153 | ||
5c7c7da9 AD |
1154 | if (!add_feed_category($link, $feed_cat)) |
1155 | print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", $feed_cat)); | |
913f374b | 1156 | |
9c483746 AD |
1157 | } |
1158 | ||
1159 | if ($action == "remove") { | |
8ffd2011 | 1160 | |
b4e75b2a | 1161 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
8ffd2011 | 1162 | |
7e329f13 AD |
1163 | foreach ($ids as $id) { |
1164 | remove_feed_category($link, $id, $_SESSION["uid"]); | |
9c483746 AD |
1165 | } |
1166 | } | |
1167 | ||
a8328019 | 1168 | print "<div dojoType=\"dijit.Toolbar\"> |
da1f74c9 AD |
1169 | <input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\"> |
1170 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">". | |
1171 | __('Create category')."</button></div>"; | |
8ffd2011 | 1172 | |
9c483746 AD |
1173 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories |
1174 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1175 | ORDER BY title"); | |
1176 | ||
a8328019 | 1177 | # print "<p>"; |
9c483746 AD |
1178 | |
1179 | if (db_num_rows($result) != 0) { | |
1180 | ||
9c483746 AD |
1181 | print "<div class=\"prefFeedCatHolder\">"; |
1182 | ||
da1f74c9 | 1183 | # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">"; |
9c483746 | 1184 | |
8ffd2011 | 1185 | print "<table width=\"100%\" class=\"prefFeedCatList\" |
9c483746 | 1186 | cellspacing=\"0\" id=\"prefFeedCatList\">"; |
8ffd2011 | 1187 | |
9c483746 | 1188 | $lnum = 0; |
8ffd2011 | 1189 | |
9c483746 | 1190 | while ($line = db_fetch_assoc($result)) { |
8ffd2011 | 1191 | |
9c483746 | 1192 | $class = ($lnum % 2) ? "even" : "odd"; |
8ffd2011 | 1193 | |
9c483746 | 1194 | $cat_id = $line["id"]; |
11f083e7 | 1195 | $this_row_id = "id=\"FCATR-$cat_id\""; |
8ffd2011 | 1196 | |
a8328019 | 1197 | print "<tr class=\"\" $this_row_id>"; |
8ffd2011 | 1198 | |
47439031 | 1199 | $edit_title = htmlspecialchars($line["title"]); |
8ffd2011 AD |
1200 | |
1201 | print "<td width='5%' align='center'><input | |
1202 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
22988692 | 1203 | type=\"checkbox\"></td>"; |
8ffd2011 | 1204 | |
44e05f79 | 1205 | print "<td>"; |
44e05f79 | 1206 | |
8ffd2011 AD |
1207 | # print "<span id=\"FCATT-$cat_id\">" . |
1208 | # $edit_title . "</span>"; | |
1209 | ||
1210 | print "<span dojoType=\"dijit.InlineEditBox\" | |
44e05f79 | 1211 | width=\"300px\" autoSave=\"false\" |
8ffd2011 | 1212 | cat-id=\"$cat_id\">" . $edit_title . |
44e05f79 AD |
1213 | "<script type=\"dojo/method\" event=\"onChange\" args=\"item\"> |
1214 | var elem = this; | |
1215 | dojo.xhrPost({ | |
1216 | url: 'backend.php', | |
1217 | content: {op: 'pref-feeds', subop: 'editCats', | |
1218 | action: 'save', | |
1219 | value: this.value, | |
1220 | cid: this.srcNodeRef.getAttribute('cat-id')}, | |
1221 | load: function(response) { | |
1222 | elem.attr('value', response); | |
da1f74c9 | 1223 | updateFeedList(); |
44e05f79 | 1224 | } |
8ffd2011 | 1225 | }); |
44e05f79 AD |
1226 | </script> |
1227 | </span>"; | |
1228 | ||
1229 | print "</td></tr>"; | |
8ffd2011 | 1230 | |
9c483746 AD |
1231 | ++$lnum; |
1232 | } | |
8ffd2011 | 1233 | |
9c483746 AD |
1234 | print "</table>"; |
1235 | ||
da1f74c9 | 1236 | # print "</form>"; |
9c483746 AD |
1237 | |
1238 | print "</div>"; | |
1239 | ||
6f5b1e04 | 1240 | } else { |
31cc42f6 | 1241 | print "<p>".__('No feed categories defined.')."</p>"; |
6f5b1e04 | 1242 | } |
9c483746 | 1243 | |
d60009cd AD |
1244 | print "<div class='dlgButtons'> |
1245 | <div style='float : left'> | |
da1f74c9 AD |
1246 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">". |
1247 | __('Remove selected categories')."</button> | |
d60009cd | 1248 | </div>"; |
9c483746 | 1249 | |
da1f74c9 | 1250 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">". |
d60009cd | 1251 | __('Close this window')."</button></div>"; |
9c483746 AD |
1252 | |
1253 | return; | |
1254 | ||
1255 | } | |
1256 | ||
ef8be8ea AD |
1257 | if ($quiet) return; |
1258 | ||
8df7184c | 1259 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; |
29f11825 | 1260 | print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">"; |
8df7184c | 1261 | |
a3656a41 | 1262 | $result = db_query($link, "SELECT COUNT(id) AS num_errors |
ef8be8ea AD |
1263 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); |
1264 | ||
a3656a41 | 1265 | $num_errors = db_fetch_result($result, 0, "num_errors"); |
ef8be8ea | 1266 | |
a3656a41 | 1267 | if ($num_errors > 0) { |
ef8be8ea | 1268 | |
49c6c279 | 1269 | $error_button = "<button dojoType=\"dijit.form.Button\" |
8ffd2011 | 1270 | onclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . |
49c6c279 AD |
1271 | __("Feeds with errors") . "</button>"; |
1272 | ||
1273 | // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">". | |
1274 | // __('Some feeds have update errors (click for details)')."</a>"); | |
ef8be8ea AD |
1275 | } |
1276 | ||
8ffd2011 AD |
1277 | if (DB_TYPE == "pgsql") { |
1278 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1279 | } else { | |
1280 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1281 | } | |
1282 | ||
1283 | $result = db_query($link, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE | |
1284 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
1285 | ttrss_entries.id = ref_id AND | |
1286 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND | |
1287 | ttrss_feeds.owner_uid = ".$_SESSION["uid"]); | |
1288 | ||
1289 | $num_inactive = db_fetch_result($result, 0, "num_inactive"); | |
1290 | ||
1291 | if ($num_inactive > 0) { | |
1292 | $inactive_button = "<button dojoType=\"dijit.form.Button\" | |
1293 | onclick=\"showInactiveFeeds()\">" . | |
1294 | __("Inactive feeds") . "</button>"; | |
1295 | } | |
1296 | ||
b4e75b2a | 1297 | $feed_search = db_escape_string($_REQUEST["search"]); |
ef8be8ea | 1298 | |
b4e75b2a | 1299 | if (array_key_exists("search", $_REQUEST)) { |
ef8be8ea AD |
1300 | $_SESSION["prefs_feed_search"] = $feed_search; |
1301 | } else { | |
1302 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1303 | } | |
1304 | ||
8df7184c AD |
1305 | print "<div dojoType=\"dijit.Toolbar\">"; |
1306 | ||
1985a5e0 | 1307 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
d69fa6d6 | 1308 | "<span>" . __('Select')."</span>"; |
1985a5e0 | 1309 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
8ffd2011 | 1310 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\" |
1985a5e0 | 1311 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
8ffd2011 | 1312 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\" |
1985a5e0 | 1313 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; |
d69fa6d6 | 1314 | print "</div></div>"; |
1e5548db | 1315 | |
7b8a143f AD |
1316 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
1317 | "<span>" . __('Feeds')."</span>"; | |
1318 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
8ffd2011 | 1319 | print "<div onclick=\"quickAddFeed()\" |
7b8a143f | 1320 | dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>"; |
8ffd2011 | 1321 | print "<div onclick=\"editSelectedFeed()\" |
82aea978 | 1322 | dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>"; |
8ffd2011 | 1323 | print "<div onclick=\"resetFeedOrder()\" |
7b8a143f AD |
1324 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; |
1325 | print "</div></div>"; | |
1e5548db AD |
1326 | |
1327 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
7b8a143f AD |
1328 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
1329 | "<span>" . __('Categories')."</span>"; | |
1330 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
8ffd2011 | 1331 | print "<div onclick=\"editFeedCats()\" |
7b8a143f | 1332 | dojoType=\"dijit.MenuItem\">".__('Edit categories')."</div>"; |
8ffd2011 | 1333 | print "<div onclick=\"resetCatOrder()\" |
7b8a143f AD |
1334 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; |
1335 | print "</div></div>"; | |
1e5548db | 1336 | |
1e5548db AD |
1337 | } |
1338 | ||
49c6c279 | 1339 | print $error_button; |
8ffd2011 | 1340 | print $inactive_button; |
49c6c279 | 1341 | |
1985a5e0 AD |
1342 | print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">" |
1343 | .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> "; | |
1e5548db | 1344 | |
a522a767 | 1345 | if (defined('_ENABLE_FEED_DEBUGGING')) { |
ef8be8ea | 1346 | |
a522a767 AD |
1347 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> |
1348 | <option value=\"facDefault\" selected>".__('More actions...')."</option>"; | |
8ffd2011 | 1349 | |
a522a767 | 1350 | if (FORCE_ARTICLE_PURGE == 0) { |
8ffd2011 | 1351 | |
a522a767 AD |
1352 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; |
1353 | } | |
8ffd2011 | 1354 | |
a522a767 AD |
1355 | print " |
1356 | <option value=\"facClear\">".__('Clear feed data')."</option> | |
1357 | <option value=\"facRescore\">".__('Rescore articles')."</option>"; | |
8ffd2011 | 1358 | |
a522a767 | 1359 | print "</select>"; |
0b9751cd | 1360 | |
a522a767 | 1361 | } |
0b9751cd | 1362 | |
8df7184c AD |
1363 | print "</div>"; # toolbar |
1364 | ||
1985a5e0 AD |
1365 | print "<div id=\"feedlistLoading\"> |
1366 | <img src='images/indicator_tiny.gif'>". | |
1367 | __("Loading, please wait...")."</div>"; | |
1368 | ||
8ffd2011 | 1369 | print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\" |
7b8a143f | 1370 | url=\"backend.php?op=pref-feeds&subop=getfeedtree\"> |
1985a5e0 AD |
1371 | </div> |
1372 | <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\" | |
1373 | query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\" | |
1374 | childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\"> | |
1375 | </div> | |
8ffd2011 AD |
1376 | <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\" |
1377 | dndController=\"dijit.tree.dndSource\" | |
7b8a143f | 1378 | betweenThreshold=\"5\" |
1985a5e0 AD |
1379 | model=\"feedModel\" openOnClick=\"false\"> |
1380 | <script type=\"dojo/method\" event=\"onClick\" args=\"item\"> | |
1381 | var id = String(item.id); | |
1382 | var bare_id = id.substr(id.indexOf(':')+1); | |
1383 | ||
7b8a143f | 1384 | if (id.match('FEED:')) { |
8a097fa3 | 1385 | editFeed(bare_id); |
7b8a143f | 1386 | } else if (id.match('CAT:')) { |
8a097fa3 | 1387 | editCat(bare_id, item); |
8ffd2011 | 1388 | } |
1985a5e0 AD |
1389 | </script> |
1390 | <script type=\"dojo/method\" event=\"onLoad\" args=\"item\"> | |
1391 | Element.hide(\"feedlistLoading\"); | |
1392 | </script> | |
1985a5e0 AD |
1393 | </div>"; |
1394 | ||
a740f4b5 | 1395 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\"> |
57e24c82 | 1396 | ".__('<b>Hint:</b> you can drag feeds and categories around.')." |
a740f4b5 AD |
1397 | </div>"; |
1398 | ||
8df7184c | 1399 | print "</div>"; # feeds pane |
94a4ba88 | 1400 | |
8df7184c | 1401 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">"; |
b6a6e262 | 1402 | |
00a35bb6 AD |
1403 | print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings."); |
1404 | ||
254ac705 | 1405 | print "<div class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</div>"; |
c107797c | 1406 | |
00a35bb6 AD |
1407 | print "</p>"; |
1408 | ||
8ffd2011 | 1409 | print "<iframe id=\"upload_iframe\" |
e1218480 | 1410 | name=\"upload_iframe\" onload=\"opmlImportComplete(this)\" |
b6a6e262 AD |
1411 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; |
1412 | ||
b6a6e262 | 1413 | print "<form style='display : block' target=\"upload_iframe\" |
8ffd2011 | 1414 | enctype=\"multipart/form-data\" method=\"POST\" |
b6a6e262 AD |
1415 | action=\"backend.php\"> |
1416 | <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
1417 | <input type=\"hidden\" name=\"op\" value=\"dlg\"> | |
1418 | <input type=\"hidden\" name=\"id\" value=\"importOpml\"> | |
d2d75353 | 1419 | <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" |
b6a6e262 | 1420 | type=\"submit\">".__('Import')."</button> |
d2d75353 | 1421 | <button dojoType=\"dijit.form.Button\" onclick=\"gotoExportOpml()\">".__('Export OPML')."</button> |
b6a6e262 | 1422 | </form>"; |
94a4ba88 | 1423 | |
c107797c AD |
1424 | print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.'); |
1425 | ||
1426 | print "<div class=\"insensitive\">" . __("Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</div>" . "</p>"; | |
e4f4b46f | 1427 | |
d2d75353 | 1428 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">". |
c107797c AD |
1429 | __('Display URL')."</button> "; |
1430 | ||
1431 | ||
8df7184c AD |
1432 | print "</div>"; # pane |
1433 | ||
68313e5d | 1434 | if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) { |
8df7184c AD |
1435 | |
1436 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">"; | |
8ffd2011 | 1437 | |
c107797c | 1438 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>"; |
cf9dc032 | 1439 | |
68313e5d | 1440 | print "<p>"; |
cf9dc032 | 1441 | |
c107797c | 1442 | print "<button onclick='window.navigator.registerContentHandler(" . |
755a43ee AD |
1443 | "\"application/vnd.mozilla.maybe.feed\", " . |
1444 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
8ffd2011 | 1445 | __('Click here to register this site as a feed reader.') . |
cf9dc032 | 1446 | "</button>"; |
755a43ee | 1447 | |
c107797c | 1448 | print "</p>"; |
755a43ee | 1449 | |
8df7184c AD |
1450 | print "</div>"; # pane |
1451 | } | |
46dc1538 | 1452 | |
8df7184c | 1453 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Subscribing using bookmarklet')."\">"; |
8ffd2011 | 1454 | |
46dc1538 AD |
1455 | print "<p>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</p>"; |
1456 | ||
1457 | $bm_subscribe_url = str_replace('%s', '', add_feed_url()); | |
1458 | ||
1459 | $confirm_str = __('Subscribe to %s in Tiny Tiny RSS?'); | |
1460 | ||
1461 | $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}"); | |
1462 | ||
d2d75353 | 1463 | print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Subscribe in Tiny Tiny RSS'). "</a>"; |
46dc1538 | 1464 | |
8df7184c AD |
1465 | print "</div>"; #pane |
1466 | ||
1467 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published articles and generated feeds')."\">"; | |
e4f4b46f | 1468 | |
e635d56a | 1469 | print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>"; |
e4f4b46f | 1470 | |
8ffd2011 | 1471 | $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . |
8801fb01 AD |
1472 | "/backend.php?op=rss&id=-2&view-mode=all_articles");; |
1473 | ||
d2d75353 | 1474 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('generatedFeed', '$rss_url')\">". |
cf9dc032 | 1475 | __('Display URL')."</button> "; |
8ffd2011 | 1476 | |
d2d75353 | 1477 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">". |
8d86f15f | 1478 | __('Clear all generated URLs')."</button> "; |
e4f4b46f | 1479 | |
8df7184c | 1480 | print "</div>"; #pane |
57e24c82 | 1481 | |
392b6d04 | 1482 | if (defined('CONSUMER_KEY') && CONSUMER_KEY != '') { |
57e24c82 | 1483 | |
392b6d04 | 1484 | print "<div id=\"pref-feeds-twitter\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Twitter')."\">"; |
8ffd2011 | 1485 | |
392b6d04 AD |
1486 | $result = db_query($link, "SELECT COUNT(*) AS cid FROM ttrss_users |
1487 | WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND | |
1488 | id = " . $_SESSION['uid']); | |
8ffd2011 | 1489 | |
392b6d04 | 1490 | $is_registered = db_fetch_result($result, 0, "cid") != 0; |
8ffd2011 | 1491 | |
392b6d04 AD |
1492 | if (!$is_registered) { |
1493 | print_notice(__('Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.')); | |
1494 | } else { | |
1495 | print_notice(__('You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.')); | |
1496 | } | |
8ffd2011 | 1497 | |
392b6d04 AD |
1498 | print "<button dojoType=\"dijit.form.Button\" onclick=\"window.location.href = 'twitter.php?op=register'\">". |
1499 | __("Register with Twitter.com")."</button>"; | |
8ffd2011 | 1500 | |
392b6d04 | 1501 | print " "; |
8ffd2011 AD |
1502 | |
1503 | print "<button dojoType=\"dijit.form.Button\" | |
392b6d04 AD |
1504 | onclick=\"return clearTwitterCredentials()\">". |
1505 | __("Clear stored credentials")."</button>"; | |
8ffd2011 | 1506 | |
392b6d04 | 1507 | print "</div>"; # pane |
57e24c82 | 1508 | |
57e24c82 AD |
1509 | } |
1510 | ||
8df7184c AD |
1511 | print "</div>"; #container |
1512 | ||
ef8be8ea | 1513 | } |
b56465dd | 1514 | |
4a16bda3 | 1515 | function make_feed_browser($link, $search, $limit, $mode = 1) { |
b56465dd | 1516 | |
4a16bda3 AD |
1517 | $owner_uid = $_SESSION["uid"]; |
1518 | $rv = ''; | |
c2913898 AD |
1519 | |
1520 | if ($search) { | |
8ffd2011 | 1521 | $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR |
c2913898 AD |
1522 | UPPER(title) LIKE UPPER('%$search%'))"; |
1523 | } else { | |
1524 | $search_qpart = ""; | |
1525 | } | |
1526 | ||
082ae95b AD |
1527 | if ($mode == 1) { |
1528 | $result = db_query($link, "SELECT feed_url, subscribers FROM | |
1529 | ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
1530 | WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url | |
8ffd2011 | 1531 | AND owner_uid = '$owner_uid') $search_qpart |
082ae95b AD |
1532 | ORDER BY subscribers DESC LIMIT $limit"); |
1533 | } else if ($mode == 2) { | |
ef88b1cc AD |
1534 | $result = db_query($link, "SELECT *, |
1535 | (SELECT COUNT(*) FROM ttrss_user_entries WHERE | |
1536 | orig_feed_id = ttrss_archived_feeds.id) AS articles_archived | |
1537 | FROM | |
1538 | ttrss_archived_feeds | |
8ffd2011 AD |
1539 | WHERE |
1540 | (SELECT COUNT(*) FROM ttrss_feeds | |
082ae95b | 1541 | WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND |
8ffd2011 AD |
1542 | owner_uid = '$owner_uid') = 0 AND |
1543 | owner_uid = '$owner_uid' $search_qpart | |
082ae95b AD |
1544 | ORDER BY id DESC LIMIT $limit"); |
1545 | } | |
b56465dd AD |
1546 | |
1547 | $feedctr = 0; | |
8ffd2011 | 1548 | |
b56465dd | 1549 | while ($line = db_fetch_assoc($result)) { |
b56465dd | 1550 | |
082ae95b | 1551 | if ($mode == 1) { |
b56465dd | 1552 | |
2211a391 | 1553 | $feed_url = $line["feed_url"]; |
082ae95b | 1554 | $subscribers = $line["subscribers"]; |
2211a391 | 1555 | |
8ffd2011 | 1556 | $det_result = db_query($link, "SELECT site_url,title,id |
082ae95b | 1557 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); |
8ffd2011 | 1558 | |
082ae95b | 1559 | $details = db_fetch_assoc($det_result); |
8ffd2011 | 1560 | |
082ae95b | 1561 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; |
8ffd2011 | 1562 | |
082ae95b | 1563 | if (file_exists($icon_file) && filesize($icon_file) > 0) { |
8ffd2011 | 1564 | $feed_icon = "<img style=\"vertical-align : middle\" class=\"tinyFeedIcon\" src=\"" . ICONS_URL . |
082ae95b AD |
1565 | "/".$details["id"].".ico\">"; |
1566 | } else { | |
1567 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1568 | } | |
8ffd2011 AD |
1569 | |
1570 | $check_box = "<input onclick='toggleSelectListRow2(this)' | |
a8328019 | 1571 | dojoType=\"dijit.form.CheckBox\" |
11b9d0be | 1572 | type=\"checkbox\" \">"; |
8ffd2011 | 1573 | |
082ae95b | 1574 | $class = ($feedctr % 2) ? "even" : "odd"; |
8ffd2011 | 1575 | |
2211a391 AD |
1576 | $feed_url = htmlspecialchars($line["feed_url"]); |
1577 | ||
082ae95b | 1578 | if ($details["site_url"]) { |
ef88b1cc AD |
1579 | $site_url = "<a target=\"_blank\" href=\"". |
1580 | htmlspecialchars($details["site_url"])."\"> | |
082ae95b AD |
1581 | <img style='border-width : 0px' src='images/www.png' alt='www'></a>"; |
1582 | } else { | |
1583 | $site_url = ""; | |
1584 | } | |
e15bb6f7 | 1585 | |
8ffd2011 AD |
1586 | $feed_url = "<a target=\"_blank\" href=\"$feed_url\"><img |
1587 | style='border-width : 0px; vertical-align : middle' | |
e15bb6f7 AD |
1588 | src='images/feed-icon-12x12.png'></a>"; |
1589 | ||
8ffd2011 | 1590 | $rv .= "<li title=\"".htmlspecialchars($details["site_url"])."\" |
a8328019 | 1591 | id=\"FBROW-".$details["id"]."\">$check_box". |
8ffd2011 | 1592 | "$feed_icon $feed_url " . htmlspecialchars($details["title"]) . |
082ae95b | 1593 | " <span class='subscribers'>($subscribers)</span> |
ef88b1cc | 1594 | $site_url</li>"; |
8ffd2011 | 1595 | |
082ae95b | 1596 | } else if ($mode == 2) { |
ef88b1cc | 1597 | $feed_url = htmlspecialchars($line["feed_url"]); |
8ffd2011 | 1598 | $site_url = htmlspecialchars($line["site_url"]); |
ef88b1cc | 1599 | $title = htmlspecialchars($line["title"]); |
69877646 AD |
1600 | |
1601 | $icon_file = ICONS_DIR . "/" . $line["id"] . ".ico"; | |
8ffd2011 | 1602 | |
69877646 | 1603 | if (file_exists($icon_file) && filesize($icon_file) > 0) { |
8ffd2011 | 1604 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . |
69877646 AD |
1605 | "/".$line["id"].".ico\">"; |
1606 | } else { | |
1607 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1608 | } | |
1609 | ||
11b9d0be AD |
1610 | $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType=\"dijit.form.CheckBox\" |
1611 | type=\"checkbox\">"; | |
8ffd2011 | 1612 | |
082ae95b | 1613 | $class = ($feedctr % 2) ? "even" : "odd"; |
ef88b1cc AD |
1614 | |
1615 | if ($line['articles_archived'] > 0) { | |
1616 | $archived = sprintf(__("%d archived articles"), $line['articles_archived']); | |
1617 | $archived = " <span class='subscribers'>($archived)</span>"; | |
1618 | } else { | |
1619 | $archived = ''; | |
1620 | } | |
1621 | ||
082ae95b | 1622 | if ($line["site_url"]) { |
ef88b1cc | 1623 | $site_url = "<a target=\"_blank\" href=\"$site_url\"> |
082ae95b AD |
1624 | <img style='border-width : 0px' src='images/www.png' alt='www'></a>"; |
1625 | } else { | |
1626 | $site_url = ""; | |
1627 | } | |
e15bb6f7 | 1628 | |
8ffd2011 AD |
1629 | $feed_url = "<a target=\"_blank\" href=\"$feed_url\"><img |
1630 | style='border-width : 0px; vertical-align : middle' | |
e15bb6f7 AD |
1631 | src='images/feed-icon-12x12.png'></a>"; |
1632 | ||
8ffd2011 | 1633 | $rv .= "<li title='".$line['site_url']."' class='$class' |
ef88b1cc | 1634 | id=\"FBROW-".$line["id"]."\">". |
8ffd2011 | 1635 | $check_box . "$feed_icon $feed_url " . $title . |
e15bb6f7 | 1636 | $archived . $site_url . "</li>"; |
b56465dd | 1637 | |
b56465dd | 1638 | |
2bab8824 AD |
1639 | } |
1640 | ||
082ae95b | 1641 | ++$feedctr; |
b56465dd AD |
1642 | } |
1643 | ||
1644 | if ($feedctr == 0) { | |
4a16bda3 | 1645 | $rv .= "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>"; |
b56465dd AD |
1646 | } |
1647 | ||
4a16bda3 | 1648 | return $rv; |
b56465dd AD |
1649 | |
1650 | } | |
a5819bb3 | 1651 | |
ef8be8ea | 1652 | ?> |