]>
git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
2c4503592e22e5fabddeea8f01cf804287373ca6
3 function batch_edit_cbox ( $elem , $label = false ) {
4 print "<input type= \" checkbox \" title= \" " . __ ( "Check to enable field" ). " \"
5 onchange= \" dijit.byId('feedEditDlg').toggleField(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\" ><hr/>" ;
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 "<hr/><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 "<hr/><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 "<hr/><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 "<hr/><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>" ;
435 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
436 print "<div class= \" dlgSecCont \" >" ;
438 print "<iframe name= \" icon_upload_iframe \"
439 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
441 print "<form style='display : block' target= \" icon_upload_iframe \"
442 enctype= \" multipart/form-data \" method= \" POST \"
443 action= \" backend.php \" >
444 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
445 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
446 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
447 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
448 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
449 type= \" submit \" >" . __ ( 'Replace' ). "</button>
450 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
451 type= \" submit \" >" . __ ( 'Remove' ). "</button>
456 $title = htmlspecialchars ( $title , ENT_QUOTES
);
458 print "<div class='dlgButtons'>
459 <div style= \" float : left \" >
460 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
461 __ ( 'Unsubscribe' ). "</button>
463 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
464 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
470 if ( $subop == "editfeeds" ) {
472 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
474 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
475 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
476 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
478 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
479 print "<div class= \" dlgSecCont \" >" ;
483 print "<input dojoType= \" dijit.form.ValidationTextBox \"
484 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
485 name= \" title \" value= \" $title\" >" ;
487 batch_edit_cbox ( "title" );
493 print __ ( 'URL:' ) . " " ;
494 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
495 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
496 name= \" feed_url \" value= \" $feed_url\" >" ;
498 batch_edit_cbox ( "feed_url" );
502 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
506 print __ ( 'Place in category:' ) . " " ;
508 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
509 'disabled="1" dojoType="dijit.form.Select"' );
511 batch_edit_cbox ( "cat_id" );
517 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
518 print "<div class= \" dlgSecCont \" >" ;
520 /* Update Interval */
522 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
523 'disabled="1" dojoType="dijit.form.Select"' );
525 batch_edit_cbox ( "update_interval" );
529 print " " . __ ( 'using' ) . " " ;
530 print_select_hash ( "update_method" , $update_method , $update_methods ,
531 'disabled="1" dojoType="dijit.form.Select"' );
532 batch_edit_cbox ( "update_method" );
536 if ( FORCE_ARTICLE_PURGE
== 0 ) {
540 print __ ( 'Article purging:' ) . " " ;
542 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
543 'disabled="1" dojoType="dijit.form.Select"' );
545 batch_edit_cbox ( "purge_interval" );
549 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
550 print "<div class= \" dlgSecCont \" >" ;
552 print "<input dojoType= \" dijit.form.TextBox \"
553 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
554 name= \" auth_login \" value= \" $auth_login\" >" ;
556 batch_edit_cbox ( "auth_login" );
558 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
559 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
560 value= \" $auth_pass\" >" ;
562 batch_edit_cbox ( "auth_pass" );
565 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
566 print "<div class= \" dlgSecCont \" >" ;
568 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
569 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
571 print " " ; batch_edit_cbox ( "private" , "private_l" );
573 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
574 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
576 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
578 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
579 name= \" include_in_digest \"
580 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
582 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
584 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
585 name= \" always_display_enclosures \"
586 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
588 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
590 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
591 name= \" cache_images \"
592 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
593 for= \" cache_images \" >" .
594 __ ( 'Cache images locally' ). "</label>" ;
597 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
601 print "<div class='dlgButtons'>
602 <button dojoType= \" dijit.form.Button \"
603 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
604 __ ( 'Save' ). "</button>
605 <button dojoType= \" dijit.form.Button \"
606 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
607 __ ( 'Cancel' ). "</button>
613 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
615 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
616 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
617 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
618 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
619 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
620 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
621 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
622 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
623 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
624 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
625 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
626 $include_in_digest = checkbox_to_sql_bool (
627 db_escape_string ( $_POST [ "include_in_digest" ]));
628 $cache_images = checkbox_to_sql_bool (
629 db_escape_string ( $_POST [ "cache_images" ]));
630 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
632 $always_display_enclosures = checkbox_to_sql_bool (
633 db_escape_string ( $_POST [ "always_display_enclosures" ]));
635 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
636 if ( $cat_id && $cat_id != 0 ) {
637 $category_qpart = "cat_id = ' $cat_id '," ;
638 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
640 $category_qpart = 'cat_id = NULL,' ;
641 $category_qpart_nocomma = 'cat_id = NULL' ;
644 $category_qpart = "" ;
645 $category_qpart_nocomma = "" ;
648 if ( SIMPLEPIE_CACHE_IMAGES
) {
649 $cache_images_qpart = "cache_images = $cache_images ," ;
651 $cache_images_qpart = "" ;
654 if ( $subop == "editSave" ) {
656 $result = db_query ( $link , "UPDATE ttrss_feeds SET
658 title = ' $feed_title ', feed_url = ' $feed_link ',
659 update_interval = ' $upd_intl ',
660 purge_interval = ' $purge_intl ',
661 auth_login = ' $auth_login ',
662 auth_pass = ' $auth_pass ',
664 rtl_content = $rtl_content ,
666 include_in_digest = $include_in_digest ,
667 always_display_enclosures = $always_display_enclosures ,
668 update_method = ' $update_method '
669 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
671 } else if ( $subop == "batchEditSave" ) {
672 $feed_data = array ();
674 foreach ( array_keys ( $_POST ) as $k ) {
675 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
676 $feed_data [ $k ] = $_POST [ $k ];
680 db_query ( $link , "BEGIN" );
682 foreach ( array_keys ( $feed_data ) as $k ) {
688 $qpart = "title = ' $feed_title '" ;
692 $qpart = "feed_url = ' $feed_link '" ;
695 case "update_interval" :
696 $qpart = "update_interval = ' $upd_intl '" ;
699 case "purge_interval" :
700 $qpart = "purge_interval = ' $purge_intl '" ;
704 $qpart = "auth_login = ' $auth_login '" ;
708 $qpart = "auth_pass = ' $auth_pass '" ;
712 $qpart = "private = ' $private '" ;
715 case "include_in_digest" :
716 $qpart = "include_in_digest = ' $include_in_digest '" ;
719 case "always_display_enclosures" :
720 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
724 $qpart = "cache_images = ' $cache_images '" ;
728 $qpart = "rtl_content = ' $rtl_content '" ;
731 case "update_method" :
732 $qpart = "update_method = ' $update_method '" ;
736 $qpart = $category_qpart_nocomma ;
743 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
744 AND owner_uid = " . $_SESSION [ "uid" ]);
749 db_query ( $link , "COMMIT" );
754 if ( $subop == "remove" ) {
756 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
758 foreach ( $ids as $id ) {
759 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
765 if ( $subop == "clear" ) {
766 $id = db_escape_string ( $_REQUEST [ "id" ]);
767 clear_feed_articles ( $link , $id );
770 if ( $subop == "rescore" ) {
771 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
773 foreach ( $ids as $id ) {
775 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
777 $result = db_query ( $link , "SELECT
778 title, content, link, ref_id, author," .
779 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
781 ttrss_user_entries, ttrss_entries
782 WHERE ref_id = id AND feed_id = ' $id ' AND
783 owner_uid = " . $_SESSION [ 'uid' ]. "
788 while ( $line = db_fetch_assoc ( $result )) {
790 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
792 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
793 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
794 $line [ 'author' ], $tags );
796 $new_score = calculate_article_score ( $article_filters );
798 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
800 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
803 foreach ( array_keys ( $scores ) as $s ) {
805 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
807 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
808 } else if ( $s < - 500 ) {
809 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
811 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
813 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
814 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
819 print __ ( "All done." );
823 if ( $subop == "rescoreAll" ) {
825 $result = db_query ( $link ,
826 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
828 while ( $feed_line = db_fetch_assoc ( $result )) {
830 $id = $feed_line [ "id" ];
832 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
834 $tmp_result = db_query ( $link , "SELECT
835 title, content, link, ref_id, author," .
836 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
838 ttrss_user_entries, ttrss_entries
839 WHERE ref_id = id AND feed_id = ' $id ' AND
840 owner_uid = " . $_SESSION [ 'uid' ]. "
845 while ( $line = db_fetch_assoc ( $tmp_result )) {
847 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
849 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
850 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
851 $line [ 'author' ], $tags );
853 $new_score = calculate_article_score ( $article_filters );
855 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
857 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
860 foreach ( array_keys ( $scores ) as $s ) {
862 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
864 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
866 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
867 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
872 print __ ( "All done." );
876 if ( $subop == "add" ) {
878 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
879 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
880 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
882 /* only read authentication information from POST */
884 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
885 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
887 if ( $p_from != 'tt-rss' ) {
890 <title>Tiny Tiny RSS</title>
891 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
894 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
895 alt= \" Tiny Tiny RSS \" />
896 <h1>Subscribe to feed...</h1>" ;
899 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
903 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
906 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
909 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
913 if ( $p_from != 'tt-rss' ) {
914 $tt_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'tt-rss.php' , $_SERVER [ "REQUEST_URI" ]);
917 $tp_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'prefs.php' , $_SERVER [ "REQUEST_URI" ]);
919 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
920 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
922 $feed_id = db_fetch_result ( $result , 0 , "id" );
927 print "<form method= \" GET \" style='display: inline'
929 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
930 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
931 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
932 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
936 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
937 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
940 print "</body></html>" ;
945 if ( $subop == "categorize" ) {
948 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
950 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
953 $cat_id_qpart = 'NULL' ;
955 $cat_id_qpart = "' $cat_id '" ;
958 db_query ( $link , "BEGIN" );
960 foreach ( $ids as $id ) {
962 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
964 AND owner_uid = " . $_SESSION [ "uid" ]);
968 db_query ( $link , "COMMIT" );
972 if ( $subop == "editCats" ) {
974 $action = $_REQUEST [ "action" ];
976 if ( $action == "save" ) {
978 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
979 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
981 db_query ( $link , "BEGIN" );
983 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
984 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
986 if ( db_num_rows ( $result ) == 1 ) {
988 $old_title = db_fetch_result ( $result , 0 , "title" );
990 if ( $cat_title != "" ) {
991 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
992 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
993 owner_uid = " . $_SESSION [ "uid" ]);
1000 print $_REQUEST [ "value" ];
1003 db_query ( $link , "COMMIT" );
1009 if ( $action == "add" ) {
1011 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1013 if (! add_feed_category ( $link , $feed_cat ))
1014 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1018 if ( $action == "remove" ) {
1020 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1022 foreach ( $ids as $id ) {
1023 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1027 print "<div dojoType= \" dijit.Toolbar \" >
1028 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1029 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1030 __ ( 'Create category' ). "</button></div>" ;
1032 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1033 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1038 if ( db_num_rows ( $result ) != 0 ) {
1040 print "<div class= \" prefFeedCatHolder \" >" ;
1042 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1044 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1045 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1049 while ( $line = db_fetch_assoc ( $result )) {
1051 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1053 $cat_id = $line [ "id" ];
1054 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1056 print "<tr class= \"\" $this_row_id >" ;
1058 $edit_title = htmlspecialchars ( $line [ "title" ]);
1060 print "<td width='5%' align='center'><input
1061 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1062 type= \" checkbox \" ></td>" ;
1066 # print "<span id=\"FCATT-$cat_id\">" .
1067 # $edit_title . "</span>";
1069 print "<span dojoType= \" dijit.InlineEditBox \"
1070 width= \" 300px \" autoSave= \" false \"
1071 cat-id= \" $cat_id\" >" . $edit_title .
1072 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1076 content: {op: 'pref-feeds', subop: 'editCats',
1079 cid: this.srcNodeRef.getAttribute('cat-id')},
1080 load: function(response) {
1081 elem.attr('value', response);
1100 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1103 print "<div class='dlgButtons'>
1104 <div style='float : left'>
1105 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1106 __ ( 'Remove selected categories' ). "</button>
1109 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1110 __ ( 'Close this window' ). "</button></div>" ;
1118 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1119 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1121 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1122 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1124 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1126 if ( $num_errors > 0 ) {
1128 $error_button = "<button dojoType= \" dijit.form.Button \"
1129 onclick= \" showFeedsWithErrors \" id= \" errorButton \" >" .
1130 __ ( "Feeds with errors" ) . "</button>" ;
1132 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1133 // __('Some feeds have update errors (click for details)')."</a>");
1136 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1138 if ( array_key_exists ( "search" , $_REQUEST )) {
1139 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1141 $feed_search = $_SESSION [ "prefs_feed_search" ];
1144 print "<div dojoType= \" dijit.Toolbar \" >" ;
1146 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1147 "<span>" . __ ( 'Select' ). "</span>" ;
1148 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1149 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1150 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1151 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1152 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1153 print "</div></div>" ;
1155 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1156 "<span>" . __ ( 'Feeds' ). "</span>" ;
1157 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1158 print "<div onclick= \" quickAddFeed() \"
1159 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1160 print "<div onclick= \" editSelectedFeed() \"
1161 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1162 print "<div onclick= \" resetFeedOrder() \"
1163 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1164 print "</div></div>" ;
1166 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1167 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1168 "<span>" . __ ( 'Categories' ). "</span>" ;
1169 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1170 print "<div onclick= \" editFeedCats() \"
1171 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1172 print "<div onclick= \" resetCatOrder() \"
1173 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1174 print "</div></div>" ;
1178 print $error_button ;
1180 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1181 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1183 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1185 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1186 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1188 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1190 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1194 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1195 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1201 print "</div>" ; # toolbar
1203 print "<div id= \" feedlistLoading \" >
1204 <img src='images/indicator_tiny.gif'>" .
1205 __ ( "Loading, please wait..." ). "</div>" ;
1207 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1208 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1210 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1211 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1212 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1214 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1215 dndController= \" dijit.tree.dndSource \"
1216 betweenThreshold= \" 5 \"
1217 model= \" feedModel \" openOnClick= \" false \" >
1218 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1219 var id = String(item.id);
1220 var bare_id = id.substr(id.indexOf(':')+1);
1222 if (id.match('FEED:')) {
1224 } else if (id.match('CAT:')) {
1225 editCat(bare_id, item);
1228 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1229 Element.hide( \" feedlistLoading \" );
1233 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1234 <b>Hint:</b> you can drag feeds and categories around.
1237 print "</div>" ; # feeds pane
1239 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1241 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1243 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1247 print "<iframe id= \" upload_iframe \"
1248 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1249 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1251 print "<form style='display : block' target= \" upload_iframe \"
1252 enctype= \" multipart/form-data \" method= \" POST \"
1253 action= \" backend.php \" >
1254 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1255 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1256 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1257 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \"
1258 type= \" submit \" >" . __ ( 'Import' ). "</button>
1259 <button dojoType= \" dijit.form.Button \" onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>
1262 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1264 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>" ;
1266 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1267 __ ( 'Display URL' ). "</button> " ;
1270 print "</div>" ; # pane
1272 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1274 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1276 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1280 print "<button onclick='window.navigator.registerContentHandler(" .
1281 " \" application/vnd.mozilla.maybe.feed \" , " .
1282 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1283 __ ( 'Click here to register this site as a feed reader.' ) .
1288 print "</div>" ; # pane
1291 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1293 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>" ;
1295 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1297 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1299 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1301 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1303 print "</div>" ; #pane
1305 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1307 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1309 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1310 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1312 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1313 __ ( 'Display URL' ). "</button> " ;
1315 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1316 __ ( 'Clear all generated URLs' ). "</button> " ;
1318 print "</div>" ; #pane
1319 print "</div>" ; #container
1323 function print_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1325 $owner_uid = $_SESSION [ "uid" ];
1328 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1329 UPPER(title) LIKE UPPER('% $search %'))" ;
1335 $result = db_query ( $link , "SELECT feed_url, subscribers FROM
1336 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1337 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1338 AND owner_uid = ' $owner_uid ') $search_qpart
1339 ORDER BY subscribers DESC LIMIT $limit " );
1340 } else if ( $mode == 2 ) {
1341 $result = db_query ( $link , "SELECT *,
1342 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1343 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1345 ttrss_archived_feeds
1347 (SELECT COUNT(*) FROM ttrss_feeds
1348 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1349 owner_uid = ' $owner_uid ') = 0 AND
1350 owner_uid = ' $owner_uid ' $search_qpart
1351 ORDER BY id DESC LIMIT $limit " );
1356 while ( $line = db_fetch_assoc ( $result )) {
1360 $feed_url = $line [ "feed_url" ];
1361 $subscribers = $line [ "subscribers" ];
1363 $det_result = db_query ( $link , "SELECT site_url,title,id
1364 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1366 $details = db_fetch_assoc ( $det_result );
1368 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1370 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1371 $feed_icon = "<img style= \" vertical-align : middle \" class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1372 "/" . $details [ "id" ]. ".ico \" >" ;
1374 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1377 $check_box = "<input onclick='toggleSelectListRow2(this)'
1378 dojoType= \" dijit.form.CheckBox \"
1379 type= \" checkbox \" \" >" ;
1381 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1383 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1385 if ( $details [ "site_url" ]) {
1386 $site_url = "<a target= \" _blank \" href= \" " .
1387 htmlspecialchars ( $details [ "site_url" ]). " \" >
1388 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1393 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1394 style='border-width : 0px; vertical-align : middle'
1395 src='images/feed-icon-12x12.png'></a>" ;
1397 print "<li title= \" " . htmlspecialchars ( $details [ "site_url" ]). " \"
1398 id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1399 " $feed_icon $feed_url " . htmlspecialchars ( $details [ "title" ]) .
1400 " <span class='subscribers'>( $subscribers )</span>
1403 } else if ( $mode == 2 ) {
1404 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1405 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1406 $title = htmlspecialchars ( $line [ "title" ]);
1408 $icon_file = ICONS_DIR
. "/" . $line [ "id" ] . ".ico" ;
1410 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1411 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1412 "/" . $line [ "id" ]. ".ico \" >" ;
1414 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1417 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1418 type= \" checkbox \" >" ;
1420 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1422 if ( $line [ 'articles_archived' ] > 0 ) {
1423 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1424 $archived = " <span class='subscribers'>( $archived )</span>" ;
1429 if ( $line [ "site_url" ]) {
1430 $site_url = "<a target= \" _blank \" href= \" $site_url\" >
1431 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1436 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1437 style='border-width : 0px; vertical-align : middle'
1438 src='images/feed-icon-12x12.png'></a>" ;
1440 print "<li title='" . $line [ 'site_url' ]. "' class=' $class '
1441 id= \" FBROW-" . $line [ "id" ]. " \" >" .
1442 $check_box . " $feed_icon $feed_url " . $title .
1443 $archived . $site_url . "</li>" ;
1451 if ( $feedctr == 0 ) {
1452 print "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;