]>
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 = $this -> dbh
-> escape_string ( $_REQUEST [ 'title' ]);
19 $id = $this -> dbh
-> escape_string ( $_REQUEST [ 'id' ]);
22 $this -> dbh
-> 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 );
43 $result = $this -> dbh
-> query ( "SELECT id, title FROM ttrss_feed_categories
44 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
46 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
49 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
50 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
51 $cat [ 'name' ] = $line [ 'title' ];
52 $cat [ 'items' ] = array ();
53 $cat [ 'checkbox' ] = false ;
54 $cat [ 'type' ] = 'category' ;
56 $cat [ 'child_unread' ] = 0 ;
58 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
60 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
62 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
63 array_push ( $items , $cat );
67 $feed_result = $this -> dbh
-> query ( "SELECT id, title, last_error,
68 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
70 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
71 " $search_qpart ORDER BY order_id, title" );
73 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
75 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
76 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
77 $feed [ 'name' ] = $feed_line [ 'title' ];
78 $feed [ 'checkbox' ] = false ;
80 $feed [ 'error' ] = $feed_line [ 'last_error' ];
81 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
82 $feed [ 'param' ] = make_local_datetime (
83 $feed_line [ 'last_updated' ], true );
85 array_push ( $items , $feed );
91 function getfeedtree () {
92 print json_encode ( $this -> makefeedtree ());
95 function makefeedtree () {
97 if ( $_REQUEST [ 'mode' ] != 2 )
98 $search = $_SESSION [ "prefs_feed_search" ];
102 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
105 $root [ 'id' ] = 'root' ;
106 $root [ 'name' ] = __ ( 'Feeds' );
107 $root [ 'items' ] = array ();
108 $root [ 'type' ] = 'category' ;
110 $enable_cats = get_pref ( 'ENABLE_FEED_CATS' );
112 if ( $_REQUEST [ 'mode' ] == 2 ) {
115 $cat = $this -> feedlist_init_cat (- 1 );
117 $cat [ 'items' ] = array ();
120 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
121 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
124 /* Plugin feeds for -1 */
126 $feeds = PluginHost
:: getInstance ()-> get_feeds (- 1 );
129 foreach ( $feeds as $feed ) {
130 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
133 $item [ 'id' ] = 'FEED:' . $feed_id ;
134 $item [ 'bare_id' ] = ( int ) $feed_id ;
135 $item [ 'name' ] = $feed [ 'title' ];
136 $item [ 'checkbox' ] = false ;
138 $item [ 'icon' ] = $feed [ 'icon' ];
141 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
142 $item [ 'type' ] = 'feed' ;
144 array_push ( $cat [ 'items' ], $item );
149 array_push ( $root [ 'items' ], $cat );
151 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
154 $result = $this -> dbh
-> query ( "SELECT * FROM
155 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
157 if ( $this -> dbh
-> num_rows ( $result ) > 0 ) {
159 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
160 $cat = $this -> feedlist_init_cat (- 2 );
162 $cat [ 'items' ] = array ();
165 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
167 $label_id = label_to_feed_id ( $line [ 'id' ]);
169 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
171 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
172 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
174 array_push ( $cat [ 'items' ], $feed );
178 array_push ( $root [ 'items' ], $cat );
180 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
186 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
187 ( $_REQUEST [ 'mode' ] != 2 && ! $search );
189 $result = $this -> dbh
-> query ( "SELECT id, title FROM ttrss_feed_categories
190 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
192 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
194 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
195 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
196 $cat [ 'name' ] = $line [ 'title' ];
197 $cat [ 'items' ] = array ();
198 $cat [ 'checkbox' ] = false ;
199 $cat [ 'type' ] = 'category' ;
201 $cat [ 'child_unread' ] = 0 ;
203 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
205 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
207 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
208 array_push ( $root [ 'items' ], $cat );
210 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
213 /* Uncategorized is a special case */
216 $cat [ 'id' ] = 'CAT:0' ;
218 $cat [ 'name' ] = __ ( "Uncategorized" );
219 $cat [ 'items' ] = array ();
220 $cat [ 'type' ] = 'category' ;
221 $cat [ 'checkbox' ] = false ;
223 $cat [ 'child_unread' ] = 0 ;
225 $feed_result = $this -> dbh
-> query ( "SELECT id, title,last_error,
226 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
228 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
229 " $search_qpart ORDER BY order_id, title" );
231 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
233 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
234 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
235 $feed [ 'name' ] = $feed_line [ 'title' ];
236 $feed [ 'checkbox' ] = false ;
237 $feed [ 'error' ] = $feed_line [ 'last_error' ];
238 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
239 $feed [ 'param' ] = make_local_datetime (
240 $feed_line [ 'last_updated' ], true );
242 $feed [ 'type' ] = 'feed' ;
244 array_push ( $cat [ 'items' ], $feed );
247 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
249 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
250 array_push ( $root [ 'items' ], $cat );
252 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
253 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
256 $feed_result = $this -> dbh
-> query ( "SELECT id, title, last_error,
257 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
259 WHERE owner_uid = " . $_SESSION [ "uid" ].
260 " $search_qpart ORDER BY order_id, title" );
262 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
264 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
265 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
266 $feed [ 'name' ] = $feed_line [ 'title' ];
267 $feed [ 'checkbox' ] = false ;
268 $feed [ 'error' ] = $feed_line [ 'last_error' ];
269 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
270 $feed [ 'param' ] = make_local_datetime (
271 $feed_line [ 'last_updated' ], true );
273 $feed [ 'type' ] = 'feed' ;
275 array_push ( $root [ 'items' ], $feed );
278 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
282 $fl [ 'identifier' ] = 'id' ;
283 $fl [ 'label' ] = 'name' ;
285 if ( $_REQUEST [ 'mode' ] != 2 ) {
286 $fl [ 'items' ] = array ( $root );
288 $fl [ 'items' ] =& $root [ 'items' ];
294 function catsortreset () {
295 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
296 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
300 function feedsortreset () {
301 $this -> dbh
-> query ( "UPDATE ttrss_feeds
302 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
306 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
307 $debug = isset ( $_REQUEST [ "debug" ]);
310 for ( $i = 0 ; $i < $nest_level ; $i ++
)
313 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
315 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
317 if ( $item_id != 'root' ) {
318 if ( $parent_id && $parent_id != 'root' ) {
319 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
320 $parent_qpart = $this -> dbh
-> escape_string ( $parent_bare_id );
322 $parent_qpart = 'NULL' ;
325 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
326 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
327 owner_uid = " . $_SESSION [ "uid" ]);
332 $cat = $data_map [ $item_id ];
334 if ( $cat && is_array ( $cat )) {
335 foreach ( $cat as $item ) {
336 $id = $item [ '_reference' ];
337 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
339 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
341 if ( $item [ '_reference' ]) {
343 if ( strpos ( $id , "FEED" ) === 0 ) {
345 $cat_id = ( $item_id != "root" ) ?
346 $this -> dbh
-> escape_string ( $bare_item_id ) : "NULL" ;
348 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
351 $this -> dbh
-> query ( "UPDATE ttrss_feeds
352 SET order_id = $order_id , $cat_qpart
353 WHERE id = ' $bare_id ' AND
354 owner_uid = " . $_SESSION [ "uid" ]);
356 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
357 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
360 if ( $item_id != 'root' ) {
361 $parent_qpart = $this -> dbh
-> escape_string ( $bare_id );
363 $parent_qpart = 'NULL' ;
366 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
367 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
368 owner_uid = " . $_SESSION [ "uid" ]);
377 function savefeedorder () {
378 $data = json_decode ( $_POST [ 'payload' ], true );
380 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
381 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
383 if (! is_array ( $data [ 'items' ]))
384 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
386 # print_r($data['items']);
388 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
394 foreach ( $data [ 'items' ] as $item ) {
396 # if ($item['id'] != 'root') {
397 if ( is_array ( $item [ 'items' ])) {
398 if ( isset ( $item [ 'items' ][ '_reference' ])) {
399 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
401 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
404 if ( $item [ 'id' ] == 'root' ) {
405 $root_item = $item [ 'id' ];
409 $this -> process_category_order ( $data_map , $root_item );
411 /* foreach ($data['items'][0]['items'] as $item) {
412 $id = $item['_reference'];
413 $bare_id = substr($id, strpos($id, ':')+1);
418 $this->dbh->query("UPDATE ttrss_feed_categories
419 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
420 owner_uid = " . $_SESSION["uid"]);
425 if (is_array($data_map[$id])) {
426 foreach ($data_map[$id] as $feed) {
427 $id = $feed['_reference'];
428 $feed_id = substr($id, strpos($id, ':')+1);
431 $cat_query = "cat_id = '$bare_id'";
433 $cat_query = "cat_id = NULL";
435 $this->dbh->query("UPDATE ttrss_feeds
436 SET order_id = '$feed_order_id',
438 WHERE id = '$feed_id' AND
439 owner_uid = " . $_SESSION["uid"]);
450 function removeicon () {
451 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "feed_id" ]);
453 $result = $this -> dbh
-> query ( "SELECT id FROM ttrss_feeds
454 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
456 if ( $this -> dbh
-> num_rows ( $result ) != 0 ) {
457 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
459 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET favicon_avg_color = NULL
460 where id = ' $feed_id '" );
466 function uploadicon () {
467 header ( "Content-type: text/html" );
471 if ( is_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ])) {
472 $tmp_file = tempnam ( CACHE_DIR
. '/upload' , 'icon' );
474 $result = move_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ],
484 $icon_file = $tmp_file ;
485 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "feed_id" ]);
487 if ( is_file ( $icon_file ) && $feed_id ) {
488 if ( filesize ( $icon_file ) < 20000 ) {
490 $result = $this -> dbh
-> query ( "SELECT id FROM ttrss_feeds
491 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
493 if ( $this -> dbh
-> num_rows ( $result ) != 0 ) {
494 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
495 if ( rename ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" )) {
496 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET
497 favicon_avg_color = ''
498 WHERE id = ' $feed_id '" );
514 print "<script type= \" text/javascript \" >" ;
515 print "parent.uploadIconHandler( $rc );" ;
520 function editfeed () {
521 global $purge_intervals ;
522 global $update_intervals ;
524 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "id" ]);
526 $result = $this -> dbh
-> query (
527 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
528 owner_uid = " . $_SESSION [ "uid" ]);
530 $auth_pass_encrypted = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 ,
531 "auth_pass_encrypted" ));
533 $title = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result ,
536 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
537 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
538 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
540 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
541 print "<div class= \" dlgSecCont \" >" ;
545 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
546 placeHolder= \" " . __ ( "Feed Title" ). " \"
547 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
551 $feed_url = $this -> dbh
-> fetch_result ( $result , 0 , "feed_url" );
552 $feed_url = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result ,
557 print __ ( 'URL:' ) . " " ;
558 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
559 placeHolder= \" " . __ ( "Feed URL" ). " \"
560 regExp='^(http|https)://.*' style= \" width : 20em \"
561 name= \" feed_url \" value= \" $feed_url\" >" ;
563 $last_error = $this -> dbh
-> fetch_result ( $result , 0 , "last_error" );
566 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
567 class= \" feed_error \" >(error)</span>" ;
573 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
575 $cat_id = $this -> dbh
-> fetch_result ( $result , 0 , "cat_id" );
579 print __ ( 'Place in category:' ) . " " ;
581 print_feed_cat_select ( "cat_id" , $cat_id ,
582 'dojoType="dijit.form.Select"' );
587 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
588 print "<div class= \" dlgSecCont \" >" ;
590 /* Update Interval */
592 $update_interval = $this -> dbh
-> fetch_result ( $result , 0 , "update_interval" );
594 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
595 'dojoType="dijit.form.Select"' );
599 $purge_interval = $this -> dbh
-> fetch_result ( $result , 0 , "purge_interval" );
602 print __ ( 'Article purging:' ) . " " ;
604 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
605 'dojoType="dijit.form.Select" ' .
606 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
609 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
610 print "<div class= \" dlgSecCont \" >" ;
612 $auth_login = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result , 0 , "auth_login" ));
614 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
615 placeHolder= \" " . __ ( "Login" ). " \"
616 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
618 $auth_pass = $this -> dbh
-> fetch_result ( $result , 0 , "auth_pass" );
620 if ( $auth_pass_encrypted ) {
621 require_once "crypt.php" ;
622 $auth_pass = decrypt_string ( $auth_pass );
625 $auth_pass = htmlspecialchars ( $auth_pass );
627 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
628 placeHolder= \" " . __ ( "Password" ). " \"
629 value= \" $auth_pass\" >" ;
631 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
632 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
636 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
637 print "<div class= \" dlgSecCont \" >" ;
639 $private = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "private" ));
642 $checked = "checked= \" 1 \" " ;
647 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
648 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
650 $include_in_digest = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "include_in_digest" ));
652 if ( $include_in_digest ) {
653 $checked = "checked= \" 1 \" " ;
658 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
659 name= \" include_in_digest \"
660 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
663 $always_display_enclosures = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "always_display_enclosures" ));
665 if ( $always_display_enclosures ) {
666 $checked = "checked" ;
671 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
672 name= \" always_display_enclosures \"
673 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
675 $hide_images = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "hide_images" ));
678 $checked = "checked= \" 1 \" " ;
683 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
685 $checked > <label for= \" hide_images \" >" .
686 __ ( 'Do not embed images' ). "</label>" ;
688 $cache_images = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "cache_images" ));
691 $checked = "checked= \" 1 \" " ;
696 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
697 name= \" cache_images \"
698 $checked > <label for= \" cache_images \" >" .
699 __ ( 'Cache images locally' ). "</label>" ;
701 $mark_unread_on_update = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "mark_unread_on_update" ));
703 if ( $mark_unread_on_update ) {
704 $checked = "checked" ;
709 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
710 name= \" mark_unread_on_update \"
711 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
717 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
718 print "<div class= \" dlgSecCont \" >" ;
720 print "<iframe name= \" icon_upload_iframe \"
721 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
723 print "<form style='display : block' target= \" icon_upload_iframe \"
724 enctype= \" multipart/form-data \" method= \" POST \"
725 action= \" backend.php \" >
726 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
727 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
728 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
729 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
730 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
731 type= \" submit \" >" . __ ( 'Replace' ). "</button>
732 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
733 type= \" submit \" >" . __ ( 'Remove' ). "</button>
738 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_EDIT_FEED
,
739 "hook_prefs_edit_feed" , $feed_id );
741 $title = htmlspecialchars ( $title , ENT_QUOTES
);
743 print "<div class='dlgButtons'>
744 <div style= \" float : left \" >
745 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
746 __ ( 'Unsubscribe' ). "</button>" ;
748 if ( PUBSUBHUBBUB_ENABLED
) {
749 $pubsub_state = $this -> dbh
-> fetch_result ( $result , 0 , "pubsub_state" );
750 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
752 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
753 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
759 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
760 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
762 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
763 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
769 function editfeeds () {
770 global $purge_intervals ;
771 global $update_intervals ;
773 $feed_ids = $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]);
775 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
779 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
780 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
781 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
783 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
784 print "<div class= \" dlgSecCont \" >" ;
788 print "<input dojoType= \" dijit.form.ValidationTextBox \"
789 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
790 name= \" title \" value= \"\" >" ;
792 $this -> batch_edit_cbox ( "title" );
798 print __ ( 'URL:' ) . " " ;
799 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
800 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
801 name= \" feed_url \" value= \"\" >" ;
803 $this -> batch_edit_cbox ( "feed_url" );
807 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
811 print __ ( 'Place in category:' ) . " " ;
813 print_feed_cat_select ( "cat_id" , false ,
814 'disabled="1" dojoType="dijit.form.Select"' );
816 $this -> batch_edit_cbox ( "cat_id" );
822 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
823 print "<div class= \" dlgSecCont \" >" ;
825 /* Update Interval */
827 print_select_hash ( "update_interval" , "" , $update_intervals ,
828 'disabled="1" dojoType="dijit.form.Select"' );
830 $this -> batch_edit_cbox ( "update_interval" );
834 if ( FORCE_ARTICLE_PURGE
== 0 ) {
838 print __ ( 'Article purging:' ) . " " ;
840 print_select_hash ( "purge_interval" , "" , $purge_intervals ,
841 'disabled="1" dojoType="dijit.form.Select"' );
843 $this -> batch_edit_cbox ( "purge_interval" );
847 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
848 print "<div class= \" dlgSecCont \" >" ;
850 print "<input dojoType= \" dijit.form.TextBox \"
851 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
852 name= \" auth_login \" value= \"\" >" ;
854 $this -> batch_edit_cbox ( "auth_login" );
856 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
857 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
860 $this -> batch_edit_cbox ( "auth_pass" );
863 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
864 print "<div class= \" dlgSecCont \" >" ;
866 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
867 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
869 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
871 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
872 name= \" include_in_digest \"
873 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
875 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
877 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
878 name= \" always_display_enclosures \"
879 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
881 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
883 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
885 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
886 for= \" hide_images \" >" .
887 __ ( 'Do not embed images' ). "</label>" ;
889 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
891 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
892 name= \" cache_images \"
893 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
894 for= \" cache_images \" >" .
895 __ ( 'Cache images locally' ). "</label>" ;
897 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
899 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
900 name= \" mark_unread_on_update \"
901 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
903 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
907 print "<div class='dlgButtons'>
908 <button dojoType= \" dijit.form.Button \"
909 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
910 __ ( 'Save' ). "</button>
911 <button dojoType= \" dijit.form.Button \"
912 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
913 __ ( 'Cancel' ). "</button>
919 function batchEditSave () {
920 return $this -> editsaveops ( true );
923 function editSave () {
924 return $this -> editsaveops ( false );
927 function editsaveops ( $batch ) {
929 $feed_title = $this -> dbh
-> escape_string ( trim ( $_POST [ "title" ]));
930 $feed_link = $this -> dbh
-> escape_string ( trim ( $_POST [ "feed_url" ]));
931 $upd_intl = ( int ) $this -> dbh
-> escape_string ( $_POST [ "update_interval" ]);
932 $purge_intl = ( int ) $this -> dbh
-> escape_string ( $_POST [ "purge_interval" ]);
933 $feed_id = ( int ) $this -> dbh
-> escape_string ( $_POST [ "id" ]); /* editSave */
934 $feed_ids = $this -> dbh
-> escape_string ( $_POST [ "ids" ]); /* batchEditSave */
935 $cat_id = ( int ) $this -> dbh
-> escape_string ( $_POST [ "cat_id" ]);
936 $auth_login = $this -> dbh
-> escape_string ( trim ( $_POST [ "auth_login" ]));
937 $auth_pass = trim ( $_POST [ "auth_pass" ]);
938 $private = checkbox_to_sql_bool ( $this -> dbh
-> escape_string ( $_POST [ "private" ]));
939 $include_in_digest = checkbox_to_sql_bool (
940 $this -> dbh
-> escape_string ( $_POST [ "include_in_digest" ]));
941 $cache_images = checkbox_to_sql_bool (
942 $this -> dbh
-> escape_string ( $_POST [ "cache_images" ]));
943 $hide_images = checkbox_to_sql_bool (
944 $this -> dbh
-> escape_string ( $_POST [ "hide_images" ]));
945 $always_display_enclosures = checkbox_to_sql_bool (
946 $this -> dbh
-> escape_string ( $_POST [ "always_display_enclosures" ]));
948 $mark_unread_on_update = checkbox_to_sql_bool (
949 $this -> dbh
-> escape_string ( $_POST [ "mark_unread_on_update" ]));
951 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
952 require_once "crypt.php" ;
953 $auth_pass = substr ( encrypt_string ( $auth_pass ), 0 , 250 );
954 $auth_pass_encrypted = 'true' ;
956 $auth_pass_encrypted = 'false' ;
959 $auth_pass = $this -> dbh
-> escape_string ( $auth_pass );
961 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
962 if ( $cat_id && $cat_id != 0 ) {
963 $category_qpart = "cat_id = ' $cat_id '," ;
964 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
966 $category_qpart = 'cat_id = NULL,' ;
967 $category_qpart_nocomma = 'cat_id = NULL' ;
970 $category_qpart = "" ;
971 $category_qpart_nocomma = "" ;
976 $result = $this -> dbh
-> query ( "UPDATE ttrss_feeds SET
978 title = ' $feed_title ', feed_url = ' $feed_link ',
979 update_interval = ' $upd_intl ',
980 purge_interval = ' $purge_intl ',
981 auth_login = ' $auth_login ',
982 auth_pass = ' $auth_pass ',
983 auth_pass_encrypted = $auth_pass_encrypted ,
985 cache_images = $cache_images ,
986 hide_images = $hide_images ,
987 include_in_digest = $include_in_digest ,
988 always_display_enclosures = $always_display_enclosures ,
989 mark_unread_on_update = $mark_unread_on_update
990 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
992 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_SAVE_FEED
,
993 "hook_prefs_save_feed" , $feed_id );
996 $feed_data = array ();
998 foreach ( array_keys ( $_POST ) as $k ) {
999 if ( $k != "op" && $k != "method" && $k != "ids" ) {
1000 $feed_data [ $k ] = $_POST [ $k ];
1004 $this -> dbh
-> query ( "BEGIN" );
1006 foreach ( array_keys ( $feed_data ) as $k ) {
1012 $qpart = "title = ' $feed_title '" ;
1016 $qpart = "feed_url = ' $feed_link '" ;
1019 case "update_interval" :
1020 $qpart = "update_interval = ' $upd_intl '" ;
1023 case "purge_interval" :
1024 $qpart = "purge_interval = ' $purge_intl '" ;
1028 $qpart = "auth_login = ' $auth_login '" ;
1032 $qpart = "auth_pass = ' $auth_pass ' AND
1033 auth_pass_encrypted = $auth_pass_encrypted " ;
1037 $qpart = "private = $private " ;
1040 case "include_in_digest" :
1041 $qpart = "include_in_digest = $include_in_digest " ;
1044 case "always_display_enclosures" :
1045 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1048 case "mark_unread_on_update" :
1049 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1052 case "cache_images" :
1053 $qpart = "cache_images = $cache_images " ;
1057 $qpart = "hide_images = $hide_images " ;
1061 $qpart = $category_qpart_nocomma ;
1068 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1069 AND owner_uid = " . $_SESSION [ "uid" ]);
1074 $this -> dbh
-> query ( "COMMIT" );
1079 function resetPubSub () {
1081 $ids = $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]);
1083 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1084 AND owner_uid = " . $_SESSION [ "uid" ]);
1091 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1093 foreach ( $ids as $id ) {
1094 Pref_Feeds
:: remove_feed ( $id , $_SESSION [ "uid" ]);
1101 $id = $this -> dbh
-> escape_string ( $_REQUEST [ "id" ]);
1102 $this -> clear_feed_articles ( $id );
1105 function rescore () {
1106 require_once "rssfuncs.php" ;
1108 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1110 foreach ( $ids as $id ) {
1112 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1114 $result = $this -> dbh
-> query ( "SELECT
1115 title, content, link, ref_id, author," .
1116 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1118 ttrss_user_entries, ttrss_entries
1119 WHERE ref_id = id AND feed_id = ' $id ' AND
1120 owner_uid = " . $_SESSION [ 'uid' ]. "
1125 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1127 $tags = get_article_tags ( $line [ "ref_id" ]);
1129 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1130 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1131 $line [ 'author' ], $tags );
1133 $new_score = calculate_article_score ( $article_filters );
1135 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1137 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1140 foreach ( array_keys ( $scores ) as $s ) {
1142 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1144 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1145 } else if ( $s < - 500 ) {
1146 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1147 unread = false WHERE
1148 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1150 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1151 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1156 print __ ( "All done." );
1160 function rescoreAll () {
1162 $result = $this -> dbh
-> query (
1163 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1165 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $result )) {
1167 $id = $feed_line [ "id" ];
1169 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1171 $tmp_result = $this -> dbh
-> query ( "SELECT
1172 title, content, link, ref_id, author," .
1173 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1175 ttrss_user_entries, ttrss_entries
1176 WHERE ref_id = id AND feed_id = ' $id ' AND
1177 owner_uid = " . $_SESSION [ 'uid' ]. "
1182 while ( $line = $this -> dbh
-> fetch_assoc ( $tmp_result )) {
1184 $tags = get_article_tags ( $line [ "ref_id" ]);
1186 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1187 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1188 $line [ 'author' ], $tags );
1190 $new_score = calculate_article_score ( $article_filters );
1192 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1194 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1197 foreach ( array_keys ( $scores ) as $s ) {
1199 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1201 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1203 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1204 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1209 print __ ( "All done." );
1213 function categorize () {
1214 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1216 $cat_id = $this -> dbh
-> escape_string ( $_REQUEST [ "cat_id" ]);
1219 $cat_id_qpart = 'NULL' ;
1221 $cat_id_qpart = "' $cat_id '" ;
1224 $this -> dbh
-> query ( "BEGIN" );
1226 foreach ( $ids as $id ) {
1228 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1230 AND owner_uid = " . $_SESSION [ "uid" ]);
1234 $this -> dbh
-> query ( "COMMIT" );
1237 function removeCat () {
1238 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1239 foreach ( $ids as $id ) {
1240 $this -> remove_feed_category ( $id , $_SESSION [ "uid" ]);
1245 $feed_cat = $this -> dbh
-> escape_string ( trim ( $_REQUEST [ "cat" ]));
1247 add_feed_category ( $feed_cat );
1252 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1253 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1255 $result = $this -> dbh
-> query ( "SELECT COUNT(id) AS num_errors
1256 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1258 $num_errors = $this -> dbh
-> fetch_result ( $result , 0 , "num_errors" );
1260 if ( $num_errors > 0 ) {
1262 $error_button = "<button dojoType= \" dijit.form.Button \"
1263 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1264 __ ( "Feeds with errors" ) . "</button>" ;
1267 if ( DB_TYPE
== "pgsql" ) {
1268 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1270 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1273 $result = $this -> dbh
-> query ( "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1274 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1275 ttrss_entries.id = ref_id AND
1276 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1277 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1279 $num_inactive = $this -> dbh
-> fetch_result ( $result , 0 , "num_inactive" );
1281 if ( $num_inactive > 0 ) {
1282 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1283 onclick= \" showInactiveFeeds() \" >" .
1284 __ ( "Inactive feeds" ) . "</button>" ;
1287 $feed_search = $this -> dbh
-> escape_string ( $_REQUEST [ "search" ]);
1289 if ( array_key_exists ( "search" , $_REQUEST )) {
1290 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1292 $feed_search = $_SESSION [ "prefs_feed_search" ];
1295 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1297 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1299 print "<div style='float : right; padding-right : 4px;'>
1300 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1301 value= \" $feed_search\" >
1302 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1303 __ ( 'Search' ). "</button>
1306 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1307 "<span>" . __ ( 'Select' ). "</span>" ;
1308 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1309 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1310 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1311 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1312 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1313 print "</div></div>" ;
1315 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1316 "<span>" . __ ( 'Feeds' ). "</span>" ;
1317 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1318 print "<div onclick= \" quickAddFeed() \"
1319 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1320 print "<div onclick= \" editSelectedFeed() \"
1321 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1322 print "<div onclick= \" resetFeedOrder() \"
1323 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1324 print "<div onclick= \" batchSubscribe() \"
1325 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1326 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1327 . __ ( 'Unsubscribe' ). "</div> " ;
1328 print "</div></div>" ;
1330 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1331 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1332 "<span>" . __ ( 'Categories' ). "</span>" ;
1333 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1334 print "<div onclick= \" createCategory() \"
1335 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1336 print "<div onclick= \" resetCatOrder() \"
1337 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1338 print "<div onclick= \" removeSelectedCategories() \"
1339 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1340 print "</div></div>" ;
1344 print $error_button ;
1345 print $inactive_button ;
1347 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1349 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1350 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1352 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1354 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1358 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1359 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1365 print "</div>" ; # toolbar
1368 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1370 print "<div id= \" feedlistLoading \" >
1371 <img src='images/indicator_tiny.gif'>" .
1372 __ ( "Loading, please wait..." ). "</div>" ;
1374 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1375 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1377 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1378 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1379 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1381 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1382 dndController= \" dijit.tree.dndSource \"
1383 betweenThreshold= \" 5 \"
1384 model= \" feedModel \" openOnClick= \" false \" >
1385 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1386 var id = String(item.id);
1387 var bare_id = id.substr(id.indexOf(':')+1);
1389 if (id.match('FEED:')) {
1391 } else if (id.match('CAT:')) {
1392 editCat(bare_id, item);
1395 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1396 Element.hide( \" feedlistLoading \" );
1400 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1401 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1407 print "</div>" ; # feeds pane
1409 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1411 print_notice ( __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . __ ( "Only main settings profile can be migrated using OPML." ));
1413 print "<iframe id= \" upload_iframe \"
1414 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1415 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1417 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1418 enctype= \" multipart/form-data \" method= \" POST \"
1419 action= \" backend.php \" >
1420 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1421 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1422 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1423 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1424 __ ( 'Import my OPML' ) . "</button>" ;
1428 print "<p>" . __ ( 'Filename:' ) .
1429 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1430 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1432 print "</p><button dojoType= \" dijit.form.Button \"
1433 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1434 __ ( 'Export OPML' ) . "</button></p></form>" ;
1438 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1440 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1442 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1443 __ ( 'Display published OPML URL' ). "</button> " ;
1445 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1446 "hook_prefs_tab_section" , "prefFeedsOPML" );
1448 print "</div>" ; # pane
1450 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1452 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1454 print_notice ( __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ));
1458 print "<button onclick='window.navigator.registerContentHandler(" .
1459 " \" application/vnd.mozilla.maybe.feed \" , " .
1460 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1461 __ ( 'Click here to register this site as a feed reader.' ) .
1466 print "</div>" ; # pane
1469 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1471 print_notice ( __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ));
1473 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1474 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1478 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1479 __ ( 'Display URL' ). "</button> " ;
1481 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1482 __ ( 'Clear all generated URLs' ). "</button> " ;
1486 print_warning ( __ ( "You can disable all articles shared by unique URLs here." ));
1490 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1491 __ ( 'Unshare all articles' ). "</button> " ;
1495 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1496 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1498 print "</div>" ; #pane
1500 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB
,
1501 "hook_prefs_tab" , "prefFeeds" );
1503 print "</div>" ; #container
1506 private function feedlist_init_cat ( $cat_id ) {
1508 $cat_id = ( int ) $cat_id ;
1511 $cat_unread = ccache_find ( $cat_id , $_SESSION [ "uid" ], true );
1512 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1513 $cat_unread = getCategoryUnread ( $cat_id );
1516 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1517 $obj [ 'items' ] = array ();
1518 $obj [ 'name' ] = getCategoryTitle ( $cat_id );
1519 $obj [ 'type' ] = 'category' ;
1520 $obj [ 'unread' ] = ( int ) $cat_unread ;
1521 $obj [ 'bare_id' ] = $cat_id ;
1526 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1528 $feed_id = ( int ) $feed_id ;
1531 $title = getFeedTitle ( $feed_id , false );
1533 if ( $unread === false )
1534 $unread = getFeedUnread ( $feed_id , false );
1536 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1537 $obj [ 'name' ] = $title ;
1538 $obj [ 'unread' ] = ( int ) $unread ;
1539 $obj [ 'type' ] = 'feed' ;
1540 $obj [ 'error' ] = $error ;
1541 $obj [ 'updated' ] = $updated ;
1542 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1543 $obj [ 'bare_id' ] = $feed_id ;
1548 function inactiveFeeds () {
1550 if ( DB_TYPE
== "pgsql" ) {
1551 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1553 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1556 $result = $this -> dbh
-> query ( "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1557 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1558 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1559 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1560 ttrss_entries.id = ref_id AND
1561 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1562 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1563 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1564 ttrss_entries.id = ref_id
1565 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1566 ORDER BY last_article" );
1568 print "<p" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</p>" ;
1570 print "<div dojoType= \" dijit.Toolbar \" >" ;
1571 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1572 "<span>" . __ ( 'Select' ). "</span>" ;
1573 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1574 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1575 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1576 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1577 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1578 print "</div></div>" ;
1579 print "</div>" ; #toolbar
1581 print "<div class= \" inactiveFeedHolder \" >" ;
1583 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1587 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1589 $feed_id = $line [ "id" ];
1590 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1592 # class needed for selectTableRows()
1593 print "<tr class= \" placeholder \" $this_row_id >" ;
1595 $edit_title = htmlspecialchars ( $line [ "title" ]);
1597 # id needed for selectTableRows()
1598 print "<td width='5%' align='center'><input
1599 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1600 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1603 print "<a class= \" visibleLink \" href= \" # \" " .
1604 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1605 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1606 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1608 print "</td><td class= \" insensitive \" align='right'>" ;
1609 print make_local_datetime ( $line [ 'last_article' ], false );
1619 print "<div class='dlgButtons'>" ;
1620 print "<div style='float : left'>" ;
1621 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1622 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1625 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1626 __ ( 'Close this window' ). "</button>" ;
1632 function feedsWithErrors () {
1633 $result = $this -> dbh
-> query ( "SELECT id,title,feed_url,last_error,site_url
1634 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1636 print "<div dojoType= \" dijit.Toolbar \" >" ;
1637 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1638 "<span>" . __ ( 'Select' ). "</span>" ;
1639 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1640 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1641 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1642 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1643 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1644 print "</div></div>" ;
1645 print "</div>" ; #toolbar
1647 print "<div class= \" inactiveFeedHolder \" >" ;
1649 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1653 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1655 $feed_id = $line [ "id" ];
1656 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1658 # class needed for selectTableRows()
1659 print "<tr class= \" placeholder \" $this_row_id >" ;
1661 $edit_title = htmlspecialchars ( $line [ "title" ]);
1663 # id needed for selectTableRows()
1664 print "<td width='5%' align='center'><input
1665 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1666 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1669 print "<a class= \" visibleLink \" href= \" # \" " .
1670 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1671 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1672 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1674 print "<span class= \" insensitive \" >" ;
1675 print htmlspecialchars ( $line [ "last_error" ]);
1687 print "<div class='dlgButtons'>" ;
1688 print "<div style='float : left'>" ;
1689 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1690 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1693 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1694 __ ( 'Close this window' ). "</button>" ;
1700 * Purge a feed contents, marked articles excepted.
1702 * @param mixed $link The database connection.
1703 * @param integer $id The id of the feed to purge.
1706 private function clear_feed_articles ( $id ) {
1709 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_user_entries
1710 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1712 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_user_entries
1713 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1716 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_entries WHERE
1717 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1719 ccache_update ( $id , $_SESSION [ 'uid' ]);
1720 } // function clear_feed_articles
1722 private function remove_feed_category ( $id , $owner_uid ) {
1724 $this -> dbh
-> query ( "DELETE FROM ttrss_feed_categories
1725 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1727 ccache_remove ( $id , $owner_uid , true );
1730 static function remove_feed ( $id , $owner_uid ) {
1734 /* save starred articles in Archived feed */
1738 /* prepare feed if necessary */
1740 $result = db_query ( "SELECT feed_url FROM ttrss_feeds WHERE id = $id
1741 AND owner_uid = $owner_uid " );
1743 $feed_url = db_escape_string ( db_fetch_result ( $result , 0 , "feed_url" ));
1745 $result = db_query ( "SELECT id FROM ttrss_archived_feeds
1746 WHERE feed_url = ' $feed_url ' AND owner_uid = $owner_uid " );
1748 if ( db_num_rows ( $result ) == 0 ) {
1749 $result = db_query ( "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1750 $new_feed_id = ( int ) db_fetch_result ( $result , 0 , "id" ) +
1 ;
1752 db_query ( "INSERT INTO ttrss_archived_feeds
1753 (id, owner_uid, title, feed_url, site_url)
1754 SELECT $new_feed_id , owner_uid, title, feed_url, site_url from ttrss_feeds
1757 $archive_id = $new_feed_id ;
1759 $archive_id = db_fetch_result ( $result , 0 , "id" );
1762 db_query ( "UPDATE ttrss_user_entries SET feed_id = NULL,
1763 orig_feed_id = ' $archive_id ' WHERE feed_id = ' $id ' AND
1764 marked = true AND owner_uid = $owner_uid " );
1766 /* Remove access key for the feed */
1768 db_query ( "DELETE FROM ttrss_access_keys WHERE
1769 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1771 /* remove the feed */
1773 db_query ( "DELETE FROM ttrss_feeds
1774 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1778 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1779 unlink ( ICONS_DIR
. "/ $id .ico" );
1782 ccache_remove ( $id , $owner_uid );
1785 label_remove ( feed_to_label_id ( $id ), $owner_uid );
1786 //ccache_remove($id, $owner_uid); don't think labels are cached
1790 function batchSubscribe () {
1791 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
1792 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchaddfeeds \" >" ;
1794 print "<table width='100%'><tr><td>
1795 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1796 </td><td align='right'>" ;
1797 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1798 print __ ( 'Place in category:' ) . " " ;
1799 print_feed_cat_select ( "cat" , false , 'dojoType="dijit.form.Select"' );
1801 print "</td></tr><tr><td colspan='2'>" ;
1803 style='font-size : 12px; width : 100%; height: 200px;'
1804 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1805 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1807 print "</td></tr><tr><td colspan='2'>" ;
1809 print "<div id='feedDlg_loginContainer' style='display : none'>
1811 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1812 placeHolder= \" " . __ ( "Login" ). " \"
1813 style= \" width : 10em; \" > " .
1815 placeHolder= \" " . __ ( "Password" ). " \"
1816 dojoType= \" dijit.form.TextBox \" type='password'
1817 style= \" width : 10em; \" name='pass' \" >" .
1820 print "</td></tr><tr><td colspan='2'>" ;
1822 print "<div style= \" clear : both \" >
1823 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1824 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1825 <label for= \" feedDlg_loginCheck \" >" .
1826 __ ( 'Feeds require authentication.' ). "</div>" ;
1830 print "</td></tr></table>" ;
1832 print "<div class= \" dlgButtons \" >
1833 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1834 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1838 function batchAddFeeds () {
1839 $cat_id = $this -> dbh
-> escape_string ( $_REQUEST [ 'cat' ]);
1840 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1841 $login = $this -> dbh
-> escape_string ( $_REQUEST [ 'login' ]);
1842 $pass = trim ( $_REQUEST [ 'pass' ]);
1844 foreach ( $feeds as $feed ) {
1845 $feed = $this -> dbh
-> escape_string ( trim ( $feed ));
1847 if ( validate_feed_url ( $feed )) {
1849 $this -> dbh
-> query ( "BEGIN" );
1851 if ( $cat_id == "0" ||
! $cat_id ) {
1852 $cat_qpart = "NULL" ;
1854 $cat_qpart = "' $cat_id '" ;
1857 $result = $this -> dbh
-> query (
1858 "SELECT id FROM ttrss_feeds
1859 WHERE feed_url = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1861 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
1862 require_once "crypt.php" ;
1863 $pass = substr ( encrypt_string ( $pass ), 0 , 250 );
1864 $auth_pass_encrypted = 'true' ;
1866 $auth_pass_encrypted = 'false' ;
1869 $pass = $this -> dbh
-> escape_string ( $pass );
1871 if ( $this -> dbh
-> num_rows ( $result ) == 0 ) {
1872 $result = $this -> dbh
-> query (
1873 "INSERT INTO ttrss_feeds
1874 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1875 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed ',
1876 '[Unknown]', $cat_qpart , ' $login ', ' $pass ', 0, $auth_pass_encrypted )" );
1879 $this -> dbh
-> query ( "COMMIT" );
1884 function regenOPMLKey () {
1885 $this -> update_feed_access_key ( 'OPML:Publish' ,
1886 false , $_SESSION [ "uid" ]);
1888 $new_link = Opml
:: opml_publish_url ();
1890 print json_encode ( array ( "link" => $new_link ));
1893 function regenFeedKey () {
1894 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ 'id' ]);
1895 $is_cat = $this -> dbh
-> escape_string ( $_REQUEST [ 'is_cat' ]) == "true" ;
1897 $new_key = $this -> update_feed_access_key ( $feed_id , $is_cat );
1899 print json_encode ( array ( "link" => $new_key ));
1903 private function update_feed_access_key ( $feed_id , $is_cat , $owner_uid = false ) {
1904 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1906 $sql_is_cat = bool_to_sql_bool ( $is_cat );
1908 $result = $this -> dbh
-> query ( "SELECT access_key FROM ttrss_access_keys
1909 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1910 AND owner_uid = " . $owner_uid );
1912 if ( $this -> dbh
-> num_rows ( $result ) == 1 ) {
1913 $key = $this -> dbh
-> escape_string ( sha1 ( uniqid ( rand (), true )));
1915 $this -> dbh
-> query ( "UPDATE ttrss_access_keys SET access_key = ' $key '
1916 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1917 AND owner_uid = " . $owner_uid );
1922 return get_feed_access_key ( $feed_id , $is_cat , $owner_uid );
1927 function clearKeys () {
1928 $this -> dbh
-> query ( "DELETE FROM ttrss_access_keys WHERE
1929 owner_uid = " . $_SESSION [ "uid" ]);