]>
git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
7f1b029a1953d70e9691ece60574625f774e4d81
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 == "remtwitterinfo" ) {
31 db_query ( $link , "UPDATE ttrss_users SET twitter_oauth = NULL
32 WHERE id = " . $_SESSION [ 'uid' ]);
37 if ( $subop == "getfeedtree" ) {
41 $root [ 'name' ] = __ ( 'Feeds' );
42 $root [ 'items' ] = array ();
43 $root [ 'type' ] = 'category' ;
45 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
47 $result = db_query ( $link , "SELECT id, title FROM ttrss_feed_categories
48 WHERE owner_uid = " . $_SESSION [ "uid" ] . " ORDER BY order_id, title" );
50 while ( $line = db_fetch_assoc ( $result )) {
52 $cat [ 'id' ] = 'CAT:' . $line [ 'id' ];
53 $cat [ 'bare_id' ] = $feed_id ;
54 $cat [ 'name' ] = $line [ 'title' ];
55 $cat [ 'items' ] = array ();
56 $cat [ 'type' ] = 'category' ;
58 $feed_result = db_query ( $link , "SELECT id, title, last_error,
59 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
61 WHERE cat_id = '" . $line [ 'id' ]. "' AND owner_uid = " . $_SESSION [ "uid" ].
62 " ORDER BY order_id, title" );
64 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
66 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
67 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
68 $feed [ 'name' ] = $feed_line [ 'title' ];
69 $feed [ 'checkbox' ] = false ;
70 $feed [ 'error' ] = $feed_line [ 'last_error' ];
71 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
72 $feed [ 'param' ] = make_local_datetime ( $link ,
73 $feed_line [ 'last_updated' ], true );
75 array_push ( $cat [ 'items' ], $feed );
78 array_push ( $root [ 'items' ], $cat );
81 /* Uncategorized is a special case */
86 $cat [ 'name' ] = __ ( "Uncategorized" );
87 $cat [ 'items' ] = array ();
88 $cat [ 'type' ] = 'category' ;
90 $feed_result = db_query ( $link , "SELECT id, title,last_error,
91 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
93 WHERE cat_id IS NULL AND owner_uid = " . $_SESSION [ "uid" ].
94 " ORDER BY order_id, title" );
96 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
98 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
99 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
100 $feed [ 'name' ] = $feed_line [ 'title' ];
101 $feed [ 'checkbox' ] = false ;
102 $feed [ 'error' ] = $feed_line [ 'last_error' ];
103 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
104 $feed [ 'param' ] = make_local_datetime ( $link ,
105 $feed_line [ 'last_updated' ], true );
107 array_push ( $cat [ 'items' ], $feed );
110 array_push ( $root [ 'items' ], $cat );
112 $feed_result = db_query ( $link , "SELECT id, title, last_error,
113 " . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
115 WHERE owner_uid = " . $_SESSION [ "uid" ].
116 " ORDER BY order_id, title" );
118 while ( $feed_line = db_fetch_assoc ( $feed_result )) {
120 $feed [ 'id' ] = 'FEED:' . $feed_line [ 'id' ];
121 $feed [ 'bare_id' ] = $feed_line [ 'id' ];
122 $feed [ 'name' ] = $feed_line [ 'title' ];
123 $feed [ 'checkbox' ] = false ;
124 $feed [ 'error' ] = $feed_line [ 'last_error' ];
125 $feed [ 'icon' ] = getFeedIcon ( $feed_line [ 'id' ]);
126 $feed [ 'param' ] = make_local_datetime ( $link ,
127 $feed_line [ 'last_updated' ], true );
129 array_push ( $root [ 'items' ], $feed );
134 $fl [ 'identifier' ] = 'id' ;
135 $fl [ 'label' ] = 'name' ;
136 $fl [ 'items' ] = array ( $root );
138 print json_encode ( $fl );
142 if ( $subop == "catsortreset" ) {
143 db_query ( $link , "UPDATE ttrss_feed_categories
144 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
148 if ( $subop == "feedsortreset" ) {
149 db_query ( $link , "UPDATE ttrss_feeds
150 SET order_id = 0 WHERE owner_uid = " . $_SESSION [ "uid" ]);
154 if ( $subop == "savefeedorder" ) {
155 # if ($_POST['payload']) {
156 # file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
157 # $data = json_decode($_POST['payload'], true);
159 # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
162 $data = json_decode ( $_POST [ 'payload' ], true );
164 if ( is_array ( $data ) && is_array ( $data [ 'items' ])) {
169 foreach ( $data [ 'items' ] as $item ) {
171 if ( $item [ 'id' ] != 'root' ) {
172 if ( is_array ( $item [ 'items' ])) {
173 if ( isset ( $item [ 'items' ][ '_reference' ])) {
174 $data_map [ $item [ 'id' ]] = array ( $item [ 'items' ]);
176 $data_map [ $item [ 'id' ]] =& $item [ 'items' ];
182 foreach ( $data [ 'items' ][ 0 ][ 'items' ] as $item ) {
183 $id = $item [ '_reference' ];
184 $bare_id = substr ( $id , strpos ( $id , ':' ) +
1 );
189 db_query ( $link , "UPDATE ttrss_feed_categories
190 SET order_id = ' $cat_order_id ' WHERE id = ' $bare_id ' AND
191 owner_uid = " . $_SESSION [ "uid" ]);
196 if ( is_array ( $data_map [ $id ])) {
197 foreach ( $data_map [ $id ] as $feed ) {
198 $id = $feed [ '_reference' ];
199 $feed_id = substr ( $id , strpos ( $id , ':' ) +
1 );
202 $cat_query = "cat_id = ' $bare_id '" ;
204 $cat_query = "cat_id = NULL" ;
206 db_query ( $link , "UPDATE ttrss_feeds
207 SET order_id = ' $feed_order_id ',
209 WHERE id = ' $feed_id ' AND
210 owner_uid = " . $_SESSION [ "uid" ]);
221 if ( $subop == "removeicon" ) {
222 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
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" );
234 if ( $subop == "uploadicon" ) {
235 $icon_file = $_FILES [ 'icon_file' ][ 'tmp_name' ];
236 $feed_id = db_escape_string ( $_REQUEST [ "feed_id" ]);
238 if ( is_file ( $icon_file ) && $feed_id ) {
239 if ( filesize ( $icon_file ) < 20000 ) {
241 $result = db_query ( $link , "SELECT id FROM ttrss_feeds
242 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
244 if ( db_num_rows ( $result ) != 0 ) {
245 unlink ( ICONS_DIR
. "/ $feed_id .ico" );
246 move_uploaded_file ( $icon_file , ICONS_DIR
. "/ $feed_id .ico" );
258 print "<script type= \" text/javascript \" >" ;
259 print "parent.uploadIconHandler( $rc );" ;
264 if ( $subop == "editfeed" ) {
266 $feed_id = db_escape_string ( $_REQUEST [ "id" ]);
268 $result = db_query ( $link ,
269 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
270 owner_uid = " . $_SESSION [ "uid" ]);
272 $title = htmlspecialchars ( db_fetch_result ( $result ,
275 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" id \" value= \" $feed_id\" >" ;
276 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
277 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" editSave \" >" ;
279 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
280 print "<div class= \" dlgSecCont \" >" ;
284 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
285 placeHolder= \" " . __ ( "Feed Title" ). " \"
286 style= \" font-size : 16px; width: 20em \" name= \" title \" value= \" $title\" >" ;
290 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
291 $feed_url = htmlspecialchars ( db_fetch_result ( $result ,
296 print __ ( 'URL:' ) . " " ;
297 print "<input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \"
298 placeHolder= \" " . __ ( "Feed URL" ). " \"
299 regExp='^(http|https)://.*' style= \" width : 20em \"
300 name= \" feed_url \" value= \" $feed_url\" >" ;
304 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
306 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
310 print __ ( 'Place in category:' ) . " " ;
312 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
313 'dojoType="dijit.form.Select"' );
318 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
319 print "<div class= \" dlgSecCont \" >" ;
321 /* Update Interval */
323 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
325 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
326 'dojoType="dijit.form.Select"' );
330 $update_method = db_fetch_result ( $result , 0 , "update_method" ,
331 'dojoType="dijit.form.Select"' );
333 print " " . __ ( 'using' ) . " " ;
334 print_select_hash ( "update_method" , $update_method , $update_methods ,
335 'dojoType="dijit.form.Select"' );
337 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
339 if ( FORCE_ARTICLE_PURGE
== 0 ) {
345 print __ ( 'Article purging:' ) . " " ;
347 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
348 'dojoType="dijit.form.Select"' );
351 print "<input style= \" display : none \" name='purge_interval'
352 dojoType= \" dijit.form.TextBox \" value=' $purge_interval '>" ;
357 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
358 print "<div class= \" dlgSecCont \" >" ;
360 $auth_login = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_login" ));
364 # print "<tr><td>" . __('Login:') . "</td><td>";
366 print "<input dojoType= \" dijit.form.TextBox \" id= \" feedEditDlg_login \"
367 placeHolder= \" " . __ ( "Login" ). " \"
368 name= \" auth_login \" value= \" $auth_login\" ><hr/>" ;
370 # print "</tr><tr><td>" . __("Password:") . "</td><td>";
372 $auth_pass = htmlspecialchars ( db_fetch_result ( $result , 0 , "auth_pass" ));
374 print "<input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
375 placeHolder= \" " . __ ( "Password" ). " \"
376 value= \" $auth_pass\" >" ;
378 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedEditDlg_login \" position= \" below \" >
379 " . __ ( '<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.' ). "
382 # print "</td></tr></table>";
385 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
386 print "<div class= \" dlgSecCont \" >" ;
388 # print "<div style=\"line-height : 100%\">";
390 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
393 $checked = "checked= \" 1 \" " ;
398 print "<input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" name= \" private \" id= \" private \"
399 $checked > <label for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
401 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
404 $checked = "checked= \" 1 \" " ;
409 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
410 $checked > <label for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
412 $include_in_digest = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "include_in_digest" ));
414 if ( $include_in_digest ) {
415 $checked = "checked= \" 1 \" " ;
420 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" include_in_digest \"
421 name= \" include_in_digest \"
422 $checked > <label for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
425 $always_display_enclosures = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "always_display_enclosures" ));
427 if ( $always_display_enclosures ) {
428 $checked = "checked" ;
433 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" always_display_enclosures \"
434 name= \" always_display_enclosures \"
435 $checked > <label for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
438 $cache_images = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "cache_images" ));
441 $checked = "checked= \" 1 \" " ;
446 print "<hr/><input dojoType= \" dijit.form.CheckBox \" type= \" checkbox \" id= \" cache_images \"
447 name= \" cache_images \"
448 $checked > <label for= \" cache_images \" >" .
449 __ ( 'Cache images locally (SimplePie only)' ). "</label>" ;
457 print "<div class= \" dlgSec \" >" . __ ( "Icon" ). "</div>" ;
458 print "<div class= \" dlgSecCont \" >" ;
460 print "<iframe name= \" icon_upload_iframe \"
461 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
463 print "<form style='display : block' target= \" icon_upload_iframe \"
464 enctype= \" multipart/form-data \" method= \" POST \"
465 action= \" backend.php \" >
466 <input id= \" icon_file \" size= \" 10 \" name= \" icon_file \" type= \" file \" >
467 <input type= \" hidden \" name= \" op \" value= \" pref-feeds \" >
468 <input type= \" hidden \" name= \" feed_id \" value= \" $feed_id\" >
469 <input type= \" hidden \" name= \" subop \" value= \" uploadicon \" >
470 <button dojoType= \" dijit.form.Button \" onclick= \" return uploadFeedIcon(); \"
471 type= \" submit \" >" . __ ( 'Replace' ). "</button>
472 <button dojoType= \" dijit.form.Button \" onclick= \" return removeFeedIcon( $feed_id ); \"
473 type= \" submit \" >" . __ ( 'Remove' ). "</button>
478 $title = htmlspecialchars ( $title , ENT_QUOTES
);
480 print "<div class='dlgButtons'>
481 <div style= \" float : left \" >
482 <button dojoType= \" dijit.form.Button \" onclick='return unsubscribeFeed( $feed_id , \" $title\" )'>" .
483 __ ( 'Unsubscribe' ). "</button>
485 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').execute() \" >" . __ ( 'Save' ). "</button>
486 <button dojoType= \" dijit.form.Button \" onclick= \" return dijit.byId('feedEditDlg').hide() \" >" . __ ( 'Cancel' ). "</button>
492 if ( $subop == "editfeeds" ) {
494 $feed_ids = db_escape_string ( $_REQUEST [ "ids" ]);
496 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" ids \" value= \" $feed_ids\" >" ;
497 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" op \" value= \" pref-feeds \" >" ;
498 print "<input dojoType= \" dijit.form.TextBox \" style= \" display : none \" name= \" subop \" value= \" batchEditSave \" >" ;
500 print "<div class= \" dlgSec \" >" . __ ( "Feed" ). "</div>" ;
501 print "<div class= \" dlgSecCont \" >" ;
505 print "<input dojoType= \" dijit.form.ValidationTextBox \"
506 disabled= \" 1 \" style= \" font-size : 16px; width : 20em; \" required= \" 1 \"
507 name= \" title \" value= \" $title\" >" ;
509 batch_edit_cbox ( "title" );
515 print __ ( 'URL:' ) . " " ;
516 print "<input dojoType= \" dijit.form.ValidationTextBox \" disabled= \" 1 \"
517 required= \" 1 \" regExp='^(http|https)://.*' style= \" width : 20em \"
518 name= \" feed_url \" value= \" $feed_url\" >" ;
520 batch_edit_cbox ( "feed_url" );
524 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
528 print __ ( 'Place in category:' ) . " " ;
530 print_feed_cat_select ( $link , "cat_id" , $cat_id ,
531 'disabled="1" dojoType="dijit.form.Select"' );
533 batch_edit_cbox ( "cat_id" );
539 print "<div class= \" dlgSec \" >" . __ ( "Update" ). "</div>" ;
540 print "<div class= \" dlgSecCont \" >" ;
542 /* Update Interval */
544 print_select_hash ( "update_interval" , $update_interval , $update_intervals ,
545 'disabled="1" dojoType="dijit.form.Select"' );
547 batch_edit_cbox ( "update_interval" );
551 print " " . __ ( 'using' ) . " " ;
552 print_select_hash ( "update_method" , $update_method , $update_methods ,
553 'disabled="1" dojoType="dijit.form.Select"' );
554 batch_edit_cbox ( "update_method" );
558 if ( FORCE_ARTICLE_PURGE
== 0 ) {
562 print __ ( 'Article purging:' ) . " " ;
564 print_select_hash ( "purge_interval" , $purge_interval , $purge_intervals ,
565 'disabled="1" dojoType="dijit.form.Select"' );
567 batch_edit_cbox ( "purge_interval" );
571 print "<div class= \" dlgSec \" >" . __ ( "Authentication" ). "</div>" ;
572 print "<div class= \" dlgSecCont \" >" ;
574 print "<input dojoType= \" dijit.form.TextBox \"
575 placeHolder= \" " . __ ( "Login" ). " \" disabled= \" 1 \"
576 name= \" auth_login \" value= \" $auth_login\" >" ;
578 batch_edit_cbox ( "auth_login" );
580 print "<br/><input dojoType= \" dijit.form.TextBox \" type= \" password \" name= \" auth_pass \"
581 placeHolder= \" " . __ ( "Password" ). " \" disabled= \" 1 \"
582 value= \" $auth_pass\" >" ;
584 batch_edit_cbox ( "auth_pass" );
587 print "<div class= \" dlgSec \" >" . __ ( "Options" ). "</div>" ;
588 print "<div class= \" dlgSecCont \" >" ;
590 print "<input disabled= \" 1 \" type= \" checkbox \" name= \" private \" id= \" private \"
591 dojoType= \" dijit.form.CheckBox \" > <label id= \" private_l \" class='insensitive' for= \" private \" >" . __ ( 'Hide from Popular feeds' ). "</label>" ;
593 print " " ; batch_edit_cbox ( "private" , "private_l" );
595 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" rtl_content \" name= \" rtl_content \"
596 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" rtl_content_l \" for= \" rtl_content \" >" . __ ( 'Right-to-left content' ). "</label>" ;
598 print " " ; batch_edit_cbox ( "rtl_content" , "rtl_content_l" );
600 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" include_in_digest \"
601 name= \" include_in_digest \"
602 dojoType= \" dijit.form.CheckBox \" > <label id= \" include_in_digest_l \" class='insensitive' for= \" include_in_digest \" >" . __ ( 'Include in e-mail digest' ). "</label>" ;
604 print " " ; batch_edit_cbox ( "include_in_digest" , "include_in_digest_l" );
606 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" always_display_enclosures \"
607 name= \" always_display_enclosures \"
608 dojoType= \" dijit.form.CheckBox \" > <label id= \" always_display_enclosures_l \" class='insensitive' for= \" always_display_enclosures \" >" . __ ( 'Always display image attachments' ). "</label>" ;
610 print " " ; batch_edit_cbox ( "always_display_enclosures" , "always_display_enclosures_l" );
612 print "<br/><input disabled= \" 1 \" type= \" checkbox \" id= \" cache_images \"
613 name= \" cache_images \"
614 dojoType= \" dijit.form.CheckBox \" > <label class='insensitive' id= \" cache_images_l \"
615 for= \" cache_images \" >" .
616 __ ( 'Cache images locally' ). "</label>" ;
619 print " " ; batch_edit_cbox ( "cache_images" , "cache_images_l" );
623 print "<div class='dlgButtons'>
624 <button dojoType= \" dijit.form.Button \"
625 onclick= \" return dijit.byId('feedEditDlg').execute() \" >" .
626 __ ( 'Save' ). "</button>
627 <button dojoType= \" dijit.form.Button \"
628 onclick= \" return dijit.byId('feedEditDlg').hide() \" >" .
629 __ ( 'Cancel' ). "</button>
635 if ( $subop == "editSave" ||
$subop == "batchEditSave" ) {
637 $feed_title = db_escape_string ( trim ( $_POST [ "title" ]));
638 $feed_link = db_escape_string ( trim ( $_POST [ "feed_url" ]));
639 $upd_intl = db_escape_string ( $_POST [ "update_interval" ]);
640 $purge_intl = db_escape_string ( $_POST [ "purge_interval" ]);
641 $feed_id = db_escape_string ( $_POST [ "id" ]); /* editSave */
642 $feed_ids = db_escape_string ( $_POST [ "ids" ]); /* batchEditSave */
643 $cat_id = db_escape_string ( $_POST [ "cat_id" ]);
644 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
645 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
646 $private = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "private" ]));
647 $rtl_content = checkbox_to_sql_bool ( db_escape_string ( $_POST [ "rtl_content" ]));
648 $include_in_digest = checkbox_to_sql_bool (
649 db_escape_string ( $_POST [ "include_in_digest" ]));
650 $cache_images = checkbox_to_sql_bool (
651 db_escape_string ( $_POST [ "cache_images" ]));
652 $update_method = ( int ) db_escape_string ( $_POST [ "update_method" ]);
654 $always_display_enclosures = checkbox_to_sql_bool (
655 db_escape_string ( $_POST [ "always_display_enclosures" ]));
657 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
658 if ( $cat_id && $cat_id != 0 ) {
659 $category_qpart = "cat_id = ' $cat_id '," ;
660 $category_qpart_nocomma = "cat_id = ' $cat_id '" ;
662 $category_qpart = 'cat_id = NULL,' ;
663 $category_qpart_nocomma = 'cat_id = NULL' ;
666 $category_qpart = "" ;
667 $category_qpart_nocomma = "" ;
670 if ( SIMPLEPIE_CACHE_IMAGES
) {
671 $cache_images_qpart = "cache_images = $cache_images ," ;
673 $cache_images_qpart = "" ;
676 if ( $subop == "editSave" ) {
678 $result = db_query ( $link , "UPDATE ttrss_feeds SET
680 title = ' $feed_title ', feed_url = ' $feed_link ',
681 update_interval = ' $upd_intl ',
682 purge_interval = ' $purge_intl ',
683 auth_login = ' $auth_login ',
684 auth_pass = ' $auth_pass ',
686 rtl_content = $rtl_content ,
688 include_in_digest = $include_in_digest ,
689 always_display_enclosures = $always_display_enclosures ,
690 update_method = ' $update_method '
691 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
693 } else if ( $subop == "batchEditSave" ) {
694 $feed_data = array ();
696 foreach ( array_keys ( $_POST ) as $k ) {
697 if ( $k != "op" && $k != "subop" && $k != "ids" ) {
698 $feed_data [ $k ] = $_POST [ $k ];
702 db_query ( $link , "BEGIN" );
704 foreach ( array_keys ( $feed_data ) as $k ) {
710 $qpart = "title = ' $feed_title '" ;
714 $qpart = "feed_url = ' $feed_link '" ;
717 case "update_interval" :
718 $qpart = "update_interval = ' $upd_intl '" ;
721 case "purge_interval" :
722 $qpart = "purge_interval = ' $purge_intl '" ;
726 $qpart = "auth_login = ' $auth_login '" ;
730 $qpart = "auth_pass = ' $auth_pass '" ;
734 $qpart = "private = ' $private '" ;
737 case "include_in_digest" :
738 $qpart = "include_in_digest = ' $include_in_digest '" ;
741 case "always_display_enclosures" :
742 $qpart = "always_display_enclosures = ' $always_display_enclosures '" ;
746 $qpart = "cache_images = ' $cache_images '" ;
750 $qpart = "rtl_content = ' $rtl_content '" ;
753 case "update_method" :
754 $qpart = "update_method = ' $update_method '" ;
758 $qpart = $category_qpart_nocomma ;
765 "UPDATE ttrss_feeds SET $qpart WHERE id IN ( $feed_ids )
766 AND owner_uid = " . $_SESSION [ "uid" ]);
771 db_query ( $link , "COMMIT" );
776 if ( $subop == "remove" ) {
778 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
780 foreach ( $ids as $id ) {
781 remove_feed ( $link , $id , $_SESSION [ "uid" ]);
787 if ( $subop == "clear" ) {
788 $id = db_escape_string ( $_REQUEST [ "id" ]);
789 clear_feed_articles ( $link , $id );
792 if ( $subop == "rescore" ) {
793 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
795 foreach ( $ids as $id ) {
797 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
799 $result = db_query ( $link , "SELECT
800 title, content, link, ref_id, author," .
801 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
803 ttrss_user_entries, ttrss_entries
804 WHERE ref_id = id AND feed_id = ' $id ' AND
805 owner_uid = " . $_SESSION [ 'uid' ]. "
810 while ( $line = db_fetch_assoc ( $result )) {
812 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
814 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
815 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
816 $line [ 'author' ], $tags );
818 $new_score = calculate_article_score ( $article_filters );
820 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
822 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
825 foreach ( array_keys ( $scores ) as $s ) {
827 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
829 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
830 } else if ( $s < - 500 ) {
831 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
833 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
835 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
836 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
841 print __ ( "All done." );
845 if ( $subop == "rescoreAll" ) {
847 $result = db_query ( $link ,
848 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ 'uid' ]);
850 while ( $feed_line = db_fetch_assoc ( $result )) {
852 $id = $feed_line [ "id" ];
854 $filters = load_filters ( $link , $id , $_SESSION [ "uid" ], 6 );
856 $tmp_result = db_query ( $link , "SELECT
857 title, content, link, ref_id, author," .
858 SUBSTRING_FOR_DATE
. "(updated, 1, 19) AS updated
860 ttrss_user_entries, ttrss_entries
861 WHERE ref_id = id AND feed_id = ' $id ' AND
862 owner_uid = " . $_SESSION [ 'uid' ]. "
867 while ( $line = db_fetch_assoc ( $tmp_result )) {
869 $tags = get_article_tags ( $link , $line [ "ref_id" ]);
871 $article_filters = get_article_filters ( $filters , $line [ 'title' ],
872 $line [ 'content' ], $line [ 'link' ], strtotime ( $line [ 'updated' ]),
873 $line [ 'author' ], $tags );
875 $new_score = calculate_article_score ( $article_filters );
877 if (! $scores [ $new_score ]) $scores [ $new_score ] = array ();
879 array_push ( $scores [ $new_score ], $line [ 'ref_id' ]);
882 foreach ( array_keys ( $scores ) as $s ) {
884 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ',
886 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
888 db_query ( $link , "UPDATE ttrss_user_entries SET score = ' $s ' WHERE
889 ref_id IN (" . join ( ',' , $scores [ $s ]) . ")" );
894 print __ ( "All done." );
898 if ( $subop == "add" ) {
900 $feed_url = db_escape_string ( trim ( $_REQUEST [ "feed_url" ]));
901 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
902 $p_from = db_escape_string ( $_REQUEST [ "from" ]);
904 /* only read authentication information from POST */
906 $auth_login = db_escape_string ( trim ( $_POST [ "auth_login" ]));
907 $auth_pass = db_escape_string ( trim ( $_POST [ "auth_pass" ]));
909 if ( $p_from != 'tt-rss' ) {
912 <title>Tiny Tiny RSS</title>
913 <link rel= \" stylesheet \" type= \" text/css \" href= \" utility.css \" >
916 <img class= \" floatingLogo \" src= \" images/ttrss_logo.png \"
917 alt= \" Tiny Tiny RSS \" />
918 <h1>Subscribe to feed...</h1>" ;
921 $rc = subscribe_to_feed ( $link , $feed_url , $cat_id , $auth_login , $auth_pass );
925 print_notice ( T_sprintf ( "Subscribed to <b> %s </b>." , $feed_url ));
928 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>." , $feed_url ));
931 print_warning ( T_sprintf ( "Already subscribed to <b> %s </b>." , $feed_url ));
934 print_error ( T_sprintf ( "Could not subscribe to <b> %s </b>.<br>Can't download the Feed URL." , $feed_url ));
938 if ( $p_from != 'tt-rss' ) {
939 if (! isset ( $_SERVER [ 'HTTPS' ])) $_SERVER [ 'HTTPS' ] = 'off' ;
940 $tt_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'tt-rss.php' , $_SERVER [ "REQUEST_URI" ]);
943 $tp_uri = ( $_SERVER [ 'HTTPS' ] != "on" ?
'http://' : 'https://' ) . $_SERVER [ 'HTTP_HOST' ] . preg_replace ( '/backend\.php.*$/' , 'prefs.php' , $_SERVER [ "REQUEST_URI" ]);
946 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
947 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
949 $feed_id = db_fetch_result ( $result , 0 , "id" );
956 print "<form method= \" GET \" style='display: inline'
958 <input type= \" hidden \" name= \" tab \" value= \" feedConfig \" >
959 <input type= \" hidden \" name= \" subop \" value= \" editFeed \" >
960 <input type= \" hidden \" name= \" subopparam \" value= \" $feed_id\" >
961 <input type= \" submit \" value= \" " . __ ( "Edit subscription options" ). " \" >
965 print "<form style='display: inline' method= \" GET \" action= \" $tt_uri\" >
966 <input type= \" submit \" value= \" " . __ ( "Return to Tiny Tiny RSS" ). " \" >
969 print "</body></html>" ;
974 if ( $subop == "categorize" ) {
977 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
979 $cat_id = db_escape_string ( $_REQUEST [ "cat_id" ]);
982 $cat_id_qpart = 'NULL' ;
984 $cat_id_qpart = "' $cat_id '" ;
987 db_query ( $link , "BEGIN" );
989 foreach ( $ids as $id ) {
991 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
993 AND owner_uid = " . $_SESSION [ "uid" ]);
997 db_query ( $link , "COMMIT" );
1001 if ( $subop == "editCats" ) {
1003 $action = $_REQUEST [ "action" ];
1005 if ( $action == "save" ) {
1007 $cat_title = db_escape_string ( trim ( $_REQUEST [ "value" ]));
1008 $cat_id = db_escape_string ( $_REQUEST [ "cid" ]);
1010 db_query ( $link , "BEGIN" );
1012 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1013 WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1015 if ( db_num_rows ( $result ) == 1 ) {
1017 $old_title = db_fetch_result ( $result , 0 , "title" );
1019 if ( $cat_title != "" ) {
1020 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
1021 title = ' $cat_title ' WHERE id = ' $cat_id ' AND
1022 owner_uid = " . $_SESSION [ "uid" ]);
1029 print $_REQUEST [ "value" ];
1032 db_query ( $link , "COMMIT" );
1038 if ( $action == "add" ) {
1040 $feed_cat = db_escape_string ( trim ( $_REQUEST [ "cat" ]));
1042 if (! add_feed_category ( $link , $feed_cat ))
1043 print_warning ( T_sprintf ( "Category <b>$ %s </b> already exists in the database." , $feed_cat ));
1047 if ( $action == "remove" ) {
1049 $ids = split ( "," , db_escape_string ( $_REQUEST [ "ids" ]));
1051 foreach ( $ids as $id ) {
1052 remove_feed_category ( $link , $id , $_SESSION [ "uid" ]);
1056 print "<div dojoType= \" dijit.Toolbar \" >
1057 <input dojoType= \" dijit.form.ValidationTextBox \" required= \" 1 \" name= \" newcat \" >
1058 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').addCategory() \" >" .
1059 __ ( 'Create category' ). "</button></div>" ;
1061 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
1062 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
1067 if ( db_num_rows ( $result ) != 0 ) {
1069 print "<div class= \" prefFeedCatHolder \" >" ;
1071 # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1073 print "<table width= \" 100% \" class= \" prefFeedCatList \"
1074 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
1078 while ( $line = db_fetch_assoc ( $result )) {
1080 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1082 $cat_id = $line [ "id" ];
1083 $this_row_id = "id= \" FCATR- $cat_id\" " ;
1085 print "<tr class= \"\" $this_row_id >" ;
1087 $edit_title = htmlspecialchars ( $line [ "title" ]);
1089 print "<td width='5%' align='center'><input
1090 onclick='toggleSelectRow2(this);' dojoType= \" dijit.form.CheckBox \"
1091 type= \" checkbox \" ></td>" ;
1095 # print "<span id=\"FCATT-$cat_id\">" .
1096 # $edit_title . "</span>";
1098 print "<span dojoType= \" dijit.InlineEditBox \"
1099 width= \" 300px \" autoSave= \" false \"
1100 cat-id= \" $cat_id\" >" . $edit_title .
1101 "<script type= \" dojo/method \" event= \" onChange \" args= \" item \" >
1105 content: {op: 'pref-feeds', subop: 'editCats',
1108 cid: this.srcNodeRef.getAttribute('cat-id')},
1109 load: function(response) {
1110 elem.attr('value', response);
1129 print "<p>" . __ ( 'No feed categories defined.' ). "</p>" ;
1132 print "<div class='dlgButtons'>
1133 <div style='float : left'>
1134 <button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').removeSelected() \" >" .
1135 __ ( 'Remove selected categories' ). "</button>
1138 print "<button dojoType= \" dijit.form.Button \" onclick= \" dijit.byId('feedCatEditDlg').hide() \" >" .
1139 __ ( 'Close this window' ). "</button></div>" ;
1147 print "<div dojoType= \" dijit.layout.AccordionContainer \" region= \" center \" >" ;
1148 print "<div id= \" pref-feeds-feeds \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Feeds' ). " \" >" ;
1150 $result = db_query ( $link , "SELECT COUNT(id) AS num_errors
1151 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
1153 $num_errors = db_fetch_result ( $result , 0 , "num_errors" );
1155 if ( $num_errors > 0 ) {
1157 $error_button = "<button dojoType= \" dijit.form.Button \"
1158 onclick= \" showFeedsWithErrors \" id= \" errorButton \" >" .
1159 __ ( "Feeds with errors" ) . "</button>" ;
1161 // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1162 // __('Some feeds have update errors (click for details)')."</a>");
1165 $feed_search = db_escape_string ( $_REQUEST [ "search" ]);
1167 if ( array_key_exists ( "search" , $_REQUEST )) {
1168 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
1170 $feed_search = $_SESSION [ "prefs_feed_search" ];
1173 print "<div dojoType= \" dijit.Toolbar \" >" ;
1175 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1176 "<span>" . __ ( 'Select' ). "</span>" ;
1177 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1178 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(true) \"
1179 dojoType= \" dijit.MenuItem \" >" . __ ( 'All' ). "</div>" ;
1180 print "<div onclick= \" dijit.byId('feedTree').model.setAllChecked(false) \"
1181 dojoType= \" dijit.MenuItem \" >" . __ ( 'None' ). "</div>" ;
1182 print "</div></div>" ;
1184 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1185 "<span>" . __ ( 'Feeds' ). "</span>" ;
1186 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1187 print "<div onclick= \" quickAddFeed() \"
1188 dojoType= \" dijit.MenuItem \" >" . __ ( 'Subscribe to feed' ). "</div>" ;
1189 print "<div onclick= \" editSelectedFeed() \"
1190 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit selected feeds' ). "</div>" ;
1191 print "<div onclick= \" resetFeedOrder() \"
1192 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1193 print "</div></div>" ;
1195 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1196 print "<div dojoType= \" dijit.form.DropDownButton \" >" .
1197 "<span>" . __ ( 'Categories' ). "</span>" ;
1198 print "<div dojoType= \" dijit.Menu \" style= \" display: none; \" >" ;
1199 print "<div onclick= \" editFeedCats() \"
1200 dojoType= \" dijit.MenuItem \" >" . __ ( 'Edit categories' ). "</div>" ;
1201 print "<div onclick= \" resetCatOrder() \"
1202 dojoType= \" dijit.MenuItem \" >" . __ ( 'Reset sort order' ). "</div>" ;
1203 print "</div></div>" ;
1207 print $error_button ;
1209 print "<button dojoType= \" dijit.form.Button \" onclick= \" removeSelectedFeeds() \" >"
1210 . __ ( 'Unsubscribe' ). "</button dojoType= \" dijit.form.Button \" > " ;
1212 if ( defined ( '_ENABLE_FEED_DEBUGGING' )) {
1214 print "<select id= \" feedActionChooser \" onchange= \" feedActionChange() \" >
1215 <option value= \" facDefault \" selected>" . __ ( 'More actions...' ). "</option>" ;
1217 if ( FORCE_ARTICLE_PURGE
== 0 ) {
1219 "<option value= \" facPurge \" >" . __ ( 'Manual purge' ). "</option>" ;
1223 <option value= \" facClear \" >" . __ ( 'Clear feed data' ). "</option>
1224 <option value= \" facRescore \" >" . __ ( 'Rescore articles' ). "</option>" ;
1230 print "</div>" ; # toolbar
1232 print "<div id= \" feedlistLoading \" >
1233 <img src='images/indicator_tiny.gif'>" .
1234 __ ( "Loading, please wait..." ). "</div>" ;
1236 print "<div dojoType= \" fox.PrefFeedStore \" jsId= \" feedStore \"
1237 url= \" backend.php?op=pref-feeds&subop=getfeedtree \" >
1239 <div dojoType= \" lib.CheckBoxStoreModel \" jsId= \" feedModel \" store= \" feedStore \"
1240 query= \" {id:'root'} \" rootId= \" root \" rootLabel= \" Feeds \"
1241 childrenAttrs= \" items \" checkboxStrict= \" false \" checkboxAll= \" false \" >
1243 <div dojoType= \" fox.PrefFeedTree \" id= \" feedTree \"
1244 dndController= \" dijit.tree.dndSource \"
1245 betweenThreshold= \" 5 \"
1246 model= \" feedModel \" openOnClick= \" false \" >
1247 <script type= \" dojo/method \" event= \" onClick \" args= \" item \" >
1248 var id = String(item.id);
1249 var bare_id = id.substr(id.indexOf(':')+1);
1251 if (id.match('FEED:')) {
1253 } else if (id.match('CAT:')) {
1254 editCat(bare_id, item);
1257 <script type= \" dojo/method \" event= \" onLoad \" args= \" item \" >
1258 Element.hide( \" feedlistLoading \" );
1262 print "<div dojoType= \" dijit.Tooltip \" connectId= \" feedTree \" position= \" below \" >
1263 " . __ ( '<b>Hint:</b> you can drag feeds and categories around.' ). "
1266 print "</div>" ; # feeds pane
1268 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'OPML' ). " \" >" ;
1270 print "<p>" . __ ( "Using OPML you can export and import your feeds and Tiny Tiny RSS settings." );
1272 print "<div class= \" insensitive \" >" . __ ( "Note: Only main settings profile can be migrated using OPML." ) . "</div>" ;
1276 print "<iframe id= \" upload_iframe \"
1277 name= \" upload_iframe \" onload= \" opmlImportComplete(this) \"
1278 style= \" width: 400px; height: 100px; display: none; \" ></iframe>" ;
1280 print "<form style='display : block' target= \" upload_iframe \"
1281 enctype= \" multipart/form-data \" method= \" POST \"
1282 action= \" backend.php \" >
1283 <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
1284 <input type= \" hidden \" name= \" op \" value= \" dlg \" >
1285 <input type= \" hidden \" name= \" id \" value= \" importOpml \" >
1286 <button dojoType= \" dijit.form.Button \" onclick= \" return opmlImport(); \"
1287 type= \" submit \" >" . __ ( 'Import' ). "</button>
1288 <button dojoType= \" dijit.form.Button \" onclick= \" gotoExportOpml() \" >" . __ ( 'Export OPML' ). "</button>
1291 print "<p>" . __ ( 'Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.' );
1293 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>" ;
1295 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('pubOPMLUrl') \" >" .
1296 __ ( 'Display URL' ). "</button> " ;
1299 print "</div>" ; # pane
1301 if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], "Firefox" ) !== false ) {
1303 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Firefox integration' ). " \" >" ;
1305 print "<p>" . __ ( 'This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.' ) . "</p>" ;
1309 print "<button onclick='window.navigator.registerContentHandler(" .
1310 " \" application/vnd.mozilla.maybe.feed \" , " .
1311 " \" " . add_feed_url () . " \" , " . " \" Tiny Tiny RSS \" )'>" .
1312 __ ( 'Click here to register this site as a feed reader.' ) .
1317 print "</div>" ; # pane
1320 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Subscribing using bookmarklet' ). " \" >" ;
1322 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>" ;
1324 $bm_subscribe_url = str_replace ( ' %s ' , '' , add_feed_url ());
1326 $confirm_str = __ ( 'Subscribe to %s in Tiny Tiny RSS?' );
1328 $bm_url = htmlspecialchars ( "javascript:{if(confirm(' $confirm_str '.replace(' %s ',window.location.href)))window.location.href=' $bm_subscribe_url '+window.location.href}" );
1330 print "<a href= \" $bm_url\" class='bookmarklet'>" . __ ( 'Subscribe in Tiny Tiny RSS' ). "</a>" ;
1332 print "</div>" ; #pane
1334 print "<div dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Published articles and generated feeds' ). " \" >" ;
1336 print "<p>" . __ ( 'Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.' ). "</p>" ;
1338 $rss_url = '-2::' . htmlspecialchars ( get_self_url_prefix () .
1339 "/backend.php?op=rss&id=-2&view-mode=all_articles" );;
1341 print "<button dojoType= \" dijit.form.Button \" onclick= \" return displayDlg('generatedFeed', ' $rss_url ') \" >" .
1342 __ ( 'Display URL' ). "</button> " ;
1344 print "<button dojoType= \" dijit.form.Button \" onclick= \" return clearFeedAccessKeys() \" >" .
1345 __ ( 'Clear all generated URLs' ). "</button> " ;
1347 print "</div>" ; #pane
1349 if ( defined ( 'CONSUMER_KEY' ) && CONSUMER_KEY
!= '' ) {
1351 print "<div id= \" pref-feeds-twitter \" dojoType= \" dijit.layout.AccordionPane \" title= \" " . __ ( 'Twitter' ). " \" >" ;
1353 $result = db_query ( $link , "SELECT COUNT(*) AS cid FROM ttrss_users
1354 WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND
1355 id = " . $_SESSION [ 'uid' ]);
1357 $is_registered = db_fetch_result ( $result , 0 , "cid" ) != 0 ;
1359 if (! $is_registered ) {
1360 print_notice ( __ ( 'Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.' ));
1362 print_notice ( __ ( 'You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.' ));
1365 print "<button dojoType= \" dijit.form.Button \" onclick= \" window.location.href = 'twitter.php?op=register' \" >" .
1366 __ ( "Register with Twitter.com" ). "</button>" ;
1370 print "<button dojoType= \" dijit.form.Button \"
1371 onclick= \" return clearTwitterCredentials() \" >" .
1372 __ ( "Clear stored credentials" ). "</button>" ;
1374 print "</div>" ; # pane
1378 print "</div>" ; #container
1382 function make_feed_browser ( $link , $search , $limit , $mode = 1 ) {
1384 $owner_uid = $_SESSION [ "uid" ];
1388 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('% $search %') OR
1389 UPPER(title) LIKE UPPER('% $search %'))" ;
1395 $result = db_query ( $link , "SELECT feed_url, subscribers FROM
1396 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1397 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1398 AND owner_uid = ' $owner_uid ') $search_qpart
1399 ORDER BY subscribers DESC LIMIT $limit " );
1400 } else if ( $mode == 2 ) {
1401 $result = db_query ( $link , "SELECT *,
1402 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1403 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1405 ttrss_archived_feeds
1407 (SELECT COUNT(*) FROM ttrss_feeds
1408 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1409 owner_uid = ' $owner_uid ') = 0 AND
1410 owner_uid = ' $owner_uid ' $search_qpart
1411 ORDER BY id DESC LIMIT $limit " );
1416 while ( $line = db_fetch_assoc ( $result )) {
1420 $feed_url = $line [ "feed_url" ];
1421 $subscribers = $line [ "subscribers" ];
1423 $det_result = db_query ( $link , "SELECT site_url,title,id
1424 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1426 $details = db_fetch_assoc ( $det_result );
1428 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1430 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1431 $feed_icon = "<img style= \" vertical-align : middle \" class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1432 "/" . $details [ "id" ]. ".ico \" >" ;
1434 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1437 $check_box = "<input onclick='toggleSelectListRow2(this)'
1438 dojoType= \" dijit.form.CheckBox \"
1439 type= \" checkbox \" \" >" ;
1441 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1443 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1445 if ( $details [ "site_url" ]) {
1446 $site_url = "<a target= \" _blank \" href= \" " .
1447 htmlspecialchars ( $details [ "site_url" ]). " \" >
1448 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1453 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1454 style='border-width : 0px; vertical-align : middle'
1455 src='images/feed-icon-12x12.png'></a>" ;
1457 $rv .= "<li title= \" " . htmlspecialchars ( $details [ "site_url" ]). " \"
1458 id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1459 " $feed_icon $feed_url " . htmlspecialchars ( $details [ "title" ]) .
1460 " <span class='subscribers'>( $subscribers )</span>
1463 } else if ( $mode == 2 ) {
1464 $feed_url = htmlspecialchars ( $line [ "feed_url" ]);
1465 $site_url = htmlspecialchars ( $line [ "site_url" ]);
1466 $title = htmlspecialchars ( $line [ "title" ]);
1468 $icon_file = ICONS_DIR
. "/" . $line [ "id" ] . ".ico" ;
1470 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1471 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1472 "/" . $line [ "id" ]. ".ico \" >" ;
1474 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1477 $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType= \" dijit.form.CheckBox \"
1478 type= \" checkbox \" >" ;
1480 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1482 if ( $line [ 'articles_archived' ] > 0 ) {
1483 $archived = sprintf ( __ ( " %d archived articles" ), $line [ 'articles_archived' ]);
1484 $archived = " <span class='subscribers'>( $archived )</span>" ;
1489 if ( $line [ "site_url" ]) {
1490 $site_url = "<a target= \" _blank \" href= \" $site_url\" >
1491 <img style='border-width : 0px' src='images/www.png' alt='www'></a>" ;
1496 $feed_url = "<a target= \" _blank \" href= \" $feed_url\" ><img
1497 style='border-width : 0px; vertical-align : middle'
1498 src='images/feed-icon-12x12.png'></a>" ;
1500 $rv .= "<li title='" . $line [ 'site_url' ]. "' class=' $class '
1501 id= \" FBROW-" . $line [ "id" ]. " \" >" .
1502 $check_box . " $feed_icon $feed_url " . $title .
1503 $archived . $site_url . "</li>" ;
1511 if ( $feedctr == 0 ) {
1512 $rv .= "<li style= \" text-align : center \" ><p>" . __ ( 'No feeds found.' ). "</p></li>" ;