]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
efa2c2af9b4b11bcaae94b1011cd92dc5d7fd924
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 ;
57 $cat [ 'auxcounter' ] = 0 ;
58 $cat [ 'parent_id' ] = $cat_id ;
60 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
62 $num_children = $this -> calculate_children_count ( $cat );
63 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , $num_children ), $num_children );
65 if ( $num_children > 0 ||
$show_empty_cats )
66 array_push ( $items , $cat );
70 $feed_result = $this -> dbh
-> query ( "SELECT id, title, last_error,
71 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
73 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
74 " $search_qpart ORDER BY order_id, title" );
76 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
78 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
79 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
80 $feed [ 'auxcounter' ] = 0 ;
81 $feed [ 'name' ] = $feed_line [ 'title' ];
82 $feed [ 'checkbox' ] = false ;
84 $feed [ 'error' ] = $feed_line [ 'last_error' ];
85 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
86 $feed [ 'param' ] = make_local_datetime (
87 $feed_line [ 'last_updated' ], true );
89 array_push ( $items , $feed );
95 function getfeedtree () {
96 print json_encode ( $this -> makefeedtree ());
99 function makefeedtree () {
101 if ( $_REQUEST [ 'mode' ] != 2 )
102 $search = $_SESSION [ "prefs_feed_search" ];
106 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
109 $root [ 'id' ] = 'root' ;
110 $root [ 'name' ] = __ ( 'Feeds' );
111 $root [ 'items' ] = array ();
112 $root [ 'type' ] = 'category' ;
114 $enable_cats = get_pref ( 'ENABLE_FEED_CATS' );
116 if ( $_REQUEST [ 'mode' ] == 2 ) {
119 $cat = $this -> feedlist_init_cat (- 1 );
121 $cat [ 'items' ] = array ();
124 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
125 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
128 /* Plugin feeds for -1 */
130 $feeds = PluginHost
:: getInstance ()-> get_feeds (- 1 );
133 foreach ( $feeds as $feed ) {
134 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
137 $item [ 'id' ] = 'FEED:' . $feed_id ;
138 $item [ 'bare_id' ] = ( int ) $feed_id ;
139 $item [ 'auxcounter' ] = 0 ;
140 $item [ 'name' ] = $feed [ 'title' ];
141 $item [ 'checkbox' ] = false ;
143 $item [ 'icon' ] = $feed [ 'icon' ];
146 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
147 $item [ 'type' ] = 'feed' ;
149 array_push ( $cat [ 'items' ], $item );
154 array_push ( $root [ 'items' ], $cat );
156 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
159 $result = $this -> dbh
-> query ( "SELECT * FROM
160 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
162 if ( $this -> dbh
-> num_rows ( $result ) > 0 ) {
164 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
165 $cat = $this -> feedlist_init_cat (- 2 );
167 $cat [ 'items' ] = array ();
170 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
172 $label_id = label_to_feed_id ( $line [ 'id' ]);
174 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
176 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
177 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
179 array_push ( $cat [ 'items' ], $feed );
183 array_push ( $root [ 'items' ], $cat );
185 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
191 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
192 ( $_REQUEST [ 'mode' ] != 2 && ! $search );
194 $result = $this -> dbh
-> query ( "SELECT id, title FROM ttrss_feed_categories
195 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
197 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
199 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
200 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
201 $cat [ 'auxcounter' ] = 0 ;
202 $cat [ 'name' ] = $line [ 'title' ];
203 $cat [ 'items' ] = array ();
204 $cat [ 'checkbox' ] = false ;
205 $cat [ 'type' ] = 'category' ;
207 $cat [ 'child_unread' ] = 0 ;
209 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
211 $num_children = $this -> calculate_children_count ( $cat );
212 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , $num_children ), $num_children );
214 if ( $num_children > 0 ||
$show_empty_cats )
215 array_push ( $root [ 'items' ], $cat );
217 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
220 /* Uncategorized is a special case */
223 $cat [ 'id' ] = 'CAT:0' ;
225 $cat [ 'auxcounter' ] = 0 ;
226 $cat [ 'name' ] = __ ( "Uncategorized" );
227 $cat [ 'items' ] = array ();
228 $cat [ 'type' ] = 'category' ;
229 $cat [ 'checkbox' ] = false ;
231 $cat [ 'child_unread' ] = 0 ;
233 $feed_result = $this -> dbh
-> query ( "SELECT id, title,last_error,
234 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
236 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
237 " $search_qpart ORDER BY order_id, title" );
239 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
241 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
242 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
243 $feed [ 'auxcounter' ] = 0 ;
244 $feed [ 'name' ] = $feed_line [ 'title' ];
245 $feed [ 'checkbox' ] = false ;
246 $feed [ 'error' ] = $feed_line [ 'last_error' ];
247 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
248 $feed [ 'param' ] = make_local_datetime (
249 $feed_line [ 'last_updated' ], true );
251 $feed [ 'type' ] = 'feed' ;
253 array_push ( $cat [ 'items' ], $feed );
256 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
258 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
259 array_push ( $root [ 'items' ], $cat );
261 $num_children = $this -> calculate_children_count ( $root );
262 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , $num_children ), $num_children );
265 $feed_result = $this -> dbh
-> query ( "SELECT id, title, last_error,
266 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
268 WHERE owner_uid = " . $_SESSION [ "uid" ].
269 " $search_qpart ORDER BY order_id, title" );
271 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
273 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
274 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
275 $feed [ 'auxcounter' ] = 0 ;
276 $feed [ 'name' ] = $feed_line [ 'title' ];
277 $feed [ 'checkbox' ] = false ;
278 $feed [ 'error' ] = $feed_line [ 'last_error' ];
279 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
280 $feed [ 'param' ] = make_local_datetime (
281 $feed_line [ 'last_updated' ], true );
283 $feed [ 'type' ] = 'feed' ;
285 array_push ( $root [ 'items' ], $feed );
288 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
292 $fl [ 'identifier' ] = 'id' ;
293 $fl [ 'label' ] = 'name' ;
295 if ( $_REQUEST [ 'mode' ] != 2 ) {
296 $fl [ 'items' ] = array ( $root );
298 $fl [ 'items' ] =& $root [ 'items' ];
304 function catsortreset () {
305 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
306 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
310 function feedsortreset () {
311 $this -> dbh
-> query ( "UPDATE ttrss_feeds
312 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
316 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
317 $debug = isset ( $_REQUEST [ "debug" ]);
320 for ( $i = 0 ; $i < $nest_level ; $i ++
)
323 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
325 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
327 if ( $item_id != 'root' ) {
328 if ( $parent_id && $parent_id != 'root' ) {
329 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
330 $parent_qpart = $this -> dbh
-> escape_string ( $parent_bare_id );
332 $parent_qpart = 'NULL' ;
335 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
336 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
337 owner_uid = " . $_SESSION [ "uid" ]);
342 $cat = $data_map [ $item_id ];
344 if ( $cat && is_array ( $cat )) {
345 foreach ( $cat as $item ) {
346 $id = $item [ '_reference' ];
347 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
349 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
351 if ( $item [ '_reference' ]) {
353 if ( strpos ( $id , "FEED" ) === 0 ) {
355 $cat_id = ( $item_id != "root" ) ?
356 $this -> dbh
-> escape_string ( $bare_item_id ) : "NULL" ;
358 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
361 $this -> dbh
-> query ( "UPDATE ttrss_feeds
362 SET order_id = $order_id , $cat_qpart
363 WHERE id = ' $bare_id ' AND
364 owner_uid = " . $_SESSION [ "uid" ]);
366 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
367 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
370 if ( $item_id != 'root' ) {
371 $parent_qpart = $this -> dbh
-> escape_string ( $bare_id );
373 $parent_qpart = 'NULL' ;
376 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
377 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
378 owner_uid = " . $_SESSION [ "uid" ]);
387 function savefeedorder () {
388 $data = json_decode ( $_POST [ 'payload' ], true );
390 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
391 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
393 if (! is_array ( $data [ 'items' ]))
394 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
396 # print_r($data['items']);
398 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
404 foreach ( $data [ 'items' ] as $item ) {
406 # if ($item['id'] != 'root') {
407 if ( is_array ( $item [ 'items' ])) {
408 if ( isset ( $item [ 'items' ][ '_reference' ])) {
409 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
411 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
414 if ( $item [ 'id' ] == 'root' ) {
415 $root_item = $item [ 'id' ];
419 $this -> process_category_order ( $data_map , $root_item );
421 /* foreach ($data['items'][0]['items'] as $item) {
422 $id = $item['_reference'];
423 $bare_id = substr($id, strpos($id, ':')+1);
428 $this->dbh->query("UPDATE ttrss_feed_categories
429 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
430 owner_uid = " . $_SESSION["uid"]);
435 if (is_array($data_map[$id])) {
436 foreach ($data_map[$id] as $feed) {
437 $id = $feed['_reference'];
438 $feed_id = substr($id, strpos($id, ':')+1);
441 $cat_query = "cat_id = '$bare_id'";
443 $cat_query = "cat_id = NULL";
445 $this->dbh->query("UPDATE ttrss_feeds
446 SET order_id = '$feed_order_id',
448 WHERE id = '$feed_id' AND
449 owner_uid = " . $_SESSION["uid"]);
460 function removeicon () {
461 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "feed_id" ]);
463 $result = $this -> dbh
-> query ( "SELECT id FROM ttrss_feeds
464 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
466 if ( $this -> dbh
-> num_rows ( $result ) != 0 ) {
467 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
469 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET favicon_avg_color = NULL
470 where id = ' $feed_id '" );
476 function uploadicon () {
477 header ( "Content-type: text/html" );
481 if ( is_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ])) {
482 $tmp_file = tempnam ( CACHE_DIR
. '/upload' , 'icon' );
484 $result = move_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ],
494 $icon_file = $tmp_file ;
495 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "feed_id" ]);
497 if ( is_file ( $icon_file ) && $feed_id ) {
498 if ( filesize ( $icon_file ) < 65535 ) {
500 $result = $this -> dbh
-> query ( "SELECT id FROM ttrss_feeds
501 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
503 if ( $this -> dbh
-> num_rows ( $result ) != 0 ) {
504 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
505 if ( rename ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" )) {
506 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET
507 favicon_avg_color = ''
508 WHERE id = ' $feed_id '" );
524 print "<script type= \" text/javascript \" >" ;
525 print "parent.uploadIconHandler( $rc );" ;
530 function editfeed () {
531 global $purge_intervals ;
532 global $update_intervals ;
534 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "id" ]);
536 $result = $this -> dbh
-> query (
537 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
538 owner_uid = " . $_SESSION [ "uid" ]);
540 $auth_pass_encrypted = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 ,
541 "auth_pass_encrypted" ));
543 $title = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result ,
546 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
547 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
548 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
550 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
551 print "<div class= \" dlgSecCont \" >" ;
555 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
556 placeHolder= \" " . __ ( "Feed Title" ). " \"
557 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
561 $feed_url = $this -> dbh
-> fetch_result ( $result , 0 , "feed_url" );
562 $feed_url = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result ,
567 print __ ( 'URL:' ) . " " ;
568 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
569 placeHolder= \" " . __ ( "Feed URL" ). " \"
570 regExp='^(http|https)://.*' style= \" width : 20em \"
571 name= \" feed_url \" value= \" $feed_url\" >" ;
573 $last_error = $this -> dbh
-> fetch_result ( $result , 0 , "last_error" );
576 print " <img src= \" images/error.png \" alt= \" (error) \"
577 style= \" vertical-align : middle \"
578 title= \" " . htmlspecialchars ( $last_error ). " \" >" ;
584 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
586 $cat_id = $this -> dbh
-> fetch_result ( $result , 0 , "cat_id" );
590 print __ ( 'Place in category:' ) . " " ;
592 print_feed_cat_select ( "cat_id" , $cat_id ,
593 'dojoType="dijit.form.Select"' );
598 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
599 print "<div class= \" dlgSecCont \" >" ;
601 /* Update Interval */
603 $update_interval = $this -> dbh
-> fetch_result ( $result , 0 , "update_interval" );
605 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
606 'dojoType="dijit.form.Select"' );
610 $purge_interval = $this -> dbh
-> fetch_result ( $result , 0 , "purge_interval" );
613 print __ ( 'Article purging:' ) . " " ;
615 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
616 'dojoType="dijit.form.Select" ' .
617 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
620 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
621 print "<div class= \" dlgSecCont \" >" ;
623 $auth_login = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result , 0 , "auth_login" ));
625 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
626 placeHolder= \" " . __ ( "Login" ). " \"
627 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
629 $auth_pass = $this -> dbh
-> fetch_result ( $result , 0 , "auth_pass" );
631 if ( $auth_pass_encrypted ) {
632 require_once "crypt.php" ;
633 $auth_pass = decrypt_string ( $auth_pass );
636 $auth_pass = htmlspecialchars ( $auth_pass );
638 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
639 placeHolder= \" " . __ ( "Password" ). " \"
640 value= \" $auth_pass\" >" ;
642 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
643 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
647 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
648 print "<div class= \" dlgSecCont \" >" ;
650 $private = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "private" ));
653 $checked = "checked= \" 1 \" " ;
658 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
659 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
661 $include_in_digest = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "include_in_digest" ));
663 if ( $include_in_digest ) {
664 $checked = "checked= \" 1 \" " ;
669 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
670 name= \" include_in_digest \"
671 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
674 $always_display_enclosures = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "always_display_enclosures" ));
676 if ( $always_display_enclosures ) {
677 $checked = "checked" ;
682 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
683 name= \" always_display_enclosures \"
684 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
686 $hide_images = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "hide_images" ));
689 $checked = "checked= \" 1 \" " ;
694 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
696 $checked > <label for= \" hide_images \" >" .
697 __ ( 'Do not embed images' ). "</label>" ;
699 $cache_images = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "cache_images" ));
702 $checked = "checked= \" 1 \" " ;
707 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
708 name= \" cache_images \"
709 $checked > <label for= \" cache_images \" >" .
710 __ ( 'Cache images locally' ). "</label>" ;
712 $mark_unread_on_update = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "mark_unread_on_update" ));
714 if ( $mark_unread_on_update ) {
715 $checked = "checked" ;
720 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
721 name= \" mark_unread_on_update \"
722 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
728 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
729 print "<div class= \" dlgSecCont \" >" ;
731 print "<iframe name= \" icon_upload_iframe \"
732 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
734 print "<form style='display : block' target= \" icon_upload_iframe \"
735 enctype= \" multipart/form-data \" method= \" POST \"
736 action= \" backend.php \" >
737 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
738 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
739 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
740 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
741 <button class= \" small \" dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
742 type= \" submit \" >" . __ ( 'Replace' ). "</button>
743 <button class= \" small \" dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
744 type= \" submit \" >" . __ ( 'Remove' ). "</button>
749 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_EDIT_FEED
,
750 "hook_prefs_edit_feed" , $feed_id );
752 $title = htmlspecialchars ( $title , ENT_QUOTES
);
754 print "<div class='dlgButtons'>
755 <div style= \" float : left \" >
756 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
757 __ ( 'Unsubscribe' ). "</button>" ;
759 if ( PUBSUBHUBBUB_ENABLED
) {
760 $pubsub_state = $this -> dbh
-> fetch_result ( $result , 0 , "pubsub_state" );
761 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
763 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
764 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
770 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
771 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
773 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
774 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
780 function editfeeds () {
781 global $purge_intervals ;
782 global $update_intervals ;
784 $feed_ids = $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]);
786 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
790 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
791 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
792 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
794 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
795 print "<div class= \" dlgSecCont \" >" ;
799 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
801 print __ ( 'Place in category:' ) . " " ;
803 print_feed_cat_select ( "cat_id" , false ,
804 'disabled="1" dojoType="dijit.form.Select"' );
806 $this -> batch_edit_cbox ( "cat_id" );
812 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
813 print "<div class= \" dlgSecCont \" >" ;
815 /* Update Interval */
817 print_select_hash ( "update_interval" , "" , $update_intervals ,
818 'disabled="1" dojoType="dijit.form.Select"' );
820 $this -> batch_edit_cbox ( "update_interval" );
824 if ( FORCE_ARTICLE_PURGE
== 0 ) {
828 print __ ( 'Article purging:' ) . " " ;
830 print_select_hash ( "purge_interval" , "" , $purge_intervals ,
831 'disabled="1" dojoType="dijit.form.Select"' );
833 $this -> batch_edit_cbox ( "purge_interval" );
837 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
838 print "<div class= \" dlgSecCont \" >" ;
840 print "<input dojoType= \" dijit.form.TextBox \"
841 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
842 name= \" auth_login \" value= \"\" >" ;
844 $this -> batch_edit_cbox ( "auth_login" );
846 print "<hr/> <input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
847 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
850 $this -> batch_edit_cbox ( "auth_pass" );
853 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
854 print "<div class= \" dlgSecCont \" >" ;
856 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
857 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
859 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
861 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
862 name= \" include_in_digest \"
863 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
865 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
867 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
868 name= \" always_display_enclosures \"
869 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
871 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
873 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
875 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
876 for= \" hide_images \" >" .
877 __ ( 'Do not embed images' ). "</label>" ;
879 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
881 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
882 name= \" cache_images \"
883 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
884 for= \" cache_images \" >" .
885 __ ( 'Cache images locally' ). "</label>" ;
887 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
889 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
890 name= \" mark_unread_on_update \"
891 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
893 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
897 print "<div class='dlgButtons'>
898 <button dojoType= \" dijit.form.Button \"
899 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
900 __ ( 'Save' ). "</button>
901 <button dojoType= \" dijit.form.Button \"
902 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
903 __ ( 'Cancel' ). "</button>
909 function batchEditSave () {
910 return $this -> editsaveops ( true );
913 function editSave () {
914 return $this -> editsaveops ( false );
917 function editsaveops ( $batch ) {
919 $feed_title = $this -> dbh
-> escape_string ( trim ( $_POST [ "title" ]));
920 $feed_link = $this -> dbh
-> escape_string ( trim ( $_POST [ "feed_url" ]));
921 $upd_intl = ( int ) $this -> dbh
-> escape_string ( $_POST [ "update_interval" ]);
922 $purge_intl = ( int ) $this -> dbh
-> escape_string ( $_POST [ "purge_interval" ]);
923 $feed_id = ( int ) $this -> dbh
-> escape_string ( $_POST [ "id" ]); /* editSave */
924 $feed_ids = $this -> dbh
-> escape_string ( $_POST [ "ids" ]); /* batchEditSave */
925 $cat_id = ( int ) $this -> dbh
-> escape_string ( $_POST [ "cat_id" ]);
926 $auth_login = $this -> dbh
-> escape_string ( trim ( $_POST [ "auth_login" ]));
927 $auth_pass = trim ( $_POST [ "auth_pass" ]);
928 $private = checkbox_to_sql_bool ( $this -> dbh
-> escape_string ( $_POST [ "private" ]));
929 $include_in_digest = checkbox_to_sql_bool (
930 $this -> dbh
-> escape_string ( $_POST [ "include_in_digest" ]));
931 $cache_images = checkbox_to_sql_bool (
932 $this -> dbh
-> escape_string ( $_POST [ "cache_images" ]));
933 $hide_images = checkbox_to_sql_bool (
934 $this -> dbh
-> escape_string ( $_POST [ "hide_images" ]));
935 $always_display_enclosures = checkbox_to_sql_bool (
936 $this -> dbh
-> escape_string ( $_POST [ "always_display_enclosures" ]));
938 $mark_unread_on_update = checkbox_to_sql_bool (
939 $this -> dbh
-> escape_string ( $_POST [ "mark_unread_on_update" ]));
941 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
942 require_once "crypt.php" ;
943 $auth_pass = substr ( encrypt_string ( $auth_pass ), 0 , 250 );
944 $auth_pass_encrypted = 'true' ;
946 $auth_pass_encrypted = 'false' ;
949 $auth_pass = $this -> dbh
-> escape_string ( $auth_pass );
951 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
952 if ( $cat_id && $cat_id != 0 ) {
953 $category_qpart = "cat_id = ' $cat_id '," ;
954 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
956 $category_qpart = 'cat_id = NULL,' ;
957 $category_qpart_nocomma = 'cat_id = NULL' ;
960 $category_qpart = "" ;
961 $category_qpart_nocomma = "" ;
966 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET
968 title = ' $feed_title ', feed_url = ' $feed_link ',
969 update_interval = ' $upd_intl ',
970 purge_interval = ' $purge_intl ',
971 auth_login = ' $auth_login ',
972 auth_pass = ' $auth_pass ',
973 auth_pass_encrypted = $auth_pass_encrypted ,
975 cache_images = $cache_images ,
976 hide_images = $hide_images ,
977 include_in_digest = $include_in_digest ,
978 always_display_enclosures = $always_display_enclosures ,
979 mark_unread_on_update = $mark_unread_on_update
980 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
982 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_SAVE_FEED
,
983 "hook_prefs_save_feed" , $feed_id );
986 $feed_data = array ();
988 foreach ( array_keys ( $_POST ) as $k ) {
989 if ( $k != "op" && $k != "method" && $k != "ids" ) {
990 $feed_data [ $k ] = $_POST [ $k ];
994 $this -> dbh
-> query ( "BEGIN" );
996 foreach ( array_keys ( $feed_data ) as $k ) {
1002 $qpart = "title = ' $feed_title '" ;
1006 $qpart = "feed_url = ' $feed_link '" ;
1009 case "update_interval" :
1010 $qpart = "update_interval = ' $upd_intl '" ;
1013 case "purge_interval" :
1014 $qpart = "purge_interval = ' $purge_intl '" ;
1018 $qpart = "auth_login = ' $auth_login '" ;
1022 $qpart = "auth_pass = ' $auth_pass ' AND
1023 auth_pass_encrypted = $auth_pass_encrypted " ;
1027 $qpart = "private = $private " ;
1030 case "include_in_digest" :
1031 $qpart = "include_in_digest = $include_in_digest " ;
1034 case "always_display_enclosures" :
1035 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1038 case "mark_unread_on_update" :
1039 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1042 case "cache_images" :
1043 $qpart = "cache_images = $cache_images " ;
1047 $qpart = "hide_images = $hide_images " ;
1051 $qpart = $category_qpart_nocomma ;
1058 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1059 AND owner_uid = " . $_SESSION [ "uid" ]);
1064 $this -> dbh
-> query ( "COMMIT" );
1069 function resetPubSub () {
1071 $ids = $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]);
1073 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1074 AND owner_uid = " . $_SESSION [ "uid" ]);
1081 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1083 foreach ( $ids as $id ) {
1084 Pref_Feeds
:: remove_feed ( $id , $_SESSION [ "uid" ]);
1091 $id = $this -> dbh
-> escape_string ( $_REQUEST [ "id" ]);
1092 $this -> clear_feed_articles ( $id );
1095 function rescore () {
1096 require_once "rssfuncs.php" ;
1098 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1100 foreach ( $ids as $id ) {
1102 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1104 $result = $this -> dbh
-> query ( "SELECT
1105 title, content, link, ref_id, author," .
1106 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1108 ttrss_user_entries, ttrss_entries
1109 WHERE ref_id = id AND feed_id = ' $id ' AND
1110 owner_uid = " . $_SESSION [ 'uid' ]. "
1115 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1117 $tags = get_article_tags ( $line [ "ref_id" ]);
1119 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1120 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1121 $line [ 'author' ], $tags );
1123 $new_score = calculate_article_score ( $article_filters );
1125 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1127 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1130 foreach ( array_keys ( $scores ) as $s ) {
1132 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1134 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1135 } else if ( $s < - 500 ) {
1136 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1137 unread = false WHERE
1138 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1140 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1141 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1146 print __ ( "All done." );
1150 function rescoreAll () {
1152 $result = $this -> dbh
-> query (
1153 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1155 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $result )) {
1157 $id = $feed_line [ "id" ];
1159 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1161 $tmp_result = $this -> dbh
-> query ( "SELECT
1162 title, content, link, ref_id, author," .
1163 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1165 ttrss_user_entries, ttrss_entries
1166 WHERE ref_id = id AND feed_id = ' $id ' AND
1167 owner_uid = " . $_SESSION [ 'uid' ]. "
1172 while ( $line = $this -> dbh
-> fetch_assoc ( $tmp_result )) {
1174 $tags = get_article_tags ( $line [ "ref_id" ]);
1176 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1177 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1178 $line [ 'author' ], $tags );
1180 $new_score = calculate_article_score ( $article_filters );
1182 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1184 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1187 foreach ( array_keys ( $scores ) as $s ) {
1189 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1191 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1193 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1194 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1199 print __ ( "All done." );
1203 function categorize () {
1204 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1206 $cat_id = $this -> dbh
-> escape_string ( $_REQUEST [ "cat_id" ]);
1209 $cat_id_qpart = 'NULL' ;
1211 $cat_id_qpart = "' $cat_id '" ;
1214 $this -> dbh
-> query ( "BEGIN" );
1216 foreach ( $ids as $id ) {
1218 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1220 AND owner_uid = " . $_SESSION [ "uid" ]);
1224 $this -> dbh
-> query ( "COMMIT" );
1227 function removeCat () {
1228 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1229 foreach ( $ids as $id ) {
1230 $this -> remove_feed_category ( $id , $_SESSION [ "uid" ]);
1235 $feed_cat = $this -> dbh
-> escape_string ( trim ( $_REQUEST [ "cat" ]));
1237 add_feed_category ( $feed_cat );
1242 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1243 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1245 $result = $this -> dbh
-> query ( "SELECT COUNT(id) AS num_errors
1246 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1248 $num_errors = $this -> dbh
-> fetch_result ( $result , 0 , "num_errors" );
1250 if ( $num_errors > 0 ) {
1252 $error_button = "<button dojoType= \" dijit.form.Button \"
1253 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1254 __ ( "Feeds with errors" ) . "</button>" ;
1257 if ( DB_TYPE
== "pgsql" ) {
1258 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1260 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1263 // could be performance-intensive and prevent feeds pref-panel from showing
1264 if (! defined ( '_DISABLE_INACTIVE_FEEDS' ) ||
! _DISABLE_INACTIVE_FEEDS
) {
1265 $result = $this -> dbh
-> query ( "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1266 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1267 ttrss_entries.id = ref_id AND
1268 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1269 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1271 $num_inactive = $this -> dbh
-> fetch_result ( $result , 0 , "num_inactive" );
1276 if ( $num_inactive > 0 ) {
1277 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1278 onclick= \" showInactiveFeeds() \" >" .
1279 __ ( "Inactive feeds" ) . "</button>" ;
1282 $feed_search = $this -> dbh
-> escape_string ( $_REQUEST [ "search" ]);
1284 if ( array_key_exists ( "search" , $_REQUEST )) {
1285 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1287 $feed_search = $_SESSION [ "prefs_feed_search" ];
1290 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1292 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1294 print "<div style='float : right; padding-right : 4px;'>
1295 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1296 value= \" $feed_search\" >
1297 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1298 __ ( 'Search' ). "</button>
1301 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1302 "<span>" . __ ( 'Select' ). "</span>" ;
1303 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1304 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1305 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1306 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1307 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1308 print "</div></div>" ;
1310 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1311 "<span>" . __ ( 'Feeds' ). "</span>" ;
1312 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1313 print "<div onclick= \" quickAddFeed() \"
1314 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1315 print "<div onclick= \" editSelectedFeed() \"
1316 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1317 print "<div onclick= \" resetFeedOrder() \"
1318 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1319 print "<div onclick= \" batchSubscribe() \"
1320 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1321 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1322 . __ ( 'Unsubscribe' ). "</div> " ;
1323 print "</div></div>" ;
1325 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1326 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1327 "<span>" . __ ( 'Categories' ). "</span>" ;
1328 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1329 print "<div onclick= \" createCategory() \"
1330 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1331 print "<div onclick= \" resetCatOrder() \"
1332 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1333 print "<div onclick= \" removeSelectedCategories() \"
1334 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1335 print "</div></div>" ;
1339 print $error_button ;
1340 print $inactive_button ;
1342 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1344 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1345 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1347 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1349 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1353 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1354 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1360 print "</div>" ; # toolbar
1363 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1365 print "<div id= \" feedlistLoading \" >
1366 <img src='images/indicator_tiny.gif'>" .
1367 __ ( "Loading, please wait..." ). "</div>" ;
1369 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1370 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1372 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1373 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1374 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1376 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1377 dndController= \" dijit.tree.dndSource \"
1378 betweenThreshold= \" 5 \"
1379 model= \" feedModel \" openOnClick= \" false \" >
1380 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1381 var id = String(item.id);
1382 var bare_id = id.substr(id.indexOf(':')+1);
1384 if (id.match('FEED:')) {
1386 } else if (id.match('CAT:')) {
1387 editCat(bare_id, item);
1390 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1391 Element.hide( \" feedlistLoading \" );
1395 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1396 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1402 print "</div>" ; # feeds pane
1404 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1406 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." ));
1408 print "<iframe id= \" upload_iframe \"
1409 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1410 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1412 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1413 enctype= \" multipart/form-data \" method= \" POST \"
1414 action= \" backend.php \" >
1415 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1416 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1417 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1418 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1419 __ ( 'Import my OPML' ) . "</button>" ;
1423 print "<p>" . __ ( 'Filename:' ) .
1424 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1425 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1427 print "</p><button dojoType= \" dijit.form.Button \"
1428 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1429 __ ( 'Export OPML' ) . "</button></p></form>" ;
1433 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1435 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1437 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1438 __ ( 'Display published OPML URL' ). "</button> " ;
1440 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1441 "hook_prefs_tab_section" , "prefFeedsOPML" );
1443 print "</div>" ; # pane
1445 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1447 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1449 print_notice ( __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ));
1453 print "<button onclick='window.navigator.registerContentHandler(" .
1454 " \" application/vnd.mozilla.maybe.feed \" , " .
1455 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1456 __ ( 'Click here to register this site as a feed reader.' ) .
1461 print "</div>" ; # pane
1464 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1466 print_notice ( __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ));
1468 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1469 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1473 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1474 __ ( 'Display URL' ). "</button> " ;
1476 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1477 __ ( 'Clear all generated URLs' ). "</button> " ;
1481 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1482 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1484 print "</div>" ; #pane
1486 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB
,
1487 "hook_prefs_tab" , "prefFeeds" );
1489 print "</div>" ; #container
1492 private function feedlist_init_cat ( $cat_id ) {
1494 $cat_id = ( int ) $cat_id ;
1497 $cat_unread = ccache_find ( $cat_id , $_SESSION [ "uid" ], true );
1498 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1499 $cat_unread = getCategoryUnread ( $cat_id );
1502 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1503 $obj [ 'items' ] = array ();
1504 $obj [ 'name' ] = getCategoryTitle ( $cat_id );
1505 $obj [ 'type' ] = 'category' ;
1506 $obj [ 'unread' ] = ( int ) $cat_unread ;
1507 $obj [ 'bare_id' ] = $cat_id ;
1512 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1514 $feed_id = ( int ) $feed_id ;
1517 $title = getFeedTitle ( $feed_id , false );
1519 if ( $unread === false )
1520 $unread = getFeedUnread ( $feed_id , false );
1522 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1523 $obj [ 'name' ] = $title ;
1524 $obj [ 'unread' ] = ( int ) $unread ;
1525 $obj [ 'type' ] = 'feed' ;
1526 $obj [ 'error' ] = $error ;
1527 $obj [ 'updated' ] = $updated ;
1528 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1529 $obj [ 'bare_id' ] = $feed_id ;
1530 $obj [ 'auxcounter' ] = 0 ;
1535 function inactiveFeeds () {
1537 if ( DB_TYPE
== "pgsql" ) {
1538 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1540 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1543 $result = $this -> dbh
-> query ( "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1544 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1545 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1546 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1547 ttrss_entries.id = ref_id AND
1548 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1549 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1550 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1551 ttrss_entries.id = ref_id
1552 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1553 ORDER BY last_article" );
1555 print "<p" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</p>" ;
1557 print "<div dojoType= \" dijit.Toolbar \" >" ;
1558 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1559 "<span>" . __ ( 'Select' ). "</span>" ;
1560 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1561 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1562 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1563 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1564 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1565 print "</div></div>" ;
1566 print "</div>" ; #toolbar
1568 print "<div class= \" inactiveFeedHolder \" >" ;
1570 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1574 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1576 $feed_id = $line [ "id" ];
1577 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1579 # class needed for selectTableRows()
1580 print "<tr class= \" placeholder \" $this_row_id >" ;
1582 # id needed for selectTableRows()
1583 print "<td width='5%' align='center'><input
1584 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1585 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1588 print "<a class= \" visibleLink \" href= \" # \" " .
1589 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1590 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1591 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1593 print "</td><td class= \" insensitive \" align='right'>" ;
1594 print make_local_datetime ( $line [ 'last_article' ], false );
1604 print "<div class='dlgButtons'>" ;
1605 print "<div style='float : left'>" ;
1606 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1607 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1610 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1611 __ ( 'Close this window' ). "</button>" ;
1617 function feedsWithErrors () {
1618 $result = $this -> dbh
-> query ( "SELECT id,title,feed_url,last_error,site_url
1619 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1621 print "<div dojoType= \" dijit.Toolbar \" >" ;
1622 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1623 "<span>" . __ ( 'Select' ). "</span>" ;
1624 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1625 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1626 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1627 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1628 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1629 print "</div></div>" ;
1630 print "</div>" ; #toolbar
1632 print "<div class= \" inactiveFeedHolder \" >" ;
1634 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1638 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1640 $feed_id = $line [ "id" ];
1641 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1643 # class needed for selectTableRows()
1644 print "<tr class= \" placeholder \" $this_row_id >" ;
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 ( $id ) {
1692 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_user_entries
1693 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1695 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_user_entries
1696 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1699 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_entries WHERE
1700 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1702 ccache_update ( $id , $_SESSION [ 'uid' ]);
1703 } // function clear_feed_articles
1705 private function remove_feed_category ( $id , $owner_uid ) {
1707 $this -> dbh
-> query ( "DELETE FROM ttrss_feed_categories
1708 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1710 ccache_remove ( $id , $owner_uid , true );
1713 static function remove_feed ( $id , $owner_uid ) {
1717 /* save starred articles in Archived feed */
1721 /* prepare feed if necessary */
1723 $result = db_query ( "SELECT feed_url FROM ttrss_feeds WHERE id = $id
1724 AND owner_uid = $owner_uid " );
1726 $feed_url = db_escape_string ( db_fetch_result ( $result , 0 , "feed_url" ));
1728 $result = db_query ( "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 ( "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1733 $new_feed_id = ( int ) db_fetch_result ( $result , 0 , "id" ) +
1 ;
1735 db_query ( "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 ( "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 ( "DELETE FROM ttrss_access_keys WHERE
1752 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1754 /* remove the feed */
1756 db_query ( "DELETE FROM ttrss_feeds
1757 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1761 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1762 unlink ( ICONS_DIR
. "/ $id .ico" );
1765 ccache_remove ( $id , $owner_uid );
1768 label_remove ( feed_to_label_id ( $id ), $owner_uid );
1769 //ccache_remove($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 ( 'ENABLE_FEED_CATS' )) {
1781 print __ ( 'Place in category:' ) . " " ;
1782 print_feed_cat_select ( "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 = $this -> dbh
-> escape_string ( $_REQUEST [ 'cat' ]);
1823 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1824 $login = $this -> dbh
-> escape_string ( $_REQUEST [ 'login' ]);
1825 $pass = trim ( $_REQUEST [ 'pass' ]);
1827 foreach ( $feeds as $feed ) {
1828 $feed = $this -> dbh
-> escape_string ( trim ( $feed ));
1830 if ( validate_feed_url ( $feed )) {
1832 $this -> dbh
-> query ( "BEGIN" );
1834 if ( $cat_id == "0" ||
! $cat_id ) {
1835 $cat_qpart = "NULL" ;
1837 $cat_qpart = "' $cat_id '" ;
1840 $result = $this -> dbh
-> query (
1841 "SELECT id FROM ttrss_feeds
1842 WHERE feed_url = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1844 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
1845 require_once "crypt.php" ;
1846 $pass = substr ( encrypt_string ( $pass ), 0 , 250 );
1847 $auth_pass_encrypted = 'true' ;
1849 $auth_pass_encrypted = 'false' ;
1852 $pass = $this -> dbh
-> escape_string ( $pass );
1854 if ( $this -> dbh
-> num_rows ( $result ) == 0 ) {
1855 $result = $this -> dbh
-> query (
1856 "INSERT INTO ttrss_feeds
1857 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1858 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed ',
1859 '[Unknown]', $cat_qpart , ' $login ', ' $pass ', 0, $auth_pass_encrypted )" );
1862 $this -> dbh
-> query ( "COMMIT" );
1867 function regenOPMLKey () {
1868 $this -> update_feed_access_key ( 'OPML:Publish' ,
1869 false , $_SESSION [ "uid" ]);
1871 $new_link = Opml
:: opml_publish_url ();
1873 print json_encode ( array ( "link" => $new_link ));
1876 function regenFeedKey () {
1877 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ 'id' ]);
1878 $is_cat = $this -> dbh
-> escape_string ( $_REQUEST [ 'is_cat' ]) == "true" ;
1880 $new_key = $this -> update_feed_access_key ( $feed_id , $is_cat );
1882 print json_encode ( array ( "link" => $new_key ));
1886 private function update_feed_access_key ( $feed_id , $is_cat , $owner_uid = false ) {
1887 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1889 $sql_is_cat = bool_to_sql_bool ( $is_cat );
1891 $result = $this -> dbh
-> query ( "SELECT access_key FROM ttrss_access_keys
1892 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1893 AND owner_uid = " . $owner_uid );
1895 if ( $this -> dbh
-> num_rows ( $result ) == 1 ) {
1896 $key = $this -> dbh
-> escape_string ( uniqid_short ());
1898 $this -> dbh
-> query ( "UPDATE ttrss_access_keys SET access_key = ' $key '
1899 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1900 AND owner_uid = " . $owner_uid );
1905 return get_feed_access_key ( $feed_id , $is_cat , $owner_uid );
1910 function clearKeys () {
1911 $this -> dbh
-> query ( "DELETE FROM ttrss_access_keys WHERE
1912 owner_uid = " . $_SESSION [ "uid" ]);
1915 private function calculate_children_count ( $cat ) {
1918 foreach ( $cat [ 'items' ] as $child ) {
1919 if ( $child [ 'type' ] == 'category' ) {
1920 $c +
= $this -> calculate_children_count ( $child );