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