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