]>
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 ( $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" );
477 if ( is_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ])) {
478 $tmp_file = tempnam ( CACHE_DIR
. '/upload' , 'icon' );
480 $result = move_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ],
490 $icon_file = $tmp_file ;
491 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
493 if ( is_file ( $icon_file ) && $feed_id ) {
494 if ( filesize ( $icon_file ) < 20000 ) {
496 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
497 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
499 if ( db_num_rows ( $result ) != 0 ) {
500 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
501 rename ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
515 print "<script type= \" text/javascript \" >" ;
516 print "parent.uploadIconHandler( $rc );" ;
521 function editfeed () {
522 global $purge_intervals ;
523 global $update_intervals ;
525 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
527 $result = db_query ( $this -> link
,
528 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
529 owner_uid = " . $_SESSION [ "uid" ]);
531 $title = htmlspecialchars ( db_fetch_result ( $result ,
534 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
535 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
536 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
538 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
539 print "<div class= \" dlgSecCont \" >" ;
543 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
544 placeHolder= \" " . __ ( "Feed Title" ). " \"
545 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
549 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
550 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
555 print __ ( 'URL:' ) . " " ;
556 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
557 placeHolder= \" " . __ ( "Feed URL" ). " \"
558 regExp='^(http|https)://.*' style= \" width : 20em \"
559 name= \" feed_url \" value= \" $feed_url\" >" ;
561 $last_error = db_fetch_result ( $result , 0 , "last_error" );
564 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
565 class= \" feed_error \" >(error)</span>" ;
571 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
573 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
577 print __ ( 'Place in category:' ) . " " ;
579 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
580 'dojoType="dijit.form.Select"' );
585 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
586 print "<div class= \" dlgSecCont \" >" ;
588 /* Update Interval */
590 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
592 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
593 'dojoType="dijit.form.Select"' );
597 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
600 print __ ( 'Article purging:' ) . " " ;
602 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
603 'dojoType="dijit.form.Select" ' .
604 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
607 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
608 print "<div class= \" dlgSecCont \" >" ;
610 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
612 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
613 placeHolder= \" " . __ ( "Login" ). " \"
614 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
616 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
618 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
619 placeHolder= \" " . __ ( "Password" ). " \"
620 value= \" $auth_pass\" >" ;
622 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
623 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
627 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
628 print "<div class= \" dlgSecCont \" >" ;
630 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
633 $checked = "checked= \" 1 \" " ;
638 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
639 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
641 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
643 if ( $include_in_digest ) {
644 $checked = "checked= \" 1 \" " ;
649 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
650 name= \" include_in_digest \"
651 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
654 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
656 if ( $always_display_enclosures ) {
657 $checked = "checked" ;
662 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
663 name= \" always_display_enclosures \"
664 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
666 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
669 $checked = "checked= \" 1 \" " ;
674 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
676 $checked > <label for= \" hide_images \" >" .
677 __ ( 'Do not embed images' ). "</label>" ;
679 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
682 $checked = "checked= \" 1 \" " ;
687 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
688 name= \" cache_images \"
689 $checked > <label for= \" cache_images \" >" .
690 __ ( 'Cache images locally' ). "</label>" ;
692 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
694 if ( $mark_unread_on_update ) {
695 $checked = "checked" ;
700 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
701 name= \" mark_unread_on_update \"
702 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
708 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
709 print "<div class= \" dlgSecCont \" >" ;
711 print "<iframe name= \" icon_upload_iframe \"
712 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
714 print "<form style='display : block' target= \" icon_upload_iframe \"
715 enctype= \" multipart/form-data \" method= \" POST \"
716 action= \" backend.php \" >
717 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
718 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
719 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
720 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
721 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
722 type= \" submit \" >" . __ ( 'Replace' ). "</button>
723 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
724 type= \" submit \" >" . __ ( 'Remove' ). "</button>
729 $title = htmlspecialchars ( $title , ENT_QUOTES
);
731 print "<div class='dlgButtons'>
732 <div style= \" float : left \" >
733 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
734 __ ( 'Unsubscribe' ). "</button>" ;
736 if ( PUBSUBHUBBUB_ENABLED
) {
737 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
738 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
740 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
741 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
747 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
748 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
750 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
751 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
757 function editfeeds () {
758 global $purge_intervals ;
759 global $update_intervals ;
761 $feed_ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
763 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
767 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
768 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
769 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
771 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
772 print "<div class= \" dlgSecCont \" >" ;
776 print "<input dojoType= \" dijit.form.ValidationTextBox \"
777 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
778 name= \" title \" value= \" $title\" >" ;
780 $this -> batch_edit_cbox ( "title" );
786 print __ ( 'URL:' ) . " " ;
787 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
788 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
789 name= \" feed_url \" value= \" $feed_url\" >" ;
791 $this -> batch_edit_cbox ( "feed_url" );
795 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
799 print __ ( 'Place in category:' ) . " " ;
801 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
802 'disabled="1" dojoType="dijit.form.Select"' );
804 $this -> batch_edit_cbox ( "cat_id" );
810 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
811 print "<div class= \" dlgSecCont \" >" ;
813 /* Update Interval */
815 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
816 'disabled="1" dojoType="dijit.form.Select"' );
818 $this -> batch_edit_cbox ( "update_interval" );
822 if ( FORCE_ARTICLE_PURGE
== 0 ) {
826 print __ ( 'Article purging:' ) . " " ;
828 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
829 'disabled="1" dojoType="dijit.form.Select"' );
831 $this -> batch_edit_cbox ( "purge_interval" );
835 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
836 print "<div class= \" dlgSecCont \" >" ;
838 print "<input dojoType= \" dijit.form.TextBox \"
839 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
840 name= \" auth_login \" value= \" $auth_login\" >" ;
842 $this -> batch_edit_cbox ( "auth_login" );
844 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
845 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
846 value= \" $auth_pass\" >" ;
848 $this -> batch_edit_cbox ( "auth_pass" );
851 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
852 print "<div class= \" dlgSecCont \" >" ;
854 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
855 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
857 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
859 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
860 name= \" include_in_digest \"
861 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
863 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
865 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
866 name= \" always_display_enclosures \"
867 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
869 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
871 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
873 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
874 for= \" hide_images \" >" .
875 __ ( 'Do not embed images' ). "</label>" ;
877 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
879 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
880 name= \" cache_images \"
881 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
882 for= \" cache_images \" >" .
883 __ ( 'Cache images locally' ). "</label>" ;
885 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
887 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
888 name= \" mark_unread_on_update \"
889 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
891 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
895 print "<div class='dlgButtons'>
896 <button dojoType= \" dijit.form.Button \"
897 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
898 __ ( 'Save' ). "</button>
899 <button dojoType= \" dijit.form.Button \"
900 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
901 __ ( 'Cancel' ). "</button>
907 function batchEditSave () {
908 return $this -> editsaveops ( true );
911 function editSave () {
912 return $this -> editsaveops ( false );
915 function editsaveops ( $batch ) {
917 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
918 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
919 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
920 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
921 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
922 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
923 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
924 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
925 $auth_pass = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_pass" ]));
926 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
927 $include_in_digest = checkbox_to_sql_bool (
928 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
929 $cache_images = checkbox_to_sql_bool (
930 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
931 $hide_images = checkbox_to_sql_bool (
932 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
933 $always_display_enclosures = checkbox_to_sql_bool (
934 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
936 $mark_unread_on_update = checkbox_to_sql_bool (
937 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
939 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
940 if ( $cat_id && $cat_id != 0 ) {
941 $category_qpart = "cat_id = ' $cat_id '," ;
942 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
944 $category_qpart = 'cat_id = NULL,' ;
945 $category_qpart_nocomma = 'cat_id = NULL' ;
948 $category_qpart = "" ;
949 $category_qpart_nocomma = "" ;
954 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
956 title = ' $feed_title ', feed_url = ' $feed_link ',
957 update_interval = ' $upd_intl ',
958 purge_interval = ' $purge_intl ',
959 auth_login = ' $auth_login ',
960 auth_pass = ' $auth_pass ',
962 cache_images = $cache_images ,
963 hide_images = $hide_images ,
964 include_in_digest = $include_in_digest ,
965 always_display_enclosures = $always_display_enclosures ,
966 mark_unread_on_update = $mark_unread_on_update
967 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
970 $feed_data = array ();
972 foreach ( array_keys ( $_POST ) as $k ) {
973 if ( $k != "op" && $k != "method" && $k != "ids" ) {
974 $feed_data [ $k ] = $_POST [ $k ];
978 db_query ( $this -> link
, "BEGIN" );
980 foreach ( array_keys ( $feed_data ) as $k ) {
986 $qpart = "title = ' $feed_title '" ;
990 $qpart = "feed_url = ' $feed_link '" ;
993 case "update_interval" :
994 $qpart = "update_interval = ' $upd_intl '" ;
997 case "purge_interval" :
998 $qpart = "purge_interval = ' $purge_intl '" ;
1002 $qpart = "auth_login = ' $auth_login '" ;
1006 $qpart = "auth_pass = ' $auth_pass '" ;
1010 $qpart = "private = $private " ;
1013 case "include_in_digest" :
1014 $qpart = "include_in_digest = $include_in_digest " ;
1017 case "always_display_enclosures" :
1018 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1021 case "mark_unread_on_update" :
1022 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1025 case "cache_images" :
1026 $qpart = "cache_images = $cache_images " ;
1030 $qpart = "hide_images = $hide_images " ;
1034 $qpart = $category_qpart_nocomma ;
1040 db_query ( $this -> link
,
1041 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1042 AND owner_uid = " . $_SESSION [ "uid" ]);
1047 db_query ( $this -> link
, "COMMIT" );
1052 function resetPubSub () {
1054 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1056 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1057 AND owner_uid = " . $_SESSION [ "uid" ]);
1064 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1066 foreach ( $ids as $id ) {
1067 Pref_Feeds
:: remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1074 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1075 $this -> clear_feed_articles ( $this -> link
, $id );
1078 function rescore () {
1079 require_once "rssfuncs.php" ;
1081 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1083 foreach ( $ids as $id ) {
1085 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1087 $result = db_query ( $this -> link
, "SELECT
1088 title, content, link, ref_id, author," .
1089 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1091 ttrss_user_entries, ttrss_entries
1092 WHERE ref_id = id AND feed_id = ' $id ' AND
1093 owner_uid = " . $_SESSION [ 'uid' ]. "
1098 while ( $line = db_fetch_assoc ( $result )) {
1100 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1102 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1103 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1104 $line [ 'author' ], $tags );
1106 $new_score = calculate_article_score ( $article_filters );
1108 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1110 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1113 foreach ( array_keys ( $scores ) as $s ) {
1115 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1117 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1118 } else if ( $s < - 500 ) {
1119 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1120 unread = false WHERE
1121 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1123 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1124 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1129 print __ ( "All done." );
1133 function rescoreAll () {
1135 $result = db_query ( $this -> link
,
1136 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1138 while ( $feed_line = db_fetch_assoc ( $result )) {
1140 $id = $feed_line [ "id" ];
1142 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1144 $tmp_result = db_query ( $this -> link
, "SELECT
1145 title, content, link, ref_id, author," .
1146 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1148 ttrss_user_entries, ttrss_entries
1149 WHERE ref_id = id AND feed_id = ' $id ' AND
1150 owner_uid = " . $_SESSION [ 'uid' ]. "
1155 while ( $line = db_fetch_assoc ( $tmp_result )) {
1157 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1159 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1160 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1161 $line [ 'author' ], $tags );
1163 $new_score = calculate_article_score ( $article_filters );
1165 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1167 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1170 foreach ( array_keys ( $scores ) as $s ) {
1172 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1174 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1176 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1177 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1182 print __ ( "All done." );
1186 function categorize () {
1187 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1189 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1192 $cat_id_qpart = 'NULL' ;
1194 $cat_id_qpart = "' $cat_id '" ;
1197 db_query ( $this -> link
, "BEGIN" );
1199 foreach ( $ids as $id ) {
1201 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1203 AND owner_uid = " . $_SESSION [ "uid" ]);
1207 db_query ( $this -> link
, "COMMIT" );
1210 function removeCat () {
1211 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1212 foreach ( $ids as $id ) {
1213 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1218 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1220 add_feed_category ( $this -> link
, $feed_cat );
1225 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1226 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1228 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1229 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1231 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1233 if ( $num_errors > 0 ) {
1235 $error_button = "<button dojoType= \" dijit.form.Button \"
1236 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1237 __ ( "Feeds with errors" ) . "</button>" ;
1240 if ( DB_TYPE
== "pgsql" ) {
1241 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1243 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1246 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1247 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1248 ttrss_entries.id = ref_id AND
1249 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1250 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1252 $num_inactive = db_fetch_result ( $result , 0 , "num_inactive" );
1254 if ( $num_inactive > 0 ) {
1255 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1256 onclick= \" showInactiveFeeds() \" >" .
1257 __ ( "Inactive feeds" ) . "</button>" ;
1260 $feed_search = db_escape_string ( $this -> link
, $_REQUEST [ "search" ]);
1262 if ( array_key_exists ( "search" , $_REQUEST )) {
1263 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1265 $feed_search = $_SESSION [ "prefs_feed_search" ];
1268 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1270 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1272 print "<div style='float : right; padding-right : 4px;'>
1273 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1274 value= \" $feed_search\" >
1275 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1276 __ ( 'Search' ). "</button>
1279 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1280 "<span>" . __ ( 'Select' ). "</span>" ;
1281 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1282 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1283 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1284 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1285 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1286 print "</div></div>" ;
1288 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1289 "<span>" . __ ( 'Feeds' ). "</span>" ;
1290 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1291 print "<div onclick= \" quickAddFeed() \"
1292 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1293 print "<div onclick= \" editSelectedFeed() \"
1294 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1295 print "<div onclick= \" resetFeedOrder() \"
1296 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1297 print "<div onclick= \" batchSubscribe() \"
1298 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1299 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1300 . __ ( 'Unsubscribe' ). "</div> " ;
1301 print "</div></div>" ;
1303 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1304 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1305 "<span>" . __ ( 'Categories' ). "</span>" ;
1306 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1307 print "<div onclick= \" createCategory() \"
1308 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1309 print "<div onclick= \" resetCatOrder() \"
1310 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1311 print "<div onclick= \" removeSelectedCategories() \"
1312 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1313 print "</div></div>" ;
1317 print $error_button ;
1318 print $inactive_button ;
1320 print "<button onclick= \" toggleHiddenFeedCats() \"
1321 dojoType= \" dijit.form.Button \" >" . __ ( '(Un)hide empty categories' ). "</button>" ;
1323 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1325 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1326 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1328 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1330 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1334 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1335 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1341 print "</div>" ; # toolbar
1344 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1346 print "<div id= \" feedlistLoading \" >
1347 <img src='images/indicator_tiny.gif'>" .
1348 __ ( "Loading, please wait..." ). "</div>" ;
1350 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1351 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1353 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1354 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1355 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1357 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1358 dndController= \" dijit.tree.dndSource \"
1359 betweenThreshold= \" 5 \"
1360 model= \" feedModel \" openOnClick= \" false \" >
1361 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1362 var id = String(item.id);
1363 var bare_id = id.substr(id.indexOf(':')+1);
1365 if (id.match('FEED:')) {
1367 } else if (id.match('CAT:')) {
1368 editCat(bare_id, item);
1371 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1372 Element.hide( \" feedlistLoading \" );
1376 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1377 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1383 print "</div>" ; # feeds pane
1385 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1387 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1389 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1391 print "<iframe id= \" upload_iframe \"
1392 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1393 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1395 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1396 enctype= \" multipart/form-data \" method= \" POST \"
1397 action= \" backend.php \" >
1398 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1399 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1400 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1401 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1402 __ ( 'Import my OPML' ) . "</button>" ;
1406 print "<p>" . __ ( 'Filename:' ) .
1407 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1408 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1410 print "</p><button dojoType= \" dijit.form.Button \"
1411 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1412 __ ( 'Export OPML' ) . "</button></p></form>" ;
1416 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1418 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1420 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1421 __ ( 'Display published OPML URL' ). "</button> " ;
1424 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1425 "hook_prefs_tab_section" , "prefFeedsOPML" );
1427 print "</div>" ; # pane
1429 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1431 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1433 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1437 print "<button onclick='window.navigator.registerContentHandler(" .
1438 " \" application/vnd.mozilla.maybe.feed \" , " .
1439 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1440 __ ( 'Click here to register this site as a feed reader.' ) .
1445 print "</div>" ; # pane
1448 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1450 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1452 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1454 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1455 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1457 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1458 __ ( 'Display URL' ). "</button> " ;
1460 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1461 __ ( 'Clear all generated URLs' ). "</button> " ;
1463 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1465 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1467 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1468 __ ( 'Unshare all articles' ). "</button> " ;
1471 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1472 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1474 print "</div>" ; #pane
1478 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1479 "hook_prefs_tab" , "prefFeeds" );
1481 print "</div>" ; #container
1484 private function feedlist_init_cat ( $cat_id ) {
1486 $cat_id = ( int ) $cat_id ;
1489 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1490 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1491 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1494 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1495 $obj [ 'items' ] = array ();
1496 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1497 $obj [ 'type' ] = 'category' ;
1498 $obj [ 'unread' ] = ( int ) $cat_unread ;
1499 $obj [ 'bare_id' ] = $cat_id ;
1504 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1506 $feed_id = ( int ) $feed_id ;
1509 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1511 if ( $unread === false )
1512 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1514 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1515 $obj [ 'name' ] = $title ;
1516 $obj [ 'unread' ] = ( int ) $unread ;
1517 $obj [ 'type' ] = 'feed' ;
1518 $obj [ 'error' ] = $error ;
1519 $obj [ 'updated' ] = $updated ;
1520 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1521 $obj [ 'bare_id' ] = $feed_id ;
1526 function inactiveFeeds () {
1528 if ( DB_TYPE
== "pgsql" ) {
1529 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1531 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1534 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1535 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1536 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1537 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1538 ttrss_entries.id = ref_id AND
1539 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1540 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1541 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1542 ttrss_entries.id = ref_id
1543 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1544 ORDER BY last_article" );
1546 print "<h2" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</h2>" ;
1548 print "<div dojoType= \" dijit.Toolbar \" >" ;
1549 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1550 "<span>" . __ ( 'Select' ). "</span>" ;
1551 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1552 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1553 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1554 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1555 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1556 print "</div></div>" ;
1557 print "</div>" ; #toolbar
1559 print "<div class= \" inactiveFeedHolder \" >" ;
1561 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1565 while ( $line = db_fetch_assoc ( $result )) {
1567 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1568 $feed_id = $line [ "id" ];
1569 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1571 # class needed for selectTableRows()
1572 print "<tr class= \" placeholder \" $this_row_id >" ;
1574 $edit_title = htmlspecialchars ( $line [ "title" ]);
1576 # id needed for selectTableRows()
1577 print "<td width='5%' align='center'><input
1578 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1579 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1582 print "<a class= \" visibleLink \" href= \" # \" " .
1583 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1584 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1585 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1587 print "</td><td class= \" insensitive \" align='right'>" ;
1588 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1598 print "<div class='dlgButtons'>" ;
1599 print "<div style='float : left'>" ;
1600 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1601 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1604 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1605 __ ( 'Close this window' ). "</button>" ;
1611 function feedsWithErrors () {
1612 print "<h2>" . __ ( "These feeds have not been updated because of errors:" ) .
1615 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1616 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1618 print "<div dojoType= \" dijit.Toolbar \" >" ;
1619 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1620 "<span>" . __ ( 'Select' ). "</span>" ;
1621 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1622 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1623 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1624 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1625 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1626 print "</div></div>" ;
1627 print "</div>" ; #toolbar
1629 print "<div class= \" inactiveFeedHolder \" >" ;
1631 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1635 while ( $line = db_fetch_assoc ( $result )) {
1637 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1638 $feed_id = $line [ "id" ];
1639 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1641 # class needed for selectTableRows()
1642 print "<tr class= \" placeholder \" $this_row_id >" ;
1644 $edit_title = htmlspecialchars ( $line [ "title" ]);
1646 # id needed for selectTableRows()
1647 print "<td width='5%' align='center'><input
1648 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1649 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1652 print "<a class= \" visibleLink \" href= \" # \" " .
1653 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1654 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1655 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1657 print "<span class= \" insensitive \" >" ;
1658 print htmlspecialchars ( $line [ "last_error" ]);
1670 print "<div class='dlgButtons'>" ;
1671 print "<div style='float : left'>" ;
1672 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1673 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1676 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1677 __ ( 'Close this window' ). "</button>" ;
1683 * Purge a feed contents, marked articles excepted.
1685 * @param mixed $link The database connection.
1686 * @param integer $id The id of the feed to purge.
1689 private function clear_feed_articles ( $link , $id ) {
1692 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1693 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1695 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1696 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1699 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1700 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1702 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1703 } // function clear_feed_articles
1705 private function remove_feed_category ( $link , $id , $owner_uid ) {
1707 db_query ( $link , "DELETE FROM ttrss_feed_categories
1708 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1710 ccache_remove ( $link , $id , $owner_uid , true );
1713 static function remove_feed ( $link , $id , $owner_uid ) {
1717 /* save starred articles in Archived feed */
1719 db_query ( $link , "BEGIN" );
1721 /* prepare feed if necessary */
1723 $result = db_query ( $link , "SELECT feed_url FROM ttrss_feeds WHERE id = $id
1724 AND owner_uid = $owner_uid " );
1726 $feed_url = db_escape_string ( $link , db_fetch_result ( $result , 0 , "feed_url" ));
1728 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1729 WHERE feed_url = ' $feed_url ' AND owner_uid = $owner_uid " );
1731 if ( db_num_rows ( $result ) == 0 ) {
1732 $result = db_query ( $link , "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1733 $new_feed_id = ( int ) db_fetch_result ( $result , 0 , "id" ) +
1 ;
1735 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1736 (id, owner_uid, title, feed_url, site_url)
1737 SELECT $new_feed_id , owner_uid, title, feed_url, site_url from ttrss_feeds
1740 $archive_id = $new_feed_id ;
1742 $archive_id = db_fetch_result ( $result , 0 , "id" );
1745 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1746 orig_feed_id = ' $archive_id ' WHERE feed_id = ' $id ' AND
1747 marked = true AND owner_uid = $owner_uid " );
1749 /* Remove access key for the feed */
1751 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1752 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1754 /* remove the feed */
1756 db_query ( $link , "DELETE FROM ttrss_feeds
1757 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1759 db_query ( $link , "COMMIT" );
1761 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1762 unlink ( ICONS_DIR
. "/ $id .ico" );
1765 ccache_remove ( $link , $id , $owner_uid );
1768 label_remove ( $link , feed_to_label_id ( $id ), $owner_uid );
1769 //ccache_remove($link, $id, $owner_uid); don't think labels are cached
1773 function batchSubscribe () {
1774 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
1775 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchaddfeeds \" >" ;
1777 print "<table width='100%'><tr><td>
1778 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1779 </td><td align='right'>" ;
1780 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1781 print __ ( 'Place in category:' ) . " " ;
1782 print_feed_cat_select ( $this -> link
, "cat" , false , 'dojoType="dijit.form.Select"' );
1784 print "</td></tr><tr><td colspan='2'>" ;
1786 style='font-size : 12px; width : 100%; height: 200px;'
1787 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1788 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1790 print "</td></tr><tr><td colspan='2'>" ;
1792 print "<div id='feedDlg_loginContainer' style='display : none'>
1794 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1795 placeHolder= \" " . __ ( "Login" ). " \"
1796 style= \" width : 10em; \" > " .
1798 placeHolder= \" " . __ ( "Password" ). " \"
1799 dojoType= \" dijit.form.TextBox \" type='password'
1800 style= \" width : 10em; \" name='pass' \" >" .
1803 print "</td></tr><tr><td colspan='2'>" ;
1805 print "<div style= \" clear : both \" >
1806 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1807 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1808 <label for= \" feedDlg_loginCheck \" >" .
1809 __ ( 'Feeds require authentication.' ). "</div>" ;
1813 print "</td></tr></table>" ;
1815 print "<div class= \" dlgButtons \" >
1816 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1817 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1821 function batchAddFeeds () {
1822 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ 'cat' ]);
1823 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1824 $login = db_escape_string ( $this -> link
, $_REQUEST [ 'login' ]);
1825 $pass = db_escape_string ( $this -> link
, $_REQUEST [ 'pass' ]);
1827 foreach ( $feeds as $feed ) {
1828 $feed = db_escape_string ( $this -> link
, trim ( $feed ));
1830 if ( validate_feed_url ( $feed )) {
1832 db_query ( $this -> link
, "BEGIN" );
1834 if ( $cat_id == "0" ||
! $cat_id ) {
1835 $cat_qpart = "NULL" ;
1837 $cat_qpart = "' $cat_id '" ;
1840 $result = db_query ( $this -> link
,
1841 "SELECT id FROM ttrss_feeds
1842 WHERE feed_url = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1844 if ( db_num_rows ( $result ) == 0 ) {
1845 $result = db_query ( $this -> link
,
1846 "INSERT INTO ttrss_feeds
1847 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method)
1848 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed ',
1849 '[Unknown]', $cat_qpart , ' $login ', ' $pass ', 0)" );
1852 db_query ( $this -> link
, "COMMIT" );
1857 function regenOPMLKey () {
1858 $this -> update_feed_access_key ( $this -> link
, 'OPML:Publish' ,
1859 false , $_SESSION [ "uid" ]);
1861 $new_link = Opml
:: opml_publish_url ( $this -> link
);
1863 print json_encode ( array ( "link" => $new_link ));
1866 function regenFeedKey () {
1867 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ 'id' ]);
1868 $is_cat = db_escape_string ( $this -> link
, $_REQUEST [ 'is_cat' ]) == "true" ;
1870 $new_key = $this -> update_feed_access_key ( $this -> link
, $feed_id , $is_cat );
1872 print json_encode ( array ( "link" => $new_key ));
1876 private function update_feed_access_key ( $link , $feed_id , $is_cat , $owner_uid = false ) {
1877 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1879 $sql_is_cat = bool_to_sql_bool ( $is_cat );
1881 $result = db_query ( $link , "SELECT access_key FROM ttrss_access_keys
1882 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1883 AND owner_uid = " . $owner_uid );
1885 if ( db_num_rows ( $result ) == 1 ) {
1886 $key = db_escape_string ( $this -> link
, sha1 ( uniqid ( rand (), true )));
1888 db_query ( $link , "UPDATE ttrss_access_keys SET access_key = ' $key '
1889 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1890 AND owner_uid = " . $owner_uid );
1895 return get_feed_access_key ( $link , $feed_id , $is_cat , $owner_uid );
1900 function clearKeys () {
1901 db_query ( $this -> link
, "DELETE FROM ttrss_access_keys WHERE
1902 owner_uid = " . $_SESSION [ "uid" ]);