]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
68535562f21debf43a88d238e54860a035a13550
2 class Pref_Feeds
extends Handler_Protected
{
4 function csrf_ignore ( $method ) {
5 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
6 "savefeedorder" , "uploadicon" , "feedswitherrors" , "inactivefeeds" ,
9 return array_search ( $method , $csrf_ignored ) !== false ;
12 function batch_edit_cbox ( $elem , $label = false ) {
13 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
14 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
17 function renamecat () {
18 $title = db_escape_string ( $this -> link
, $_REQUEST [ 'title' ]);
19 $id = db_escape_string ( $this -> link
, $_REQUEST [ 'id' ]);
22 db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
23 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
28 private function get_category_items ( $cat_id ) {
30 if ( $_REQUEST [ 'mode' ] != 2 )
31 $search = $_SESSION [ "prefs_feed_search" ];
35 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
37 // first one is set by API
38 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
39 ( $_REQUEST [ 'mode' ] != 2 && ! $search &&
40 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ));
44 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
45 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
47 while ( $line = db_fetch_assoc ( $result )) {
50 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
51 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
52 $cat [ 'name' ] = $line [ 'title' ];
53 $cat [ 'items' ] = array ();
54 $cat [ 'checkbox' ] = false ;
55 $cat [ 'type' ] = 'category' ;
57 $cat [ 'child_unread' ] = 0 ;
59 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
61 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
63 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
64 array_push ( $items , $cat );
68 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
69 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
71 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
72 " $search_qpart ORDER BY order_id, title" );
74 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
76 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
77 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
78 $feed [ 'name' ] = $feed_line [ 'title' ];
79 $feed [ 'checkbox' ] = false ;
81 $feed [ 'error' ] = $feed_line [ 'last_error' ];
82 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
83 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
84 $feed_line [ 'last_updated' ], true );
86 array_push ( $items , $feed );
92 function getfeedtree () {
93 print json_encode ( $this -> makefeedtree ());
96 function makefeedtree () {
98 if ( $_REQUEST [ 'mode' ] != 2 )
99 $search = $_SESSION [ "prefs_feed_search" ];
103 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
106 $root [ 'id' ] = 'root' ;
107 $root [ 'name' ] = __ ( 'Feeds' );
108 $root [ 'items' ] = array ();
109 $root [ 'type' ] = 'category' ;
111 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
113 if ( $_REQUEST [ 'mode' ] == 2 ) {
116 $cat = $this -> feedlist_init_cat (- 1 );
118 $cat [ 'items' ] = array ();
121 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
122 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
125 /* Plugin feeds for -1 */
129 $feeds = $pluginhost -> get_feeds (- 1 );
132 foreach ( $feeds as $feed ) {
133 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
136 $item [ 'id' ] = 'FEED:' . $feed_id ;
137 $item [ 'bare_id' ] = ( int ) $feed_id ;
138 $item [ 'name' ] = $feed [ 'title' ];
139 $item [ 'checkbox' ] = false ;
141 $item [ 'icon' ] = $feed [ 'icon' ];
144 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
145 $item [ 'type' ] = 'feed' ;
147 array_push ( $cat [ 'items' ], $item );
152 array_push ( $root [ 'items' ], $cat );
154 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
157 $result = db_query ( $this -> link
, "SELECT * FROM
158 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
160 if ( db_num_rows ( $result ) > 0 ) {
162 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
163 $cat = $this -> feedlist_init_cat (- 2 );
165 $cat [ 'items' ] = array ();
168 while ( $line = db_fetch_assoc ( $result )) {
170 $label_id = label_to_feed_id ( $line [ 'id' ]);
172 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
174 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
175 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
177 array_push ( $cat [ 'items' ], $feed );
181 array_push ( $root [ 'items' ], $cat );
183 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
189 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
190 ( $_REQUEST [ 'mode' ] != 2 && ! $search &&
191 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ));
193 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
194 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
196 while ( $line = db_fetch_assoc ( $result )) {
198 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
199 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
200 $cat [ 'name' ] = $line [ 'title' ];
201 $cat [ 'items' ] = array ();
202 $cat [ 'checkbox' ] = false ;
203 $cat [ 'type' ] = 'category' ;
205 $cat [ 'child_unread' ] = 0 ;
207 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
209 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
211 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
212 array_push ( $root [ 'items' ], $cat );
214 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
217 /* Uncategorized is a special case */
220 $cat [ 'id' ] = 'CAT:0' ;
222 $cat [ 'name' ] = __ ( "Uncategorized" );
223 $cat [ 'items' ] = array ();
224 $cat [ 'type' ] = 'category' ;
225 $cat [ 'checkbox' ] = false ;
227 $cat [ 'child_unread' ] = 0 ;
229 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
230 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
232 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
233 " $search_qpart ORDER BY order_id, title" );
235 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
237 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
238 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
239 $feed [ 'name' ] = $feed_line [ 'title' ];
240 $feed [ 'checkbox' ] = false ;
241 $feed [ 'error' ] = $feed_line [ 'last_error' ];
242 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
243 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
244 $feed_line [ 'last_updated' ], true );
246 $feed [ 'type' ] = 'feed' ;
248 array_push ( $cat [ 'items' ], $feed );
251 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
253 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
254 array_push ( $root [ 'items' ], $cat );
256 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
257 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
260 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
261 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
263 WHERE owner_uid = " . $_SESSION [ "uid" ].
264 " $search_qpart ORDER BY order_id, title" );
266 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
268 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
269 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
270 $feed [ 'name' ] = $feed_line [ 'title' ];
271 $feed [ 'checkbox' ] = false ;
272 $feed [ 'error' ] = $feed_line [ 'last_error' ];
273 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
274 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
275 $feed_line [ 'last_updated' ], true );
277 $feed [ 'type' ] = 'feed' ;
279 array_push ( $root [ 'items' ], $feed );
282 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
286 $fl [ 'identifier' ] = 'id' ;
287 $fl [ 'label' ] = 'name' ;
289 if ( $_REQUEST [ 'mode' ] != 2 ) {
290 $fl [ 'items' ] = array ( $root );
292 $fl [ 'items' ] =& $root [ 'items' ];
298 function catsortreset () {
299 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
300 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
304 function feedsortreset () {
305 db_query ( $this -> link
, "UPDATE ttrss_feeds
306 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
310 function togglehiddenfeedcats () {
311 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
312 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
315 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
316 $debug = isset ( $_REQUEST [ "debug" ]);
319 for ( $i = 0 ; $i < $nest_level ; $i ++
)
322 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
324 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
326 if ( $item_id != 'root' ) {
327 if ( $parent_id && $parent_id != 'root' ) {
328 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
329 $parent_qpart = db_escape_string ( $this -> link
, $parent_bare_id );
331 $parent_qpart = 'NULL' ;
334 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
335 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
336 owner_uid = " . $_SESSION [ "uid" ]);
341 $cat = $data_map [ $item_id ];
343 if ( $cat && is_array ( $cat )) {
344 foreach ( $cat as $item ) {
345 $id = $item [ '_reference' ];
346 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
348 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
350 if ( $item [ '_reference' ]) {
352 if ( strpos ( $id , "FEED" ) === 0 ) {
354 $cat_id = ( $item_id != "root" ) ?
355 db_escape_string ( $this -> link
, $bare_item_id ) : "NULL" ;
357 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
360 db_query ( $this -> link
, "UPDATE ttrss_feeds
361 SET order_id = $order_id , $cat_qpart
362 WHERE id = ' $bare_id ' AND
363 owner_uid = " . $_SESSION [ "uid" ]);
365 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
366 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
369 if ( $item_id != 'root' ) {
370 $parent_qpart = db_escape_string ( $this -> link
, $bare_id );
372 $parent_qpart = 'NULL' ;
375 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
376 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
377 owner_uid = " . $_SESSION [ "uid" ]);
386 function savefeedorder () {
387 $data = json_decode ( $_POST [ 'payload' ], true );
389 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
390 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
392 if (! is_array ( $data [ 'items' ]))
393 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
395 # print_r($data['items']);
397 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
403 foreach ( $data [ 'items' ] as $item ) {
405 # if ($item['id'] != 'root') {
406 if ( is_array ( $item [ 'items' ])) {
407 if ( isset ( $item [ 'items' ][ '_reference' ])) {
408 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
410 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
413 if ( $item [ 'id' ] == 'root' ) {
414 $root_item = $item [ 'id' ];
418 $this -> process_category_order ( $data_map , $root_item );
420 /* foreach ($data['items'][0]['items'] as $item) {
421 $id = $item['_reference'];
422 $bare_id = substr($id, strpos($id, ':')+1);
427 db_query($this->link, "UPDATE ttrss_feed_categories
428 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
429 owner_uid = " . $_SESSION["uid"]);
434 if (is_array($data_map[$id])) {
435 foreach ($data_map[$id] as $feed) {
436 $id = $feed['_reference'];
437 $feed_id = substr($id, strpos($id, ':')+1);
440 $cat_query = "cat_id = '$bare_id'";
442 $cat_query = "cat_id = NULL";
444 db_query($this->link, "UPDATE ttrss_feeds
445 SET order_id = '$feed_order_id',
447 WHERE id = '$feed_id' AND
448 owner_uid = " . $_SESSION["uid"]);
459 function removeicon () {
460 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
462 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
463 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
465 if ( db_num_rows ( $result ) != 0 ) {
466 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
472 function uploadicon () {
473 header ( "Content-type: text/html" );
475 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
476 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
478 if ( is_file ( $icon_file ) && $feed_id ) {
479 if ( filesize ( $icon_file ) < 20000 ) {
481 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
482 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
484 if ( db_num_rows ( $result ) != 0 ) {
485 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
486 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
498 print "<script type= \" text/javascript \" >" ;
499 print "parent.uploadIconHandler( $rc );" ;
504 function editfeed () {
505 global $purge_intervals ;
506 global $update_intervals ;
508 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
510 $result = db_query ( $this -> link
,
511 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
512 owner_uid = " . $_SESSION [ "uid" ]);
514 $title = htmlspecialchars ( db_fetch_result ( $result ,
517 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
518 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
519 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
521 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
522 print "<div class= \" dlgSecCont \" >" ;
526 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
527 placeHolder= \" " . __ ( "Feed Title" ). " \"
528 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
532 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
533 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
538 print __ ( 'URL:' ) . " " ;
539 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
540 placeHolder= \" " . __ ( "Feed URL" ). " \"
541 regExp='^(http|https)://.*' style= \" width : 20em \"
542 name= \" feed_url \" value= \" $feed_url\" >" ;
544 $last_error = db_fetch_result ( $result , 0 , "last_error" );
547 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
548 class= \" feed_error \" >(error)</span>" ;
554 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
556 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
560 print __ ( 'Place in category:' ) . " " ;
562 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
563 'dojoType="dijit.form.Select"' );
568 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
569 print "<div class= \" dlgSecCont \" >" ;
571 /* Update Interval */
573 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
575 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
576 'dojoType="dijit.form.Select"' );
580 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
583 print __ ( 'Article purging:' ) . " " ;
585 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
586 'dojoType="dijit.form.Select" ' .
587 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
590 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
591 print "<div class= \" dlgSecCont \" >" ;
593 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
595 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
596 placeHolder= \" " . __ ( "Login" ). " \"
597 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
599 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
601 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
602 placeHolder= \" " . __ ( "Password" ). " \"
603 value= \" $auth_pass\" >" ;
605 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
606 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
610 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
611 print "<div class= \" dlgSecCont \" >" ;
613 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
616 $checked = "checked= \" 1 \" " ;
621 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
622 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
624 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
626 if ( $include_in_digest ) {
627 $checked = "checked= \" 1 \" " ;
632 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
633 name= \" include_in_digest \"
634 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
637 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
639 if ( $always_display_enclosures ) {
640 $checked = "checked" ;
645 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
646 name= \" always_display_enclosures \"
647 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
649 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
652 $checked = "checked= \" 1 \" " ;
657 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
659 $checked > <label for= \" hide_images \" >" .
660 __ ( 'Do not embed images' ). "</label>" ;
662 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
665 $checked = "checked= \" 1 \" " ;
670 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
671 name= \" cache_images \"
672 $checked > <label for= \" cache_images \" >" .
673 __ ( 'Cache images locally' ). "</label>" ;
675 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
677 if ( $mark_unread_on_update ) {
678 $checked = "checked" ;
683 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
684 name= \" mark_unread_on_update \"
685 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
691 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
692 print "<div class= \" dlgSecCont \" >" ;
694 print "<iframe name= \" icon_upload_iframe \"
695 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
697 print "<form style='display : block' target= \" icon_upload_iframe \"
698 enctype= \" multipart/form-data \" method= \" POST \"
699 action= \" backend.php \" >
700 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
701 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
702 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
703 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
704 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
705 type= \" submit \" >" . __ ( 'Replace' ). "</button>
706 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
707 type= \" submit \" >" . __ ( 'Remove' ). "</button>
712 $title = htmlspecialchars ( $title , ENT_QUOTES
);
714 print "<div class='dlgButtons'>
715 <div style= \" float : left \" >
716 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
717 __ ( 'Unsubscribe' ). "</button>" ;
719 if ( PUBSUBHUBBUB_ENABLED
) {
720 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
721 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
723 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
724 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
730 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
731 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
733 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
734 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
740 function editfeeds () {
741 global $purge_intervals ;
742 global $update_intervals ;
744 $feed_ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
746 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
750 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
751 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
752 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
754 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
755 print "<div class= \" dlgSecCont \" >" ;
759 print "<input dojoType= \" dijit.form.ValidationTextBox \"
760 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
761 name= \" title \" value= \" $title\" >" ;
763 $this -> batch_edit_cbox ( "title" );
769 print __ ( 'URL:' ) . " " ;
770 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
771 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
772 name= \" feed_url \" value= \" $feed_url\" >" ;
774 $this -> batch_edit_cbox ( "feed_url" );
778 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
782 print __ ( 'Place in category:' ) . " " ;
784 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
785 'disabled="1" dojoType="dijit.form.Select"' );
787 $this -> batch_edit_cbox ( "cat_id" );
793 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
794 print "<div class= \" dlgSecCont \" >" ;
796 /* Update Interval */
798 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
799 'disabled="1" dojoType="dijit.form.Select"' );
801 $this -> batch_edit_cbox ( "update_interval" );
805 if ( FORCE_ARTICLE_PURGE
== 0 ) {
809 print __ ( 'Article purging:' ) . " " ;
811 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
812 'disabled="1" dojoType="dijit.form.Select"' );
814 $this -> batch_edit_cbox ( "purge_interval" );
818 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
819 print "<div class= \" dlgSecCont \" >" ;
821 print "<input dojoType= \" dijit.form.TextBox \"
822 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
823 name= \" auth_login \" value= \" $auth_login\" >" ;
825 $this -> batch_edit_cbox ( "auth_login" );
827 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
828 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
829 value= \" $auth_pass\" >" ;
831 $this -> batch_edit_cbox ( "auth_pass" );
834 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
835 print "<div class= \" dlgSecCont \" >" ;
837 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
838 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
840 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
842 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
843 name= \" include_in_digest \"
844 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
846 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
848 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
849 name= \" always_display_enclosures \"
850 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
852 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
854 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
856 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
857 for= \" hide_images \" >" .
858 __ ( 'Do not embed images' ). "</label>" ;
860 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
862 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
863 name= \" cache_images \"
864 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
865 for= \" cache_images \" >" .
866 __ ( 'Cache images locally' ). "</label>" ;
868 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
870 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
871 name= \" mark_unread_on_update \"
872 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
874 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
878 print "<div class='dlgButtons'>
879 <button dojoType= \" dijit.form.Button \"
880 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
881 __ ( 'Save' ). "</button>
882 <button dojoType= \" dijit.form.Button \"
883 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
884 __ ( 'Cancel' ). "</button>
890 function batchEditSave () {
891 return $this -> editsaveops ( true );
894 function editSave () {
895 return $this -> editsaveops ( false );
898 function editsaveops ( $batch ) {
900 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
901 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
902 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
903 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
904 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
905 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
906 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
907 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
908 $auth_pass = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_pass" ]));
909 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
910 $include_in_digest = checkbox_to_sql_bool (
911 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
912 $cache_images = checkbox_to_sql_bool (
913 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
914 $hide_images = checkbox_to_sql_bool (
915 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
916 $always_display_enclosures = checkbox_to_sql_bool (
917 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
919 $mark_unread_on_update = checkbox_to_sql_bool (
920 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
922 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
923 if ( $cat_id && $cat_id != 0 ) {
924 $category_qpart = "cat_id = ' $cat_id '," ;
925 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
927 $category_qpart = 'cat_id = NULL,' ;
928 $category_qpart_nocomma = 'cat_id = NULL' ;
931 $category_qpart = "" ;
932 $category_qpart_nocomma = "" ;
937 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
939 title = ' $feed_title ', feed_url = ' $feed_link ',
940 update_interval = ' $upd_intl ',
941 purge_interval = ' $purge_intl ',
942 auth_login = ' $auth_login ',
943 auth_pass = ' $auth_pass ',
945 cache_images = $cache_images ,
946 hide_images = $hide_images ,
947 include_in_digest = $include_in_digest ,
948 always_display_enclosures = $always_display_enclosures ,
949 mark_unread_on_update = $mark_unread_on_update
950 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
953 $feed_data = array ();
955 foreach ( array_keys ( $_POST ) as $k ) {
956 if ( $k != "op" && $k != "method" && $k != "ids" ) {
957 $feed_data [ $k ] = $_POST [ $k ];
961 db_query ( $this -> link
, "BEGIN" );
963 foreach ( array_keys ( $feed_data ) as $k ) {
969 $qpart = "title = ' $feed_title '" ;
973 $qpart = "feed_url = ' $feed_link '" ;
976 case "update_interval" :
977 $qpart = "update_interval = ' $upd_intl '" ;
980 case "purge_interval" :
981 $qpart = "purge_interval = ' $purge_intl '" ;
985 $qpart = "auth_login = ' $auth_login '" ;
989 $qpart = "auth_pass = ' $auth_pass '" ;
993 $qpart = "private = $private " ;
996 case "include_in_digest" :
997 $qpart = "include_in_digest = $include_in_digest " ;
1000 case "always_display_enclosures" :
1001 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1004 case "mark_unread_on_update" :
1005 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1008 case "cache_images" :
1009 $qpart = "cache_images = $cache_images " ;
1013 $qpart = "hide_images = $hide_images " ;
1017 $qpart = $category_qpart_nocomma ;
1023 db_query ( $this -> link
,
1024 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1025 AND owner_uid = " . $_SESSION [ "uid" ]);
1030 db_query ( $this -> link
, "COMMIT" );
1035 function resetPubSub () {
1037 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1039 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1040 AND owner_uid = " . $_SESSION [ "uid" ]);
1047 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1049 foreach ( $ids as $id ) {
1050 Pref_Feeds
:: remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1057 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1058 $this -> clear_feed_articles ( $this -> link
, $id );
1061 function rescore () {
1062 require_once "rssfuncs.php" ;
1064 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1066 foreach ( $ids as $id ) {
1068 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1070 $result = db_query ( $this -> link
, "SELECT
1071 title, content, link, ref_id, author," .
1072 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1074 ttrss_user_entries, ttrss_entries
1075 WHERE ref_id = id AND feed_id = ' $id ' AND
1076 owner_uid = " . $_SESSION [ 'uid' ]. "
1081 while ( $line = db_fetch_assoc ( $result )) {
1083 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1085 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1086 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1087 $line [ 'author' ], $tags );
1089 $new_score = calculate_article_score ( $article_filters );
1091 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1093 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1096 foreach ( array_keys ( $scores ) as $s ) {
1098 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1100 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1101 } else if ( $s < - 500 ) {
1102 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1103 unread = false WHERE
1104 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1106 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1107 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1112 print __ ( "All done." );
1116 function rescoreAll () {
1118 $result = db_query ( $this -> link
,
1119 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1121 while ( $feed_line = db_fetch_assoc ( $result )) {
1123 $id = $feed_line [ "id" ];
1125 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1127 $tmp_result = db_query ( $this -> link
, "SELECT
1128 title, content, link, ref_id, author," .
1129 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1131 ttrss_user_entries, ttrss_entries
1132 WHERE ref_id = id AND feed_id = ' $id ' AND
1133 owner_uid = " . $_SESSION [ 'uid' ]. "
1138 while ( $line = db_fetch_assoc ( $tmp_result )) {
1140 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1142 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1143 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1144 $line [ 'author' ], $tags );
1146 $new_score = calculate_article_score ( $article_filters );
1148 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1150 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1153 foreach ( array_keys ( $scores ) as $s ) {
1155 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1157 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1159 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1160 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1165 print __ ( "All done." );
1169 function categorize () {
1170 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1172 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1175 $cat_id_qpart = 'NULL' ;
1177 $cat_id_qpart = "' $cat_id '" ;
1180 db_query ( $this -> link
, "BEGIN" );
1182 foreach ( $ids as $id ) {
1184 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1186 AND owner_uid = " . $_SESSION [ "uid" ]);
1190 db_query ( $this -> link
, "COMMIT" );
1193 function removeCat () {
1194 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1195 foreach ( $ids as $id ) {
1196 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1201 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1203 add_feed_category ( $this -> link
, $feed_cat );
1208 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1209 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1211 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1212 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1214 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1216 if ( $num_errors > 0 ) {
1218 $error_button = "<button dojoType= \" dijit.form.Button \"
1219 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1220 __ ( "Feeds with errors" ) . "</button>" ;
1223 if ( DB_TYPE
== "pgsql" ) {
1224 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1226 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1229 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1230 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1231 ttrss_entries.id = ref_id AND
1232 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1233 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1235 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1237 if ( $num_inactive > 0 ) {
1238 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1239 onclick= \" showInactiveFeeds() \" >" .
1240 __ ( "Inactive feeds" ) . "</button>" ;
1243 $feed_search = db_escape_string ( $this -> link
, $_REQUEST [ "search" ]);
1245 if ( array_key_exists ( "search" , $_REQUEST )) {
1246 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1248 $feed_search = $_SESSION [ "prefs_feed_search" ];
1251 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1253 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1255 print "<div style='float : right; padding-right : 4px;'>
1256 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1257 value= \" $feed_search\" >
1258 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1259 __ ( 'Search' ). "</button>
1262 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1263 "<span>" . __ ( 'Select' ). "</span>" ;
1264 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1265 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1266 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1267 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1268 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1269 print "</div></div>" ;
1271 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1272 "<span>" . __ ( 'Feeds' ). "</span>" ;
1273 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1274 print "<div onclick= \" quickAddFeed() \"
1275 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1276 print "<div onclick= \" editSelectedFeed() \"
1277 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1278 print "<div onclick= \" resetFeedOrder() \"
1279 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1280 print "<div onclick= \" batchSubscribe() \"
1281 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1282 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1283 . __ ( 'Unsubscribe' ). "</div> " ;
1284 print "</div></div>" ;
1286 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1287 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1288 "<span>" . __ ( 'Categories' ). "</span>" ;
1289 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1290 print "<div onclick= \" createCategory() \"
1291 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1292 print "<div onclick= \" resetCatOrder() \"
1293 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1294 print "<div onclick= \" removeSelectedCategories() \"
1295 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1296 print "</div></div>" ;
1300 print $error_button ;
1301 print $inactive_button ;
1303 print "<button onclick= \" toggleHiddenFeedCats() \"
1304 dojoType= \" dijit.form.Button \" >" . __ ( '(Un)hide empty categories' ). "</button>" ;
1306 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1308 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1309 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1311 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1313 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1317 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1318 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1324 print "</div>" ; # toolbar
1327 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1329 print "<div id= \" feedlistLoading \" >
1330 <img src='images/indicator_tiny.gif'>" .
1331 __ ( "Loading, please wait..." ). "</div>" ;
1333 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1334 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1336 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1337 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1338 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1340 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1341 dndController= \" dijit.tree.dndSource \"
1342 betweenThreshold= \" 5 \"
1343 model= \" feedModel \" openOnClick= \" false \" >
1344 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1345 var id = String(item.id);
1346 var bare_id = id.substr(id.indexOf(':')+1);
1348 if (id.match('FEED:')) {
1350 } else if (id.match('CAT:')) {
1351 editCat(bare_id, item);
1354 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1355 Element.hide( \" feedlistLoading \" );
1359 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1360 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1366 print "</div>" ; # feeds pane
1368 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1370 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1372 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1374 print "<iframe id= \" upload_iframe \"
1375 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1376 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1378 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1379 enctype= \" multipart/form-data \" method= \" POST \"
1380 action= \" backend.php \" >
1381 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1382 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1383 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1384 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1385 __ ( 'Import my OPML' ) . "</button>" ;
1389 print "<p>" . __ ( 'Filename:' ) .
1390 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1391 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1393 print "</p><button dojoType= \" dijit.form.Button \"
1394 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1395 __ ( 'Export OPML' ) . "</button></p></form>" ;
1399 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1401 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1403 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1404 __ ( 'Display published OPML URL' ). "</button> " ;
1407 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1408 "hook_prefs_tab_section" , "prefFeedsOPML" );
1410 print "</div>" ; # pane
1412 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1414 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1416 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1420 print "<button onclick='window.navigator.registerContentHandler(" .
1421 " \" application/vnd.mozilla.maybe.feed \" , " .
1422 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1423 __ ( 'Click here to register this site as a feed reader.' ) .
1428 print "</div>" ; # pane
1431 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1433 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1435 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1437 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1438 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1440 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1441 __ ( 'Display URL' ). "</button> " ;
1443 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1444 __ ( 'Clear all generated URLs' ). "</button> " ;
1446 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1448 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1450 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1451 __ ( 'Unshare all articles' ). "</button> " ;
1454 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1455 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1457 print "</div>" ; #pane
1461 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1462 "hook_prefs_tab" , "prefFeeds" );
1464 print "</div>" ; #container
1467 private function feedlist_init_cat ( $cat_id ) {
1469 $cat_id = ( int ) $cat_id ;
1472 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1473 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1474 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1477 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1478 $obj [ 'items' ] = array ();
1479 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1480 $obj [ 'type' ] = 'category' ;
1481 $obj [ 'unread' ] = ( int ) $cat_unread ;
1482 $obj [ 'bare_id' ] = $cat_id ;
1487 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1489 $feed_id = ( int ) $feed_id ;
1492 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1494 if ( $unread === false )
1495 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1497 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1498 $obj [ 'name' ] = $title ;
1499 $obj [ 'unread' ] = ( int ) $unread ;
1500 $obj [ 'type' ] = 'feed' ;
1501 $obj [ 'error' ] = $error ;
1502 $obj [ 'updated' ] = $updated ;
1503 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1504 $obj [ 'bare_id' ] = $feed_id ;
1509 function inactiveFeeds () {
1511 if ( DB_TYPE
== "pgsql" ) {
1512 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1514 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1517 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1518 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1519 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1520 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1521 ttrss_entries.id = ref_id AND
1522 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1523 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1524 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1525 ttrss_entries.id = ref_id
1526 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1527 ORDER BY last_article" );
1529 print "<h2" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</h2>" ;
1531 print "<div dojoType= \" dijit.Toolbar \" >" ;
1532 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1533 "<span>" . __ ( 'Select' ). "</span>" ;
1534 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1535 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1536 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1537 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1538 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1539 print "</div></div>" ;
1540 print "</div>" ; #toolbar
1542 print "<div class= \" inactiveFeedHolder \" >" ;
1544 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1548 while ( $line = db_fetch_assoc ( $result )) {
1550 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1551 $feed_id = $line [ "id" ];
1552 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1554 # class needed for selectTableRows()
1555 print "<tr class= \" placeholder \" $this_row_id >" ;
1557 $edit_title = htmlspecialchars ( $line [ "title" ]);
1559 # id needed for selectTableRows()
1560 print "<td width='5%' align='center'><input
1561 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1562 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1565 print "<a class= \" visibleLink \" href= \" # \" " .
1566 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1567 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1568 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1570 print "</td><td class= \" insensitive \" align='right'>" ;
1571 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1581 print "<div class='dlgButtons'>" ;
1582 print "<div style='float : left'>" ;
1583 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1584 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1587 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1588 __ ( 'Close this window' ). "</button>" ;
1594 function feedsWithErrors () {
1595 print "<h2>" . __ ( "These feeds have not been updated because of errors:" ) .
1598 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1599 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1601 print "<div dojoType= \" dijit.Toolbar \" >" ;
1602 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1603 "<span>" . __ ( 'Select' ). "</span>" ;
1604 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1605 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1606 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1607 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1608 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1609 print "</div></div>" ;
1610 print "</div>" ; #toolbar
1612 print "<div class= \" inactiveFeedHolder \" >" ;
1614 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1618 while ( $line = db_fetch_assoc ( $result )) {
1620 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1621 $feed_id = $line [ "id" ];
1622 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1624 # class needed for selectTableRows()
1625 print "<tr class= \" placeholder \" $this_row_id >" ;
1627 $edit_title = htmlspecialchars ( $line [ "title" ]);
1629 # id needed for selectTableRows()
1630 print "<td width='5%' align='center'><input
1631 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1632 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1635 print "<a class= \" visibleLink \" href= \" # \" " .
1636 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1637 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1638 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1640 print "<span class= \" insensitive \" >" ;
1641 print htmlspecialchars ( $line [ "last_error" ]);
1653 print "<div class='dlgButtons'>" ;
1654 print "<div style='float : left'>" ;
1655 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1656 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1659 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1660 __ ( 'Close this window' ). "</button>" ;
1666 * Purge a feed contents, marked articles excepted.
1668 * @param mixed $link The database connection.
1669 * @param integer $id The id of the feed to purge.
1672 private function clear_feed_articles ( $link , $id ) {
1675 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1676 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1678 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1679 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1682 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1683 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1685 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1686 } // function clear_feed_articles
1688 private function remove_feed_category ( $link , $id , $owner_uid ) {
1690 db_query ( $link , "DELETE FROM ttrss_feed_categories
1691 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1693 ccache_remove ( $link , $id , $owner_uid , true );
1696 static function remove_feed ( $link , $id , $owner_uid ) {
1700 /* save starred articles in Archived feed */
1702 db_query ( $link , "BEGIN" );
1704 /* prepare feed if necessary */
1706 $result = db_query ( $link , "SELECT feed_url FROM ttrss_feeds WHERE id = $id
1707 AND owner_uid = $owner_uid " );
1709 $feed_url = db_escape_string ( $link , db_fetch_result ( $result , 0 , "feed_url" ));
1711 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1712 WHERE feed_url = ' $feed_url ' AND owner_uid = $owner_uid " );
1714 if ( db_num_rows ( $result ) == 0 ) {
1715 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1716 (id, owner_uid, title, feed_url, site_url)
1717 SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
1722 $archive_id = db_fetch_result ( $result , 0 , "id" );
1725 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1726 orig_feed_id = ' $archive_id ' WHERE feed_id = ' $id ' AND
1727 marked = true AND owner_uid = $owner_uid " );
1729 /* Remove access key for the feed */
1731 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1732 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1734 /* remove the feed */
1736 db_query ( $link , "DELETE FROM ttrss_feeds
1737 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1739 db_query ( $link , "COMMIT" );
1741 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1742 unlink ( ICONS_DIR
. "/ $id .ico" );
1745 ccache_remove ( $link , $id , $owner_uid );
1748 label_remove ( $link , feed_to_label_id ( $id ), $owner_uid );
1749 //ccache_remove($link, $id, $owner_uid); don't think labels are cached
1753 function batchSubscribe () {
1754 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
1755 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchaddfeeds \" >" ;
1757 print "<table width='100%'><tr><td>
1758 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1759 </td><td align='right'>" ;
1760 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1761 print __ ( 'Place in category:' ) . " " ;
1762 print_feed_cat_select ( $this -> link
, "cat" , false , 'dojoType="dijit.form.Select"' );
1764 print "</td></tr><tr><td colspan='2'>" ;
1766 style='font-size : 12px; width : 100%; height: 200px;'
1767 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1768 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1770 print "</td></tr><tr><td colspan='2'>" ;
1772 print "<div id='feedDlg_loginContainer' style='display : none'>
1774 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1775 placeHolder= \" " . __ ( "Login" ). " \"
1776 style= \" width : 10em; \" > " .
1778 placeHolder= \" " . __ ( "Password" ). " \"
1779 dojoType= \" dijit.form.TextBox \" type='password'
1780 style= \" width : 10em; \" name='pass' \" >" .
1783 print "</td></tr><tr><td colspan='2'>" ;
1785 print "<div style= \" clear : both \" >
1786 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1787 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1788 <label for= \" feedDlg_loginCheck \" >" .
1789 __ ( 'Feeds require authentication.' ). "</div>" ;
1793 print "</td></tr></table>" ;
1795 print "<div class= \" dlgButtons \" >
1796 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1797 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1801 function batchAddFeeds () {
1802 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ 'cat' ]);
1803 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1804 $login = db_escape_string ( $this -> link
, $_REQUEST [ 'login' ]);
1805 $pass = db_escape_string ( $this -> link
, $_REQUEST [ 'pass' ]);
1807 foreach ( $feeds as $feed ) {
1808 $feed = db_escape_string ( $this -> link
, trim ( $feed ));
1810 if ( validate_feed_url ( $feed )) {
1812 db_query ( $this -> link
, "BEGIN" );
1814 if ( $cat_id == "0" ||
! $cat_id ) {
1815 $cat_qpart = "NULL" ;
1817 $cat_qpart = "' $cat_id '" ;
1820 $result = db_query ( $this -> link
,
1821 "SELECT id FROM ttrss_feeds
1822 WHERE feed_url = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1824 if ( db_num_rows ( $result ) == 0 ) {
1825 $result = db_query ( $this -> link
,
1826 "INSERT INTO ttrss_feeds
1827 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method)
1828 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed ',
1829 '[Unknown]', $cat_qpart , ' $login ', ' $pass ', 0)" );
1832 db_query ( $this -> link
, "COMMIT" );
1837 function regenOPMLKey () {
1838 $this -> update_feed_access_key ( $this -> link
, 'OPML:Publish' ,
1839 false , $_SESSION [ "uid" ]);
1841 $new_link = Opml
:: opml_publish_url ( $this -> link
);
1843 print json_encode ( array ( "link" => $new_link ));
1846 function regenFeedKey () {
1847 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ 'id' ]);
1848 $is_cat = db_escape_string ( $this -> link
, $_REQUEST [ 'is_cat' ]) == "true" ;
1850 $new_key = $this -> update_feed_access_key ( $this -> link
, $feed_id , $is_cat );
1852 print json_encode ( array ( "link" => $new_key ));
1856 private function update_feed_access_key ( $link , $feed_id , $is_cat , $owner_uid = false ) {
1857 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1859 $sql_is_cat = bool_to_sql_bool ( $is_cat );
1861 $result = db_query ( $link , "SELECT access_key FROM ttrss_access_keys
1862 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1863 AND owner_uid = " . $owner_uid );
1865 if ( db_num_rows ( $result ) == 1 ) {
1866 $key = db_escape_string ( $this -> link
, sha1 ( uniqid ( rand (), true )));
1868 db_query ( $link , "UPDATE ttrss_access_keys SET access_key = ' $key '
1869 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1870 AND owner_uid = " . $owner_uid );
1875 return get_feed_access_key ( $link , $feed_id , $is_cat , $owner_uid );
1880 function clearKeys () {
1881 db_query ( $this -> link
, "DELETE FROM ttrss_access_keys WHERE
1882 owner_uid = " . $_SESSION [ "uid" ]);