]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
530d851d7812bb28621e0805bb9d61d0c600549c
2 class Pref_Feeds
extends Handler_Protected
{
3 public static $feed_languages = array ( "English" , "Danish" , "Dutch" , "Finnish" , "French" , "German" , "Hungarian" , "Italian" , "Norwegian" ,
4 "Portuguese" , "Russian" , "Spanish" , "Swedish" , "Turkish" , "Simple" );
6 function csrf_ignore ( $method ) {
7 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
8 "savefeedorder" , "uploadicon" , "feedswitherrors" , "inactivefeeds" ,
11 return array_search ( $method , $csrf_ignored ) !== false ;
14 function batch_edit_cbox ( $elem , $label = false ) {
15 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
16 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
19 function renamecat () {
20 $title = $this -> dbh
-> escape_string ( $_REQUEST [ 'title' ]);
21 $id = $this -> dbh
-> escape_string ( $_REQUEST [ 'id' ]);
24 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories SET
25 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
30 private function get_category_items ( $cat_id ) {
32 if ( $_REQUEST [ 'mode' ] != 2 )
33 $search = $_SESSION [ "prefs_feed_search" ];
37 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
39 // first one is set by API
40 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
41 ( $_REQUEST [ 'mode' ] != 2 && ! $search );
45 $result = $this -> dbh
-> query ( "SELECT id, title FROM ttrss_feed_categories
46 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
48 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
51 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
52 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
53 $cat [ 'name' ] = $line [ 'title' ];
54 $cat [ 'items' ] = array ();
55 $cat [ 'checkbox' ] = false ;
56 $cat [ 'type' ] = 'category' ;
58 $cat [ 'child_unread' ] = 0 ;
59 $cat [ 'auxcounter' ] = 0 ;
60 $cat [ 'parent_id' ] = $cat_id ;
62 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
64 $num_children = $this -> calculate_children_count ( $cat );
65 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , $num_children ), $num_children );
67 if ( $num_children > 0 ||
$show_empty_cats )
68 array_push ( $items , $cat );
72 $feed_result = $this -> dbh
-> query ( "SELECT id, title, last_error,
73 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
75 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
76 " $search_qpart ORDER BY order_id, title" );
78 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
80 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
81 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
82 $feed [ 'auxcounter' ] = 0 ;
83 $feed [ 'name' ] = $feed_line [ 'title' ];
84 $feed [ 'checkbox' ] = false ;
86 $feed [ 'error' ] = $feed_line [ 'last_error' ];
87 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
88 $feed [ 'param' ] = make_local_datetime (
89 $feed_line [ 'last_updated' ], true );
91 array_push ( $items , $feed );
97 function getfeedtree () {
98 print json_encode ( $this -> makefeedtree ());
101 function makefeedtree () {
103 if ( $_REQUEST [ 'mode' ] != 2 )
104 $search = $_SESSION [ "prefs_feed_search" ];
108 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
111 $root [ 'id' ] = 'root' ;
112 $root [ 'name' ] = __ ( 'Feeds' );
113 $root [ 'items' ] = array ();
114 $root [ 'type' ] = 'category' ;
116 $enable_cats = get_pref ( 'ENABLE_FEED_CATS' );
118 if ( $_REQUEST [ 'mode' ] == 2 ) {
121 $cat = $this -> feedlist_init_cat (- 1 );
123 $cat [ 'items' ] = array ();
126 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
127 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
130 /* Plugin feeds for -1 */
132 $feeds = PluginHost
:: getInstance ()-> get_feeds (- 1 );
135 foreach ( $feeds as $feed ) {
136 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
139 $item [ 'id' ] = 'FEED:' . $feed_id ;
140 $item [ 'bare_id' ] = ( int ) $feed_id ;
141 $item [ 'auxcounter' ] = 0 ;
142 $item [ 'name' ] = $feed [ 'title' ];
143 $item [ 'checkbox' ] = false ;
145 $item [ 'icon' ] = $feed [ 'icon' ];
148 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
149 $item [ 'type' ] = 'feed' ;
151 array_push ( $cat [ 'items' ], $item );
156 array_push ( $root [ 'items' ], $cat );
158 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
161 $result = $this -> dbh
-> query ( "SELECT * FROM
162 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
164 if ( $this -> dbh
-> num_rows ( $result ) > 0 ) {
166 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
167 $cat = $this -> feedlist_init_cat (- 2 );
169 $cat [ 'items' ] = array ();
172 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
174 $label_id = label_to_feed_id ( $line [ 'id' ]);
176 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
178 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
179 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
181 array_push ( $cat [ 'items' ], $feed );
185 array_push ( $root [ 'items' ], $cat );
187 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
193 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
194 ( $_REQUEST [ 'mode' ] != 2 && ! $search );
196 $result = $this -> dbh
-> query ( "SELECT id, title FROM ttrss_feed_categories
197 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
199 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
201 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
202 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
203 $cat [ 'auxcounter' ] = 0 ;
204 $cat [ 'name' ] = $line [ 'title' ];
205 $cat [ 'items' ] = array ();
206 $cat [ 'checkbox' ] = false ;
207 $cat [ 'type' ] = 'category' ;
209 $cat [ 'child_unread' ] = 0 ;
211 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
213 $num_children = $this -> calculate_children_count ( $cat );
214 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , $num_children ), $num_children );
216 if ( $num_children > 0 ||
$show_empty_cats )
217 array_push ( $root [ 'items' ], $cat );
219 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
222 /* Uncategorized is a special case */
225 $cat [ 'id' ] = 'CAT:0' ;
227 $cat [ 'auxcounter' ] = 0 ;
228 $cat [ 'name' ] = __ ( "Uncategorized" );
229 $cat [ 'items' ] = array ();
230 $cat [ 'type' ] = 'category' ;
231 $cat [ 'checkbox' ] = false ;
233 $cat [ 'child_unread' ] = 0 ;
235 $feed_result = $this -> dbh
-> query ( "SELECT id, title,last_error,
236 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
238 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
239 " $search_qpart ORDER BY order_id, title" );
241 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
243 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
244 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
245 $feed [ 'auxcounter' ] = 0 ;
246 $feed [ 'name' ] = $feed_line [ 'title' ];
247 $feed [ 'checkbox' ] = false ;
248 $feed [ 'error' ] = $feed_line [ 'last_error' ];
249 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
250 $feed [ 'param' ] = make_local_datetime (
251 $feed_line [ 'last_updated' ], true );
253 $feed [ 'type' ] = 'feed' ;
255 array_push ( $cat [ 'items' ], $feed );
258 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
260 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
261 array_push ( $root [ 'items' ], $cat );
263 $num_children = $this -> calculate_children_count ( $root );
264 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , $num_children ), $num_children );
267 $feed_result = $this -> dbh
-> query ( "SELECT id, title, last_error,
268 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
270 WHERE owner_uid = " . $_SESSION [ "uid" ].
271 " $search_qpart ORDER BY order_id, title" );
273 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $feed_result )) {
275 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
276 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
277 $feed [ 'auxcounter' ] = 0 ;
278 $feed [ 'name' ] = $feed_line [ 'title' ];
279 $feed [ 'checkbox' ] = false ;
280 $feed [ 'error' ] = $feed_line [ 'last_error' ];
281 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
282 $feed [ 'param' ] = make_local_datetime (
283 $feed_line [ 'last_updated' ], true );
285 $feed [ 'type' ] = 'feed' ;
287 array_push ( $root [ 'items' ], $feed );
290 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
294 $fl [ 'identifier' ] = 'id' ;
295 $fl [ 'label' ] = 'name' ;
297 if ( $_REQUEST [ 'mode' ] != 2 ) {
298 $fl [ 'items' ] = array ( $root );
300 $fl [ 'items' ] =& $root [ 'items' ];
306 function catsortreset () {
307 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
308 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
312 function feedsortreset () {
313 $this -> dbh
-> query ( "UPDATE ttrss_feeds
314 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
318 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
319 $debug = isset ( $_REQUEST [ "debug" ]);
322 for ( $i = 0 ; $i < $nest_level ; $i ++
)
325 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
327 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
329 if ( $item_id != 'root' ) {
330 if ( $parent_id && $parent_id != 'root' ) {
331 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
332 $parent_qpart = $this -> dbh
-> escape_string ( $parent_bare_id );
334 $parent_qpart = 'NULL' ;
337 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
338 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
339 owner_uid = " . $_SESSION [ "uid" ]);
344 $cat = $data_map [ $item_id ];
346 if ( $cat && is_array ( $cat )) {
347 foreach ( $cat as $item ) {
348 $id = $item [ '_reference' ];
349 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
351 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
353 if ( $item [ '_reference' ]) {
355 if ( strpos ( $id , "FEED" ) === 0 ) {
357 $cat_id = ( $item_id != "root" ) ?
358 $this -> dbh
-> escape_string ( $bare_item_id ) : "NULL" ;
360 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
363 $this -> dbh
-> query ( "UPDATE ttrss_feeds
364 SET order_id = $order_id , $cat_qpart
365 WHERE id = ' $bare_id ' AND
366 owner_uid = " . $_SESSION [ "uid" ]);
368 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
369 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
372 if ( $item_id != 'root' ) {
373 $parent_qpart = $this -> dbh
-> escape_string ( $bare_id );
375 $parent_qpart = 'NULL' ;
378 $this -> dbh
-> query ( "UPDATE ttrss_feed_categories
379 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
380 owner_uid = " . $_SESSION [ "uid" ]);
389 function savefeedorder () {
390 $data = json_decode ( $_POST [ 'payload' ], true );
392 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
393 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
395 if (! is_array ( $data [ 'items' ]))
396 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
398 # print_r($data['items']);
400 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
406 foreach ( $data [ 'items' ] as $item ) {
408 # if ($item['id'] != 'root') {
409 if ( is_array ( $item [ 'items' ])) {
410 if ( isset ( $item [ 'items' ][ '_reference' ])) {
411 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
413 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
416 if ( $item [ 'id' ] == 'root' ) {
417 $root_item = $item [ 'id' ];
421 $this -> process_category_order ( $data_map , $root_item );
423 /* foreach ($data['items'][0]['items'] as $item) {
424 $id = $item['_reference'];
425 $bare_id = substr($id, strpos($id, ':')+1);
430 $this->dbh->query("UPDATE ttrss_feed_categories
431 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
432 owner_uid = " . $_SESSION["uid"]);
437 if (is_array($data_map[$id])) {
438 foreach ($data_map[$id] as $feed) {
439 $id = $feed['_reference'];
440 $feed_id = substr($id, strpos($id, ':')+1);
443 $cat_query = "cat_id = '$bare_id'";
445 $cat_query = "cat_id = NULL";
447 $this->dbh->query("UPDATE ttrss_feeds
448 SET order_id = '$feed_order_id',
450 WHERE id = '$feed_id' AND
451 owner_uid = " . $_SESSION["uid"]);
462 function removeicon () {
463 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "feed_id" ]);
465 $result = $this -> dbh
-> query ( "SELECT id FROM ttrss_feeds
466 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
468 if ( $this -> dbh
-> num_rows ( $result ) != 0 ) {
469 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
471 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET favicon_avg_color = NULL
472 where id = ' $feed_id '" );
478 function uploadicon () {
479 header ( "Content-type: text/html" );
483 if ( is_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ])) {
484 $tmp_file = tempnam ( CACHE_DIR
. '/upload' , 'icon' );
486 $result = move_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ],
496 $icon_file = $tmp_file ;
497 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "feed_id" ]);
499 if ( is_file ( $icon_file ) && $feed_id ) {
500 if ( filesize ( $icon_file ) < 65535 ) {
502 $result = $this -> dbh
-> query ( "SELECT id FROM ttrss_feeds
503 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
505 if ( $this -> dbh
-> num_rows ( $result ) != 0 ) {
506 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
507 if ( rename ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" )) {
508 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET
509 favicon_avg_color = ''
510 WHERE id = ' $feed_id '" );
526 print "<script type= \" text/javascript \" >" ;
527 print "parent.uploadIconHandler( $rc );" ;
532 function editfeed () {
533 global $purge_intervals ;
534 global $update_intervals ;
536 print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
537 <div dojoType="dijit.layout.ContentPane" title="' . __ ( 'General' ). '">' ;
539 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ "id" ]);
541 $result = $this -> dbh
-> query (
542 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
543 owner_uid = " . $_SESSION [ "uid" ]);
545 $auth_pass_encrypted = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 ,
546 "auth_pass_encrypted" ));
548 $title = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result ,
551 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
552 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
553 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
555 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
556 print "<div class= \" dlgSecCont \" >" ;
560 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
561 placeHolder= \" " . __ ( "Feed Title" ). " \"
562 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
566 $feed_url = $this -> dbh
-> fetch_result ( $result , 0 , "feed_url" );
567 $feed_url = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result ,
572 print __ ( 'URL:' ) . " " ;
573 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
574 placeHolder= \" " . __ ( "Feed URL" ). " \"
575 regExp='^(http|https)://.*' style= \" width : 20em \"
576 name= \" feed_url \" value= \" $feed_url\" >" ;
578 $last_error = $this -> dbh
-> fetch_result ( $result , 0 , "last_error" );
581 print " <img src= \" images/error.png \" alt= \" (error) \"
582 style= \" vertical-align : middle \"
583 title= \" " . htmlspecialchars ( $last_error ). " \" >" ;
589 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
591 $cat_id = $this -> dbh
-> fetch_result ( $result , 0 , "cat_id" );
595 print __ ( 'Place in category:' ) . " " ;
597 print_feed_cat_select ( "cat_id" , $cat_id ,
598 'dojoType="dijit.form.Select"' );
601 /* FTS Stemming Language */
603 if ( DB_TYPE
== "pgsql" ) {
604 $feed_language = $this -> dbh
-> fetch_result ( $result , 0 , "feed_language" );
608 print __ ( 'Language:' ) . " " ;
609 print_select ( "feed_language" , $feed_language , $this :: $feed_languages ,
610 'dojoType="dijit.form.Select"' );
615 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
616 print "<div class= \" dlgSecCont \" >" ;
618 /* Update Interval */
620 $update_interval = $this -> dbh
-> fetch_result ( $result , 0 , "update_interval" );
622 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
623 'dojoType="dijit.form.Select"' );
627 $purge_interval = $this -> dbh
-> fetch_result ( $result , 0 , "purge_interval" );
630 print __ ( 'Article purging:' ) . " " ;
632 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
633 'dojoType="dijit.form.Select" ' .
634 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
637 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
638 print "<div class= \" dlgSecCont \" >" ;
640 $auth_login = htmlspecialchars ( $this -> dbh
-> fetch_result ( $result , 0 , "auth_login" ));
642 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
643 placeHolder= \" " . __ ( "Login" ). " \"
644 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
646 $auth_pass = $this -> dbh
-> fetch_result ( $result , 0 , "auth_pass" );
648 if ( $auth_pass_encrypted ) {
649 require_once "crypt.php" ;
650 $auth_pass = decrypt_string ( $auth_pass );
653 $auth_pass = htmlspecialchars ( $auth_pass );
655 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
656 placeHolder= \" " . __ ( "Password" ). " \"
657 value= \" $auth_pass\" >" ;
659 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
660 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
665 print '</div><div dojoType="dijit.layout.ContentPane" title="' . __ ( 'Options' ). '">' ;
667 //print "<div class=\"dlgSec\">".__("Options")."</div>";
668 print "<div class= \" dlgSecSimple \" >" ;
670 $private = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "private" ));
673 $checked = "checked= \" 1 \" " ;
678 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
679 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
681 $include_in_digest = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "include_in_digest" ));
683 if ( $include_in_digest ) {
684 $checked = "checked= \" 1 \" " ;
689 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
690 name= \" include_in_digest \"
691 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
694 $always_display_enclosures = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "always_display_enclosures" ));
696 if ( $always_display_enclosures ) {
697 $checked = "checked" ;
702 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
703 name= \" always_display_enclosures \"
704 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
706 $hide_images = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "hide_images" ));
709 $checked = "checked= \" 1 \" " ;
714 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
716 $checked > <label for= \" hide_images \" >" .
717 __ ( 'Do not embed images' ). "</label>" ;
719 $cache_images = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "cache_images" ));
722 $checked = "checked= \" 1 \" " ;
727 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
728 name= \" cache_images \"
729 $checked > <label for= \" cache_images \" >" .
730 __ ( 'Cache images locally' ). "</label>" ;
732 $mark_unread_on_update = sql_bool_to_bool ( $this -> dbh
-> fetch_result ( $result , 0 , "mark_unread_on_update" ));
734 if ( $mark_unread_on_update ) {
735 $checked = "checked" ;
740 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
741 name= \" mark_unread_on_update \"
742 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
746 print '</div><div dojoType="dijit.layout.ContentPane" title="' . __ ( 'Icon' ). '">' ;
750 print "<div class= \" dlgSecSimple \" >" ;
752 print "<iframe name= \" icon_upload_iframe \"
753 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
755 print "<form style='display : block' target= \" icon_upload_iframe \"
756 enctype= \" multipart/form-data \" method= \" POST \"
757 action= \" backend.php \" >
758 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
759 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
760 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
761 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" ><p>
762 <button class= \"\" dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
763 type= \" submit \" >" . __ ( 'Replace' ). "</button>
764 <button class= \"\" dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
765 type= \" submit \" >" . __ ( 'Remove' ). "</button>
770 print '</div><div dojoType="dijit.layout.ContentPane" title="' . __ ( 'Plugins' ). '">' ;
772 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_EDIT_FEED
,
773 "hook_prefs_edit_feed" , $feed_id );
776 print "</div></div>" ;
778 $title = htmlspecialchars ( $title , ENT_QUOTES
);
780 print "<div class='dlgButtons'>
781 <div style= \" float : left \" >
782 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
783 __ ( 'Unsubscribe' ). "</button>" ;
785 if ( PUBSUBHUBBUB_ENABLED
) {
786 $pubsub_state = $this -> dbh
-> fetch_result ( $result , 0 , "pubsub_state" );
787 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
789 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
790 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
796 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
797 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
799 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
800 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
807 function editfeeds () {
808 global $purge_intervals ;
809 global $update_intervals ;
811 $feed_ids = $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]);
813 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
817 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
818 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
819 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
821 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
822 print "<div class= \" dlgSecCont \" >" ;
826 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
828 print __ ( 'Place in category:' ) . " " ;
830 print_feed_cat_select ( "cat_id" , false ,
831 'disabled="1" dojoType="dijit.form.Select"' );
833 $this -> batch_edit_cbox ( "cat_id" );
837 /* FTS Stemming Language */
839 if ( DB_TYPE
== "pgsql" ) {
842 print __ ( 'Language:' ) . " " ;
843 print_select ( "feed_language" , "" , $this :: $feed_languages ,
844 'disabled="1" dojoType="dijit.form.Select"' );
846 $this -> batch_edit_cbox ( "feed_language" );
851 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
852 print "<div class= \" dlgSecCont \" >" ;
854 /* Update Interval */
856 print_select_hash ( "update_interval" , "" , $update_intervals ,
857 'disabled="1" dojoType="dijit.form.Select"' );
859 $this -> batch_edit_cbox ( "update_interval" );
863 if ( FORCE_ARTICLE_PURGE
== 0 ) {
867 print __ ( 'Article purging:' ) . " " ;
869 print_select_hash ( "purge_interval" , "" , $purge_intervals ,
870 'disabled="1" dojoType="dijit.form.Select"' );
872 $this -> batch_edit_cbox ( "purge_interval" );
876 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
877 print "<div class= \" dlgSecCont \" >" ;
879 print "<input dojoType= \" dijit.form.TextBox \"
880 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
881 name= \" auth_login \" value= \"\" >" ;
883 $this -> batch_edit_cbox ( "auth_login" );
885 print "<hr/> <input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
886 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
889 $this -> batch_edit_cbox ( "auth_pass" );
892 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
893 print "<div class= \" dlgSecCont \" >" ;
895 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
896 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
898 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
900 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
901 name= \" include_in_digest \"
902 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
904 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
906 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
907 name= \" always_display_enclosures \"
908 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
910 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
912 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
914 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
915 for= \" hide_images \" >" .
916 __ ( 'Do not embed images' ). "</label>" ;
918 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
920 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
921 name= \" cache_images \"
922 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
923 for= \" cache_images \" >" .
924 __ ( 'Cache images locally' ). "</label>" ;
926 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
928 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
929 name= \" mark_unread_on_update \"
930 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
932 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
936 print "<div class='dlgButtons'>
937 <button dojoType= \" dijit.form.Button \"
938 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
939 __ ( 'Save' ). "</button>
940 <button dojoType= \" dijit.form.Button \"
941 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
942 __ ( 'Cancel' ). "</button>
948 function batchEditSave () {
949 return $this -> editsaveops ( true );
952 function editSave () {
953 return $this -> editsaveops ( false );
956 function editsaveops ( $batch ) {
958 $feed_title = $this -> dbh
-> escape_string ( trim ( $_POST [ "title" ]));
959 $feed_link = $this -> dbh
-> escape_string ( trim ( $_POST [ "feed_url" ]));
960 $upd_intl = ( int ) $this -> dbh
-> escape_string ( $_POST [ "update_interval" ]);
961 $purge_intl = ( int ) $this -> dbh
-> escape_string ( $_POST [ "purge_interval" ]);
962 $feed_id = ( int ) $this -> dbh
-> escape_string ( $_POST [ "id" ]); /* editSave */
963 $feed_ids = $this -> dbh
-> escape_string ( $_POST [ "ids" ]); /* batchEditSave */
964 $cat_id = ( int ) $this -> dbh
-> escape_string ( $_POST [ "cat_id" ]);
965 $auth_login = $this -> dbh
-> escape_string ( trim ( $_POST [ "auth_login" ]));
966 $auth_pass = trim ( $_POST [ "auth_pass" ]);
967 $private = checkbox_to_sql_bool ( $this -> dbh
-> escape_string ( $_POST [ "private" ]));
968 $include_in_digest = checkbox_to_sql_bool (
969 $this -> dbh
-> escape_string ( $_POST [ "include_in_digest" ]));
970 $cache_images = checkbox_to_sql_bool (
971 $this -> dbh
-> escape_string ( $_POST [ "cache_images" ]));
972 $hide_images = checkbox_to_sql_bool (
973 $this -> dbh
-> escape_string ( $_POST [ "hide_images" ]));
974 $always_display_enclosures = checkbox_to_sql_bool (
975 $this -> dbh
-> escape_string ( $_POST [ "always_display_enclosures" ]));
977 $mark_unread_on_update = checkbox_to_sql_bool (
978 $this -> dbh
-> escape_string ( $_POST [ "mark_unread_on_update" ]));
980 $feed_language = $this -> dbh
-> escape_string ( trim ( $_POST [ "feed_language" ]));
982 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
983 require_once "crypt.php" ;
984 $auth_pass = substr ( encrypt_string ( $auth_pass ), 0 , 250 );
985 $auth_pass_encrypted = 'true' ;
987 $auth_pass_encrypted = 'false' ;
990 $auth_pass = $this -> dbh
-> escape_string ( $auth_pass );
992 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
993 if ( $cat_id && $cat_id != 0 ) {
994 $category_qpart = "cat_id = ' $cat_id '," ;
995 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
997 $category_qpart = 'cat_id = NULL,' ;
998 $category_qpart_nocomma = 'cat_id = NULL' ;
1001 $category_qpart = "" ;
1002 $category_qpart_nocomma = "" ;
1007 $result = db_query ( "SELECT feed_url FROM ttrss_feeds WHERE id = " . $feed_id );
1008 $orig_feed_url = db_fetch_result ( $result , 0 , "feed_url" );
1010 $reset_basic_info = $orig_feed_url != $feed_link ;
1012 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET
1014 title = ' $feed_title ', feed_url = ' $feed_link ',
1015 update_interval = ' $upd_intl ',
1016 purge_interval = ' $purge_intl ',
1017 auth_login = ' $auth_login ',
1018 auth_pass = ' $auth_pass ',
1019 auth_pass_encrypted = $auth_pass_encrypted ,
1021 cache_images = $cache_images ,
1022 hide_images = $hide_images ,
1023 include_in_digest = $include_in_digest ,
1024 always_display_enclosures = $always_display_enclosures ,
1025 mark_unread_on_update = $mark_unread_on_update ,
1026 feed_language = ' $feed_language '
1027 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1029 if ( $reset_basic_info ) {
1030 require_once "rssfuncs.php" ;
1032 set_basic_feed_info ( $feed_id );
1035 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_SAVE_FEED
,
1036 "hook_prefs_save_feed" , $feed_id );
1039 $feed_data = array ();
1041 foreach ( array_keys ( $_POST ) as $k ) {
1042 if ( $k != "op" && $k != "method" && $k != "ids" ) {
1043 $feed_data [ $k ] = $_POST [ $k ];
1047 $this -> dbh
-> query ( "BEGIN" );
1049 foreach ( array_keys ( $feed_data ) as $k ) {
1055 $qpart = "title = ' $feed_title '" ;
1059 $qpart = "feed_url = ' $feed_link '" ;
1062 case "update_interval" :
1063 $qpart = "update_interval = ' $upd_intl '" ;
1066 case "purge_interval" :
1067 $qpart = "purge_interval = ' $purge_intl '" ;
1071 $qpart = "auth_login = ' $auth_login '" ;
1075 $qpart = "auth_pass = ' $auth_pass ' AND
1076 auth_pass_encrypted = $auth_pass_encrypted " ;
1080 $qpart = "private = $private " ;
1083 case "include_in_digest" :
1084 $qpart = "include_in_digest = $include_in_digest " ;
1087 case "always_display_enclosures" :
1088 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1091 case "mark_unread_on_update" :
1092 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1095 case "cache_images" :
1096 $qpart = "cache_images = $cache_images " ;
1100 $qpart = "hide_images = $hide_images " ;
1104 $qpart = $category_qpart_nocomma ;
1107 case "feed_language" :
1108 $qpart = "feed_language = ' $feed_language '" ;
1115 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1116 AND owner_uid = " . $_SESSION [ "uid" ]);
1121 $this -> dbh
-> query ( "COMMIT" );
1126 function resetPubSub () {
1128 $ids = $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]);
1130 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1131 AND owner_uid = " . $_SESSION [ "uid" ]);
1138 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1140 foreach ( $ids as $id ) {
1141 Pref_Feeds
:: remove_feed ( $id , $_SESSION [ "uid" ]);
1148 $id = $this -> dbh
-> escape_string ( $_REQUEST [ "id" ]);
1149 $this -> clear_feed_articles ( $id );
1152 function rescore () {
1153 require_once "rssfuncs.php" ;
1155 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1157 foreach ( $ids as $id ) {
1159 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1161 $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 ( $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 ]) . ")" );
1192 } else if ( $s < - 500 ) {
1193 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1194 unread = false WHERE
1195 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1197 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1198 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1203 print __ ( "All done." );
1207 function rescoreAll () {
1209 $result = $this -> dbh
-> query (
1210 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1212 while ( $feed_line = $this -> dbh
-> fetch_assoc ( $result )) {
1214 $id = $feed_line [ "id" ];
1216 $filters = load_filters ( $id , $_SESSION [ "uid" ], 6 );
1218 $tmp_result = $this -> dbh
-> query ( "SELECT
1219 title, content, link, ref_id, author," .
1220 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1222 ttrss_user_entries, ttrss_entries
1223 WHERE ref_id = id AND feed_id = ' $id ' AND
1224 owner_uid = " . $_SESSION [ 'uid' ]. "
1229 while ( $line = $this -> dbh
-> fetch_assoc ( $tmp_result )) {
1231 $tags = get_article_tags ( $line [ "ref_id" ]);
1233 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1234 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1235 $line [ 'author' ], $tags );
1237 $new_score = calculate_article_score ( $article_filters );
1239 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1241 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1244 foreach ( array_keys ( $scores ) as $s ) {
1246 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ',
1248 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1250 $this -> dbh
-> query ( "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1251 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1256 print __ ( "All done." );
1260 function categorize () {
1261 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1263 $cat_id = $this -> dbh
-> escape_string ( $_REQUEST [ "cat_id" ]);
1266 $cat_id_qpart = 'NULL' ;
1268 $cat_id_qpart = "' $cat_id '" ;
1271 $this -> dbh
-> query ( "BEGIN" );
1273 foreach ( $ids as $id ) {
1275 $this -> dbh
-> query ( "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1277 AND owner_uid = " . $_SESSION [ "uid" ]);
1281 $this -> dbh
-> query ( "COMMIT" );
1284 function removeCat () {
1285 $ids = explode ( "," , $this -> dbh
-> escape_string ( $_REQUEST [ "ids" ]));
1286 foreach ( $ids as $id ) {
1287 $this -> remove_feed_category ( $id , $_SESSION [ "uid" ]);
1292 $feed_cat = $this -> dbh
-> escape_string ( trim ( $_REQUEST [ "cat" ]));
1294 add_feed_category ( $feed_cat );
1299 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1300 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1302 $result = $this -> dbh
-> query ( "SELECT COUNT(id) AS num_errors
1303 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1305 $num_errors = $this -> dbh
-> fetch_result ( $result , 0 , "num_errors" );
1307 if ( $num_errors > 0 ) {
1309 $error_button = "<button dojoType= \" dijit.form.Button \"
1310 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1311 __ ( "Feeds with errors" ) . "</button>" ;
1314 $inactive_button = "<button dojoType= \" dijit.form.Button \"
1315 id= \" pref_feeds_inactive_btn \"
1316 style= \" display : none \"
1317 onclick= \" showInactiveFeeds() \" >" .
1318 __ ( "Inactive feeds" ) . "</button>" ;
1320 $feed_search = $this -> dbh
-> escape_string ( $_REQUEST [ "search" ]);
1322 if ( array_key_exists ( "search" , $_REQUEST )) {
1323 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1325 $feed_search = $_SESSION [ "prefs_feed_search" ];
1328 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">' ;
1330 print "<div region='top' dojoType= \" dijit.Toolbar \" >" ; #toolbar
1332 print "<div style='float : right; padding-right : 4px;'>
1333 <input dojoType= \" dijit.form.TextBox \" id= \" feed_search \" size= \" 20 \" type= \" search \"
1334 value= \" $feed_search\" >
1335 <button dojoType= \" dijit.form.Button \" onclick= \" updateFeedList() \" >" .
1336 __ ( 'Search' ). "</button>
1339 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1340 "<span>" . __ ( 'Select' ). "</span>" ;
1341 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1342 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1343 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1344 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1345 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1346 print "</div></div>" ;
1348 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1349 "<span>" . __ ( 'Feeds' ). "</span>" ;
1350 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1351 print "<div onclick= \" quickAddFeed() \"
1352 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1353 print "<div onclick= \" editSelectedFeed() \"
1354 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1355 print "<div onclick= \" resetFeedOrder() \"
1356 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1357 print "<div onclick= \" batchSubscribe() \"
1358 dojoType= \" dijit.MenuItem \" >" . __ ( 'Batch subscribe' ). "</div>" ;
1359 print "<div dojoType= \" dijit.MenuItem \" onclick= \" removeSelectedFeeds() \" >"
1360 . __ ( 'Unsubscribe' ). "</div> " ;
1361 print "</div></div>" ;
1363 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1364 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1365 "<span>" . __ ( 'Categories' ). "</span>" ;
1366 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1367 print "<div onclick= \" createCategory() \"
1368 dojoType= \" dijit.MenuItem \" >" . __ ( 'Add category' ). "</div>" ;
1369 print "<div onclick= \" resetCatOrder() \"
1370 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1371 print "<div onclick= \" removeSelectedCategories() \"
1372 dojoType= \" dijit.MenuItem \" >" . __ ( 'Remove selected' ). "</div>" ;
1373 print "</div></div>" ;
1377 print $error_button ;
1378 print $inactive_button ;
1380 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1382 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1383 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1385 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1387 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1391 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1392 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1398 print "</div>" ; # toolbar
1401 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1403 print "<div id= \" feedlistLoading \" >
1404 <img src='images/indicator_tiny.gif'>" .
1405 __ ( "Loading, please wait..." ). "</div>" ;
1407 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1408 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1410 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1411 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1412 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1414 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1415 dndController= \" dijit.tree.dndSource \"
1416 betweenThreshold= \" 5 \"
1417 model= \" feedModel \" openOnClick= \" false \" >
1418 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1419 var id = String(item.id);
1420 var bare_id = id.substr(id.indexOf(':')+1);
1422 if (id.match('FEED:')) {
1424 } else if (id.match('CAT:')) {
1425 editCat(bare_id, item);
1428 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1429 Element.hide( \" feedlistLoading \" );
1431 checkInactiveFeeds();
1435 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1436 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1442 print "</div>" ; # feeds pane
1444 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1446 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." ));
1448 print "<iframe id= \" upload_iframe \"
1449 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1450 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1452 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1453 enctype= \" multipart/form-data \" method= \" POST \"
1454 action= \" backend.php \" >
1455 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1456 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1457 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1458 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1459 __ ( 'Import my OPML' ) . "</button>" ;
1463 print "<p>" . __ ( 'Filename:' ) .
1464 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1465 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1467 print "</p><button dojoType= \" dijit.form.Button \"
1468 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1469 __ ( 'Export OPML' ) . "</button></p></form>" ;
1473 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1475 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1477 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1478 __ ( 'Display published OPML URL' ). "</button> " ;
1480 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1481 "hook_prefs_tab_section" , "prefFeedsOPML" );
1483 print "</div>" ; # pane
1485 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1487 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1489 print_notice ( __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ));
1493 print "<button onclick='window.navigator.registerContentHandler(" .
1494 " \" application/vnd.mozilla.maybe.feed \" , " .
1495 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1496 __ ( 'Click here to register this site as a feed reader.' ) .
1501 print "</div>" ; # pane
1504 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1506 print_notice ( __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ));
1508 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1509 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1513 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1514 __ ( 'Display URL' ). "</button> " ;
1516 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1517 __ ( 'Clear all generated URLs' ). "</button> " ;
1521 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB_SECTION
,
1522 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1524 print "</div>" ; #pane
1526 PluginHost
:: getInstance ()-> run_hooks ( PluginHost
:: HOOK_PREFS_TAB
,
1527 "hook_prefs_tab" , "prefFeeds" );
1529 print "</div>" ; #container
1532 private function feedlist_init_cat ( $cat_id ) {
1534 $cat_id = ( int ) $cat_id ;
1537 $cat_unread = ccache_find ( $cat_id , $_SESSION [ "uid" ], true );
1538 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1539 $cat_unread = getCategoryUnread ( $cat_id );
1542 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1543 $obj [ 'items' ] = array ();
1544 $obj [ 'name' ] = getCategoryTitle ( $cat_id );
1545 $obj [ 'type' ] = 'category' ;
1546 $obj [ 'unread' ] = ( int ) $cat_unread ;
1547 $obj [ 'bare_id' ] = $cat_id ;
1552 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1554 $feed_id = ( int ) $feed_id ;
1557 $title = getFeedTitle ( $feed_id , false );
1559 if ( $unread === false )
1560 $unread = getFeedUnread ( $feed_id , false );
1562 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1563 $obj [ 'name' ] = $title ;
1564 $obj [ 'unread' ] = ( int ) $unread ;
1565 $obj [ 'type' ] = 'feed' ;
1566 $obj [ 'error' ] = $error ;
1567 $obj [ 'updated' ] = $updated ;
1568 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1569 $obj [ 'bare_id' ] = $feed_id ;
1570 $obj [ 'auxcounter' ] = 0 ;
1575 function inactiveFeeds () {
1577 if ( DB_TYPE
== "pgsql" ) {
1578 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1580 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1583 $result = $this -> dbh
-> query ( "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1584 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1585 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1586 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1587 ttrss_entries.id = ref_id AND
1588 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1589 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1590 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1591 ttrss_entries.id = ref_id
1592 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1593 ORDER BY last_article" );
1595 print "<p" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</p>" ;
1597 print "<div dojoType= \" dijit.Toolbar \" >" ;
1598 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1599 "<span>" . __ ( 'Select' ). "</span>" ;
1600 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1601 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1602 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1603 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1604 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1605 print "</div></div>" ;
1606 print "</div>" ; #toolbar
1608 print "<div class= \" inactiveFeedHolder \" >" ;
1610 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1614 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1616 $feed_id = $line [ "id" ];
1617 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1619 # class needed for selectTableRows()
1620 print "<tr class= \" placeholder \" $this_row_id >" ;
1622 # id needed for selectTableRows()
1623 print "<td width='5%' align='center'><input
1624 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1625 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1628 print "<a class= \" visibleLink \" href= \" # \" " .
1629 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1630 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1631 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1633 print "</td><td class= \" insensitive \" align='right'>" ;
1634 print make_local_datetime ( $line [ 'last_article' ], false );
1644 print "<div class='dlgButtons'>" ;
1645 print "<div style='float : left'>" ;
1646 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1647 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1650 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1651 __ ( 'Close this window' ). "</button>" ;
1657 function feedsWithErrors () {
1658 $result = $this -> dbh
-> query ( "SELECT id,title,feed_url,last_error,site_url
1659 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1661 print "<div dojoType= \" dijit.Toolbar \" >" ;
1662 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1663 "<span>" . __ ( 'Select' ). "</span>" ;
1664 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1665 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1666 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1667 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1668 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1669 print "</div></div>" ;
1670 print "</div>" ; #toolbar
1672 print "<div class= \" inactiveFeedHolder \" >" ;
1674 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1678 while ( $line = $this -> dbh
-> fetch_assoc ( $result )) {
1680 $feed_id = $line [ "id" ];
1681 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1683 # class needed for selectTableRows()
1684 print "<tr class= \" placeholder \" $this_row_id >" ;
1686 # id needed for selectTableRows()
1687 print "<td width='5%' align='center'><input
1688 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1689 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1692 print "<a class= \" visibleLink \" href= \" # \" " .
1693 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1694 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1695 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1697 print "<span class= \" insensitive \" >" ;
1698 print htmlspecialchars ( $line [ "last_error" ]);
1710 print "<div class='dlgButtons'>" ;
1711 print "<div style='float : left'>" ;
1712 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1713 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1716 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1717 __ ( 'Close this window' ). "</button>" ;
1723 * Purge a feed contents, marked articles excepted.
1725 * @param mixed $link The database connection.
1726 * @param integer $id The id of the feed to purge.
1729 private function clear_feed_articles ( $id ) {
1732 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_user_entries
1733 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1735 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_user_entries
1736 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1739 $result = $this -> dbh
-> query ( "DELETE FROM ttrss_entries WHERE
1740 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1742 ccache_update ( $id , $_SESSION [ 'uid' ]);
1743 } // function clear_feed_articles
1745 private function remove_feed_category ( $id , $owner_uid ) {
1747 $this -> dbh
-> query ( "DELETE FROM ttrss_feed_categories
1748 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1750 ccache_remove ( $id , $owner_uid , true );
1753 static function remove_feed ( $id , $owner_uid ) {
1757 /* save starred articles in Archived feed */
1761 /* prepare feed if necessary */
1763 $result = db_query ( "SELECT feed_url FROM ttrss_feeds WHERE id = $id
1764 AND owner_uid = $owner_uid " );
1766 $feed_url = db_escape_string ( db_fetch_result ( $result , 0 , "feed_url" ));
1768 $result = db_query ( "SELECT id FROM ttrss_archived_feeds
1769 WHERE feed_url = ' $feed_url ' AND owner_uid = $owner_uid " );
1771 if ( db_num_rows ( $result ) == 0 ) {
1772 $result = db_query ( "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1773 $new_feed_id = ( int ) db_fetch_result ( $result , 0 , "id" ) +
1 ;
1775 db_query ( "INSERT INTO ttrss_archived_feeds
1776 (id, owner_uid, title, feed_url, site_url)
1777 SELECT $new_feed_id , owner_uid, title, feed_url, site_url from ttrss_feeds
1780 $archive_id = $new_feed_id ;
1782 $archive_id = db_fetch_result ( $result , 0 , "id" );
1785 db_query ( "UPDATE ttrss_user_entries SET feed_id = NULL,
1786 orig_feed_id = ' $archive_id ' WHERE feed_id = ' $id ' AND
1787 marked = true AND owner_uid = $owner_uid " );
1789 /* Remove access key for the feed */
1791 db_query ( "DELETE FROM ttrss_access_keys WHERE
1792 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1794 /* remove the feed */
1796 db_query ( "DELETE FROM ttrss_feeds
1797 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1801 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1802 unlink ( ICONS_DIR
. "/ $id .ico" );
1805 ccache_remove ( $id , $owner_uid );
1808 label_remove ( feed_to_label_id ( $id ), $owner_uid );
1809 //ccache_remove($id, $owner_uid); don't think labels are cached
1813 function batchSubscribe () {
1814 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
1815 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchaddfeeds \" >" ;
1817 print "<table width='100%'><tr><td>
1818 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1819 </td><td align='right'>" ;
1820 if ( get_pref ( 'ENABLE_FEED_CATS' )) {
1821 print __ ( 'Place in category:' ) . " " ;
1822 print_feed_cat_select ( "cat" , false , 'dojoType="dijit.form.Select"' );
1824 print "</td></tr><tr><td colspan='2'>" ;
1826 style='font-size : 12px; width : 98%; height: 200px;'
1827 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1828 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1830 print "</td></tr><tr><td colspan='2'>" ;
1832 print "<div id='feedDlg_loginContainer' style='display : none'>
1834 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1835 placeHolder= \" " . __ ( "Login" ). " \"
1836 style= \" width : 10em; \" > " .
1838 placeHolder= \" " . __ ( "Password" ). " \"
1839 dojoType= \" dijit.form.TextBox \" type='password'
1840 style= \" width : 10em; \" name='pass' \" >" .
1843 print "</td></tr><tr><td colspan='2'>" ;
1845 print "<div style= \" clear : both \" >
1846 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1847 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1848 <label for= \" feedDlg_loginCheck \" >" .
1849 __ ( 'Feeds require authentication.' ). "</div>" ;
1853 print "</td></tr></table>" ;
1855 print "<div class= \" dlgButtons \" >
1856 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1857 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1861 function batchAddFeeds () {
1862 $cat_id = $this -> dbh
-> escape_string ( $_REQUEST [ 'cat' ]);
1863 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1864 $login = $this -> dbh
-> escape_string ( $_REQUEST [ 'login' ]);
1865 $pass = trim ( $_REQUEST [ 'pass' ]);
1867 foreach ( $feeds as $feed ) {
1868 $feed = $this -> dbh
-> escape_string ( trim ( $feed ));
1870 if ( validate_feed_url ( $feed )) {
1872 $this -> dbh
-> query ( "BEGIN" );
1874 if ( $cat_id == "0" ||
! $cat_id ) {
1875 $cat_qpart = "NULL" ;
1877 $cat_qpart = "' $cat_id '" ;
1880 $result = $this -> dbh
-> query (
1881 "SELECT id FROM ttrss_feeds
1882 WHERE feed_url = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1884 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
1885 require_once "crypt.php" ;
1886 $pass = substr ( encrypt_string ( $pass ), 0 , 250 );
1887 $auth_pass_encrypted = 'true' ;
1889 $auth_pass_encrypted = 'false' ;
1892 $pass = $this -> dbh
-> escape_string ( $pass );
1894 if ( $this -> dbh
-> num_rows ( $result ) == 0 ) {
1895 $result = $this -> dbh
-> query (
1896 "INSERT INTO ttrss_feeds
1897 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1898 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed ',
1899 '[Unknown]', $cat_qpart , ' $login ', ' $pass ', 0, $auth_pass_encrypted )" );
1902 $this -> dbh
-> query ( "COMMIT" );
1907 function regenOPMLKey () {
1908 $this -> update_feed_access_key ( 'OPML:Publish' ,
1909 false , $_SESSION [ "uid" ]);
1911 $new_link = Opml
:: opml_publish_url ();
1913 print json_encode ( array ( "link" => $new_link ));
1916 function regenFeedKey () {
1917 $feed_id = $this -> dbh
-> escape_string ( $_REQUEST [ 'id' ]);
1918 $is_cat = $this -> dbh
-> escape_string ( $_REQUEST [ 'is_cat' ]) == "true" ;
1920 $new_key = $this -> update_feed_access_key ( $feed_id , $is_cat );
1922 print json_encode ( array ( "link" => $new_key ));
1926 private function update_feed_access_key ( $feed_id , $is_cat , $owner_uid = false ) {
1927 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1929 $sql_is_cat = bool_to_sql_bool ( $is_cat );
1931 $result = $this -> dbh
-> query ( "SELECT access_key FROM ttrss_access_keys
1932 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1933 AND owner_uid = " . $owner_uid );
1935 if ( $this -> dbh
-> num_rows ( $result ) == 1 ) {
1936 $key = $this -> dbh
-> escape_string ( uniqid_short ());
1938 $this -> dbh
-> query ( "UPDATE ttrss_access_keys SET access_key = ' $key '
1939 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1940 AND owner_uid = " . $owner_uid );
1945 return get_feed_access_key ( $feed_id , $is_cat , $owner_uid );
1950 function clearKeys () {
1951 $this -> dbh
-> query ( "DELETE FROM ttrss_access_keys WHERE
1952 owner_uid = " . $_SESSION [ "uid" ]);
1955 private function calculate_children_count ( $cat ) {
1958 foreach ( $cat [ 'items' ] as $child ) {
1959 if ( $child [ 'type' ] == 'category' ) {
1960 $c +
= $this -> calculate_children_count ( $child );
1969 function getinactivefeeds () {
1970 if ( DB_TYPE
== "pgsql" ) {
1971 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1973 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1976 $result = $this -> dbh
-> query ( "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1977 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1978 ttrss_entries.id = ref_id AND
1979 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1980 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1982 print ( int ) $this -> dbh
-> fetch_result ( $result , 0 , "num_inactive" );