]>
git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
3 function batch_edit_cbox ( $elem , $label = false ) {
4 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
5 onchange= \" batchFeedsToggleField(this, ' $elem ', ' $label ') \" >" ;
8 function module_pref_feeds ( $link ) {
10 global $update_intervals ;
11 global $purge_intervals ;
12 global $update_methods ;
14 $subop = $_REQUEST [ "subop" ];
15 $quiet = $_REQUEST [ "quiet" ];
16 $mode = $_REQUEST [ "mode" ];
18 if ( $subop == "renamecat" ) {
19 $title = db_escape_string ( $_REQUEST [ 'title' ]);
20 $id = db_escape_string ( $_REQUEST [ 'id' ]);
23 db_query ( $link , "UPDATE ttrss_feed_categories SET
24 title = ' $title ' WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
29 if ( $subop == "getfeedtree" ) {
33 $root [ 'name' ] = __ ( 'Feeds' );
34 $root [ 'items' ] = array ();
35 $root [ 'type' ] = 'category' ;
37 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
39 $result = db_query ( $link , "SELECT id, title FROM ttrss_feed_categories
40 WHERE owner_uid = " . $_SESSION [ "uid" ] . " ORDER BY order_id, title" );
42 while ( $line = db_fetch_assoc ( $result )) {
44 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
45 $cat [ 'bare_id' ] = $feed_id ;
46 $cat [ 'name' ] = $line [ 'title' ];
47 $cat [ 'items' ] = array ();
48 $cat [ 'type' ] = 'category' ;
50 $feed_result = db_query ( $link , "SELECT id, title, last_error
52 WHERE cat_id = '" . $line [ 'id' ]. "' AND owner_uid = " . $_SESSION [ "uid" ].
53 " ORDER BY order_id, title" );
55 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
57 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
58 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
59 $feed [ 'name' ] = $feed_line [ 'title' ];
60 $feed [ 'checkbox' ] = false ;
61 $feed [ 'error' ] = $feed_line [ 'last_error' ];
62 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
64 array_push ( $cat [ 'items' ], $feed );
67 array_push ( $root [ 'items' ], $cat );
70 /* Uncategorized is a special case */
75 $cat [ 'name' ] = __ ( "Uncategorized" );
76 $cat [ 'items' ] = array ();
78 $feed_result = db_query ( $link , "SELECT id, title,last_error
80 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
81 " ORDER BY order_id, title" );
83 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
85 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
86 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
87 $feed [ 'name' ] = $feed_line [ 'title' ];
88 $feed [ 'checkbox' ] = false ;
89 $feed [ 'error' ] = $feed_line [ 'last_error' ];
90 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
92 array_push ( $cat [ 'items' ], $feed );
95 array_push ( $root [ 'items' ], $cat );
97 $feed_result = db_query ( $link , "SELECT id, title, last_error
99 WHERE owner_uid = " . $_SESSION [ "uid" ].
100 " ORDER BY order_id, title" );
102 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
104 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
105 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
106 $feed [ 'name' ] = $feed_line [ 'title' ];
107 $feed [ 'checkbox' ] = false ;
108 $feed [ 'error' ] = $feed_line [ 'last_error' ];
109 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
111 array_push ( $root [ 'items' ], $feed );
116 $fl [ 'identifier' ] = 'id' ;
117 $fl [ 'label' ] = 'name' ;
118 $fl [ 'items' ] = array ( $root );
120 print json_encode ( $fl );
124 if ( $subop == "catsortreset" ) {
125 db_query ( $link , "UPDATE ttrss_feed_categories
126 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
130 if ( $subop == "feedsortreset" ) {
131 db_query ( $link , "UPDATE ttrss_feeds
132 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
136 if ( $subop == "savefeedorder" ) {
137 # if ($_POST['payload']) {
138 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
139 # $data = json_decode($_POST['payload'], true);
141 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
144 $data = json_decode ( $_POST [ 'payload' ], true );
146 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
151 foreach ( $data [ 'items' ] as $item ) {
153 if ( $item [ 'id' ] != 'root' ) {
154 if ( is_array ( $item [ 'items' ])) {
155 if ( isset ( $item [ 'items' ][ '_reference' ])) {
156 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
158 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
164 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
165 $id = $item [ '_reference' ];
166 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
171 db_query ( $link , "UPDATE ttrss_feed_categories
172 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
173 owner_uid = " . $_SESSION [ "uid" ]);
178 if ( is_array ( $data_map [ $id ])) {
179 foreach ( $data_map [ $id ] as $feed ) {
180 $id = $feed [ '_reference' ];
181 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
184 $cat_query = "cat_id = ' $bare_id '" ;
186 $cat_query = "cat_id = NULL" ;
188 db_query ( $link , "UPDATE ttrss_feeds
189 SET order_id = ' $feed_order_id ',
191 WHERE id = ' $feed_id ' AND
192 owner_uid = " . $_SESSION [ "uid" ]);
203 if ( $subop == "removeicon" ) {
204 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
206 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
207 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
209 if ( db_num_rows ( $result ) != 0 ) {
210 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
216 if ( $subop == "uploadicon" ) {
217 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
218 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
220 if ( is_file ( $icon_file ) && $feed_id ) {
221 if ( filesize ( $icon_file ) < 20000 ) {
223 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
224 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
226 if ( db_num_rows ( $result ) != 0 ) {
227 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
228 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
240 print "<script type= \" text/javascript \" >" ;
241 print "parent.uploadIconHandler( $rc );" ;
246 if ( $subop == "editfeed" ) {
247 header ( "Content-Type: text/xml" );
249 print "<dlg id= \" $subop\" >" ;
250 print "<title>" . __ ( 'Feed Editor' ). "</title>" ;
251 print "<content><![CDATA[" ;
253 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
255 $result = db_query ( $link ,
256 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
257 owner_uid = " . $_SESSION [ "uid" ]);
259 $title = htmlspecialchars ( db_fetch_result ( $result ,
262 $icon_file = ICONS_DIR
. "/ $feed_id .ico" ;
264 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
265 $feed_icon = "<img width= \" 16 \" height= \" 16 \"
266 src= \" " . ICONS_URL
. "/ $feed_id .ico \" >" ;
271 print "<form id= \" edit_feed_form \" onsubmit= \" return false \" >" ;
273 print "<input type= \" hidden \" name= \" id \" value= \" $feed_id\" >" ;
274 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
275 print "<input type= \" hidden \" name= \" subop \" value= \" editSave \" >" ;
277 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
278 print "<div class= \" dlgSecCont \" >" ;
282 print "<input style= \" font-size : 16px \" size= \" 40 \" onkeypress= \" return filterCR(event, feedEditSave) \"
283 name= \" title \" value= \" $title\" >" ;
287 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
288 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
293 print __ ( 'URL:' ) . " " ;
294 print "<input size= \" 40 \" onkeypress= \" return filterCR(event, feedEditSave) \"
295 name= \" feed_url \" value= \" $feed_url\" >" ;
299 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
301 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
305 print __ ( 'Place in category:' ) . " " ;
307 print_feed_cat_select ( $link , "cat_id" , $cat_id , $disabled );
312 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
313 print "<div class= \" dlgSecCont \" >" ;
315 /* Update Interval */
317 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
319 print_select_hash ( "update_interval" , $update_interval , $update_intervals );
323 $update_method = db_fetch_result ( $result , 0 , "update_method" );
325 print " " . __ ( 'using' ) . " " ;
326 print_select_hash ( "update_method" , $update_method , $update_methods );
328 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
330 if ( FORCE_ARTICLE_PURGE
== 0 ) {
336 print __ ( 'Article purging:' ) . " " ;
338 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals );
341 print "<input type='hidden' name='purge_interval' value=' $purge_interval '>" ;
346 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
347 print "<div class= \" dlgSecCont \" >" ;
349 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
353 print "<tr><td>" . __ ( 'Login:' ) . "</td><td>" ;
355 print "<input size= \" 20 \" onkeypress= \" return filterCR(event, feedEditSave) \"
356 name= \" auth_login \" value= \" $auth_login\" >" ;
358 print "</tr><tr><td>" . __ ( "Password:" ) . "</td><td>" ;
360 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
362 print "<input size= \" 20 \" type= \" password \" name= \" auth_pass \"
363 onkeypress= \" return filterCR(event, feedEditSave) \"
364 value= \" $auth_pass\" >" ;
366 print "</td></tr></table>" ;
369 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
370 print "<div class= \" dlgSecCont \" >" ;
372 print "<div style= \" line-height : 100% \" >" ;
374 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
377 $checked = "checked" ;
382 print "<input type= \" checkbox \" name= \" private \" id= \" private \"
383 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
385 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
388 $checked = "checked" ;
393 print "<br/><input type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
394 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
396 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
398 if ( $include_in_digest ) {
399 $checked = "checked" ;
404 print "<br/><input type= \" checkbox \" id= \" include_in_digest \"
405 name= \" include_in_digest \"
406 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
409 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
411 if ( $always_display_enclosures ) {
412 $checked = "checked" ;
417 print "<br/><input type= \" checkbox \" id= \" always_display_enclosures \"
418 name= \" always_display_enclosures \"
419 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
422 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
425 $checked = "checked" ;
430 if ( SIMPLEPIE_CACHE_IMAGES
) {
434 $disabled = "disabled" ;
435 $label_class = "class='insensitive'" ;
438 print "<br/><input type= \" checkbox \" id= \" cache_images \"
439 name= \" cache_images \" $disabled
440 $checked > <label $label_class for= \" cache_images \" >" .
441 __ ( 'Cache images locally' ). "</label>" ;
453 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
454 print "<div class= \" dlgSecCont \" >" ;
456 print "<iframe name= \" icon_upload_iframe \"
457 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
459 print "<form style='display : block' target= \" icon_upload_iframe \"
460 enctype= \" multipart/form-data \" method= \" POST \"
461 action= \" backend.php \" >
462 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
463 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
464 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
465 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
466 <button onclick= \" return uploadFeedIcon(); \"
467 type= \" submit \" >" . __ ( 'Replace' ). "</button>
468 <button onclick= \" return removeFeedIcon( $feed_id ); \"
469 type= \" submit \" >" . __ ( 'Remove' ). "</button>
474 $title = htmlspecialchars ( $title , ENT_QUOTES
);
476 print "<div class='dlgButtons'>
477 <div style= \" float : left \" >
478 <button onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
479 __ ( 'Unsubscribe' ). "</button>
481 <button onclick= \" return feedEditSave() \" >" . __ ( 'Save' ). "</button>
482 <button onclick= \" return feedEditCancel() \" >" . __ ( 'Cancel' ). "</button>
485 print "]]></content></dlg>" ;
490 if ( $subop == "editfeeds" ) {
492 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
494 header ( "Content-Type: text/xml" );
495 print "<dlg id= \" $subop\" >" ;
496 print "<title>" . __ ( 'Multiple Feed Editor' ). "</title>" ;
497 print "<content><![CDATA[" ;
499 print "<form id= \" batch_edit_feed_form \" onsubmit= \" return false \" >" ;
501 print "<input type= \" hidden \" name= \" ids \" value= \" $feed_ids\" >" ;
502 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
503 print "<input type= \" hidden \" name= \" subop \" value= \" batchEditSave \" >" ;
505 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
506 print "<div class= \" dlgSecCont \" >" ;
510 print "<input disabled style= \" font-size : 16px \" size= \" 35 \" onkeypress= \" return filterCR(event, feedEditSave) \"
511 name= \" title \" value= \" $title\" >" ;
513 batch_edit_cbox ( "title" );
519 print __ ( 'URL:' ) . " " ;
520 print "<input disabled size= \" 40 \" onkeypress= \" return filterCR(event, feedEditSave) \"
521 name= \" feed_url \" value= \" $feed_url\" >" ;
523 batch_edit_cbox ( "feed_url" );
527 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
531 print __ ( 'Place in category:' ) . " " ;
533 print_feed_cat_select ( $link , "cat_id" , $cat_id , "disabled" );
535 batch_edit_cbox ( "cat_id" );
541 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
542 print "<div class= \" dlgSecCont \" >" ;
544 /* Update Interval */
546 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
549 batch_edit_cbox ( "update_interval" );
553 print " " . __ ( 'using' ) . " " ;
554 print_select_hash ( "update_method" , $update_method , $update_methods ,
556 batch_edit_cbox ( "update_method" );
560 if ( FORCE_ARTICLE_PURGE
!= 0 ) {
564 print __ ( 'Article purging:' ) . " " ;
566 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
569 batch_edit_cbox ( "purge_interval" );
573 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
574 print "<div class= \" dlgSecCont \" >" ;
576 print __ ( 'Login:' ) . " " ;
577 print "<input disabled size= \" 15 \" onkeypress= \" return filterCR(event, feedEditSave) \"
578 name= \" auth_login \" value= \" $auth_login\" >" ;
580 batch_edit_cbox ( "auth_login" );
582 print " " . __ ( "Password:" ) . " " ;
584 print "<input disabled size= \" 15 \" type= \" password \" name= \" auth_pass \"
585 onkeypress= \" return filterCR(event, feedEditSave) \"
586 value= \" $auth_pass\" >" ;
588 batch_edit_cbox ( "auth_pass" );
591 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
592 print "<div class= \" dlgSecCont \" >" ;
594 print "<div style= \" line-height : 100% \" >" ;
596 print "<input disabled type= \" checkbox \" name= \" private \" id= \" private \"
597 $checked > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
599 print " " ; batch_edit_cbox ( "private" , "private_l" );
601 print "<br/><input disabled type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
602 $checked > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
604 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
606 print "<br/><input disabled type= \" checkbox \" id= \" include_in_digest \"
607 name= \" include_in_digest \"
608 $checked > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
610 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
612 print "<br/><input disabled type= \" checkbox \" id= \" always_display_enclosures \"
613 name= \" always_display_enclosures \"
614 $checked > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
616 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
618 print "<br/><input disabled type= \" checkbox \" id= \" cache_images \"
619 name= \" cache_images \"
620 $checked > <label class='insensitive' id= \" cache_images_l \"
621 for= \" cache_images \" >" .
622 __ ( 'Cache images locally' ). "</label>" ;
625 if ( SIMPLEPIE_CACHE_IMAGES
) {
626 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
634 print "<div class='dlgButtons'>
635 <input type= \" submit \" class= \" button \"
636 onclick= \" return feedsEditSave() \" value= \" " . __ ( 'Save' ). " \" >
637 <input type='submit' class='button'
638 onclick= \" return feedEditCancel() \" value= \" " . __ ( 'Cancel' ). " \" >
641 print "]]></content></dlg>" ;
646 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
648 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
649 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
650 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
651 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
652 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
653 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
654 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
655 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
656 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
657 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
658 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
659 $include_in_digest = checkbox_to_sql_bool (
660 db_escape_string ( $_POST [ "include_in_digest" ]));
661 $cache_images = checkbox_to_sql_bool (
662 db_escape_string ( $_POST [ "cache_images" ]));
663 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
665 $always_display_enclosures = checkbox_to_sql_bool (
666 db_escape_string ( $_POST [ "always_display_enclosures" ]));
668 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
669 if ( $cat_id && $cat_id != 0 ) {
670 $category_qpart = "cat_id = ' $cat_id '," ;
671 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
673 $category_qpart = 'cat_id = NULL,' ;
674 $category_qpart_nocomma = 'cat_id = NULL' ;
677 $category_qpart = "" ;
678 $category_qpart_nocomma = "" ;
681 if ( SIMPLEPIE_CACHE_IMAGES
) {
682 $cache_images_qpart = "cache_images = $cache_images ," ;
684 $cache_images_qpart = "" ;
687 if ( $subop == "editSave" ) {
689 $result = db_query ( $link , "UPDATE ttrss_feeds SET
691 title = ' $feed_title ', feed_url = ' $feed_link ',
692 update_interval = ' $upd_intl ',
693 purge_interval = ' $purge_intl ',
694 auth_login = ' $auth_login ',
695 auth_pass = ' $auth_pass ',
697 rtl_content = $rtl_content ,
699 include_in_digest = $include_in_digest ,
700 always_display_enclosures = $always_display_enclosures ,
701 update_method = ' $update_method '
702 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
704 } else if ( $subop == "batchEditSave" ) {
705 $feed_data = array ();
707 foreach ( array_keys ( $_POST ) as $k ) {
708 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
709 $feed_data [ $k ] = $_POST [ $k ];
713 db_query ( $link , "BEGIN" );
715 foreach ( array_keys ( $feed_data ) as $k ) {
721 $qpart = "title = ' $feed_title '" ;
725 $qpart = "feed_url = ' $feed_link '" ;
728 case "update_interval" :
729 $qpart = "update_interval = ' $upd_intl '" ;
732 case "purge_interval" :
733 $qpart = "purge_interval = ' $purge_intl '" ;
737 $qpart = "auth_login = ' $auth_login '" ;
741 $qpart = "auth_pass = ' $auth_pass '" ;
745 $qpart = "private = ' $private '" ;
748 case "include_in_digest" :
749 $qpart = "include_in_digest = ' $include_in_digest '" ;
752 case "always_display_enclosures" :
753 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
757 $qpart = "cache_images = ' $cache_images '" ;
761 $qpart = "rtl_content = ' $rtl_content '" ;
764 case "update_method" :
765 $qpart = "update_method = ' $update_method '" ;
769 $qpart = $category_qpart_nocomma ;
776 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
777 AND owner_uid = " . $_SESSION [ "uid" ]);
782 db_query ( $link , "COMMIT" );
787 if ( $subop == "remove" ) {
789 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
791 foreach ( $ids as $id ) {
792 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
798 if ( $subop == "clear" ) {
799 $id = db_escape_string ( $_REQUEST [ "id" ]);
800 clear_feed_articles ( $link , $id );
803 if ( $subop == "rescore" ) {
804 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
806 foreach ( $ids as $id ) {
808 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
810 $result = db_query ( $link , "SELECT
811 title, content, link, ref_id, author," .
812 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
814 ttrss_user_entries, ttrss_entries
815 WHERE ref_id = id AND feed_id = ' $id ' AND
816 owner_uid = " . $_SESSION [ 'uid' ]. "
821 while ( $line = db_fetch_assoc ( $result )) {
823 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
825 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
826 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
827 $line [ 'author' ], $tags );
829 $new_score = calculate_article_score ( $article_filters );
831 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
833 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
836 foreach ( array_keys ( $scores ) as $s ) {
838 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
840 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
841 } else if ( $s < - 500 ) {
842 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
844 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
846 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
847 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
852 print __ ( "All done." );
856 if ( $subop == "rescoreAll" ) {
858 $result = db_query ( $link ,
859 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
861 while ( $feed_line = db_fetch_assoc ( $result )) {
863 $id = $feed_line [ "id" ];
865 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
867 $tmp_result = db_query ( $link , "SELECT
868 title, content, link, ref_id, author," .
869 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
871 ttrss_user_entries, ttrss_entries
872 WHERE ref_id = id AND feed_id = ' $id ' AND
873 owner_uid = " . $_SESSION [ 'uid' ]. "
878 while ( $line = db_fetch_assoc ( $tmp_result )) {
880 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
882 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
883 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
884 $line [ 'author' ], $tags );
886 $new_score = calculate_article_score ( $article_filters );
888 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
890 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
893 foreach ( array_keys ( $scores ) as $s ) {
895 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
897 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
899 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
900 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
905 print __ ( "All done." );
909 if ( $subop == "add" ) {
911 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
912 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
913 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
915 /* only read authentication information from POST */
917 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
918 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
920 if ( $p_from != 'tt-rss' ) {
923 <title>Tiny Tiny RSS</title>
924 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
927 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
928 alt= \" Tiny Tiny RSS \" />
929 <h1>Subscribe to feed...</h1>" ;
932 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
936 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
939 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
942 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
946 if ( $p_from != 'tt-rss' ) {
947 $tt_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'tt-rss.php' , $_SERVER [ "REQUEST_URI" ]);
950 $tp_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'prefs.php' , $_SERVER [ "REQUEST_URI" ]);
952 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
953 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
955 $feed_id = db_fetch_result ( $result , 0 , "id" );
960 print "<form method= \" GET \" style='display: inline'
962 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
963 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
964 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
965 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
969 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
970 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
973 print "</body></html>" ;
978 if ( $subop == "categorize" ) {
981 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
983 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
986 $cat_id_qpart = 'NULL' ;
988 $cat_id_qpart = "' $cat_id '" ;
991 db_query ( $link , "BEGIN" );
993 foreach ( $ids as $id ) {
995 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
997 AND owner_uid = " . $_SESSION [ "uid" ]);
1001 db_query ( $link , "COMMIT" );
1005 if ( $subop == "editCats" ) {
1007 $action = $_REQUEST [ "action" ];
1009 if ( $action == "save" ) {
1011 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1012 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1014 db_query ( $link , "BEGIN" );
1016 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1017 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1019 if ( db_num_rows ( $result ) == 1 ) {
1021 $old_title = db_fetch_result ( $result , 0 , "title" );
1023 if ( $cat_title != "" ) {
1024 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1025 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1026 owner_uid = " . $_SESSION [ "uid" ]);
1033 print $_REQUEST [ "value" ];
1036 db_query ( $link , "COMMIT" );
1042 header ( "Content-Type: text/xml" );
1043 print "<dlg id= \" $subop\" >" ;
1044 print "<title>" . __ ( 'Category editor' ). "</title>" ;
1045 print "<content><![CDATA[" ;
1047 if ( $action == "add" ) {
1049 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1051 if (! add_feed_category ( $link , $feed_cat ))
1052 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1056 if ( $action == "remove" ) {
1058 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1060 foreach ( $ids as $id ) {
1061 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1065 print "<div dojoType= \" dijit.Toolbar \" >
1066 <input id= \" fadd_cat \"
1067 onkeypress= \" return filterCR(event, addFeedCat) \"
1069 <button onclick= \" addFeedCat() \" >" .
1070 __ ( 'Create category' ). "</button></div>" ;
1072 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1073 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1078 if ( db_num_rows ( $result ) != 0 ) {
1080 # print __('Select:')."
1081 # <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'all')\">".__('All')."</a>,
1082 # <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'none')\">".__('None')."</a>";
1084 print "<div class= \" prefFeedCatHolder \" >" ;
1086 print "<form id= \" feed_cat_edit_form \" onsubmit= \" return false \" >" ;
1088 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1089 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1093 while ( $line = db_fetch_assoc ( $result )) {
1095 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1097 $cat_id = $line [ "id" ];
1098 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1100 print "<tr class= \"\" $this_row_id >" ;
1102 $edit_title = htmlspecialchars ( $line [ "title" ]);
1104 print "<td width='5%' align='center'><input
1105 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1106 type= \" checkbox \" id= \" FCCHK- $cat_id\" ></td>" ;
1110 # print "<span id=\"FCATT-$cat_id\">" .
1111 # $edit_title . "</span>";
1113 print "<span dojoType= \" dijit.InlineEditBox \"
1114 width= \" 300px \" autoSave= \" false \"
1115 cat-id= \" $cat_id\" >" . $edit_title .
1116 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1120 content: {op: 'pref-feeds', subop: 'editCats',
1123 cid: this.srcNodeRef.getAttribute('cat-id')},
1124 load: function(response) {
1125 elem.attr('value', response);
1143 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1146 print "<div class='dlgButtons'>
1147 <div style='float : left'>
1148 <button onclick= \" return removeSelectedFeedCats() \" >" .
1149 __ ( 'Remove' ). "</button>
1152 print "<button onclick= \" selectTab('feedConfig') \" >" .
1153 __ ( 'Close this window' ). "</button></div>" ;
1155 print "]]></content></dlg>" ;
1163 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1164 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1166 set_pref ( $link , "_PREFS_ACTIVE_TAB" , "feedConfig" );
1168 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1169 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1171 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1173 if ( $num_errors > 0 ) {
1175 $error_button = "<button dojoType= \" dijit.form.Button \"
1176 onclick= \" showFeedsWithErrors \" id= \" errorButton \" >" .
1177 __ ( "Feeds with errors" ) . "</button>" ;
1179 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1180 // __('Some feeds have update errors (click for details)')."</a>");
1183 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1185 if ( array_key_exists ( "search" , $_REQUEST )) {
1186 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1188 $feed_search = $_SESSION [ "prefs_feed_search" ];
1191 print "<div dojoType= \" dijit.Toolbar \" >" ;
1194 print "<div style='float : right'>
1195 <input id=\"feed_search\" size=\"20\" type=\"search\"
1196 onfocus=\"disableHotkeys();\"
1197 onblur=\"enableHotkeys();\"
1198 onchange=\"updateFeedList()\" value=\"$feed_search\">
1199 <button onclick=\"updateFeedList()\">".
1200 __('Search')."</button>
1203 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1204 "<span>" . __ ( 'Select' ). "</span>" ;
1205 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1206 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1207 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1208 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1209 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1210 print "</div></div>" ;
1212 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1213 "<span>" . __ ( 'Feeds' ). "</span>" ;
1214 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1215 print "<div onclick= \" quickAddFeed() \"
1216 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1217 print "<div onclick= \" editSelectedFeed() \"
1218 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1219 print "<div onclick= \" resetFeedOrder() \"
1220 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1221 print "</div></div>" ;
1223 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1224 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1225 "<span>" . __ ( 'Categories' ). "</span>" ;
1226 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1227 print "<div onclick= \" editFeedCats() \"
1228 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1229 print "<div onclick= \" resetCatOrder() \"
1230 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1231 print "</div></div>" ;
1235 print $error_button ;
1237 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1238 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1240 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1242 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1243 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1245 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1247 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1251 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1252 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1258 print "</div>" ; # toolbar
1260 print "<div id= \" feedlistLoading \" >
1261 <img src='images/indicator_tiny.gif'>" .
1262 __ ( "Loading, please wait..." ). "</div>" ;
1264 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1265 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1267 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1268 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1269 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1271 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1272 dndController= \" dijit.tree.dndSource \"
1273 betweenThreshold= \" 5 \"
1274 model= \" feedModel \" openOnClick= \" false \" >
1275 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1276 var id = String(item.id);
1277 var bare_id = id.substr(id.indexOf(':')+1);
1279 if (id.match('FEED:')) {
1280 editFeed(bare_id, event);
1281 } else if (id.match('CAT:')) {
1282 editCat(bare_id, item, event);
1285 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1286 Element.hide( \" feedlistLoading \" );
1290 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1291 <b>Hint:</b> you can drag feeds and categories around.
1294 print "</div>" ; # feeds pane
1296 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1298 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1300 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1304 print "<iframe name= \" upload_iframe \"
1305 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1307 print "<div style='float : left'>" ;
1308 print "<form style='display : block' target= \" upload_iframe \"
1309 enctype= \" multipart/form-data \" method= \" POST \"
1310 action= \" backend.php \" >
1311 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1312 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1313 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1314 <button onclick= \" return opmlImport(); \"
1315 type= \" submit \" >" . __ ( 'Import' ). "</button>
1317 print "</div> " ;
1319 print "<button onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>" ;
1321 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1323 print "<div class= \" insensitive \" >" . __ ( "Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds." ) . "</div>" . "</p>" ;
1325 print "<button onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1326 __ ( 'Display URL' ). "</button> " ;
1329 print "</div>" ; # pane
1331 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1333 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1335 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1339 print "<button onclick='window.navigator.registerContentHandler(" .
1340 " \" application/vnd.mozilla.maybe.feed \" , " .
1341 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1342 __ ( 'Click here to register this site as a feed reader.' ) .
1347 print "</div>" ; # pane
1350 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1352 print "<p>" . __ ( "Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it." ) . "</p>" ;
1354 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1356 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1358 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1360 print "<a href= \" $bm_url\" class='visibleLink'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1362 print "</div>" ; #pane
1364 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1366 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1368 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1369 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1371 print "<button onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1372 __ ( 'Display URL' ). "</button> " ;
1374 print "<button onclick= \" return clearFeedAccessKeys() \" >" .
1375 __ ( 'Clear all generated URLs' ). "</button> " ;
1377 print "</div>" ; #pane
1378 print "</div>" ; #container
1382 function print_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1384 $owner_uid = $_SESSION [ "uid" ];
1387 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1388 UPPER(title) LIKE UPPER('% $search %'))" ;
1394 $result = db_query ( $link , "SELECT feed_url, subscribers FROM
1395 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1396 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1397 AND owner_uid = ' $owner_uid ') $search_qpart
1398 ORDER BY subscribers DESC LIMIT $limit " );
1399 } else if ( $mode == 2 ) {
1400 $result = db_query ( $link , "SELECT *,
1401 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1402 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1404 ttrss_archived_feeds
1406 (SELECT COUNT(*) FROM ttrss_feeds
1407 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1408 owner_uid = ' $owner_uid ') = 0 AND
1409 owner_uid = ' $owner_uid ' $search_qpart
1410 ORDER BY id DESC LIMIT $limit " );
1415 while ( $line = db_fetch_assoc ( $result )) {
1419 $feed_url = $line [ "feed_url" ];
1420 $subscribers = $line [ "subscribers" ];
1422 $det_result = db_query ( $link , "SELECT site_url,title,id
1423 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1425 $details = db_fetch_assoc ( $det_result );
1427 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1429 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1430 $feed_icon = "<img style= \" vertical-align : middle \" class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1431 "/" . $details [ "id" ]. ".ico \" >" ;
1433 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1436 $check_box = "<input onclick='toggleSelectListRow2(this)'
1437 dojoType= \" dijit.form.CheckBox \"
1438 type= \" checkbox \" id= \" FBCHK-" . $details [ "id" ] . " \" >" ;
1440 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1442 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1444 if ( $details [ "site_url" ]) {
1445 $site_url = "<a target= \" _blank \" href= \" " .
1446 htmlspecialchars ( $details [ "site_url" ]). " \" >
1447 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1452 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1453 style='border-width : 0px; vertical-align : middle'
1454 src='images/feed-icon-12x12.png'></a>" ;
1456 print "<li title= \" " . htmlspecialchars ( $details [ "site_url" ]). " \"
1457 id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1458 " $feed_icon $feed_url " . htmlspecialchars ( $details [ "title" ]) .
1459 " <span class='subscribers'>( $subscribers )</span>
1462 } else if ( $mode == 2 ) {
1463 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1464 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1465 $title = htmlspecialchars ( $line [ "title" ]);
1467 $icon_file = ICONS_DIR
. "/" . $line [ "id" ] . ".ico" ;
1469 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1470 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1471 "/" . $line [ "id" ]. ".ico \" >" ;
1473 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1476 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1477 type= \" checkbox \" id= \" FBCHK-" . $line [ "id" ] . " \" >" ;
1479 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1481 if ( $line [ 'articles_archived' ] > 0 ) {
1482 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1483 $archived = " <span class='subscribers'>( $archived )</span>" ;
1488 if ( $line [ "site_url" ]) {
1489 $site_url = "<a target= \" _blank \" href= \" $site_url\" >
1490 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1495 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1496 style='border-width : 0px; vertical-align : middle'
1497 src='images/feed-icon-12x12.png'></a>" ;
1499 print "<li title='" . $line [ 'site_url' ]. "' class=' $class '
1500 id= \" FBROW-" . $line [ "id" ]. " \" >" .
1501 $check_box . " $feed_icon $feed_url " . $title .
1502 $archived . $site_url . "</li>" ;
1510 if ( $feedctr == 0 ) {
1511 print "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;