]>
git.wh0rd.org - tt-rss.git/blob - classes/pref/feeds.php
2 class Pref_Feeds
extends Handler_Protected
{
4 function csrf_ignore ( $method ) {
5 $csrf_ignored = array ( "index" , "getfeedtree" , "add" , "editcats" , "editfeed" ,
6 "savefeedorder" , "uploadicon" , "feedswitherrors" , "inactivefeeds" ,
9 return array_search ( $method , $csrf_ignored ) !== false ;
12 function batch_edit_cbox ( $elem , $label = false ) {
13 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
14 onchange= \" dijit.byId('feedEditDlg').toggleField(this, ' $elem ', ' $label ') \" >" ;
17 function renamecat () {
18 $title = db_escape_string ( $this -> link
, $_REQUEST [ 'title' ]);
19 $id = db_escape_string ( $this -> link
, $_REQUEST [ 'id' ]);
22 db_query ( $this -> link
, "UPDATE ttrss_feed_categories SET
23 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
28 private function get_category_items ( $cat_id ) {
30 if ( $_REQUEST [ 'mode' ] != 2 )
31 $search = $_SESSION [ "prefs_feed_search" ];
35 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
37 // first one is set by API
38 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
39 ( $_REQUEST [ 'mode' ] != 2 && ! $search &&
40 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ));
44 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
45 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat = ' $cat_id ' ORDER BY order_id, title" );
47 while ( $line = db_fetch_assoc ( $result )) {
50 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
51 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
52 $cat [ 'name' ] = $line [ 'title' ];
53 $cat [ 'items' ] = array ();
54 $cat [ 'checkbox' ] = false ;
55 $cat [ 'type' ] = 'category' ;
57 $cat [ 'child_unread' ] = 0 ;
59 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
61 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
63 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
64 array_push ( $items , $cat );
68 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
69 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
71 WHERE cat_id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ].
72 " $search_qpart ORDER BY order_id, title" );
74 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
76 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
77 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
78 $feed [ 'name' ] = $feed_line [ 'title' ];
79 $feed [ 'checkbox' ] = false ;
81 $feed [ 'error' ] = $feed_line [ 'last_error' ];
82 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
83 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
84 $feed_line [ 'last_updated' ], true );
86 array_push ( $items , $feed );
92 function getfeedtree () {
93 print json_encode ( $this -> makefeedtree ());
96 function makefeedtree () {
98 if ( $_REQUEST [ 'mode' ] != 2 )
99 $search = $_SESSION [ "prefs_feed_search" ];
103 if ( $search ) $search_qpart = " AND LOWER(title) LIKE LOWER('% $search %')" ;
106 $root [ 'id' ] = 'root' ;
107 $root [ 'name' ] = __ ( 'Feeds' );
108 $root [ 'items' ] = array ();
109 $root [ 'type' ] = 'category' ;
111 $enable_cats = get_pref ( $this -> link
, 'ENABLE_FEED_CATS' );
113 if ( $_REQUEST [ 'mode' ] == 2 ) {
116 $cat = $this -> feedlist_init_cat (- 1 );
118 $cat [ 'items' ] = array ();
121 foreach ( array (- 4 , - 3 , - 1 , - 2 , 0 , - 6 ) as $i ) {
122 array_push ( $cat [ 'items' ], $this -> feedlist_init_feed ( $i ));
125 /* Plugin feeds for -1 */
129 $feeds = $pluginhost -> get_feeds (- 1 );
132 foreach ( $feeds as $feed ) {
133 $feed_id = PluginHost
:: pfeed_to_feed_id ( $feed [ 'id' ]);
136 $item [ 'id' ] = 'FEED:' . $feed_id ;
137 $item [ 'bare_id' ] = ( int ) $feed_id ;
138 $item [ 'name' ] = $feed [ 'title' ];
139 $item [ 'checkbox' ] = false ;
141 $item [ 'icon' ] = $feed [ 'icon' ];
144 $item [ 'unread' ] = 0 ; //$feed['sender']->get_unread($feed['id']);
145 $item [ 'type' ] = 'feed' ;
147 array_push ( $cat [ 'items' ], $item );
152 array_push ( $root [ 'items' ], $cat );
154 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
157 $result = db_query ( $this -> link
, "SELECT * FROM
158 ttrss_labels2 WHERE owner_uid = " . $_SESSION [ 'uid' ]. " ORDER by caption" );
160 if ( db_num_rows ( $result ) > 0 ) {
162 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
163 $cat = $this -> feedlist_init_cat (- 2 );
165 $cat [ 'items' ] = array ();
168 while ( $line = db_fetch_assoc ( $result )) {
170 $label_id = label_to_feed_id ( $line [ 'id' ]);
172 $feed = $this -> feedlist_init_feed ( $label_id , false , 0 );
174 $feed [ 'fg_color' ] = $line [ 'fg_color' ];
175 $feed [ 'bg_color' ] = $line [ 'bg_color' ];
177 array_push ( $cat [ 'items' ], $feed );
181 array_push ( $root [ 'items' ], $cat );
183 $root [ 'items' ] = array_merge ( $root [ 'items' ], $cat [ 'items' ]);
189 $show_empty_cats = $_REQUEST [ 'force_show_empty' ] ||
190 ( $_REQUEST [ 'mode' ] != 2 && ! $search &&
191 get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ));
193 $result = db_query ( $this -> link
, "SELECT id, title FROM ttrss_feed_categories
194 WHERE owner_uid = " . $_SESSION [ "uid" ] . " AND parent_cat IS NULL ORDER BY order_id, title" );
196 while ( $line = db_fetch_assoc ( $result )) {
198 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
199 $cat [ 'bare_id' ] = ( int ) $line [ 'id' ];
200 $cat [ 'name' ] = $line [ 'title' ];
201 $cat [ 'items' ] = array ();
202 $cat [ 'checkbox' ] = false ;
203 $cat [ 'type' ] = 'category' ;
205 $cat [ 'child_unread' ] = 0 ;
207 $cat [ 'items' ] = $this -> get_category_items ( $line [ 'id' ]);
209 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
211 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
212 array_push ( $root [ 'items' ], $cat );
214 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
217 /* Uncategorized is a special case */
220 $cat [ 'id' ] = 'CAT:0' ;
222 $cat [ 'name' ] = __ ( "Uncategorized" );
223 $cat [ 'items' ] = array ();
224 $cat [ 'type' ] = 'category' ;
225 $cat [ 'checkbox' ] = false ;
227 $cat [ 'child_unread' ] = 0 ;
229 $feed_result = db_query ( $this -> link
, "SELECT id, title,last_error,
230 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
232 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
233 " $search_qpart ORDER BY order_id, title" );
235 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
237 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
238 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
239 $feed [ 'name' ] = $feed_line [ 'title' ];
240 $feed [ 'checkbox' ] = false ;
241 $feed [ 'error' ] = $feed_line [ 'last_error' ];
242 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
243 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
244 $feed_line [ 'last_updated' ], true );
246 $feed [ 'type' ] = 'feed' ;
248 array_push ( $cat [ 'items' ], $feed );
251 $cat [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
253 if ( count ( $cat [ 'items' ]) > 0 ||
$show_empty_cats )
254 array_push ( $root [ 'items' ], $cat );
256 $root [ 'param' ] +
= count ( $cat [ 'items' ]);
257 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
260 $feed_result = db_query ( $this -> link
, "SELECT id, title, last_error,
261 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
263 WHERE owner_uid = " . $_SESSION [ "uid" ].
264 " $search_qpart ORDER BY order_id, title" );
266 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
268 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
269 $feed [ 'bare_id' ] = ( int ) $feed_line [ 'id' ];
270 $feed [ 'name' ] = $feed_line [ 'title' ];
271 $feed [ 'checkbox' ] = false ;
272 $feed [ 'error' ] = $feed_line [ 'last_error' ];
273 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
274 $feed [ 'param' ] = make_local_datetime ( $this -> link
,
275 $feed_line [ 'last_updated' ], true );
277 $feed [ 'type' ] = 'feed' ;
279 array_push ( $root [ 'items' ], $feed );
282 $root [ 'param' ] = vsprintf ( _ngettext ( '( %d feed)' , '( %d feeds)' , count ( $cat [ 'items' ])), count ( $cat [ 'items' ]));
286 $fl [ 'identifier' ] = 'id' ;
287 $fl [ 'label' ] = 'name' ;
289 if ( $_REQUEST [ 'mode' ] != 2 ) {
290 $fl [ 'items' ] = array ( $root );
292 $fl [ 'items' ] =& $root [ 'items' ];
298 function catsortreset () {
299 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
300 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
304 function feedsortreset () {
305 db_query ( $this -> link
, "UPDATE ttrss_feeds
306 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
310 function togglehiddenfeedcats () {
311 set_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ,
312 ( get_pref ( $this -> link
, '_PREFS_SHOW_EMPTY_CATS' ) ?
'false' : 'true' ));
315 private function process_category_order (& $data_map , $item_id , $parent_id = false , $nest_level = 0 ) {
316 $debug = isset ( $_REQUEST [ "debug" ]);
319 for ( $i = 0 ; $i < $nest_level ; $i ++
)
322 if ( $debug ) _debug ( " $prefix C: $item_id P: $parent_id " );
324 $bare_item_id = substr ( $item_id , strpos ( $item_id , ':' ) +
1 );
326 if ( $item_id != 'root' ) {
327 if ( $parent_id && $parent_id != 'root' ) {
328 $parent_bare_id = substr ( $parent_id , strpos ( $parent_id , ':' ) +
1 );
329 $parent_qpart = db_escape_string ( $this -> link
, $parent_bare_id );
331 $parent_qpart = 'NULL' ;
334 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
335 SET parent_cat = $parent_qpart WHERE id = ' $bare_item_id ' AND
336 owner_uid = " . $_SESSION [ "uid" ]);
341 $cat = $data_map [ $item_id ];
343 if ( $cat && is_array ( $cat )) {
344 foreach ( $cat as $item ) {
345 $id = $item [ '_reference' ];
346 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
348 if ( $debug ) _debug ( " $prefix [ $order_id ] $id / $bare_id " );
350 if ( $item [ '_reference' ]) {
352 if ( strpos ( $id , "FEED" ) === 0 ) {
354 $cat_id = ( $item_id != "root" ) ?
355 db_escape_string ( $this -> link
, $bare_item_id ) : "NULL" ;
357 $cat_qpart = ( $cat_id != 0 ) ?
"cat_id = ' $cat_id '" :
360 db_query ( $this -> link
, "UPDATE ttrss_feeds
361 SET order_id = $order_id , $cat_qpart
362 WHERE id = ' $bare_id ' AND
363 owner_uid = " . $_SESSION [ "uid" ]);
365 } else if ( strpos ( $id , "CAT:" ) === 0 ) {
366 $this -> process_category_order ( $data_map , $item [ '_reference' ], $item_id ,
369 if ( $item_id != 'root' ) {
370 $parent_qpart = db_escape_string ( $this -> link
, $bare_id );
372 $parent_qpart = 'NULL' ;
375 db_query ( $this -> link
, "UPDATE ttrss_feed_categories
376 SET order_id = ' $order_id ' WHERE id = ' $bare_id ' AND
377 owner_uid = " . $_SESSION [ "uid" ]);
386 function savefeedorder () {
387 $data = json_decode ( $_POST [ 'payload' ], true );
389 #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
390 #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
392 if (! is_array ( $data [ 'items' ]))
393 $data [ 'items' ] = json_decode ( $data [ 'items' ], true );
395 # print_r($data['items']);
397 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
403 foreach ( $data [ 'items' ] as $item ) {
405 # if ($item['id'] != 'root') {
406 if ( is_array ( $item [ 'items' ])) {
407 if ( isset ( $item [ 'items' ][ '_reference' ])) {
408 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
410 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
413 if ( $item [ 'id' ] == 'root' ) {
414 $root_item = $item [ 'id' ];
418 $this -> process_category_order ( $data_map , $root_item );
420 /* foreach ($data['items'][0]['items'] as $item) {
421 $id = $item['_reference'];
422 $bare_id = substr($id, strpos($id, ':')+1);
427 db_query($this->link, "UPDATE ttrss_feed_categories
428 SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND
429 owner_uid = " . $_SESSION["uid"]);
434 if (is_array($data_map[$id])) {
435 foreach ($data_map[$id] as $feed) {
436 $id = $feed['_reference'];
437 $feed_id = substr($id, strpos($id, ':')+1);
440 $cat_query = "cat_id = '$bare_id'";
442 $cat_query = "cat_id = NULL";
444 db_query($this->link, "UPDATE ttrss_feeds
445 SET order_id = '$feed_order_id',
447 WHERE id = '$feed_id' AND
448 owner_uid = " . $_SESSION["uid"]);
459 function removeicon () {
460 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
462 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
463 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
465 if ( db_num_rows ( $result ) != 0 ) {
466 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
472 function uploadicon () {
473 header ( "Content-type: text/html" );
477 if ( is_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ])) {
478 $tmp_file = tempnam ( CACHE_DIR
. '/upload' , 'icon' );
480 $result = move_uploaded_file ( $_FILES [ 'icon_file' ][ 'tmp_name' ],
490 $icon_file = $tmp_file ;
491 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "feed_id" ]);
493 if ( is_file ( $icon_file ) && $feed_id ) {
494 if ( filesize ( $icon_file ) < 20000 ) {
496 $result = db_query ( $this -> link
, "SELECT id FROM ttrss_feeds
497 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
499 if ( db_num_rows ( $result ) != 0 ) {
500 @unlink
( ICONS_DIR
. "/ $feed_id .ico" );
501 rename ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
515 print "<script type= \" text/javascript \" >" ;
516 print "parent.uploadIconHandler( $rc );" ;
521 function editfeed () {
522 global $purge_intervals ;
523 global $update_intervals ;
525 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
527 $result = db_query ( $this -> link
,
528 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
529 owner_uid = " . $_SESSION [ "uid" ]);
531 $auth_pass_encrypted = sql_bool_to_bool ( db_fetch_result ( $result , 0 ,
532 "auth_pass_encrypted" ));
534 $title = htmlspecialchars ( db_fetch_result ( $result ,
537 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
538 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
539 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" editSave \" >" ;
541 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
542 print "<div class= \" dlgSecCont \" >" ;
546 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
547 placeHolder= \" " . __ ( "Feed Title" ). " \"
548 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
552 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
553 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
558 print __ ( 'URL:' ) . " " ;
559 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
560 placeHolder= \" " . __ ( "Feed URL" ). " \"
561 regExp='^(http|https)://.*' style= \" width : 20em \"
562 name= \" feed_url \" value= \" $feed_url\" >" ;
564 $last_error = db_fetch_result ( $result , 0 , "last_error" );
567 print " <span title= \" " . htmlspecialchars ( $last_error ). " \"
568 class= \" feed_error \" >(error)</span>" ;
574 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
576 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
580 print __ ( 'Place in category:' ) . " " ;
582 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
583 'dojoType="dijit.form.Select"' );
588 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
589 print "<div class= \" dlgSecCont \" >" ;
591 /* Update Interval */
593 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
595 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
596 'dojoType="dijit.form.Select"' );
600 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
603 print __ ( 'Article purging:' ) . " " ;
605 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
606 'dojoType="dijit.form.Select" ' .
607 (( FORCE_ARTICLE_PURGE
== 0 ) ?
"" : 'disabled="1"' ));
610 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
611 print "<div class= \" dlgSecCont \" >" ;
613 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
615 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
616 placeHolder= \" " . __ ( "Login" ). " \"
617 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
619 $auth_pass = db_fetch_result ( $result , 0 , "auth_pass" );
621 if ( $auth_pass_encrypted ) {
622 require_once "crypt.php" ;
623 $auth_pass = decrypt_string ( $auth_pass );
626 $auth_pass = htmlspecialchars ( $auth_pass );
628 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
629 placeHolder= \" " . __ ( "Password" ). " \"
630 value= \" $auth_pass\" >" ;
632 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
633 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
637 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
638 print "<div class= \" dlgSecCont \" >" ;
640 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
643 $checked = "checked= \" 1 \" " ;
648 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
649 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
651 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
653 if ( $include_in_digest ) {
654 $checked = "checked= \" 1 \" " ;
659 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
660 name= \" include_in_digest \"
661 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
664 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
666 if ( $always_display_enclosures ) {
667 $checked = "checked" ;
672 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
673 name= \" always_display_enclosures \"
674 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
676 $hide_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "hide_images" ));
679 $checked = "checked= \" 1 \" " ;
684 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" hide_images \"
686 $checked > <label for= \" hide_images \" >" .
687 __ ( 'Do not embed images' ). "</label>" ;
689 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
692 $checked = "checked= \" 1 \" " ;
697 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
698 name= \" cache_images \"
699 $checked > <label for= \" cache_images \" >" .
700 __ ( 'Cache images locally' ). "</label>" ;
702 $mark_unread_on_update = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "mark_unread_on_update" ));
704 if ( $mark_unread_on_update ) {
705 $checked = "checked" ;
710 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" mark_unread_on_update \"
711 name= \" mark_unread_on_update \"
712 $checked > <label for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
718 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
719 print "<div class= \" dlgSecCont \" >" ;
721 print "<iframe name= \" icon_upload_iframe \"
722 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
724 print "<form style='display : block' target= \" icon_upload_iframe \"
725 enctype= \" multipart/form-data \" method= \" POST \"
726 action= \" backend.php \" >
727 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
728 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
729 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
730 <input type= \" hidden \" name= \" method \" value= \" uploadicon \" >
731 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
732 type= \" submit \" >" . __ ( 'Replace' ). "</button>
733 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
734 type= \" submit \" >" . __ ( 'Remove' ). "</button>
739 $title = htmlspecialchars ( $title , ENT_QUOTES
);
741 print "<div class='dlgButtons'>
742 <div style= \" float : left \" >
743 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
744 __ ( 'Unsubscribe' ). "</button>" ;
746 if ( PUBSUBHUBBUB_ENABLED
) {
747 $pubsub_state = db_fetch_result ( $result , 0 , "pubsub_state" );
748 $pubsub_btn_disabled = ( $pubsub_state == 2 ) ?
"" : "disabled= \" 1 \" " ;
750 print "<button dojoType= \" dijit.form.Button \" id= \" pubsubReset_Btn \" $pubsub_btn_disabled
751 onclick='return resetPubSub( $feed_id , \" $title\" )'>" . __ ( 'Resubscribe to push updates' ).
757 print "<div dojoType= \" dijit.Tooltip \" connectId= \" pubsubReset_Btn \" position= \" below \" >" .
758 __ ( 'Resets PubSubHubbub subscription status for push-enabled feeds.' ). "</div>" ;
760 print "<button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
761 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
767 function editfeeds () {
768 global $purge_intervals ;
769 global $update_intervals ;
771 $feed_ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
773 print_notice ( "Enable the options you wish to apply using checkboxes on the right:" );
777 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
778 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
779 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchEditSave \" >" ;
781 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
782 print "<div class= \" dlgSecCont \" >" ;
786 print "<input dojoType= \" dijit.form.ValidationTextBox \"
787 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
788 name= \" title \" value= \" $title\" >" ;
790 $this -> batch_edit_cbox ( "title" );
796 print __ ( 'URL:' ) . " " ;
797 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
798 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
799 name= \" feed_url \" value= \" $feed_url\" >" ;
801 $this -> batch_edit_cbox ( "feed_url" );
805 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
809 print __ ( 'Place in category:' ) . " " ;
811 print_feed_cat_select ( $this -> link
, "cat_id" , $cat_id ,
812 'disabled="1" dojoType="dijit.form.Select"' );
814 $this -> batch_edit_cbox ( "cat_id" );
820 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
821 print "<div class= \" dlgSecCont \" >" ;
823 /* Update Interval */
825 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
826 'disabled="1" dojoType="dijit.form.Select"' );
828 $this -> batch_edit_cbox ( "update_interval" );
832 if ( FORCE_ARTICLE_PURGE
== 0 ) {
836 print __ ( 'Article purging:' ) . " " ;
838 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
839 'disabled="1" dojoType="dijit.form.Select"' );
841 $this -> batch_edit_cbox ( "purge_interval" );
845 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
846 print "<div class= \" dlgSecCont \" >" ;
848 print "<input dojoType= \" dijit.form.TextBox \"
849 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
850 name= \" auth_login \" value= \" $auth_login\" >" ;
852 $this -> batch_edit_cbox ( "auth_login" );
854 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
855 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
856 value= \" $auth_pass\" >" ;
858 $this -> batch_edit_cbox ( "auth_pass" );
861 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
862 print "<div class= \" dlgSecCont \" >" ;
864 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
865 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
867 print " " ; $this -> batch_edit_cbox ( "private" , "private_l" );
869 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
870 name= \" include_in_digest \"
871 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
873 print " " ; $this -> batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
875 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
876 name= \" always_display_enclosures \"
877 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
879 print " " ; $this -> batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
881 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" hide_images \"
883 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" hide_images_l \"
884 for= \" hide_images \" >" .
885 __ ( 'Do not embed images' ). "</label>" ;
887 print " " ; $this -> batch_edit_cbox ( "hide_images" , "hide_images_l" );
889 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
890 name= \" cache_images \"
891 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
892 for= \" cache_images \" >" .
893 __ ( 'Cache images locally' ). "</label>" ;
895 print " " ; $this -> batch_edit_cbox ( "cache_images" , "cache_images_l" );
897 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" mark_unread_on_update \"
898 name= \" mark_unread_on_update \"
899 dojoType= \" dijit.form.CheckBox \" > <label id= \" mark_unread_on_update_l \" class='insensitive' for= \" mark_unread_on_update \" >" . __ ( 'Mark updated articles as unread' ). "</label>" ;
901 print " " ; $this -> batch_edit_cbox ( "mark_unread_on_update" , "mark_unread_on_update_l" );
905 print "<div class='dlgButtons'>
906 <button dojoType= \" dijit.form.Button \"
907 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
908 __ ( 'Save' ). "</button>
909 <button dojoType= \" dijit.form.Button \"
910 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
911 __ ( 'Cancel' ). "</button>
917 function batchEditSave () {
918 return $this -> editsaveops ( true );
921 function editSave () {
922 return $this -> editsaveops ( false );
925 function editsaveops ( $batch ) {
927 $feed_title = db_escape_string ( $this -> link
, trim ( $_POST [ "title" ]));
928 $feed_link = db_escape_string ( $this -> link
, trim ( $_POST [ "feed_url" ]));
929 $upd_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "update_interval" ]);
930 $purge_intl = ( int ) db_escape_string ( $this -> link
, $_POST [ "purge_interval" ]);
931 $feed_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "id" ]); /* editSave */
932 $feed_ids = db_escape_string ( $this -> link
, $_POST [ "ids" ]); /* batchEditSave */
933 $cat_id = ( int ) db_escape_string ( $this -> link
, $_POST [ "cat_id" ]);
934 $auth_login = db_escape_string ( $this -> link
, trim ( $_POST [ "auth_login" ]));
935 $auth_pass = trim ( $_POST [ "auth_pass" ]);
936 $private = checkbox_to_sql_bool ( db_escape_string ( $this -> link
, $_POST [ "private" ]));
937 $include_in_digest = checkbox_to_sql_bool (
938 db_escape_string ( $this -> link
, $_POST [ "include_in_digest" ]));
939 $cache_images = checkbox_to_sql_bool (
940 db_escape_string ( $this -> link
, $_POST [ "cache_images" ]));
941 $hide_images = checkbox_to_sql_bool (
942 db_escape_string ( $this -> link
, $_POST [ "hide_images" ]));
943 $always_display_enclosures = checkbox_to_sql_bool (
944 db_escape_string ( $this -> link
, $_POST [ "always_display_enclosures" ]));
946 $mark_unread_on_update = checkbox_to_sql_bool (
947 db_escape_string ( $this -> link
, $_POST [ "mark_unread_on_update" ]));
949 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
950 require_once "crypt.php" ;
951 $auth_pass = substr ( encrypt_string ( $auth_pass ), 0 , 250 );
952 $auth_pass_encrypted = 'true' ;
954 $auth_pass_encrypted = 'false' ;
957 $auth_pass = db_escape_string ( $this -> link
, $auth_pass );
959 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
960 if ( $cat_id && $cat_id != 0 ) {
961 $category_qpart = "cat_id = ' $cat_id '," ;
962 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
964 $category_qpart = 'cat_id = NULL,' ;
965 $category_qpart_nocomma = 'cat_id = NULL' ;
968 $category_qpart = "" ;
969 $category_qpart_nocomma = "" ;
974 $result = db_query ( $this -> link
, "UPDATE ttrss_feeds SET
976 title = ' $feed_title ', feed_url = ' $feed_link ',
977 update_interval = ' $upd_intl ',
978 purge_interval = ' $purge_intl ',
979 auth_login = ' $auth_login ',
980 auth_pass = ' $auth_pass ',
981 auth_pass_encrypted = $auth_pass_encrypted ,
983 cache_images = $cache_images ,
984 hide_images = $hide_images ,
985 include_in_digest = $include_in_digest ,
986 always_display_enclosures = $always_display_enclosures ,
987 mark_unread_on_update = $mark_unread_on_update
988 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
991 $feed_data = array ();
993 foreach ( array_keys ( $_POST ) as $k ) {
994 if ( $k != "op" && $k != "method" && $k != "ids" ) {
995 $feed_data [ $k ] = $_POST [ $k ];
999 db_query ( $this -> link
, "BEGIN" );
1001 foreach ( array_keys ( $feed_data ) as $k ) {
1007 $qpart = "title = ' $feed_title '" ;
1011 $qpart = "feed_url = ' $feed_link '" ;
1014 case "update_interval" :
1015 $qpart = "update_interval = ' $upd_intl '" ;
1018 case "purge_interval" :
1019 $qpart = "purge_interval = ' $purge_intl '" ;
1023 $qpart = "auth_login = ' $auth_login '" ;
1027 $qpart = "auth_pass = ' $auth_pass ' AND
1028 auth_pass_encrypted = $auth_pass_encrypted " ;
1032 $qpart = "private = $private " ;
1035 case "include_in_digest" :
1036 $qpart = "include_in_digest = $include_in_digest " ;
1039 case "always_display_enclosures" :
1040 $qpart = "always_display_enclosures = $always_display_enclosures " ;
1043 case "mark_unread_on_update" :
1044 $qpart = "mark_unread_on_update = $mark_unread_on_update " ;
1047 case "cache_images" :
1048 $qpart = "cache_images = $cache_images " ;
1052 $qpart = "hide_images = $hide_images " ;
1056 $qpart = $category_qpart_nocomma ;
1062 db_query ( $this -> link
,
1063 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
1064 AND owner_uid = " . $_SESSION [ "uid" ]);
1069 db_query ( $this -> link
, "COMMIT" );
1074 function resetPubSub () {
1076 $ids = db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]);
1078 db_query ( $this -> link
, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ( $ids )
1079 AND owner_uid = " . $_SESSION [ "uid" ]);
1086 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1088 foreach ( $ids as $id ) {
1089 Pref_Feeds
:: remove_feed ( $this -> link
, $id , $_SESSION [ "uid" ]);
1096 $id = db_escape_string ( $this -> link
, $_REQUEST [ "id" ]);
1097 $this -> clear_feed_articles ( $this -> link
, $id );
1100 function rescore () {
1101 require_once "rssfuncs.php" ;
1103 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1105 foreach ( $ids as $id ) {
1107 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1109 $result = db_query ( $this -> link
, "SELECT
1110 title, content, link, ref_id, author," .
1111 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1113 ttrss_user_entries, ttrss_entries
1114 WHERE ref_id = id AND feed_id = ' $id ' AND
1115 owner_uid = " . $_SESSION [ 'uid' ]. "
1120 while ( $line = db_fetch_assoc ( $result )) {
1122 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1124 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1125 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1126 $line [ 'author' ], $tags );
1128 $new_score = calculate_article_score ( $article_filters );
1130 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1132 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1135 foreach ( array_keys ( $scores ) as $s ) {
1137 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1139 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1140 } else if ( $s < - 500 ) {
1141 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1142 unread = false WHERE
1143 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1145 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1146 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1151 print __ ( "All done." );
1155 function rescoreAll () {
1157 $result = db_query ( $this -> link
,
1158 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
1160 while ( $feed_line = db_fetch_assoc ( $result )) {
1162 $id = $feed_line [ "id" ];
1164 $filters = load_filters ( $this -> link
, $id , $_SESSION [ "uid" ], 6 );
1166 $tmp_result = db_query ( $this -> link
, "SELECT
1167 title, content, link, ref_id, author," .
1168 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
1170 ttrss_user_entries, ttrss_entries
1171 WHERE ref_id = id AND feed_id = ' $id ' AND
1172 owner_uid = " . $_SESSION [ 'uid' ]. "
1177 while ( $line = db_fetch_assoc ( $tmp_result )) {
1179 $tags = get_article_tags ( $this -> link
, $line [ "ref_id" ]);
1181 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
1182 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
1183 $line [ 'author' ], $tags );
1185 $new_score = calculate_article_score ( $article_filters );
1187 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
1189 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
1192 foreach ( array_keys ( $scores ) as $s ) {
1194 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ',
1196 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1198 db_query ( $this -> link
, "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
1199 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
1204 print __ ( "All done." );
1208 function categorize () {
1209 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1211 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ "cat_id" ]);
1214 $cat_id_qpart = 'NULL' ;
1216 $cat_id_qpart = "' $cat_id '" ;
1219 db_query ( $this -> link
, "BEGIN" );
1221 foreach ( $ids as $id ) {
1223 db_query ( $this -> link
, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1225 AND owner_uid = " . $_SESSION [ "uid" ]);
1229 db_query ( $this -> link
, "COMMIT" );
1232 function removeCat () {
1233 $ids = split ( "," , db_escape_string ( $this -> link
, $_REQUEST [ "ids" ]));
1234 foreach ( $ids as $id ) {
1235 $this -> remove_feed_category ( $this -> link
, $id , $_SESSION [ "uid" ]);
1240 $feed_cat = db_escape_string ( $this -> link
, trim ( $_REQUEST [ "cat" ]));
1242 add_feed_category ( $this -> link
, $feed_cat );
1247 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1248 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1250 $result = db_query ( $this -> link
, "SELECT COUNT(id) AS num_errors
1251 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1253 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1255 if ( $num_errors > 0 ) {
1257 $error_button = "<button dojoType= \" dijit.form.Button \"
1258 onclick= \" showFeedsWithErrors() \" id= \" errorButton \" >" .
1259 __ ( "Feeds with errors" ) . "</button>" ;
1262 if ( DB_TYPE
== "pgsql" ) {
1263 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1265 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1268 $result = db_query ( $this -> link
, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
1269 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1270 ttrss_entries.id = ref_id AND
1271 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1272 ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]);
1274 $num_inactive = db_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 = db_escape_string ( $this -> link
, $_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 ( $this -> link
, '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 print "<button onclick= \" toggleHiddenFeedCats() \"
1343 dojoType= \" dijit.form.Button \" >" . __ ( '(Un)hide empty categories' ). "</button>" ;
1345 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1347 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1348 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1350 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1352 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1356 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1357 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1363 print "</div>" ; # toolbar
1366 print '<div dojoType="dijit.layout.ContentPane" region="center">' ;
1368 print "<div id= \" feedlistLoading \" >
1369 <img src='images/indicator_tiny.gif'>" .
1370 __ ( "Loading, please wait..." ). "</div>" ;
1372 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1373 url= \" backend.php?op=pref-feeds&method=getfeedtree \" >
1375 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1376 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1377 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1379 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1380 dndController= \" dijit.tree.dndSource \"
1381 betweenThreshold= \" 5 \"
1382 model= \" feedModel \" openOnClick= \" false \" >
1383 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1384 var id = String(item.id);
1385 var bare_id = id.substr(id.indexOf(':')+1);
1387 if (id.match('FEED:')) {
1389 } else if (id.match('CAT:')) {
1390 editCat(bare_id, item);
1393 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1394 Element.hide( \" feedlistLoading \" );
1398 # print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
1399 # ".__('<b>Hint:</b> you can drag feeds and categories around.')."
1405 print "</div>" ; # feeds pane
1407 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1409 print "<p>" . __ ( "Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings." ) . " " ;
1411 print __ ( "Only main settings profile can be migrated using OPML." ) . "</p>" ;
1413 print "<iframe id= \" upload_iframe \"
1414 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1415 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1417 print "<form name= \" opml_form \" style='display : block' target= \" upload_iframe \"
1418 enctype= \" multipart/form-data \" method= \" POST \"
1419 action= \" backend.php \" >
1420 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1421 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1422 <input type= \" hidden \" name= \" method \" value= \" importOpml \" >
1423 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \" type= \" submit \" >" .
1424 __ ( 'Import my OPML' ) . "</button>" ;
1428 print "<p>" . __ ( 'Filename:' ) .
1429 " <input type= \" text \" id= \" filename \" value= \" TinyTinyRSS.opml \" /> " .
1430 __ ( 'Include settings' ) . "<input type= \" checkbox \" id= \" settings \" checked= \" 1 \" />" ;
1432 print "</p><button dojoType= \" dijit.form.Button \"
1433 onclick= \" gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked) \" >" .
1434 __ ( 'Export OPML' ) . "</button></p></form>" ;
1438 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' ) . " " ;
1440 print __ ( "Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</p>" ;
1442 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "Public OPML URL" ). "','pubOPMLUrl') \" >" .
1443 __ ( 'Display published OPML URL' ). "</button> " ;
1446 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1447 "hook_prefs_tab_section" , "prefFeedsOPML" );
1449 print "</div>" ; # pane
1451 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1453 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1455 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1459 print "<button onclick='window.navigator.registerContentHandler(" .
1460 " \" application/vnd.mozilla.maybe.feed \" , " .
1461 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1462 __ ( 'Click here to register this site as a feed reader.' ) .
1467 print "</div>" ; # pane
1470 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published & shared articles / Generated feeds' ). " \" >" ;
1472 print "<h3>" . __ ( "Published articles and generated feeds" ) . "</h3>" ;
1474 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1476 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1477 "/public.php?op=rss&id=-2&view-mode=all_articles" );;
1479 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('" . __ ( "View as RSS" ). "','generatedFeed', ' $rss_url ') \" >" .
1480 __ ( 'Display URL' ). "</button> " ;
1482 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1483 __ ( 'Clear all generated URLs' ). "</button> " ;
1485 print "<h3>" . __ ( "Articles shared by URL" ) . "</h3>" ;
1487 print "<p>" . __ ( "You can disable all articles shared by unique URLs here." ) . "</p>" ;
1489 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearArticleAccessKeys() \" >" .
1490 __ ( 'Unshare all articles' ). "</button> " ;
1493 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB_SECTION
,
1494 "hook_prefs_tab_section" , "prefFeedsPublishedGenerated" );
1496 print "</div>" ; #pane
1500 $pluginhost -> run_hooks ( $pluginhost :: HOOK_PREFS_TAB
,
1501 "hook_prefs_tab" , "prefFeeds" );
1503 print "</div>" ; #container
1506 private function feedlist_init_cat ( $cat_id ) {
1508 $cat_id = ( int ) $cat_id ;
1511 $cat_unread = ccache_find ( $this -> link
, $cat_id , $_SESSION [ "uid" ], true );
1512 } else if ( $cat_id == 0 ||
$cat_id == - 2 ) {
1513 $cat_unread = getCategoryUnread ( $this -> link
, $cat_id );
1516 $obj [ 'id' ] = 'CAT:' . $cat_id ;
1517 $obj [ 'items' ] = array ();
1518 $obj [ 'name' ] = getCategoryTitle ( $this -> link
, $cat_id );
1519 $obj [ 'type' ] = 'category' ;
1520 $obj [ 'unread' ] = ( int ) $cat_unread ;
1521 $obj [ 'bare_id' ] = $cat_id ;
1526 private function feedlist_init_feed ( $feed_id , $title = false , $unread = false , $error = '' , $updated = '' ) {
1528 $feed_id = ( int ) $feed_id ;
1531 $title = getFeedTitle ( $this -> link
, $feed_id , false );
1533 if ( $unread === false )
1534 $unread = getFeedUnread ( $this -> link
, $feed_id , false );
1536 $obj [ 'id' ] = 'FEED:' . $feed_id ;
1537 $obj [ 'name' ] = $title ;
1538 $obj [ 'unread' ] = ( int ) $unread ;
1539 $obj [ 'type' ] = 'feed' ;
1540 $obj [ 'error' ] = $error ;
1541 $obj [ 'updated' ] = $updated ;
1542 $obj [ 'icon' ] = getFeedIcon ( $feed_id );
1543 $obj [ 'bare_id' ] = $feed_id ;
1548 function inactiveFeeds () {
1550 if ( DB_TYPE
== "pgsql" ) {
1551 $interval_qpart = "NOW() - INTERVAL '3 months'" ;
1553 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)" ;
1556 $result = db_query ( $this -> link
, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1557 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1558 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1559 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1560 ttrss_entries.id = ref_id AND
1561 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
1562 AND ttrss_feeds.owner_uid = " . $_SESSION [ "uid" ]. " AND
1563 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1564 ttrss_entries.id = ref_id
1565 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1566 ORDER BY last_article" );
1568 print "<h2" . __ ( "These feeds have not been updated with new content for 3 months (oldest first):" ) . "</h2>" ;
1570 print "<div dojoType= \" dijit.Toolbar \" >" ;
1571 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1572 "<span>" . __ ( 'Select' ). "</span>" ;
1573 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1574 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'all') \"
1575 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1576 print "<div onclick= \" selectTableRows('prefInactiveFeedList', 'none') \"
1577 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1578 print "</div></div>" ;
1579 print "</div>" ; #toolbar
1581 print "<div class= \" inactiveFeedHolder \" >" ;
1583 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefInactiveFeedList \" >" ;
1587 while ( $line = db_fetch_assoc ( $result )) {
1589 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1590 $feed_id = $line [ "id" ];
1591 $this_row_id = "id= \" FUPDD- $feed_id\" " ;
1593 # class needed for selectTableRows()
1594 print "<tr class= \" placeholder \" $this_row_id >" ;
1596 $edit_title = htmlspecialchars ( $line [ "title" ]);
1598 # id needed for selectTableRows()
1599 print "<td width='5%' align='center'><input
1600 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1601 type= \" checkbox \" id= \" FUPDC- $feed_id\" ></td>" ;
1604 print "<a class= \" visibleLink \" href= \" # \" " .
1605 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1606 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1607 htmlspecialchars ( $line [ "title" ]). "</a>" ;
1609 print "</td><td class= \" insensitive \" align='right'>" ;
1610 print make_local_datetime ( $this -> link
, $line [ 'last_article' ], false );
1620 print "<div class='dlgButtons'>" ;
1621 print "<div style='float : left'>" ;
1622 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').removeSelected() \" >"
1623 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1626 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('inactiveFeedsDlg').hide() \" >" .
1627 __ ( 'Close this window' ). "</button>" ;
1633 function feedsWithErrors () {
1634 print "<h2>" . __ ( "These feeds have not been updated because of errors:" ) .
1637 $result = db_query ( $this -> link
, "SELECT id,title,feed_url,last_error,site_url
1638 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1640 print "<div dojoType= \" dijit.Toolbar \" >" ;
1641 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1642 "<span>" . __ ( 'Select' ). "</span>" ;
1643 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1644 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'all') \"
1645 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1646 print "<div onclick= \" selectTableRows('prefErrorFeedList', 'none') \"
1647 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1648 print "</div></div>" ;
1649 print "</div>" ; #toolbar
1651 print "<div class= \" inactiveFeedHolder \" >" ;
1653 print "<table width= \" 100% \" cellspacing= \" 0 \" id= \" prefErrorFeedList \" >" ;
1657 while ( $line = db_fetch_assoc ( $result )) {
1659 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1660 $feed_id = $line [ "id" ];
1661 $this_row_id = "id= \" FERDD- $feed_id\" " ;
1663 # class needed for selectTableRows()
1664 print "<tr class= \" placeholder \" $this_row_id >" ;
1666 $edit_title = htmlspecialchars ( $line [ "title" ]);
1668 # id needed for selectTableRows()
1669 print "<td width='5%' align='center'><input
1670 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1671 type= \" checkbox \" id= \" FERDC- $feed_id\" ></td>" ;
1674 print "<a class= \" visibleLink \" href= \" # \" " .
1675 "title= \" " . __ ( "Click to edit feed" ). " \" " .
1676 "onclick= \" editFeed(" . $line [ "id" ]. ") \" >" .
1677 htmlspecialchars ( $line [ "title" ]). "</a>: " ;
1679 print "<span class= \" insensitive \" >" ;
1680 print htmlspecialchars ( $line [ "last_error" ]);
1692 print "<div class='dlgButtons'>" ;
1693 print "<div style='float : left'>" ;
1694 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').removeSelected() \" >"
1695 . __ ( 'Unsubscribe from selected feeds' ). "</button> " ;
1698 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('errorFeedsDlg').hide() \" >" .
1699 __ ( 'Close this window' ). "</button>" ;
1705 * Purge a feed contents, marked articles excepted.
1707 * @param mixed $link The database connection.
1708 * @param integer $id The id of the feed to purge.
1711 private function clear_feed_articles ( $link , $id ) {
1714 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1715 WHERE feed_id = ' $id ' AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1717 $result = db_query ( $link , "DELETE FROM ttrss_user_entries
1718 WHERE feed_id IS NULL AND marked = false AND owner_uid = " . $_SESSION [ "uid" ]);
1721 $result = db_query ( $link , "DELETE FROM ttrss_entries WHERE
1722 (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0" );
1724 ccache_update ( $link , $id , $_SESSION [ 'uid' ]);
1725 } // function clear_feed_articles
1727 private function remove_feed_category ( $link , $id , $owner_uid ) {
1729 db_query ( $link , "DELETE FROM ttrss_feed_categories
1730 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1732 ccache_remove ( $link , $id , $owner_uid , true );
1735 static function remove_feed ( $link , $id , $owner_uid ) {
1739 /* save starred articles in Archived feed */
1741 db_query ( $link , "BEGIN" );
1743 /* prepare feed if necessary */
1745 $result = db_query ( $link , "SELECT feed_url FROM ttrss_feeds WHERE id = $id
1746 AND owner_uid = $owner_uid " );
1748 $feed_url = db_escape_string ( $link , db_fetch_result ( $result , 0 , "feed_url" ));
1750 $result = db_query ( $link , "SELECT id FROM ttrss_archived_feeds
1751 WHERE feed_url = ' $feed_url ' AND owner_uid = $owner_uid " );
1753 if ( db_num_rows ( $result ) == 0 ) {
1754 $result = db_query ( $link , "SELECT MAX(id) AS id FROM ttrss_archived_feeds" );
1755 $new_feed_id = ( int ) db_fetch_result ( $result , 0 , "id" ) +
1 ;
1757 db_query ( $link , "INSERT INTO ttrss_archived_feeds
1758 (id, owner_uid, title, feed_url, site_url)
1759 SELECT $new_feed_id , owner_uid, title, feed_url, site_url from ttrss_feeds
1762 $archive_id = $new_feed_id ;
1764 $archive_id = db_fetch_result ( $result , 0 , "id" );
1767 db_query ( $link , "UPDATE ttrss_user_entries SET feed_id = NULL,
1768 orig_feed_id = ' $archive_id ' WHERE feed_id = ' $id ' AND
1769 marked = true AND owner_uid = $owner_uid " );
1771 /* Remove access key for the feed */
1773 db_query ( $link , "DELETE FROM ttrss_access_keys WHERE
1774 feed_id = ' $id ' AND owner_uid = $owner_uid " );
1776 /* remove the feed */
1778 db_query ( $link , "DELETE FROM ttrss_feeds
1779 WHERE id = ' $id ' AND owner_uid = $owner_uid " );
1781 db_query ( $link , "COMMIT" );
1783 if ( file_exists ( ICONS_DIR
. "/ $id .ico" )) {
1784 unlink ( ICONS_DIR
. "/ $id .ico" );
1787 ccache_remove ( $link , $id , $owner_uid );
1790 label_remove ( $link , feed_to_label_id ( $id ), $owner_uid );
1791 //ccache_remove($link, $id, $owner_uid); don't think labels are cached
1795 function batchSubscribe () {
1796 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
1797 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" method \" value= \" batchaddfeeds \" >" ;
1799 print "<table width='100%'><tr><td>
1800 " . __ ( "Add one valid RSS feed per line (no feed detection is done)" ). "
1801 </td><td align='right'>" ;
1802 if ( get_pref ( $this -> link
, 'ENABLE_FEED_CATS' )) {
1803 print __ ( 'Place in category:' ) . " " ;
1804 print_feed_cat_select ( $this -> link
, "cat" , false , 'dojoType="dijit.form.Select"' );
1806 print "</td></tr><tr><td colspan='2'>" ;
1808 style='font-size : 12px; width : 100%; height: 200px;'
1809 placeHolder= \" " . __ ( "Feeds to subscribe, One per line" ). " \"
1810 dojoType= \" dijit.form.SimpleTextarea \" required= \" 1 \" name= \" feeds \" ></textarea>" ;
1812 print "</td></tr><tr><td colspan='2'>" ;
1814 print "<div id='feedDlg_loginContainer' style='display : none'>
1816 " <input dojoType= \" dijit.form.TextBox \" name='login' \"
1817 placeHolder= \" " . __ ( "Login" ). " \"
1818 style= \" width : 10em; \" > " .
1820 placeHolder= \" " . __ ( "Password" ). " \"
1821 dojoType= \" dijit.form.TextBox \" type='password'
1822 style= \" width : 10em; \" name='pass' \" >" .
1825 print "</td></tr><tr><td colspan='2'>" ;
1827 print "<div style= \" clear : both \" >
1828 <input type= \" checkbox \" name= \" need_auth \" dojoType= \" dijit.form.CheckBox \" id= \" feedDlg_loginCheck \"
1829 onclick='checkboxToggleElement(this, \" feedDlg_loginContainer \" )'>
1830 <label for= \" feedDlg_loginCheck \" >" .
1831 __ ( 'Feeds require authentication.' ). "</div>" ;
1835 print "</td></tr></table>" ;
1837 print "<div class= \" dlgButtons \" >
1838 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').execute() \" >" . __ ( 'Subscribe' ). "</button>
1839 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('batchSubDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
1843 function batchAddFeeds () {
1844 $cat_id = db_escape_string ( $this -> link
, $_REQUEST [ 'cat' ]);
1845 $feeds = explode ( " \n " , $_REQUEST [ 'feeds' ]);
1846 $login = db_escape_string ( $this -> link
, $_REQUEST [ 'login' ]);
1847 $pass = trim ( $_REQUEST [ 'pass' ]);
1849 foreach ( $feeds as $feed ) {
1850 $feed = db_escape_string ( $this -> link
, trim ( $feed ));
1852 if ( validate_feed_url ( $feed )) {
1854 db_query ( $this -> link
, "BEGIN" );
1856 if ( $cat_id == "0" ||
! $cat_id ) {
1857 $cat_qpart = "NULL" ;
1859 $cat_qpart = "' $cat_id '" ;
1862 $result = db_query ( $this -> link
,
1863 "SELECT id FROM ttrss_feeds
1864 WHERE feed_url = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1866 if ( strlen ( FEED_CRYPT_KEY
) > 0 ) {
1867 require_once "crypt.php" ;
1868 $pass = substr ( encrypt_string ( $pass ), 0 , 250 );
1869 $auth_pass_encrypted = 'true' ;
1871 $auth_pass_encrypted = 'false' ;
1874 $pass = db_escape_string ( $this -> link
, $pass );
1876 if ( db_num_rows ( $result ) == 0 ) {
1877 $result = db_query ( $this -> link
,
1878 "INSERT INTO ttrss_feeds
1879 (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1880 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed ',
1881 '[Unknown]', $cat_qpart , ' $login ', ' $pass ', 0, $auth_pass_encrypted )" );
1884 db_query ( $this -> link
, "COMMIT" );
1889 function regenOPMLKey () {
1890 $this -> update_feed_access_key ( $this -> link
, 'OPML:Publish' ,
1891 false , $_SESSION [ "uid" ]);
1893 $new_link = Opml
:: opml_publish_url ( $this -> link
);
1895 print json_encode ( array ( "link" => $new_link ));
1898 function regenFeedKey () {
1899 $feed_id = db_escape_string ( $this -> link
, $_REQUEST [ 'id' ]);
1900 $is_cat = db_escape_string ( $this -> link
, $_REQUEST [ 'is_cat' ]) == "true" ;
1902 $new_key = $this -> update_feed_access_key ( $this -> link
, $feed_id , $is_cat );
1904 print json_encode ( array ( "link" => $new_key ));
1908 private function update_feed_access_key ( $link , $feed_id , $is_cat , $owner_uid = false ) {
1909 if (! $owner_uid ) $owner_uid = $_SESSION [ "uid" ];
1911 $sql_is_cat = bool_to_sql_bool ( $is_cat );
1913 $result = db_query ( $link , "SELECT access_key FROM ttrss_access_keys
1914 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1915 AND owner_uid = " . $owner_uid );
1917 if ( db_num_rows ( $result ) == 1 ) {
1918 $key = db_escape_string ( $this -> link
, sha1 ( uniqid ( rand (), true )));
1920 db_query ( $link , "UPDATE ttrss_access_keys SET access_key = ' $key '
1921 WHERE feed_id = ' $feed_id ' AND is_cat = $sql_is_cat
1922 AND owner_uid = " . $owner_uid );
1927 return get_feed_access_key ( $link , $feed_id , $is_cat , $owner_uid );
1932 function clearKeys () {
1933 db_query ( $this -> link
, "DELETE FROM ttrss_access_keys WHERE
1934 owner_uid = " . $_SESSION [ "uid" ]);