]>
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 ();
77 $cat [ 'type' ] = 'category' ;
79 $feed_result = db_query ( $link , "SELECT id, title,last_error
81 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
82 " ORDER BY order_id, title" );
84 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
86 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
87 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
88 $feed [ 'name' ] = $feed_line [ 'title' ];
89 $feed [ 'checkbox' ] = false ;
90 $feed [ 'error' ] = $feed_line [ 'last_error' ];
91 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
93 array_push ( $cat [ 'items' ], $feed );
96 array_push ( $root [ 'items' ], $cat );
98 $feed_result = db_query ( $link , "SELECT id, title, last_error
100 WHERE owner_uid = " . $_SESSION [ "uid" ].
101 " ORDER BY order_id, title" );
103 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
105 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
106 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
107 $feed [ 'name' ] = $feed_line [ 'title' ];
108 $feed [ 'checkbox' ] = false ;
109 $feed [ 'error' ] = $feed_line [ 'last_error' ];
110 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
112 array_push ( $root [ 'items' ], $feed );
117 $fl [ 'identifier' ] = 'id' ;
118 $fl [ 'label' ] = 'name' ;
119 $fl [ 'items' ] = array ( $root );
121 print json_encode ( $fl );
125 if ( $subop == "catsortreset" ) {
126 db_query ( $link , "UPDATE ttrss_feed_categories
127 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
131 if ( $subop == "feedsortreset" ) {
132 db_query ( $link , "UPDATE ttrss_feeds
133 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
137 if ( $subop == "savefeedorder" ) {
138 # if ($_POST['payload']) {
139 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
140 # $data = json_decode($_POST['payload'], true);
142 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
145 $data = json_decode ( $_POST [ 'payload' ], true );
147 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
152 foreach ( $data [ 'items' ] as $item ) {
154 if ( $item [ 'id' ] != 'root' ) {
155 if ( is_array ( $item [ 'items' ])) {
156 if ( isset ( $item [ 'items' ][ '_reference' ])) {
157 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
159 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
165 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
166 $id = $item [ '_reference' ];
167 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
172 db_query ( $link , "UPDATE ttrss_feed_categories
173 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
174 owner_uid = " . $_SESSION [ "uid" ]);
179 if ( is_array ( $data_map [ $id ])) {
180 foreach ( $data_map [ $id ] as $feed ) {
181 $id = $feed [ '_reference' ];
182 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
185 $cat_query = "cat_id = ' $bare_id '" ;
187 $cat_query = "cat_id = NULL" ;
189 db_query ( $link , "UPDATE ttrss_feeds
190 SET order_id = ' $feed_order_id ',
192 WHERE id = ' $feed_id ' AND
193 owner_uid = " . $_SESSION [ "uid" ]);
204 if ( $subop == "removeicon" ) {
205 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
207 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
208 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
210 if ( db_num_rows ( $result ) != 0 ) {
211 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
217 if ( $subop == "uploadicon" ) {
218 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
219 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
221 if ( is_file ( $icon_file ) && $feed_id ) {
222 if ( filesize ( $icon_file ) < 20000 ) {
224 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
225 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
227 if ( db_num_rows ( $result ) != 0 ) {
228 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
229 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
241 print "<script type= \" text/javascript \" >" ;
242 print "parent.uploadIconHandler( $rc );" ;
247 if ( $subop == "editfeed" ) {
249 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
251 $result = db_query ( $link ,
252 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
253 owner_uid = " . $_SESSION [ "uid" ]);
255 $title = htmlspecialchars ( db_fetch_result ( $result ,
258 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
259 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
260 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
262 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
263 print "<div class= \" dlgSecCont \" >" ;
267 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
268 placeHolder= \" " . __ ( "Feed Title" ). " \"
269 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
273 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
274 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
279 print __ ( 'URL:' ) . " " ;
280 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
281 placeHolder= \" " . __ ( "Feed URL" ). " \"
282 regExp='^(http|https)://.*' style= \" width : 20em \"
283 name= \" feed_url \" value= \" $feed_url\" >" ;
287 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
289 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
293 print __ ( 'Place in category:' ) . " " ;
295 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
296 'dojoType="dijit.form.Select"' );
301 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
302 print "<div class= \" dlgSecCont \" >" ;
304 /* Update Interval */
306 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
308 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
309 'dojoType="dijit.form.Select"' );
313 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
314 'dojoType="dijit.form.Select"' );
316 print " " . __ ( 'using' ) . " " ;
317 print_select_hash ( "update_method" , $update_method , $update_methods ,
318 'dojoType="dijit.form.Select"' );
320 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
322 if ( FORCE_ARTICLE_PURGE
== 0 ) {
328 print __ ( 'Article purging:' ) . " " ;
330 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
331 'dojoType="dijit.form.Select"' );
334 print "<input type='hidden' name='purge_interval' value=' $purge_interval '>" ;
339 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
340 print "<div class= \" dlgSecCont \" >" ;
342 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
346 # print "<tr><td>" . __('Login:') . "</td><td>";
348 print "<input dojoType= \" dijit.form.TextBox \"
349 placeHolder= \" " . __ ( "Login" ). " \"
350 name= \" auth_login \" value= \" $auth_login\" ><br/>" ;
352 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
354 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
356 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
357 placeHolder= \" " . __ ( "Password" ). " \"
358 value= \" $auth_pass\" >" ;
360 # print "</td></tr></table>";
363 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
364 print "<div class= \" dlgSecCont \" >" ;
366 # print "<div style=\"line-height : 100%\">";
368 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
371 $checked = "checked= \" 1 \" " ;
376 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
377 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
379 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
382 $checked = "checked= \" 1 \" " ;
387 print "<br/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
388 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
390 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
392 if ( $include_in_digest ) {
393 $checked = "checked= \" 1 \" " ;
398 print "<br/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
399 name= \" include_in_digest \"
400 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
403 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
405 if ( $always_display_enclosures ) {
406 $checked = "checked" ;
411 print "<br/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
412 name= \" always_display_enclosures \"
413 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
416 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
419 $checked = "checked= \" 1 \" " ;
424 print "<br/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
425 name= \" cache_images \"
426 $checked > <label for= \" cache_images \" >" .
427 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
437 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
438 print "<div class= \" dlgSecCont \" >" ;
440 print "<iframe name= \" icon_upload_iframe \"
441 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
443 print "<form style='display : block' target= \" icon_upload_iframe \"
444 enctype= \" multipart/form-data \" method= \" POST \"
445 action= \" backend.php \" >
446 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
447 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
448 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
449 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
450 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
451 type= \" submit \" >" . __ ( 'Replace' ). "</button>
452 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
453 type= \" submit \" >" . __ ( 'Remove' ). "</button>
458 $title = htmlspecialchars ( $title , ENT_QUOTES
);
460 print "<div class='dlgButtons'>
461 <div style= \" float : left \" >
462 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
463 __ ( 'Unsubscribe' ). "</button>
465 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
466 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
472 if ( $subop == "editfeeds" ) {
474 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
476 header ( "Content-Type: text/xml" );
477 print "<dlg id= \" $subop\" >" ;
478 print "<title>" . __ ( 'Multiple Feed Editor' ). "</title>" ;
479 print "<content><![CDATA[" ;
481 print "<form id= \" batch_edit_feed_form \" onsubmit= \" return false \" >" ;
483 print "<input type= \" hidden \" name= \" ids \" value= \" $feed_ids\" >" ;
484 print "<input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >" ;
485 print "<input type= \" hidden \" name= \" subop \" value= \" batchEditSave \" >" ;
487 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
488 print "<div class= \" dlgSecCont \" >" ;
492 print "<input disabled style= \" font-size : 16px \" size= \" 35 \" onkeypress= \" return filterCR(event, feedEditSave) \"
493 name= \" title \" value= \" $title\" >" ;
495 batch_edit_cbox ( "title" );
501 print __ ( 'URL:' ) . " " ;
502 print "<input disabled size= \" 40 \" onkeypress= \" return filterCR(event, feedEditSave) \"
503 name= \" feed_url \" value= \" $feed_url\" >" ;
505 batch_edit_cbox ( "feed_url" );
509 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
513 print __ ( 'Place in category:' ) . " " ;
515 print_feed_cat_select ( $link , "cat_id" , $cat_id , "disabled" );
517 batch_edit_cbox ( "cat_id" );
523 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
524 print "<div class= \" dlgSecCont \" >" ;
526 /* Update Interval */
528 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
531 batch_edit_cbox ( "update_interval" );
535 print " " . __ ( 'using' ) . " " ;
536 print_select_hash ( "update_method" , $update_method , $update_methods ,
538 batch_edit_cbox ( "update_method" );
542 if ( FORCE_ARTICLE_PURGE
!= 0 ) {
546 print __ ( 'Article purging:' ) . " " ;
548 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
551 batch_edit_cbox ( "purge_interval" );
555 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
556 print "<div class= \" dlgSecCont \" >" ;
558 print __ ( 'Login:' ) . " " ;
559 print "<input disabled size= \" 15 \" onkeypress= \" return filterCR(event, feedEditSave) \"
560 name= \" auth_login \" value= \" $auth_login\" >" ;
562 batch_edit_cbox ( "auth_login" );
564 print " " . __ ( "Password:" ) . " " ;
566 print "<input disabled size= \" 15 \" type= \" password \" name= \" auth_pass \"
567 onkeypress= \" return filterCR(event, feedEditSave) \"
568 value= \" $auth_pass\" >" ;
570 batch_edit_cbox ( "auth_pass" );
573 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
574 print "<div class= \" dlgSecCont \" >" ;
576 print "<div style= \" line-height : 100% \" >" ;
578 print "<input disabled type= \" checkbox \" name= \" private \" id= \" private \"
579 $checked > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
581 print " " ; batch_edit_cbox ( "private" , "private_l" );
583 print "<br/><input disabled type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
584 $checked > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
586 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
588 print "<br/><input disabled type= \" checkbox \" id= \" include_in_digest \"
589 name= \" include_in_digest \"
590 $checked > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
592 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
594 print "<br/><input disabled type= \" checkbox \" id= \" always_display_enclosures \"
595 name= \" always_display_enclosures \"
596 $checked > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
598 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
600 print "<br/><input disabled type= \" checkbox \" id= \" cache_images \"
601 name= \" cache_images \"
602 $checked > <label class='insensitive' id= \" cache_images_l \"
603 for= \" cache_images \" >" .
604 __ ( 'Cache images locally' ). "</label>" ;
607 if ( SIMPLEPIE_CACHE_IMAGES
) {
608 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
616 print "<div class='dlgButtons'>
617 <input type= \" submit \" class= \" button \"
618 onclick= \" return feedsEditSave() \" value= \" " . __ ( 'Save' ). " \" >
619 <input type='submit' class='button'
620 onclick= \" return closeInfoBox() \" value= \" " . __ ( 'Cancel' ). " \" >
623 print "]]></content></dlg>" ;
628 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
630 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
631 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
632 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
633 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
634 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
635 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
636 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
637 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
638 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
639 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
640 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
641 $include_in_digest = checkbox_to_sql_bool (
642 db_escape_string ( $_POST [ "include_in_digest" ]));
643 $cache_images = checkbox_to_sql_bool (
644 db_escape_string ( $_POST [ "cache_images" ]));
645 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
647 $always_display_enclosures = checkbox_to_sql_bool (
648 db_escape_string ( $_POST [ "always_display_enclosures" ]));
650 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
651 if ( $cat_id && $cat_id != 0 ) {
652 $category_qpart = "cat_id = ' $cat_id '," ;
653 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
655 $category_qpart = 'cat_id = NULL,' ;
656 $category_qpart_nocomma = 'cat_id = NULL' ;
659 $category_qpart = "" ;
660 $category_qpart_nocomma = "" ;
663 if ( SIMPLEPIE_CACHE_IMAGES
) {
664 $cache_images_qpart = "cache_images = $cache_images ," ;
666 $cache_images_qpart = "" ;
669 if ( $subop == "editSave" ) {
671 $result = db_query ( $link , "UPDATE ttrss_feeds SET
673 title = ' $feed_title ', feed_url = ' $feed_link ',
674 update_interval = ' $upd_intl ',
675 purge_interval = ' $purge_intl ',
676 auth_login = ' $auth_login ',
677 auth_pass = ' $auth_pass ',
679 rtl_content = $rtl_content ,
681 include_in_digest = $include_in_digest ,
682 always_display_enclosures = $always_display_enclosures ,
683 update_method = ' $update_method '
684 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
686 } else if ( $subop == "batchEditSave" ) {
687 $feed_data = array ();
689 foreach ( array_keys ( $_POST ) as $k ) {
690 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
691 $feed_data [ $k ] = $_POST [ $k ];
695 db_query ( $link , "BEGIN" );
697 foreach ( array_keys ( $feed_data ) as $k ) {
703 $qpart = "title = ' $feed_title '" ;
707 $qpart = "feed_url = ' $feed_link '" ;
710 case "update_interval" :
711 $qpart = "update_interval = ' $upd_intl '" ;
714 case "purge_interval" :
715 $qpart = "purge_interval = ' $purge_intl '" ;
719 $qpart = "auth_login = ' $auth_login '" ;
723 $qpart = "auth_pass = ' $auth_pass '" ;
727 $qpart = "private = ' $private '" ;
730 case "include_in_digest" :
731 $qpart = "include_in_digest = ' $include_in_digest '" ;
734 case "always_display_enclosures" :
735 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
739 $qpart = "cache_images = ' $cache_images '" ;
743 $qpart = "rtl_content = ' $rtl_content '" ;
746 case "update_method" :
747 $qpart = "update_method = ' $update_method '" ;
751 $qpart = $category_qpart_nocomma ;
758 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
759 AND owner_uid = " . $_SESSION [ "uid" ]);
764 db_query ( $link , "COMMIT" );
769 if ( $subop == "remove" ) {
771 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
773 foreach ( $ids as $id ) {
774 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
780 if ( $subop == "clear" ) {
781 $id = db_escape_string ( $_REQUEST [ "id" ]);
782 clear_feed_articles ( $link , $id );
785 if ( $subop == "rescore" ) {
786 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
788 foreach ( $ids as $id ) {
790 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
792 $result = db_query ( $link , "SELECT
793 title, content, link, ref_id, author," .
794 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
796 ttrss_user_entries, ttrss_entries
797 WHERE ref_id = id AND feed_id = ' $id ' AND
798 owner_uid = " . $_SESSION [ 'uid' ]. "
803 while ( $line = db_fetch_assoc ( $result )) {
805 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
807 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
808 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
809 $line [ 'author' ], $tags );
811 $new_score = calculate_article_score ( $article_filters );
813 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
815 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
818 foreach ( array_keys ( $scores ) as $s ) {
820 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
822 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
823 } else if ( $s < - 500 ) {
824 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
826 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
828 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
829 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
834 print __ ( "All done." );
838 if ( $subop == "rescoreAll" ) {
840 $result = db_query ( $link ,
841 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
843 while ( $feed_line = db_fetch_assoc ( $result )) {
845 $id = $feed_line [ "id" ];
847 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
849 $tmp_result = db_query ( $link , "SELECT
850 title, content, link, ref_id, author," .
851 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
853 ttrss_user_entries, ttrss_entries
854 WHERE ref_id = id AND feed_id = ' $id ' AND
855 owner_uid = " . $_SESSION [ 'uid' ]. "
860 while ( $line = db_fetch_assoc ( $tmp_result )) {
862 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
864 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
865 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
866 $line [ 'author' ], $tags );
868 $new_score = calculate_article_score ( $article_filters );
870 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
872 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
875 foreach ( array_keys ( $scores ) as $s ) {
877 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
879 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
881 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
882 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
887 print __ ( "All done." );
891 if ( $subop == "add" ) {
893 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
894 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
895 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
897 /* only read authentication information from POST */
899 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
900 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
902 if ( $p_from != 'tt-rss' ) {
905 <title>Tiny Tiny RSS</title>
906 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
909 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
910 alt= \" Tiny Tiny RSS \" />
911 <h1>Subscribe to feed...</h1>" ;
914 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
918 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
921 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
924 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
928 if ( $p_from != 'tt-rss' ) {
929 $tt_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'tt-rss.php' , $_SERVER [ "REQUEST_URI" ]);
932 $tp_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'prefs.php' , $_SERVER [ "REQUEST_URI" ]);
934 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
935 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
937 $feed_id = db_fetch_result ( $result , 0 , "id" );
942 print "<form method= \" GET \" style='display: inline'
944 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
945 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
946 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
947 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
951 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
952 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
955 print "</body></html>" ;
960 if ( $subop == "categorize" ) {
963 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
965 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
968 $cat_id_qpart = 'NULL' ;
970 $cat_id_qpart = "' $cat_id '" ;
973 db_query ( $link , "BEGIN" );
975 foreach ( $ids as $id ) {
977 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
979 AND owner_uid = " . $_SESSION [ "uid" ]);
983 db_query ( $link , "COMMIT" );
987 if ( $subop == "editCats" ) {
989 $action = $_REQUEST [ "action" ];
991 if ( $action == "save" ) {
993 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
994 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
996 db_query ( $link , "BEGIN" );
998 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
999 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1001 if ( db_num_rows ( $result ) == 1 ) {
1003 $old_title = db_fetch_result ( $result , 0 , "title" );
1005 if ( $cat_title != "" ) {
1006 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1007 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1008 owner_uid = " . $_SESSION [ "uid" ]);
1015 print $_REQUEST [ "value" ];
1018 db_query ( $link , "COMMIT" );
1024 header ( "Content-Type: text/xml" );
1025 print "<dlg id= \" $subop\" >" ;
1026 print "<title>" . __ ( 'Category editor' ). "</title>" ;
1027 print "<content><![CDATA[" ;
1029 if ( $action == "add" ) {
1031 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1033 if (! add_feed_category ( $link , $feed_cat ))
1034 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1038 if ( $action == "remove" ) {
1040 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1042 foreach ( $ids as $id ) {
1043 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1047 print "<div dojoType= \" dijit.Toolbar \" >
1048 <input id= \" fadd_cat \"
1049 onkeypress= \" return filterCR(event, addFeedCat) \"
1051 <button onclick= \" addFeedCat() \" >" .
1052 __ ( 'Create category' ). "</button></div>" ;
1054 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1055 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1060 if ( db_num_rows ( $result ) != 0 ) {
1062 # print __('Select:')."
1063 # <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'all')\">".__('All')."</a>,
1064 # <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'none')\">".__('None')."</a>";
1066 print "<div class= \" prefFeedCatHolder \" >" ;
1068 print "<form id= \" feed_cat_edit_form \" onsubmit= \" return false \" >" ;
1070 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1071 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1075 while ( $line = db_fetch_assoc ( $result )) {
1077 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1079 $cat_id = $line [ "id" ];
1080 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1082 print "<tr class= \"\" $this_row_id >" ;
1084 $edit_title = htmlspecialchars ( $line [ "title" ]);
1086 print "<td width='5%' align='center'><input
1087 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1088 type= \" checkbox \" id= \" FCCHK- $cat_id\" ></td>" ;
1092 # print "<span id=\"FCATT-$cat_id\">" .
1093 # $edit_title . "</span>";
1095 print "<span dojoType= \" dijit.InlineEditBox \"
1096 width= \" 300px \" autoSave= \" false \"
1097 cat-id= \" $cat_id\" >" . $edit_title .
1098 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1102 content: {op: 'pref-feeds', subop: 'editCats',
1105 cid: this.srcNodeRef.getAttribute('cat-id')},
1106 load: function(response) {
1107 elem.attr('value', response);
1125 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1128 print "<div class='dlgButtons'>
1129 <div style='float : left'>
1130 <button onclick= \" return removeSelectedFeedCats() \" >" .
1131 __ ( 'Remove' ). "</button>
1134 print "<button onclick= \" selectTab('feedConfig') \" >" .
1135 __ ( 'Close this window' ). "</button></div>" ;
1137 print "]]></content></dlg>" ;
1145 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1146 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1148 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1149 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1151 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1153 if ( $num_errors > 0 ) {
1155 $error_button = "<button dojoType= \" dijit.form.Button \"
1156 onclick= \" showFeedsWithErrors \" id= \" errorButton \" >" .
1157 __ ( "Feeds with errors" ) . "</button>" ;
1159 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1160 // __('Some feeds have update errors (click for details)')."</a>");
1163 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1165 if ( array_key_exists ( "search" , $_REQUEST )) {
1166 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1168 $feed_search = $_SESSION [ "prefs_feed_search" ];
1171 print "<div dojoType= \" dijit.Toolbar \" >" ;
1174 print "<div style='float : right'>
1175 <input id=\"feed_search\" size=\"20\" type=\"search\"
1176 onfocus=\"disableHotkeys();\"
1177 onblur=\"enableHotkeys();\"
1178 onchange=\"updateFeedList()\" value=\"$feed_search\">
1179 <button onclick=\"updateFeedList()\">".
1180 __('Search')."</button>
1183 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1184 "<span>" . __ ( 'Select' ). "</span>" ;
1185 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1186 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1187 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1188 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1189 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1190 print "</div></div>" ;
1192 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1193 "<span>" . __ ( 'Feeds' ). "</span>" ;
1194 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1195 print "<div onclick= \" quickAddFeed() \"
1196 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1197 print "<div onclick= \" editSelectedFeed() \"
1198 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1199 print "<div onclick= \" resetFeedOrder() \"
1200 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1201 print "</div></div>" ;
1203 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1204 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1205 "<span>" . __ ( 'Categories' ). "</span>" ;
1206 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1207 print "<div onclick= \" editFeedCats() \"
1208 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1209 print "<div onclick= \" resetCatOrder() \"
1210 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1211 print "</div></div>" ;
1215 print $error_button ;
1217 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1218 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1220 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1222 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1223 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1225 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1227 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1231 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1232 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1238 print "</div>" ; # toolbar
1240 print "<div id= \" feedlistLoading \" >
1241 <img src='images/indicator_tiny.gif'>" .
1242 __ ( "Loading, please wait..." ). "</div>" ;
1244 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1245 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1247 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1248 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1249 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1251 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1252 dndController= \" dijit.tree.dndSource \"
1253 betweenThreshold= \" 5 \"
1254 model= \" feedModel \" openOnClick= \" false \" >
1255 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1256 var id = String(item.id);
1257 var bare_id = id.substr(id.indexOf(':')+1);
1259 if (id.match('FEED:')) {
1260 editFeed(bare_id, event);
1261 } else if (id.match('CAT:')) {
1262 editCat(bare_id, item, event);
1265 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1266 Element.hide( \" feedlistLoading \" );
1270 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1271 <b>Hint:</b> you can drag feeds and categories around.
1274 print "</div>" ; # feeds pane
1276 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1278 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1280 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1284 print "<iframe name= \" upload_iframe \"
1285 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1287 print "<div style='float : left'>" ;
1288 print "<form style='display : block' target= \" upload_iframe \"
1289 enctype= \" multipart/form-data \" method= \" POST \"
1290 action= \" backend.php \" >
1291 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1292 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1293 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1294 <button onclick= \" return opmlImport(); \"
1295 type= \" submit \" >" . __ ( 'Import' ). "</button>
1297 print "</div> " ;
1299 print "<button onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>" ;
1301 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1303 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>" ;
1305 print "<button onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1306 __ ( 'Display URL' ). "</button> " ;
1309 print "</div>" ; # pane
1311 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1313 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1315 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1319 print "<button onclick='window.navigator.registerContentHandler(" .
1320 " \" application/vnd.mozilla.maybe.feed \" , " .
1321 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1322 __ ( 'Click here to register this site as a feed reader.' ) .
1327 print "</div>" ; # pane
1330 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1332 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>" ;
1334 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1336 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1338 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1340 print "<a href= \" $bm_url\" class='visibleLink'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1342 print "</div>" ; #pane
1344 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1346 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1348 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1349 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1351 print "<button onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1352 __ ( 'Display URL' ). "</button> " ;
1354 print "<button onclick= \" return clearFeedAccessKeys() \" >" .
1355 __ ( 'Clear all generated URLs' ). "</button> " ;
1357 print "</div>" ; #pane
1358 print "</div>" ; #container
1362 function print_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1364 $owner_uid = $_SESSION [ "uid" ];
1367 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1368 UPPER(title) LIKE UPPER('% $search %'))" ;
1374 $result = db_query ( $link , "SELECT feed_url, subscribers FROM
1375 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1376 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1377 AND owner_uid = ' $owner_uid ') $search_qpart
1378 ORDER BY subscribers DESC LIMIT $limit " );
1379 } else if ( $mode == 2 ) {
1380 $result = db_query ( $link , "SELECT *,
1381 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1382 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1384 ttrss_archived_feeds
1386 (SELECT COUNT(*) FROM ttrss_feeds
1387 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1388 owner_uid = ' $owner_uid ') = 0 AND
1389 owner_uid = ' $owner_uid ' $search_qpart
1390 ORDER BY id DESC LIMIT $limit " );
1395 while ( $line = db_fetch_assoc ( $result )) {
1399 $feed_url = $line [ "feed_url" ];
1400 $subscribers = $line [ "subscribers" ];
1402 $det_result = db_query ( $link , "SELECT site_url,title,id
1403 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1405 $details = db_fetch_assoc ( $det_result );
1407 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1409 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1410 $feed_icon = "<img style= \" vertical-align : middle \" class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1411 "/" . $details [ "id" ]. ".ico \" >" ;
1413 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1416 $check_box = "<input onclick='toggleSelectListRow2(this)'
1417 dojoType= \" dijit.form.CheckBox \"
1418 type= \" checkbox \" \" >" ;
1420 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1422 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1424 if ( $details [ "site_url" ]) {
1425 $site_url = "<a target= \" _blank \" href= \" " .
1426 htmlspecialchars ( $details [ "site_url" ]). " \" >
1427 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1432 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1433 style='border-width : 0px; vertical-align : middle'
1434 src='images/feed-icon-12x12.png'></a>" ;
1436 print "<li title= \" " . htmlspecialchars ( $details [ "site_url" ]). " \"
1437 id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1438 " $feed_icon $feed_url " . htmlspecialchars ( $details [ "title" ]) .
1439 " <span class='subscribers'>( $subscribers )</span>
1442 } else if ( $mode == 2 ) {
1443 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1444 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1445 $title = htmlspecialchars ( $line [ "title" ]);
1447 $icon_file = ICONS_DIR
. "/" . $line [ "id" ] . ".ico" ;
1449 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1450 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1451 "/" . $line [ "id" ]. ".ico \" >" ;
1453 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1456 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1457 type= \" checkbox \" >" ;
1459 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1461 if ( $line [ 'articles_archived' ] > 0 ) {
1462 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1463 $archived = " <span class='subscribers'>( $archived )</span>" ;
1468 if ( $line [ "site_url" ]) {
1469 $site_url = "<a target= \" _blank \" href= \" $site_url\" >
1470 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1475 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1476 style='border-width : 0px; vertical-align : middle'
1477 src='images/feed-icon-12x12.png'></a>" ;
1479 print "<li title='" . $line [ 'site_url' ]. "' class=' $class '
1480 id= \" FBROW-" . $line [ "id" ]. " \" >" .
1481 $check_box . " $feed_icon $feed_url " . $title .
1482 $archived . $site_url . "</li>" ;
1490 if ( $feedctr == 0 ) {
1491 print "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;