]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
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 ( $_REQUEST [ 'title' ]);
19 $id = db_escape_string ( $_REQUEST [ 'id' ]);
22 db_query ( "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 ( '_PREFS_SHOW_EMPTY_CATS' ));
44 $result = db_query ( "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 ( "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 (
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 ( '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 ( "SELECT * FROM
158 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
160 if ( db_num_rows ( $result ) > 0 ) {
162 if ( get_pref ( '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 ( '_PREFS_SHOW_EMPTY_CATS' ));
193 $result = db_query ( "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 ( "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 (
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 ( "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 (
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 ( "UPDATE ttrss_feed_categories
300 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
304 function feedsortreset () {
305 db_query ( "UPDATE ttrss_feeds
306 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
310 function togglehiddenfeedcats () {
311 set_pref ( '_PREFS_SHOW_EMPTY_CATS' ,
312 ( get_pref ( '_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 ( $parent_bare_id );
331 $parent_qpart = 'NULL' ;
334 db_query ( "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 ( $bare_item_id ) : "NULL" ;
357 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
360 db_query ( "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 ( $bare_id );
372 $parent_qpart = 'NULL' ;
375 db_query ( "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( "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( "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 ( $_REQUEST [ "feed_id" ]);
462 $result = db_query ( "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" );
468 db_query ( "UPDATE ttrss_feeds SET favicon_avg_color = NULL
469 where id = ' $feed_id '" );
475 function uploadicon () {
476 header ( "Content-type: text/html" );
480 if ( is_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ])) {
481 $tmp_file = tempnam ( CACHE_DIR
. '/upload' , 'icon' );
483 $result = move_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ],
493 $icon_file = $tmp_file ;
494 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
496 if ( is_file ( $icon_file ) && $feed_id ) {
497 if ( filesize ( $icon_file ) < 20000 ) {
499 $result = db_query ( "SELECT id FROM ttrss_feeds
500 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
502 if ( db_num_rows ( $result ) != 0 ) {
503 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
504 if ( rename ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" )) {
506 require_once "colors.php" ;
508 $favicon_color = db_escape_string (
509 calculate_avg_color ( ICONS_DIR
. "/ $feed_id .ico" ));
511 db_query ( "UPDATE ttrss_feeds SET
512 favicon_avg_color = ' $favicon_color '
513 WHERE id = ' $feed_id '" );
529 print "<script type= \" text/javascript \" >" ;
530 print "parent.uploadIconHandler( $rc );" ;
535 function editfeed () {
536 global $purge_intervals ;
537 global $update_intervals ;
539 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
542 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
543 owner_uid = " . $_SESSION [ "uid" ]);
545 $auth_pass_encrypted = sql_bool_to_bool ( db_fetch_result ( $result , 0 ,
546 "auth_pass_encrypted" ));
548 $title = htmlspecialchars ( db_fetch_result ( $result ,
551 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
552 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
553 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
555 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
556 print "<div class= \" dlgSecCont \" >" ;
560 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
561 placeHolder= \" " . __ ( "Feed Title" ). " \"
562 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
566 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
567 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
572 print __ ( 'URL:' ) . " " ;
573 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
574 placeHolder= \" " . __ ( "Feed URL" ). " \"
575 regExp='^(http|https)://.*' style= \" width : 20em \"
576 name= \" feed_url \" value= \" $feed_url\" >" ;
578 $last_error = db_fetch_result ( $result , 0 , "last_error" );
581 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
582 class= \" feed_error \" >(error)</span>" ;
588 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
590 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
594 print __ ( 'Place in category:' ) . " " ;
596 print_feed_cat_select ( "cat_id" , $cat_id ,
597 'dojoType="dijit.form.Select"' );
602 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
603 print "<div class= \" dlgSecCont \" >" ;
605 /* Update Interval */
607 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
609 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
610 'dojoType="dijit.form.Select"' );
614 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
617 print __ ( 'Article purging:' ) . " " ;
619 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
620 'dojoType="dijit.form.Select" ' .
621 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
624 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
625 print "<div class= \" dlgSecCont \" >" ;
627 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
629 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
630 placeHolder= \" " . __ ( "Login" ). " \"
631 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
633 $auth_pass = db_fetch_result ( $result , 0 , "auth_pass" );
635 if ( $auth_pass_encrypted ) {
636 require_once "crypt.php" ;
637 $auth_pass = decrypt_string ( $auth_pass );
640 $auth_pass = htmlspecialchars ( $auth_pass );
642 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
643 placeHolder= \" " . __ ( "Password" ). " \"
644 value= \" $auth_pass\" >" ;
646 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
647 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
651 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
652 print "<div class= \" dlgSecCont \" >" ;
654 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
657 $checked = "checked= \" 1 \" " ;
662 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
663 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
665 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
667 if ( $include_in_digest ) {
668 $checked = "checked= \" 1 \" " ;
673 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
674 name= \" include_in_digest \"
675 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
678 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
680 if ( $always_display_enclosures ) {
681 $checked = "checked" ;
686 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
687 name= \" always_display_enclosures \"
688 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
690 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
693 $checked = "checked= \" 1 \" " ;
698 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
700 $checked > <label for= \" hide_images \" >" .
701 __ ( 'Do not embed images' ). "</label>" ;
703 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
706 $checked = "checked= \" 1 \" " ;
711 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
712 name= \" cache_images \"
713 $checked > <label for= \" cache_images \" >" .
714 __ ( 'Cache images locally' ). "</label>" ;
716 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
718 if ( $mark_unread_on_update ) {
719 $checked = "checked" ;
724 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
725 name= \" mark_unread_on_update \"
726 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
732 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
733 print "<div class= \" dlgSecCont \" >" ;
735 print "<iframe name= \" icon_upload_iframe \"
736 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
738 print "<form style='display : block' target= \" icon_upload_iframe \"
739 enctype= \" multipart/form-data \" method= \" POST \"
740 action= \" backend.php \" >
741 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
742 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
743 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
744 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
745 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
746 type= \" submit \" >" . __ ( 'Replace' ). "</button>
747 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
748 type= \" submit \" >" . __ ( 'Remove' ). "</button>
753 $title = htmlspecialchars ( $title , ENT_QUOTES
);
755 print "<div class='dlgButtons'>
756 <div style= \" float : left \" >
757 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
758 __ ( 'Unsubscribe' ). "</button>" ;
760 if ( PUBSUBHUBBUB_ENABLED
) {
761 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
762 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
764 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
765 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
771 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
772 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
774 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
775 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
781 function editfeeds () {
782 global $purge_intervals ;
783 global $update_intervals ;
785 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
787 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
791 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
792 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
793 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
795 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
796 print "<div class= \" dlgSecCont \" >" ;
800 print "<input dojoType= \" dijit.form.ValidationTextBox \"
801 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
802 name= \" title \" value= \" $title\" >" ;
804 $this -> batch_edit_cbox ( "title" );
810 print __ ( 'URL:' ) . " " ;
811 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
812 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
813 name= \" feed_url \" value= \" $feed_url\" >" ;
815 $this -> batch_edit_cbox ( "feed_url" );
819 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
823 print __ ( 'Place in category:' ) . " " ;
825 print_feed_cat_select ( "cat_id" , $cat_id ,
826 'disabled="1" dojoType="dijit.form.Select"' );
828 $this -> batch_edit_cbox ( "cat_id" );
834 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
835 print "<div class= \" dlgSecCont \" >" ;
837 /* Update Interval */
839 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
840 'disabled="1" dojoType="dijit.form.Select"' );
842 $this -> batch_edit_cbox ( "update_interval" );
846 if ( FORCE_ARTICLE_PURGE
== 0 ) {
850 print __ ( 'Article purging:' ) . " " ;
852 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
853 'disabled="1" dojoType="dijit.form.Select"' );
855 $this -> batch_edit_cbox ( "purge_interval" );
859 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
860 print "<div class= \" dlgSecCont \" >" ;
862 print "<input dojoType= \" dijit.form.TextBox \"
863 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
864 name= \" auth_login \" value= \" $auth_login\" >" ;
866 $this -> batch_edit_cbox ( "auth_login" );
868 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
869 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
870 value= \" $auth_pass\" >" ;
872 $this -> batch_edit_cbox ( "auth_pass" );
875 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
876 print "<div class= \" dlgSecCont \" >" ;
878 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
879 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
881 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
883 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
884 name= \" include_in_digest \"
885 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
887 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
889 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
890 name= \" always_display_enclosures \"
891 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
893 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
895 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
897 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
898 for= \" hide_images \" >" .
899 __ ( 'Do not embed images' ). "</label>" ;
901 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
903 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
904 name= \" cache_images \"
905 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
906 for= \" cache_images \" >" .
907 __ ( 'Cache images locally' ). "</label>" ;
909 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
911 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
912 name= \" mark_unread_on_update \"
913 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
915 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
919 print "<div class='dlgButtons'>
920 <button dojoType= \" dijit.form.Button \"
921 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
922 __ ( 'Save' ). "</button>
923 <button dojoType= \" dijit.form.Button \"
924 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
925 __ ( 'Cancel' ). "</button>
931 function batchEditSave () {
932 return $this -> editsaveops ( true );
935 function editSave () {
936 return $this -> editsaveops ( false );
939 function editsaveops ( $batch ) {
941 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
942 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
943 $upd_intl = ( int ) db_escape_string ( $_POST [ "update_interval" ]);
944 $purge_intl = ( int ) db_escape_string ( $_POST [ "purge_interval" ]);
945 $feed_id = ( int ) db_escape_string ( $_POST [ "id" ]); /* editSave */
946 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
947 $cat_id = ( int ) db_escape_string ( $_POST [ "cat_id" ]);
948 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
949 $auth_pass = trim ( $_POST [ "auth_pass" ]);
950 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
951 $include_in_digest = checkbox_to_sql_bool (
952 db_escape_string ( $_POST [ "include_in_digest" ]));
953 $cache_images = checkbox_to_sql_bool (
954 db_escape_string ( $_POST [ "cache_images" ]));
955 $hide_images = checkbox_to_sql_bool (
956 db_escape_string ( $_POST [ "hide_images" ]));
957 $always_display_enclosures = checkbox_to_sql_bool (
958 db_escape_string ( $_POST [ "always_display_enclosures" ]));
960 $mark_unread_on_update = checkbox_to_sql_bool (
961 db_escape_string ( $_POST [ "mark_unread_on_update" ]));
963 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
964 require_once "crypt.php" ;
965 $auth_pass = substr ( encrypt_string ( $auth_pass ), 0 , 250 );
966 $auth_pass_encrypted = 'true' ;
968 $auth_pass_encrypted = 'false' ;
971 $auth_pass = db_escape_string ( $auth_pass );
973 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
974 if ( $cat_id && $cat_id != 0 ) {
975 $category_qpart = "cat_id = ' $cat_id '," ;
976 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
978 $category_qpart = 'cat_id = NULL,' ;
979 $category_qpart_nocomma = 'cat_id = NULL' ;
982 $category_qpart = "" ;
983 $category_qpart_nocomma = "" ;
988 $result = db_query ( "UPDATE ttrss_feeds SET
990 title = ' $feed_title ', feed_url = ' $feed_link ',
991 update_interval = ' $upd_intl ',
992 purge_interval = ' $purge_intl ',
993 auth_login = ' $auth_login ',
994 auth_pass = ' $auth_pass ',
995 auth_pass_encrypted = $auth_pass_encrypted ,
997 cache_images = $cache_images ,
998 hide_images = $hide_images ,
999 include_in_digest = $include_in_digest ,
1000 always_display_enclosures = $always_display_enclosures ,
1001 mark_unread_on_update = $mark_unread_on_update
1002 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1005 $feed_data = array ();
1007 foreach ( array_keys ( $_POST ) as $k ) {
1008 if ( $k != "op" && $k != "method" && $k != "ids" ) {
1009 $feed_data [ $k ] = $_POST [ $k ];
1015 foreach ( array_keys ( $feed_data ) as $k ) {
1021 $qpart = "title = ' $feed_title '" ;
1025 $qpart = "feed_url = ' $feed_link '" ;
1028 case "update_interval" :
1029 $qpart = "update_interval = ' $upd_intl '" ;
1032 case "purge_interval" :
1033 $qpart = "purge_interval = ' $purge_intl '" ;
1037 $qpart = "auth_login = ' $auth_login '" ;
1041 $qpart = "auth_pass = ' $auth_pass ' AND
1042 auth_pass_encrypted = $auth_pass_encrypted " ;
1046 $qpart = "private = $private " ;
1049 case "include_in_digest" :
1050 $qpart = "include_in_digest = $include_in_digest " ;
1053 case "always_display_enclosures" :
1054 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1057 case "mark_unread_on_update" :
1058 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1061 case "cache_images" :
1062 $qpart = "cache_images = $cache_images " ;
1066 $qpart = "hide_images = $hide_images " ;
1070 $qpart = $category_qpart_nocomma ;
1077 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1078 AND owner_uid = " . $_SESSION [ "uid" ]);
1083 db_query ( "COMMIT" );
1088 function resetPubSub () {
1090 $ids = db_escape_string ( $_REQUEST [ "ids" ]);
1092 db_query ( "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1093 AND owner_uid = " . $_SESSION [ "uid" ]);
1100 $ids = explode ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1102 foreach ( $ids as $id ) {
1103 Pref_Feeds
:: remove_feed ( $id , $_SESSION [ "uid" ]);
1110 $id = db_escape_string ( $_REQUEST [ "id" ]);
1111 $this -> clear_feed_articles ( $id );
1114 function rescore () {
1115 require_once "rssfuncs.php" ;
1117 $ids = explode ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1119 foreach ( $ids as $id ) {
1121 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1123 $result = db_query ( "SELECT
1124 title, content, link, ref_id, author," .
1125 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1127 ttrss_user_entries, ttrss_entries
1128 WHERE ref_id = id AND feed_id = ' $id ' AND
1129 owner_uid = " . $_SESSION [ 'uid' ]. "
1134 while ( $line = db_fetch_assoc ( $result )) {
1136 $tags = get_article_tags ( $line [ "ref_id" ]);
1138 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1139 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1140 $line [ 'author' ], $tags );
1142 $new_score = calculate_article_score ( $article_filters );
1144 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1146 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1149 foreach ( array_keys ( $scores ) as $s ) {
1151 db_query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1153 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1154 } else if ( $s < - 500 ) {
1155 db_query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1156 unread = false WHERE
1157 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1159 db_query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1160 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1165 print __ ( "All done." );
1169 function rescoreAll () {
1172 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1174 while ( $feed_line = db_fetch_assoc ( $result )) {
1176 $id = $feed_line [ "id" ];
1178 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1180 $tmp_result = db_query ( "SELECT
1181 title, content, link, ref_id, author," .
1182 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1184 ttrss_user_entries, ttrss_entries
1185 WHERE ref_id = id AND feed_id = ' $id ' AND
1186 owner_uid = " . $_SESSION [ 'uid' ]. "
1191 while ( $line = db_fetch_assoc ( $tmp_result )) {
1193 $tags = get_article_tags ( $line [ "ref_id" ]);
1195 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1196 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1197 $line [ 'author' ], $tags );
1199 $new_score = calculate_article_score ( $article_filters );
1201 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1203 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1206 foreach ( array_keys ( $scores ) as $s ) {
1208 db_query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1210 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1212 db_query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1213 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1218 print __ ( "All done." );
1222 function categorize () {
1223 $ids = explode ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1225 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
1228 $cat_id_qpart = 'NULL' ;
1230 $cat_id_qpart = "' $cat_id '" ;
1235 foreach ( $ids as $id ) {
1237 db_query ( "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1239 AND owner_uid = " . $_SESSION [ "uid" ]);
1243 db_query ( "COMMIT" );
1246 function removeCat () {
1247 $ids = explode ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1248 foreach ( $ids as $id ) {
1249 $this -> remove_feed_category ( $id , $_SESSION [ "uid" ]);
1254 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1256 add_feed_category ( $feed_cat );
1261 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1262 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1264 $result = db_query ( "SELECT COUNT(id) AS num_errors
1265 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1267 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1269 if ( $num_errors > 0 ) {
1271 $error_button = "<button dojoType= \" dijit.form.Button \"
1272 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1273 __ ( "Feeds with errors" ) . "</button>" ;
1276 if ( DB_TYPE
== "pgsql" ) {
1277 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1279 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1282 $result = db_query ( "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1283 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1284 ttrss_entries.id = ref_id AND
1285 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1286 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1288 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1290 if ( $num_inactive > 0 ) {
1291 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1292 onclick= \" showInactiveFeeds() \" >" .
1293 __ ( "Inactive feeds" ) . "</button>" ;
1296 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1298 if ( array_key_exists ( "search" , $_REQUEST )) {
1299 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1301 $feed_search = $_SESSION [ "prefs_feed_search" ];
1304 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1306 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1308 print "<div style='float : right; padding-right : 4px;'>
1309 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1310 value= \" $feed_search\" >
1311 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1312 __ ( 'Search' ). "</button>
1315 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1316 "<span>" . __ ( 'Select' ). "</span>" ;
1317 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1318 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1319 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1320 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1321 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1322 print "</div></div>" ;
1324 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1325 "<span>" . __ ( 'Feeds' ). "</span>" ;
1326 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1327 print "<div onclick= \" quickAddFeed() \"
1328 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1329 print "<div onclick= \" editSelectedFeed() \"
1330 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1331 print "<div onclick= \" resetFeedOrder() \"
1332 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1333 print "<div onclick= \" batchSubscribe() \"
1334 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1335 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1336 . __ ( 'Unsubscribe' ). "</div> " ;
1337 print "</div></div>" ;
1339 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1340 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1341 "<span>" . __ ( 'Categories' ). "</span>" ;
1342 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1343 print "<div onclick= \" createCategory() \"
1344 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1345 print "<div onclick= \" resetCatOrder() \"
1346 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1347 print "<div onclick= \" removeSelectedCategories() \"
1348 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1349 print "</div></div>" ;
1353 print $error_button ;
1354 print $inactive_button ;
1356 print "<button onclick= \" toggleHiddenFeedCats() \"
1357 dojoType= \" dijit.form.Button \" >" . __ ( '(Un)hide empty categories' ). "</button>" ;
1359 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1361 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1362 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1364 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1366 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1370 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1371 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1377 print "</div>" ; # toolbar
1380 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1382 print "<div id= \" feedlistLoading \" >
1383 <img src='images/indicator_tiny.gif'>" .
1384 __ ( "Loading, please wait..." ). "</div>" ;
1386 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1387 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1389 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1390 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1391 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1393 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1394 dndController= \" dijit.tree.dndSource \"
1395 betweenThreshold= \" 5 \"
1396 model= \" feedModel \" openOnClick= \" false \" >
1397 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1398 var id = String(item.id);
1399 var bare_id = id.substr(id.indexOf(':')+1);
1401 if (id.match('FEED:')) {
1403 } else if (id.match('CAT:')) {
1404 editCat(bare_id, item);
1407 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1408 Element.hide( \" feedlistLoading \" );
1412 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1413 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1419 print "</div>" ; # feeds pane
1421 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1423 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1425 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1427 print "<iframe id= \" upload_iframe \"
1428 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1429 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1431 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1432 enctype= \" multipart/form-data \" method= \" POST \"
1433 action= \" backend.php \" >
1434 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1435 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1436 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1437 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1438 __ ( 'Import my OPML' ) . "</button>" ;
1442 print "<p>" . __ ( 'Filename:' ) .
1443 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1444 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1446 print "</p><button dojoType= \" dijit.form.Button \"
1447 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1448 __ ( 'Export OPML' ) . "</button></p></form>" ;
1452 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1454 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1456 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1457 __ ( 'Display published OPML URL' ). "</button> " ;
1460 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1461 "hook_prefs_tab_section" , "prefFeedsOPML" );
1463 print "</div>" ; # pane
1465 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1467 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1469 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1473 print "<button onclick='window.navigator.registerContentHandler(" .
1474 " \" application/vnd.mozilla.maybe.feed \" , " .
1475 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1476 __ ( 'Click here to register this site as a feed reader.' ) .
1481 print "</div>" ; # pane
1484 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1486 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1488 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1490 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1491 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1493 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1494 __ ( 'Display URL' ). "</button> " ;
1496 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1497 __ ( 'Clear all generated URLs' ). "</button> " ;
1499 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1501 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1503 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1504 __ ( 'Unshare all articles' ). "</button> " ;
1507 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1508 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1510 print "</div>" ; #pane
1514 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1515 "hook_prefs_tab" , "prefFeeds" );
1517 print "</div>" ; #container
1520 private function feedlist_init_cat ( $cat_id ) {
1522 $cat_id = ( int ) $cat_id ;
1525 $cat_unread = ccache_find ( $cat_id , $_SESSION [ "uid" ], true );
1526 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1527 $cat_unread = getCategoryUnread ( $cat_id );
1530 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1531 $obj [ 'items' ] = array ();
1532 $obj [ 'name' ] = getCategoryTitle ( $cat_id );
1533 $obj [ 'type' ] = 'category' ;
1534 $obj [ 'unread' ] = ( int ) $cat_unread ;
1535 $obj [ 'bare_id' ] = $cat_id ;
1540 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1542 $feed_id = ( int ) $feed_id ;
1545 $title = getFeedTitle ( $feed_id , false );
1547 if ( $unread === false )
1548 $unread = getFeedUnread ( $feed_id , false );
1550 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1551 $obj [ 'name' ] = $title ;
1552 $obj [ 'unread' ] = ( int ) $unread ;
1553 $obj [ 'type' ] = 'feed' ;
1554 $obj [ 'error' ] = $error ;
1555 $obj [ 'updated' ] = $updated ;
1556 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1557 $obj [ 'bare_id' ] = $feed_id ;
1562 function inactiveFeeds () {
1564 if ( DB_TYPE
== "pgsql" ) {
1565 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1567 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1570 $result = db_query ( "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1571 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1572 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1573 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1574 ttrss_entries.id = ref_id AND
1575 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1576 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1577 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1578 ttrss_entries.id = ref_id
1579 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1580 ORDER BY last_article" );
1582 print "<h2" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</h2>" ;
1584 print "<div dojoType= \" dijit.Toolbar \" >" ;
1585 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1586 "<span>" . __ ( 'Select' ). "</span>" ;
1587 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1588 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1589 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1590 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1591 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1592 print "</div></div>" ;
1593 print "</div>" ; #toolbar
1595 print "<div class= \" inactiveFeedHolder \" >" ;
1597 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1601 while ( $line = db_fetch_assoc ( $result )) {
1603 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1604 $feed_id = $line [ "id" ];
1605 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1607 # class needed for selectTableRows()
1608 print "<tr class= \" placeholder \" $this_row_id >" ;
1610 $edit_title = htmlspecialchars ( $line [ "title" ]);
1612 # id needed for selectTableRows()
1613 print "<td width='5%' align='center'><input
1614 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1615 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1618 print "<a class= \" visibleLink \" href= \" # \" " .
1619 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1620 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1621 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1623 print "</td><td class= \" insensitive \" align='right'>" ;
1624 print make_local_datetime ( $line [ 'last_article' ], false );
1634 print "<div class='dlgButtons'>" ;
1635 print "<div style='float : left'>" ;
1636 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1637 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1640 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1641 __ ( 'Close this window' ). "</button>" ;
1647 function feedsWithErrors () {
1648 print "<h2>" . __ ( "These feeds have not been updated because of errors:" ) .
1651 $result = db_query ( "SELECT id,title,feed_url,last_error,site_url
1652 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1654 print "<div dojoType= \" dijit.Toolbar \" >" ;
1655 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1656 "<span>" . __ ( 'Select' ). "</span>" ;
1657 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1658 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1659 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1660 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1661 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1662 print "</div></div>" ;
1663 print "</div>" ; #toolbar
1665 print "<div class= \" inactiveFeedHolder \" >" ;
1667 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1671 while ( $line = db_fetch_assoc ( $result )) {
1673 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1674 $feed_id = $line [ "id" ];
1675 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1677 # class needed for selectTableRows()
1678 print "<tr class= \" placeholder \" $this_row_id >" ;
1680 $edit_title = htmlspecialchars ( $line [ "title" ]);
1682 # id needed for selectTableRows()
1683 print "<td width='5%' align='center'><input
1684 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1685 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1688 print "<a class= \" visibleLink \" href= \" # \" " .
1689 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1690 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1691 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1693 print "<span class= \" insensitive \" >" ;
1694 print htmlspecialchars ( $line [ "last_error" ]);
1706 print "<div class='dlgButtons'>" ;
1707 print "<div style='float : left'>" ;
1708 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1709 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1712 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1713 __ ( 'Close this window' ). "</button>" ;
1719 * Purge a feed contents, marked articles excepted.
1721 * @param mixed $link The database connection.
1722 * @param integer $id The id of the feed to purge.
1725 private function clear_feed_articles ( $id ) {
1728 $result = db_query ( "DELETE FROM ttrss_user_entries
1729 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1731 $result = db_query ( "DELETE FROM ttrss_user_entries
1732 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1735 $result = db_query ( "DELETE FROM ttrss_entries WHERE
1736 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1738 ccache_update ( $id , $_SESSION [ 'uid' ]);
1739 } // function clear_feed_articles
1741 private function remove_feed_category ( $id , $owner_uid ) {
1743 db_query ( "DELETE FROM ttrss_feed_categories
1744 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1746 ccache_remove ( $id , $owner_uid , true );
1749 static function remove_feed ( $id , $owner_uid ) {
1753 /* save starred articles in Archived feed */
1757 /* prepare feed if necessary */
1759 $result = db_query ( "SELECT feed_url FROM ttrss_feeds WHERE id = $id
1760 AND owner_uid = $owner_uid " );
1762 $feed_url = db_escape_string ( db_fetch_result ( $result , 0 , "feed_url" ));
1764 $result = db_query ( "SELECT id FROM ttrss_archived_feeds
1765 WHERE feed_url = ' $feed_url ' AND owner_uid = $owner_uid " );
1767 if ( db_num_rows ( $result ) == 0 ) {
1768 $result = db_query ( "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1769 $new_feed_id = ( int ) db_fetch_result ( $result , 0 , "id" ) +
1 ;
1771 db_query ( "INSERT INTO ttrss_archived_feeds
1772 (id, owner_uid, title, feed_url, site_url)
1773 SELECT $new_feed_id , owner_uid, title, feed_url, site_url from ttrss_feeds
1776 $archive_id = $new_feed_id ;
1778 $archive_id = db_fetch_result ( $result , 0 , "id" );
1781 db_query ( "UPDATE ttrss_user_entries SET feed_id = NULL,
1782 orig_feed_id = ' $archive_id ' WHERE feed_id = ' $id ' AND
1783 marked = true AND owner_uid = $owner_uid " );
1785 /* Remove access key for the feed */
1787 db_query ( "DELETE FROM ttrss_access_keys WHERE
1788 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1790 /* remove the feed */
1792 db_query ( "DELETE FROM ttrss_feeds
1793 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1795 db_query ( "COMMIT" );
1797 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1798 unlink ( ICONS_DIR
. "/ $id .ico" );
1801 ccache_remove ( $id , $owner_uid );
1804 label_remove ( feed_to_label_id ( $id ), $owner_uid );
1805 //ccache_remove( $id, $owner_uid); don't think labels are cached
1809 function batchSubscribe () {
1810 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
1811 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchaddfeeds \" >" ;
1813 print "<table width='100%'><tr><td>
1814 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1815 </td><td align='right'>" ;
1816 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1817 print __ ( 'Place in category:' ) . " " ;
1818 print_feed_cat_select ( "cat" , false , 'dojoType="dijit.form.Select"' );
1820 print "</td></tr><tr><td colspan='2'>" ;
1822 style='font-size : 12px; width : 100%; height: 200px;'
1823 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1824 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1826 print "</td></tr><tr><td colspan='2'>" ;
1828 print "<div id='feedDlg_loginContainer' style='display : none'>
1830 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1831 placeHolder= \" " . __ ( "Login" ). " \"
1832 style= \" width : 10em; \" > " .
1834 placeHolder= \" " . __ ( "Password" ). " \"
1835 dojoType= \" dijit.form.TextBox \" type='password'
1836 style= \" width : 10em; \" name='pass' \" >" .
1839 print "</td></tr><tr><td colspan='2'>" ;
1841 print "<div style= \" clear : both \" >
1842 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1843 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1844 <label for= \" feedDlg_loginCheck \" >" .
1845 __ ( 'Feeds require authentication.' ). "</div>" ;
1849 print "</td></tr></table>" ;
1851 print "<div class= \" dlgButtons \" >
1852 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1853 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1857 function batchAddFeeds () {
1858 $cat_id = db_escape_string ( $_REQUEST [ 'cat' ]);
1859 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1860 $login = db_escape_string ( $_REQUEST [ 'login' ]);
1861 $pass = trim ( $_REQUEST [ 'pass' ]);
1863 foreach ( $feeds as $feed ) {
1864 $feed = db_escape_string ( trim ( $feed ));
1866 if ( validate_feed_url ( $feed )) {
1870 if ( $cat_id == "0" ||
! $cat_id ) {
1871 $cat_qpart = "NULL" ;
1873 $cat_qpart = "' $cat_id '" ;
1877 "SELECT id FROM ttrss_feeds
1878 WHERE feed_url = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1880 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
1881 require_once "crypt.php" ;
1882 $pass = substr ( encrypt_string ( $pass ), 0 , 250 );
1883 $auth_pass_encrypted = 'true' ;
1885 $auth_pass_encrypted = 'false' ;
1888 $pass = db_escape_string ( $pass );
1890 if ( db_num_rows ( $result ) == 0 ) {
1892 "INSERT INTO ttrss_feeds
1893 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1894 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed ',
1895 '[Unknown]', $cat_qpart , ' $login ', ' $pass ', 0, $auth_pass_encrypted )" );
1898 db_query ( "COMMIT" );
1903 function regenOPMLKey () {
1904 $this -> update_feed_access_key ( 'OPML:Publish' ,
1905 false , $_SESSION [ "uid" ]);
1907 $new_link = Opml
:: opml_publish_url ();
1909 print json_encode ( array ( "link" => $new_link ));
1912 function regenFeedKey () {
1913 $feed_id = db_escape_string ( $_REQUEST [ 'id' ]);
1914 $is_cat = db_escape_string ( $_REQUEST [ 'is_cat' ]) == "true" ;
1916 $new_key = $this -> update_feed_access_key ( $feed_id , $is_cat );
1918 print json_encode ( array ( "link" => $new_key ));
1922 private function update_feed_access_key ( $feed_id , $is_cat , $owner_uid = false ) {
1923 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1925 $sql_is_cat = bool_to_sql_bool ( $is_cat );
1927 $result = db_query ( "SELECT access_key FROM ttrss_access_keys
1928 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1929 AND owner_uid = " . $owner_uid );
1931 if ( db_num_rows ( $result ) == 1 ) {
1932 $key = db_escape_string ( sha1 ( uniqid ( rand (), true )));
1934 db_query ( "UPDATE ttrss_access_keys SET access_key = ' $key '
1935 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1936 AND owner_uid = " . $owner_uid );
1941 return get_feed_access_key ( $feed_id , $is_cat , $owner_uid );
1946 function clearKeys () {
1947 db_query ( "DELETE FROM ttrss_access_keys WHERE
1948 owner_uid = " . $_SESSION [ "uid" ]);