]>
git.wh0rd.org - tt-rss.git/blob - backend.php
2 require_once "sessions.php" ;
4 header ( "Cache-Control: no-cache, must-revalidate" );
5 header ( "Pragma: no-cache" );
8 /* if ($_GET["debug"]) {
9 define('DEFAULT_ERROR_LEVEL', E_ALL);
11 define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
14 error_reporting(DEFAULT_ERROR_LEVEL); */
16 $op = $_REQUEST [ "op" ];
18 if ((! $op ||
$op == "rpc" ||
$op == "globalUpdateFeeds" ) && ! $_REQUEST [ "noxml" ]) {
19 header ( "Content-Type: application/xml" );
22 if (! $_SESSION [ "uid" ] && $op != "globalUpdateFeeds" ) {
25 print "<error error-code= \" 6 \" />" ;
29 <p>Error: Not logged in.</p>
30 <script type= \" text/javascript \" >
31 if (parent.window != 'undefined') {
32 parent.window.location = \" login.php \" ;
34 window.location = \" login.php \" ;
44 print "<error error-code= \" 7 \" />" ;
48 define ( 'SCHEMA_VERSION' , 7 );
50 require_once "sanity_check.php" ;
51 require_once "config.php" ;
52 require_once "db.php" ;
53 require_once "db-prefs.php" ;
54 require_once "functions.php" ;
55 require_once "magpierss/rss_fetch.inc" ;
57 $purge_intervals = array (
66 $update_intervals = array (
68 - 1 => "Disable updates" ,
76 $script_started = getmicrotime ();
78 $link = db_connect ( DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
81 if ( DB_TYPE
== "mysql" ) {
84 // PG seems to display its own errors just fine by default.
88 if ( DB_TYPE
== "pgsql" ) {
89 pg_query ( "set client_encoding = 'utf-8'" );
92 if ( $_SESSION [ "uid" ]) {
93 if ( get_pref ( $link , "HIDE_READ_FEEDS" ) == "true" ) {
94 setcookie ( "ttrss_vf_hreadf" , 1 );
96 setcookie ( "ttrss_vf_hreadf" , 0 );
99 setcookie ( 'ttrss_vf_refresh' , FEEDS_FRAME_REFRESH
);
100 setcookie ( 'ttrss_vf_daemon' , ENABLE_UPDATE_DAEMON
);
103 $fetch = $_GET [ "fetch" ];
105 // setcookie("ttrss_icons_url", ICONS_URL);
107 if (! sanity_check ( $link )) { return ; }
109 function getAllCounters ( $link ) {
110 getLabelCounters ( $link );
111 getFeedCounters ( $link );
112 getTagCounters ( $link );
113 getGlobalCounters ( $link );
114 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
115 getCategoryCounters ( $link );
119 function getCategoryCounters ( $link ) {
120 $result = db_query ( $link , "SELECT cat_id,SUM((SELECT COUNT(int_id)
121 FROM ttrss_user_entries WHERE feed_id = ttrss_feeds.id
122 AND unread = true)) AS unread FROM ttrss_feeds
124 owner_uid = " . $_SESSION [ "uid" ]. " GROUP BY cat_id" );
126 while ( $line = db_fetch_assoc ( $result )) {
127 $line [ "cat_id" ] = sprintf ( " %d " , $line [ "cat_id" ]);
128 print "<counter type= \" category \" id= \" " . $line [ "cat_id" ]. " \" counter= \" " .
129 $line [ "unread" ]. " \" />" ;
133 function getFeedUnread ( $link , $feed ) {
134 $n_feed = sprintf ( " %d " , $feed );
137 $match_part = "marked = true" ;
138 } else if ( $feed > 0 ) {
139 $match_part = "feed_id = ' $n_feed '" ;
140 } else if ( $feed < - 10 ) {
141 $label_id = - $feed - 11 ;
143 $result = db_query ( $link , "SELECT sql_exp FROM ttrss_labels WHERE
144 id = ' $label_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
146 $match_part = db_fetch_result ( $result , 0 , "sql_exp" );
151 $result = db_query ( $link , "SELECT count(int_id) AS unread
152 FROM ttrss_user_entries
153 WHERE unread = true AND $match_part AND owner_uid = " . $_SESSION [ "uid" ]);
157 $result = db_query ( $link , "SELECT COUNT(post_int_id) AS unread
158 FROM ttrss_tags,ttrss_user_entries
159 WHERE tag_name = ' $feed ' AND post_int_id = int_id AND unread = true AND
160 ttrss_tags.owner_uid = " . $_SESSION [ "uid" ]);
163 $unread = db_fetch_result ( $result , 0 , "unread" );
167 /* FIXME this needs reworking */
169 function getGlobalUnread ( $link ) {
170 $result = db_query ( $link , "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries
171 WHERE unread = true AND
172 ttrss_user_entries.ref_id = ttrss_entries.id AND
173 owner_uid = " . $_SESSION [ "uid" ]);
174 $c_id = db_fetch_result ( $result , 0 , "c_id" );
178 function getGlobalCounters ( $link , $global_unread = - 1 ) {
179 if ( $global_unread == - 1 ) {
180 $global_unread = getGlobalUnread ( $link );
182 print "<counter type= \" global \" id='global-unread' counter=' $global_unread '/>" ;
185 function getTagCounters ( $link , $smart_mode = SMART_RPC_COUNTERS
) {
188 if (! $_SESSION [ "tctr_last_value" ]) {
189 $_SESSION [ "tctr_last_value" ] = array ();
193 $old_counters = $_SESSION [ "tctr_last_value" ];
195 $tctrs_modified = false ;
197 /* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
198 FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
199 ttrss_user_entries.ref_id = ttrss_entries.id AND
200 ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND
201 post_int_id = ttrss_user_entries.int_id AND unread = true GROUP BY tag_name
203 select tag_name,0 as count FROM ttrss_tags
204 WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]); */
206 $result = db_query ( $link , "SELECT tag_name,SUM((SELECT COUNT(int_id)
207 FROM ttrss_user_entries WHERE int_id = post_int_id
208 AND unread = true)) AS count FROM ttrss_tags
209 WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name" );
213 while ( $line = db_fetch_assoc ( $result )) {
214 $tags [ $line [ "tag_name" ]] +
= $line [ "count" ];
217 foreach ( array_keys ( $tags ) as $tag ) {
218 $unread = $tags [ $tag ];
220 $tag = htmlspecialchars ( $tag );
222 if (! $smart_mode ||
$old_counters [ $tag ] != $unread ) {
223 $old_counters [ $tag ] = $unread ;
224 $tctrs_modified = true ;
225 print "<counter type= \" tag \" id= \" $tag\" counter= \" $unread\" />" ;
230 if ( $smart_mode && $tctrs_modified ) {
231 $_SESSION [ "tctr_last_value" ] = $old_counters ;
236 function getLabelCounters ( $link , $smart_mode = SMART_RPC_COUNTERS
) {
239 if (! $_SESSION [ "lctr_last_value" ]) {
240 $_SESSION [ "lctr_last_value" ] = array ();
244 $old_counters = $_SESSION [ "lctr_last_value" ];
245 $lctrs_modified = false ;
247 $result = db_query ( $link , "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
248 WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND
249 unread = true AND owner_uid = " . $_SESSION [ "uid" ]);
251 $count = db_fetch_result ( $result , 0 , "count" );
253 print "<counter type= \" label \" id= \" -1 \" counter= \" $count\" />" ;
255 $result = db_query ( $link , "SELECT owner_uid,id,sql_exp,description FROM
256 ttrss_labels WHERE owner_uid = " . $_SESSION [ "uid" ]. " ORDER by description" );
258 while ( $line = db_fetch_assoc ( $result )) {
260 $id = - $line [ "id" ] - 11 ;
264 $tmp_result = db_query ( $link , "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries
265 WHERE (" . $line [ "sql_exp" ] . ") AND unread = true AND
266 ttrss_user_entries.ref_id = ttrss_entries.id AND
267 owner_uid = " . $_SESSION [ "uid" ]);
269 $count = db_fetch_result ( $tmp_result , 0 , "count" );
271 if (! $smart_mode ||
$old_counters [ $id ] != $count ) {
272 $old_counters [ $id ] = $count ;
273 $lctrs_modified = true ;
274 print "<counter type= \" label \" id= \" $id\" counter= \" $count\" />" ;
277 error_reporting ( DEFAULT_ERROR_LEVEL
);
280 if ( $smart_mode && $lctrs_modified ) {
281 $_SESSION [ "lctr_last_value" ] = $old_counters ;
285 /* function getFeedCounter($link, $id) {
287 $result = db_query($link, "SELECT
288 count(id) as count,last_error
289 FROM ttrss_entries,ttrss_user_entries,ttrss_feeds
290 WHERE feed_id = '$id' AND unread = true
291 AND ttrss_user_entries.feed_id = ttrss_feeds.id
292 AND ttrss_user_entries.ref_id = ttrss_entries.id");
294 $count = db_fetch_result($result, 0, "count");
295 $last_error = htmlspecialchars(db_fetch_result($result, 0, "last_error"));
297 print "<counter type=\"feed\" id=\"$id\" counter=\"$count\" error=\"$last_error\"/>";
300 function getFeedCounters ( $link , $smart_mode = SMART_RPC_COUNTERS
) {
303 if (! $_SESSION [ "fctr_last_value" ]) {
304 $_SESSION [ "fctr_last_value" ] = array ();
308 $old_counters = $_SESSION [ "fctr_last_value" ];
310 $result = db_query ( $link , "SELECT id,last_error,parent_feed,
312 FROM ttrss_entries,ttrss_user_entries
313 WHERE feed_id = ttrss_feeds.id AND
314 ttrss_user_entries.ref_id = ttrss_entries.id
315 AND unread = true AND owner_uid = " . $_SESSION [ "uid" ]. ") as count
316 FROM ttrss_feeds WHERE owner_uid = " . $_SESSION [ "uid" ] . "
317 AND parent_feed IS NULL" );
319 $fctrs_modified = false ;
321 while ( $line = db_fetch_assoc ( $result )) {
324 $count = $line [ "count" ];
325 $last_error = htmlspecialchars ( $line [ "last_error" ]);
327 $has_img = is_file ( ICONS_DIR
. "/ $id .ico" );
329 $tmp_result = db_query ( $link ,
330 "SELECT id,COUNT(unread) AS unread
331 FROM ttrss_feeds LEFT JOIN ttrss_user_entries
332 ON (ttrss_feeds.id = ttrss_user_entries.feed_id)
333 WHERE parent_feed = ' $id ' AND unread = true GROUP BY ttrss_feeds.id" );
335 if ( db_num_rows ( $tmp_result ) > 0 ) {
336 while ( $l = db_fetch_assoc ( $tmp_result )) {
337 $count +
= $l [ "unread" ];
341 if (! $smart_mode ||
$old_counters [ $id ] != $count ) {
342 $old_counters [ $id ] = $count ;
343 $fctrs_modified = true ;
346 $error_part = "error= \" $last_error\" " ;
352 $has_img_part = "hi= \" $has_img\" " ;
357 print "<counter type= \" feed \" id= \" $id\" counter= \" $count\" $has_img_part $error_part />" ;
361 if ( $smart_mode && $fctrs_modified ) {
362 $_SESSION [ "fctr_last_value" ] = $old_counters ;
366 function outputFeedList ( $link , $tags = false ) {
369 <title>Tiny Tiny RSS : Feedlist</title>
370 <link rel= \" stylesheet \" href= \" tt-rss.css \" type= \" text/css \" >" ;
372 $user_theme = $_SESSION [ "theme" ];
374 print "<link rel= \" stylesheet \" type= \" text/css \"
375 href= \" themes/ $user_theme /theme.css \" >" ;
378 if ( get_pref ( $link , 'USE_COMPACT_STYLESHEET' )) {
379 print "<link rel= \" stylesheet \" type= \" text/css \"
380 href= \" tt-rss_compact.css \" />" ;
382 print "<link title= \" Compact Stylesheet \" rel= \" alternate stylesheet \"
383 type= \" text/css \" href= \" tt-rss_compact.css \" />" ;
386 print "<script type= \" text/javascript \" src= \" functions.js \" ></script>
387 <script type= \" text/javascript \" src= \" feedlist.js \" ></script>
388 <meta http-equiv= \" Content-Type \" content= \" text/html; charset=utf-8 \" >
389 <!--[if gte IE 5.5000]>
390 <script type= \" text/javascript \" src= \" pngfix.js \" ></script>
391 <link rel= \" stylesheet \" type= \" text/css \" href= \" tt-rss-ie.css \" >
394 <script type= \" text/javascript \" >
395 if (document.addEventListener) {
396 document.addEventListener( \" DOMContentLoaded \" , init, null);
398 window.onload = init;
401 print "<ul class= \" feedList \" id= \" feedList \" > \n " ;
403 $owner_uid = $_SESSION [ "uid" ];
409 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
410 print "<li class= \" feedCat \" >Special</li>" ;
411 print "<li id= \" feedCatHolder \" ><ul class= \" feedCatList \" >" ;
414 $result = db_query ( $link , "SELECT count(id) as num_starred
415 FROM ttrss_entries,ttrss_user_entries
416 WHERE marked = true AND
417 ttrss_user_entries.ref_id = ttrss_entries.id AND
418 unread = true AND owner_uid = ' $owner_uid '" );
419 $num_starred = db_fetch_result ( $result , 0 , "num_starred" );
423 if ( $num_starred > 0 ) $class .= "Unread" ;
425 printFeedEntry (- 1 , $class , "Starred articles" , $num_starred ,
426 "images/mark_set.png" , $link );
428 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
432 if ( GLOBAL_ENABLE_LABELS
&& get_pref ( $link , 'ENABLE_LABELS' )) {
434 $result = db_query ( $link , "SELECT id,sql_exp,description FROM
435 ttrss_labels WHERE owner_uid = ' $owner_uid ' ORDER by description" );
437 if ( db_num_rows ( $result ) > 0 ) {
438 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
439 print "<li class= \" feedCat \" >Labels</li>" ;
440 print "<li id= \" feedCatHolder \" ><ul class= \" feedCatList \" >" ;
442 print "<li><hr></li>" ;
446 while ( $line = db_fetch_assoc ( $result )) {
450 $tmp_result = db_query ( $link , "SELECT count(id) as count
451 FROM ttrss_entries,ttrss_user_entries
452 WHERE (" . $line [ "sql_exp" ] . ") AND unread = true AND
453 ttrss_user_entries.ref_id = ttrss_entries.id
454 AND owner_uid = ' $owner_uid '" );
456 $count = db_fetch_result ( $tmp_result , 0 , "count" );
464 error_reporting ( DEFAULT_ERROR_LEVEL
);
466 printFeedEntry (- $line [ "id" ]- 11 ,
467 $class , $line [ "description" ], $count , "images/label.png" , $link );
471 if ( db_num_rows ( $result ) > 0 ) {
472 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
479 // if (!get_pref($link, 'ENABLE_FEED_CATS')) {
480 print "<li><hr></li>" ;
483 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
484 $order_by_qpart = "category,title" ;
486 $order_by_qpart = "title" ;
489 $result = db_query ( $link , "SELECT ttrss_feeds.*,
490 (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
491 WHERE feed_id = ttrss_feeds.id AND
492 ttrss_user_entries.ref_id = ttrss_entries.id AND
493 owner_uid = ' $owner_uid ') AS total,
494 (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
495 WHERE feed_id = ttrss_feeds.id AND unread = true
496 AND ttrss_user_entries.ref_id = ttrss_entries.id
497 AND owner_uid = ' $owner_uid ') as unread,
499 ttrss_feed_categories.title AS category,
500 ttrss_feed_categories.collapsed
501 FROM ttrss_feeds LEFT JOIN ttrss_feed_categories
502 ON (ttrss_feed_categories.id = cat_id)
504 ttrss_feeds.owner_uid = ' $owner_uid ' AND parent_feed IS NULL
505 ORDER BY $order_by_qpart " );
507 $actid = $_GET [ "actid" ];
517 while ( $line = db_fetch_assoc ( $result )) {
519 $feed = db_unescape_string ( $line [ "title" ]);
520 $feed_id = $line [ "id" ];
522 $subop = $_GET [ "subop" ];
524 $total = $line [ "total" ];
525 $unread = $line [ "unread" ];
527 $tmp_result = db_query ( $link ,
528 "SELECT id,COUNT(unread) AS unread
529 FROM ttrss_feeds LEFT JOIN ttrss_user_entries
530 ON (ttrss_feeds.id = ttrss_user_entries.feed_id)
531 WHERE parent_feed = ' $feed_id ' AND unread = true
532 GROUP BY ttrss_feeds.id" );
534 if ( db_num_rows ( $tmp_result ) > 0 ) {
535 while ( $l = db_fetch_assoc ( $tmp_result )) {
536 $unread +
= $l [ "unread" ];
540 $cat_id = $line [ "cat_id" ];
542 $tmp_category = $line [ "category" ];
544 if (! $tmp_category ) {
545 $tmp_category = "Uncategorized" ;
548 // $class = ($lnum % 2) ? "even" : "odd";
550 if ( $line [ "last_error" ]) {
556 if ( $unread > 0 ) $class .= "Unread" ;
558 if ( $actid == $feed_id ) {
559 $class .= "Selected" ;
562 $total_unread +
= $unread ;
564 if ( $category != $tmp_category && get_pref ( $link , 'ENABLE_FEED_CATS' )) {
570 $category = $tmp_category ;
572 $collapsed = $line [ "collapsed" ];
574 // workaround for NULL category
575 if ( $category == "Uncategorized" ) {
576 if ( $_COOKIE [ "ttrss_vf_uclps" ] == 1 ) {
581 if ( $collapsed == "t" ||
$collapsed == "1" ) {
582 $holder_class = "invisible" ;
590 $cat_id_qpart = "cat_id = ' $cat_id '" ;
592 $cat_id_qpart = "cat_id IS NULL" ;
595 $tmp_result = db_query ( $link , "SELECT count(int_id) AS unread
596 FROM ttrss_user_entries,ttrss_feeds WHERE
598 feed_id = ttrss_feeds.id AND $cat_id_qpart AND
599 ttrss_user_entries.owner_uid = " . $_SESSION [ "uid" ]);
601 $cat_unread = db_fetch_result ( $tmp_result , 0 , "unread" );
603 $cat_id = sprintf ( " %d " , $cat_id );
605 print "<li class= \" feedCat \" id= \" FCAT- $cat_id\" >
606 <a href= \" javascript:toggleCollapseCat( $cat_id ) \" > $tmp_category </a>
607 <a href= \" javascript:viewCategory( $cat_id ) \" id= \" FCAP- $cat_id\" >
608 <span id= \" FCATCTR- $cat_id\"
609 class= \" $catctr_class\" >( $cat_unread unread) $ellipsis </span></a>
610 <!-- <div style= \" float : right \" >
611 <a href= \" javascript:viewCategory( $cat_id ) \" >[view]</a>
615 // !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function
616 // -> keyboard navigation, etc.
617 print "<li id= \" feedCatHolder \" class= \" $holder_class\" ><ul class= \" feedCatList \" id= \" FCATLIST- $cat_id\" >" ;
620 printFeedEntry ( $feed_id , $class , $feed , $unread ,
621 "icons/ $feed_id .ico" , $link );
630 /* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
631 FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
632 post_int_id = ttrss_user_entries.int_id AND
633 unread = true AND ref_id = ttrss_entries.id
634 AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name
636 select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid'
637 ORDER BY tag_name"); */
639 $result = db_query ( $link , "SELECT tag_name,SUM((SELECT COUNT(int_id)
640 FROM ttrss_user_entries WHERE int_id = post_int_id
641 AND unread = true)) AS count FROM ttrss_tags
642 WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name" );
646 while ( $line = db_fetch_assoc ( $result )) {
647 $tags [ $line [ "tag_name" ]] +
= $line [ "count" ];
650 foreach ( array_keys ( $tags ) as $tag ) {
652 $unread = $tags [ $tag ];
660 printFeedEntry ( $tag , $class , $tag , $unread , "images/tag.png" , $link );
666 if ( db_num_rows ( $result ) == 0 ) {
672 print "<li>No $what to display.</li>" ;
678 <script type="text/javascript">
680 function statechange() {
681 if (document.readyState == "interactive") init();
684 if (document.readyState) {
685 if (document.readyState == "interactive" || document.readyState == "complete") {
688 document.onreadystatechange = statechange;
691 </script></body></html>' ;
697 $subop = $_GET [ "subop" ];
699 if ( $subop == "setpref" ) {
706 $key = db_escape_string ( $_GET [ "key" ]);
707 $value = db_escape_string ( $_GET [ "value" ]);
709 set_pref ( $link , $key , $value );
711 print "<param-set key= \" $key\" value= \" $value\" />" ;
713 print "</rpc-reply>" ;
717 if ( $subop == "getLabelCounters" ) {
720 getLabelCounters ( $link );
722 getFeedCounter ( $link , $aid );
724 print "</rpc-reply>" ;
727 if ( $subop == "getFeedCounters" ) {
729 getFeedCounters ( $link );
730 print "</rpc-reply>" ;
733 if ( $subop == "getAllCounters" ) {
735 getAllCounters ( $link );
736 print "</rpc-reply>" ;
739 if ( $subop == "mark" ) {
740 $mark = $_GET [ "mark" ];
741 $id = db_escape_string ( $_GET [ "id" ]);
749 // FIXME this needs collision testing
751 $result = db_query ( $link , "UPDATE ttrss_user_entries SET marked = $mark
752 WHERE ref_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
755 if ( $subop == "updateFeed" ) {
756 $feed_id = db_escape_string ( $_GET [ "feed" ]);
758 $result = db_query ( $link ,
759 "SELECT feed_url FROM ttrss_feeds WHERE id = ' $feed_id '
760 AND owner_uid = " . $_SESSION [ "uid" ]);
762 if ( db_num_rows ( $result ) > 0 ) {
763 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
764 update_rss_feed ( $link , $feed_url , $feed_id );
768 getFeedCounter ( $link , $feed_id );
769 print "</rpc-reply>" ;
774 if ( $subop == "forceUpdateAllFeeds" ||
$subop == "updateAllFeeds" ) {
776 if ( ENABLE_UPDATE_DAEMON
) {
778 if ( $subop == "forceUpdateAllFeeds" ) {
780 $result = db_query ( $link , "SELECT count(id) AS cid FROM
781 ttrss_scheduled_updates WHERE feed_id IS NULL AND
782 owner_uid = " . $_SESSION [ "uid" ]);
784 $cid = db_fetch_result ( $result , 0 , "cid" );
786 # print "<rpc-reply>";
790 db_query ( $link , "INSERT INTO ttrss_scheduled_updates
791 (owner_uid, feed_id, entered) VALUES
792 (" . $_SESSION [ "uid" ]. ", NULL, NOW())" );
794 // print "<!-- ScheduledOK -->";
797 // print "<!-- RequestAlreadyInQueue -->";
800 # print "</rpc-reply>";
804 update_all_feeds ( $link , $subop == "forceUpdateAllFeeds" );
807 $global_unread_caller = sprintf ( " %d " , $_GET [ "uctr" ]);
808 $global_unread = getGlobalUnread ( $link );
812 if ( $global_unread_caller != $global_unread ) {
814 $omode = $_GET [ "omode" ];
816 if (! $omode ) $omode = "tflc" ;
818 if ( strchr ( $omode , "l" )) getLabelCounters ( $link );
819 if ( strchr ( $omode , "f" )) getFeedCounters ( $link );
820 if ( strchr ( $omode , "t" )) getTagCounters ( $link );
821 if ( strchr ( $omode , "c" )) {
822 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
823 getCategoryCounters ( $link );
828 getGlobalCounters ( $link , $global_unread );
830 print "</rpc-reply>" ;
834 /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
835 if ( $subop == "catchupSelected" ) {
837 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
839 $cmode = sprintf ( " %d " , $_GET [ "cmode" ]);
841 foreach ( $ids as $id ) {
844 db_query ( $link , "UPDATE ttrss_user_entries SET
845 unread = false,last_read = NOW()
846 WHERE ref_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
847 } else if ( $cmode == 1 ) {
848 db_query ( $link , "UPDATE ttrss_user_entries SET
850 WHERE ref_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
852 db_query ( $link , "UPDATE ttrss_user_entries SET
853 unread = NOT unread,last_read = NOW()
854 WHERE ref_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
858 getAllCounters ( $link );
859 print "</rpc-reply>" ;
862 if ( $subop == "markSelected" ) {
864 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
866 $cmode = sprintf ( " %d " , $_GET [ "cmode" ]);
868 foreach ( $ids as $id ) {
871 db_query ( $link , "UPDATE ttrss_user_entries SET
873 WHERE ref_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
874 } else if ( $cmode == 1 ) {
875 db_query ( $link , "UPDATE ttrss_user_entries SET
877 WHERE ref_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
879 db_query ( $link , "UPDATE ttrss_user_entries SET
881 WHERE ref_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
885 getAllCounters ( $link );
886 print "</rpc-reply>" ;
889 if ( $subop == "sanityCheck" ) {
890 if ( sanity_check ( $link )) {
891 print "<error error-code= \" 0 \" />" ;
895 if ( $subop == "globalPurge" ) {
898 global_purge_old_posts ( $link , true );
899 print "</rpc-reply>" ;
905 if ( $op == "feeds" ) {
907 $tags = $_GET [ "tags" ];
909 $subop = $_GET [ "subop" ];
911 if ( $subop == "catchupAll" ) {
912 db_query ( $link , "UPDATE ttrss_user_entries SET
913 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION [ "uid" ]);
916 if ( $subop == "collapse" ) {
917 $cat_id = db_escape_string ( $_GET [ "cid" ]);
919 db_query ( $link , "UPDATE ttrss_feed_categories SET
920 collapsed = NOT collapsed WHERE id = ' $cat_id ' AND owner_uid = " .
925 outputFeedList ( $link , $tags );
931 $id = db_escape_string ( $_GET [ "id" ]);
932 $feed_id = db_escape_string ( $_GET [ "feed" ]);
934 $result = db_query ( $link , "SELECT rtl_content FROM ttrss_feeds
935 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
937 if ( db_num_rows ( $result ) == 1 ) {
938 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
940 $rtl_content = false ;
944 $rtl_tag = "dir= \" RTL \" " ;
949 $result = db_query ( $link , "UPDATE ttrss_user_entries
950 SET unread = false,last_read = NOW()
951 WHERE ref_id = ' $id ' AND feed_id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
953 $result = db_query ( $link , "SELECT title,link,content,feed_id,comments,int_id,
954 SUBSTRING(updated,1,16) as updated,
955 (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
958 FROM ttrss_entries,ttrss_user_entries
959 WHERE id = ' $id ' AND ref_id = id" );
962 <title>Tiny Tiny RSS : Article $id </title>
963 <link rel= \" stylesheet \" href= \" tt-rss.css \" type= \" text/css \" >" ;
965 $user_theme = $_SESSION [ "theme" ];
967 print "<link rel= \" stylesheet \" type= \" text/css \"
968 href= \" themes/ $user_theme /theme.css \" >" ;
971 if ( get_pref ( $link , 'USE_COMPACT_STYLESHEET' )) {
972 print "<link rel= \" stylesheet \" type= \" text/css \"
973 href= \" tt-rss_compact.css \" />" ;
975 print "<link title= \" Compact Stylesheet \" rel= \" alternate stylesheet \"
976 type= \" text/css \" href= \" tt-rss_compact.css \" />" ;
979 print "<script type= \" text/javascript \" src= \" functions.js \" ></script>
980 <meta http-equiv= \" Content-Type \" content= \" text/html; charset=utf-8 \" >
981 </head><body $rtl_tag >" ;
985 $line = db_fetch_assoc ( $result );
987 if ( $line [ "icon_url" ]) {
988 $feed_icon = "<img class= \" feedIcon \" src= \" " . $line [ "icon_url" ] . " \" >" ;
990 $feed_icon = " " ;
993 /* if ($line["comments"] && $line["link"] != $line["comments"]) {
994 $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
996 $entry_comments = "";
999 $num_comments = $line [ "num_comments" ];
1000 $entry_comments = "" ;
1002 if ( $num_comments > 0 ) {
1003 if ( $line [ "comments" ]) {
1004 $comments_url = $line [ "comments" ];
1006 $comments_url = $line [ "link" ];
1008 $entry_comments = "<a href= \" $comments_url\" > $num_comments comments</a>" ;
1010 if ( $line [ "comments" ] && $line [ "link" ] != $line [ "comments" ]) {
1011 $entry_comments = "<a href= \" " . $line [ "comments" ]. " \" >comments</a>" ;
1015 print "<div class= \" postReply \" >" ;
1017 print "<div class= \" postHeader \" ><table width= \" 100% \" >" ;
1019 $entry_author = $line [ "author" ];
1021 if ( $entry_author ) {
1022 $entry_author = " - by $entry_author " ;
1025 print "<tr><td><a href= \" " . $line [ "link" ] . " \" >" . $line [ "title" ] .
1026 "</a> $entry_author </td>" ;
1028 $parsed_updated = date ( get_pref ( $link , 'LONG_DATE_FORMAT' ),
1029 strtotime ( $line [ "updated" ]));
1031 print "<td class= \" postDate \" > $parsed_updated </td>" ;
1035 $tmp_result = db_query ( $link , "SELECT DISTINCT tag_name FROM
1036 ttrss_tags WHERE post_int_id = " . $line [ "int_id" ] . "
1037 ORDER BY tag_name" );
1044 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
1046 $tag = $tmp_line [ "tag_name" ];
1047 $tag_str = "<a href= \" javascript:parent.viewfeed(' $tag ') \" > $tag </a>, " ;
1049 if ( $num_tags == 5 ) {
1050 $tags_str .= "<a href= \" javascript:showBlockElement('allEntryTags') \" >...</a>" ;
1051 } else if ( $num_tags < 5 ) {
1052 $tags_str .= $tag_str ;
1054 $f_tags_str .= $tag_str ;
1057 $tags_str = preg_replace ( "/, $/" , "" , $tags_str );
1058 $f_tags_str = preg_replace ( "/, $/" , "" , $f_tags_str );
1060 // $truncated_link = truncate_string($line["link"], 60);
1062 if ( $tags_str ||
$entry_comments ) {
1063 print "<tr><td width='50%'>
1064 $entry_comments </td>
1065 <td align= \" right \" > $tags_str </td></tr>" ;
1068 print "</table></div>" ;
1070 print "<div class= \" postIcon \" >" . $feed_icon . "</div>" ;
1071 print "<div class= \" postContent \" >" ;
1073 if ( db_num_rows ( $tmp_result ) > 5 ) {
1074 print "<div id= \" allEntryTags \" >Tags: $f_tags_str </div>" ;
1077 if ( get_pref ( $link , 'OPEN_LINKS_IN_NEW_WINDOW' )) {
1078 $line [ "content" ] = preg_replace ( "/href=/i" , "target= \" _new \" href=" , $line [ "content" ]);
1081 print $line [ "content" ] . "</div>" ;
1085 print "<script type= \" text/javascript \" >
1086 update_all_counters(' $feed_id ');
1090 print "</body></html>" ;
1093 if ( $op == "viewfeed" ) {
1095 $feed = $_GET [ "feed" ];
1096 $skip = $_GET [ "skip" ];
1097 $subop = $_GET [ "subop" ];
1098 $view_mode = $_GET [ "view" ];
1099 $limit = $_GET [ "limit" ];
1100 $cat_view = $_GET [ "cat" ];
1102 if (! $skip ) $skip = 0 ;
1104 if ( $subop == "undefined" ) $subop = "" ;
1107 <title>Tiny Tiny RSS : Feed $feed </title>
1108 <link rel= \" stylesheet \" href= \" tt-rss.css \" type= \" text/css \" >" ;
1110 $user_theme = $_SESSION [ "theme" ];
1112 print "<link rel= \" stylesheet \" type= \" text/css \"
1113 href= \" themes/ $user_theme /theme.css \" >" ;
1116 if ( get_pref ( $link , 'USE_COMPACT_STYLESHEET' )) {
1117 print "<link rel= \" stylesheet \"
1118 type= \" text/css \" href= \" tt-rss_compact.css \" />" ;
1121 print "<link title= \" Compact Stylesheet \" rel= \" alternate stylesheet \"
1122 type= \" text/css \" href= \" tt-rss_compact.css \" />" ;
1125 $result = db_query ( $link , "SELECT rtl_content FROM ttrss_feeds
1126 WHERE id = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1128 if ( db_num_rows ( $result ) == 1 ) {
1129 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
1131 $rtl_content = false ;
1135 $rtl_tag = "dir= \" RTL \" " ;
1140 print "<meta http-equiv= \" Content-Type \" content= \" text/html; charset=utf-8 \" >
1141 <script type= \" text/javascript \" src= \" functions.js \" ></script>
1142 <script type= \" text/javascript \" src= \" viewfeed.js \" ></script>
1143 <!--[if gte IE 5.5000]>
1144 <script type= \" text/javascript \" src= \" pngfix.js \" ></script>
1145 <link rel= \" stylesheet \" type= \" text/css \" href= \" tt-rss-ie.css \" >
1148 <script type= \" text/javascript \" >
1149 if (document.addEventListener) {
1150 document.addEventListener( \" DOMContentLoaded \" , init, null);
1152 window.onload = init;
1155 if ( $subop == "ForceUpdate" && sprintf ( " %d " , $feed ) > 0 ) {
1157 /* if (ENABLE_UPDATE_DAEMON) {
1161 db_query($link, "INSERT INTO ttrss_scheduled_updates
1162 (owner_uid, feed_id, entered) VALUES
1163 (".$_SESSION["uid"].", '$feed', NOW())");
1167 // fixme update_rss_feed...
1173 $cat_qpart = "cat_id = ' $feed '" ;
1175 $cat_qpart = "cat_id IS NULL" ;
1178 $tmp_result = db_query ( $link , "SELECT feed_url FROM ttrss_feeds
1179 WHERE $cat_qpart AND owner_uid = " . $_SESSION [ "uid" ]);
1181 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
1182 $feed_url = $tmp_line [ "feed_url" ];
1183 update_rss_feed ( $link , $feed_url , $feed , ENABLE_UPDATE_DAEMON
);
1187 $tmp_result = db_query ( $link , "SELECT feed_url FROM ttrss_feeds
1188 WHERE id = ' $feed '" );
1189 $feed_url = db_fetch_result ( $tmp_result , 0 , "feed_url" );
1190 update_rss_feed ( $link , $feed_url , $feed , ENABLE_UPDATE_DAEMON
);
1194 if ( $subop == "MarkAllRead" ) {
1196 if ( preg_match ( "/^[0-9][0-9]*$/" , $feed ) != false && $feed >= 0 ) {
1201 $cat_qpart = "cat_id = ' $feed '" ;
1203 $cat_qpart = "cat_id IS NULL" ;
1206 $tmp_result = db_query ( $link , "SELECT id
1207 FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = " .
1210 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
1212 $tmp_feed = $tmp_line [ "id" ];
1214 db_query ( $link , "UPDATE ttrss_user_entries
1215 SET unread = false,last_read = NOW()
1216 WHERE feed_id = ' $tmp_feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1219 } else if ( $feed > 0 ) {
1221 $tmp_result = db_query ( $link , "SELECT id
1222 FROM ttrss_feeds WHERE parent_feed = ' $feed '
1223 ORDER BY cat_id,title" );
1225 $parent_ids = array ();
1227 if ( db_num_rows ( $tmp_result ) > 0 ) {
1228 while ( $p = db_fetch_assoc ( $tmp_result )) {
1229 array_push ( $parent_ids , "feed_id = " . $p [ "id" ]);
1232 $children_qpart = implode ( " OR " , $parent_ids );
1234 db_query ( $link , "UPDATE ttrss_user_entries
1235 SET unread = false,last_read = NOW()
1236 WHERE (feed_id = ' $feed ' OR $children_qpart )
1237 AND owner_uid = " . $_SESSION [ "uid" ]);
1240 db_query ( $link , "UPDATE ttrss_user_entries
1241 SET unread = false,last_read = NOW()
1242 WHERE feed_id = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1245 } else if ( $feed < 0 && $feed > - 10 ) { // special, like starred
1248 db_query ( $link , "UPDATE ttrss_user_entries
1249 SET unread = false,last_read = NOW()
1250 WHERE marked = true AND owner_uid = " . $_SESSION [ "uid" ]);
1253 } else if ( $feed < - 10 ) { // label
1255 // TODO make this more efficient
1257 $label_id = - $feed - 11 ;
1259 $tmp_result = db_query ( $link , "SELECT sql_exp FROM ttrss_labels
1260 WHERE id = ' $label_id '" );
1263 $sql_exp = db_fetch_result ( $tmp_result , 0 , "sql_exp" );
1265 db_query ( $link , "BEGIN" );
1267 $tmp2_result = db_query ( $link ,
1271 ttrss_user_entries,ttrss_entries
1275 owner_uid = " . $_SESSION [ "uid" ]);
1277 while ( $tmp_line = db_fetch_assoc ( $tmp2_result )) {
1278 db_query ( $link , "UPDATE
1281 unread = false, last_read = NOW()
1283 int_id = " . $tmp_line [ "int_id" ]);
1286 db_query ( $link , "COMMIT" );
1288 /* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries
1289 SET unread = false,last_read = NOW()
1292 AND owner_uid = ".$_SESSION["uid"]); */
1296 db_query ( $link , "BEGIN" );
1298 $tag_name = db_escape_string ( $feed );
1300 $result = db_query ( $link , "SELECT post_int_id FROM ttrss_tags
1301 WHERE tag_name = ' $tag_name ' AND owner_uid = " . $_SESSION [ "uid" ]);
1303 while ( $line = db_fetch_assoc ( $result )) {
1304 db_query ( $link , "UPDATE ttrss_user_entries SET
1305 unread = false, last_read = NOW()
1306 WHERE int_id = " . $line [ "post_int_id" ]);
1308 db_query ( $link , "COMMIT" );
1313 $search = db_escape_string ( $_GET [ "search" ]);
1314 $search_mode = db_escape_string ( $_GET [ "smode" ]);
1317 $search_query_part = "(upper(ttrss_entries.title) LIKE upper('% $search %')
1318 OR ttrss_entries.content LIKE '% $search %') AND" ;
1320 $search_query_part = "" ;
1323 $view_query_part = "" ;
1325 if ( $view_mode == "Adaptive" ) {
1327 $view_query_part = " " ;
1328 } else if ( $feed != - 1 ) {
1329 $unread = getFeedUnread ( $link , $feed );
1331 $view_query_part = " unread = true AND " ;
1336 if ( $view_mode == "Starred" ) {
1337 $view_query_part = " marked = true AND " ;
1340 if ( $view_mode == "Unread" ) {
1341 $view_query_part = " unread = true AND " ;
1344 if ( $limit && $limit != "All" ) {
1345 $limit_query_part = "LIMIT " . $limit ;
1348 $vfeed_query_part = "" ;
1350 // override query strategy and enable feed display when searching globally
1351 if ( $search && $search_mode == "All feeds" ) {
1352 $query_strategy_part = "ttrss_entries.id > 0" ;
1353 $vfeed_query_part = "ttrss_feeds.title AS feed_title," ;
1354 } else if ( preg_match ( "/^-?[0-9][0-9]*$/" , $feed ) == false ) {
1355 $query_strategy_part = "ttrss_entries.id > 0" ;
1356 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
1357 id = feed_id) as feed_title," ;
1358 } else if ( $feed >= 0 && $search && $search_mode == "This category" ) {
1360 $vfeed_query_part = "ttrss_feeds.title AS feed_title," ;
1362 $tmp_result = db_query ( $link , "SELECT id
1363 FROM ttrss_feeds WHERE cat_id =
1364 (SELECT cat_id FROM ttrss_feeds WHERE id = ' $feed ') AND id != ' $feed '" );
1366 $cat_siblings = array ();
1368 if ( db_num_rows ( $tmp_result ) > 0 ) {
1369 while ( $p = db_fetch_assoc ( $tmp_result )) {
1370 array_push ( $cat_siblings , "feed_id = " . $p [ "id" ]);
1373 $query_strategy_part = sprintf ( "(feed_id = %d OR %s )" ,
1374 $feed , implode ( " OR " , $cat_siblings ));
1377 $query_strategy_part = "ttrss_entries.id > 0" ;
1380 } else if ( $feed >= 0 ) {
1385 $query_strategy_part = "cat_id = ' $feed '" ;
1387 $query_strategy_part = "cat_id IS NULL" ;
1390 $vfeed_query_part = "ttrss_feeds.title AS feed_title," ;
1393 $tmp_result = db_query ( $link , "SELECT id
1394 FROM ttrss_feeds WHERE parent_feed = ' $feed '
1395 ORDER BY cat_id,title" );
1397 $parent_ids = array ();
1399 if ( db_num_rows ( $tmp_result ) > 0 ) {
1400 while ( $p = db_fetch_assoc ( $tmp_result )) {
1401 array_push ( $parent_ids , "feed_id = " . $p [ "id" ]);
1404 $query_strategy_part = sprintf ( "(feed_id = %d OR %s )" ,
1405 $feed , implode ( " OR " , $parent_ids ));
1407 $vfeed_query_part = "ttrss_feeds.title AS feed_title," ;
1409 $query_strategy_part = "feed_id = ' $feed '" ;
1412 } else if ( $feed == - 1 ) { // starred virtual feed
1413 $query_strategy_part = "marked = true" ;
1414 $vfeed_query_part = "ttrss_feeds.title AS feed_title," ;
1415 } else if ( $feed <= - 10 ) { // labels
1416 $label_id = - $feed - 11 ;
1418 $tmp_result = db_query ( $link , "SELECT sql_exp FROM ttrss_labels
1419 WHERE id = ' $label_id '" );
1421 $query_strategy_part = db_fetch_result ( $tmp_result , 0 , "sql_exp" );
1423 $vfeed_query_part = "ttrss_feeds.title AS feed_title," ;
1425 $query_strategy_part = "id > 0" ; // dumb
1428 $order_by = "updated DESC" ;
1430 // if ($feed < -10) {
1431 // $order_by = "feed_id,updated DESC";
1436 if ( $search && $search_mode == "All feeds" ) {
1437 $feed_title = "Global search results ( $search )" ;
1438 } else if ( $search && preg_match ( '/^-?[0-9][0-9]*$/' , $feed ) == false ) {
1439 $feed_title = "Feed search results ( $search , $feed )" ;
1440 } else if ( preg_match ( '/^-?[0-9][0-9]*$/' , $feed ) == false ) {
1441 $feed_title = $feed ;
1442 } else if ( preg_match ( '/^-?[0-9][0-9]*$/' , $feed ) != false && $feed >= 0 ) {
1447 $result = db_query ( $link , "SELECT title FROM ttrss_feed_categories
1448 WHERE id = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1449 $feed_title = db_fetch_result ( $result , 0 , "title" );
1451 $feed_title = "Uncategorized" ;
1455 $result = db_query ( $link , "SELECT title,site_url,last_error FROM ttrss_feeds
1456 WHERE id = ' $feed ' AND owner_uid = " . $_SESSION [ "uid" ]);
1458 $feed_title = db_fetch_result ( $result , 0 , "title" );
1459 $feed_site_url = db_fetch_result ( $result , 0 , "site_url" );
1460 $last_error = db_fetch_result ( $result , 0 , "last_error" );
1464 } else if ( $feed == - 1 ) {
1465 $feed_title = "Starred articles" ;
1466 } else if ( $feed < - 10 ) {
1467 $label_id = - $feed - 11 ;
1468 $result = db_query ( $link , "SELECT description FROM ttrss_labels
1469 WHERE id = ' $label_id '" );
1470 $feed_title = db_fetch_result ( $result , 0 , "description" );
1475 if ( $feed < - 10 ) error_reporting ( 0 );
1477 print "<div id= \" headlinesContainer \" >" ;
1479 if ( preg_match ( "/^-?[0-9][0-9]*$/" , $feed ) != false ) {
1482 $feed_kind = "Feeds" ;
1484 $feed_kind = "Labels" ;
1487 // if (!$vfeed_query_part) {
1488 $content_query_part = "content as content_preview," ;
1490 // $content_query_part = "";
1494 ttrss_entries.id,ttrss_entries.title,
1495 SUBSTRING(updated,1,16) as updated,
1496 unread,feed_id,marked,link,last_read,
1497 SUBSTRING(last_read,1,19) as last_read_noms,
1500 SUBSTRING(updated,1,19) as updated_noms
1502 ttrss_entries,ttrss_user_entries,ttrss_feeds
1504 ttrss_user_entries.feed_id = ttrss_feeds.id AND
1505 ttrss_user_entries.ref_id = ttrss_entries.id AND
1506 ttrss_user_entries.owner_uid = '" . $_SESSION [ "uid" ]. "' AND
1509 $query_strategy_part ORDER BY $order_by
1512 $result = db_query ( $link , $query );
1514 if ( $_GET [ "debug" ]) print $query ;
1519 $feed_kind = "Tags" ;
1521 $result = db_query ( $link , "SELECT
1522 ttrss_entries.id as id,title,
1523 SUBSTRING(updated,1,16) as updated,
1525 marked,link,last_read,
1526 SUBSTRING(last_read,1,19) as last_read_noms,
1529 SUBSTRING(updated,1,19) as updated_noms
1531 ttrss_entries,ttrss_user_entries,ttrss_tags
1533 ref_id = ttrss_entries.id AND
1534 ttrss_user_entries.owner_uid = '" . $_SESSION [ "uid" ]. "' AND
1535 post_int_id = int_id AND tag_name = ' $feed ' AND
1538 $query_strategy_part ORDER BY $order_by
1539 $limit_query_part " );
1543 print "<div align='center'>
1544 Could not display feed (query failed). Please check label match syntax or local configuration.</div>" ;
1548 function print_headline_subtoolbar ( $link , $feed_site_url , $feed_title ,
1552 $class = "headlinesSubToolbar" ;
1553 $tid = "headlineActionsTop" ;
1555 $class = "invisible" ;
1556 $tid = "headlineActionsBottom" ;
1559 print "<table class= \" $class\" id= \" $tid\"
1560 width= \" 100% \" cellspacing= \" 0 \" cellpadding= \" 0 \" ><tr>" ;
1562 if (! get_pref ( $link , 'COMBINED_DISPLAY_MODE' )) {
1564 print "<td class= \" headlineActions \" >
1566 <a href='#' onclick= \" javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, '', true) \" >All</a>,
1567 <a href='#' onclick= \" javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true) \" >Unread</a>,
1568 <a href='#' onclick= \" javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false) \" >None</a>
1570 Toggle: <a href='#' onclick= \" javascript:selectionToggleUnread() \" >Unread</a>,
1571 <a href='#' onclick= \" javascript:selectionToggleMarked() \" >Starred</a>" ;
1576 print "<td class= \" headlineActions \" >
1578 <a href= \" # \" onclick= \" javascript:cdmSelectArticles('all') \" >All</a>,
1579 <a href= \" # \" onclick= \" javascript:cdmSelectArticles('unread') \" >Unread</a>,
1580 <a href= \" # \" onclick= \" javascript:cdmSelectArticles('none') \" >None</a>
1582 Toggle: <a href= \" # \" onclick= \" javascript:selectionToggleUnread(true) \" >Unread</a>,
1583 <a href= \" # \" onclick= \" javascript:selectionToggleMarked(true) \" >Starred</a>" ;
1590 print "<td align='center' class='small'>
1591 <a class= \" warning \" href= \" javascript:alert('TT-RSS encountered an error while trying to update this feed. \\ n \\ n $last_error ') \" >Could not update this feed.</a></td>" ;
1594 print "<td class= \" headlineTitle \" >" ;
1596 if ( $feed_site_url ) {
1598 $target = "target= \" _blank \" " ;
1600 print "<a $target href= \" $feed_site_url\" > $feed_title </a>" ;
1606 print "</tr></table>" ;
1610 if ( db_num_rows ( $result ) > 0 ) {
1612 print_headline_subtoolbar ( $link , $feed_site_url , $feed_title );
1614 if (! get_pref ( $link , 'COMBINED_DISPLAY_MODE' )) {
1615 print "<table class= \" headlinesList \" id= \" headlinesList \"
1616 cellspacing= \" 0 \" width= \" 100% \" $rtl_tag >" ;
1621 error_reporting ( DEFAULT_ERROR_LEVEL
);
1625 while ( $line = db_fetch_assoc ( $result )) {
1627 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
1630 $feed_id = $line [ "feed_id" ];
1632 if ( $line [ "last_read" ] == "" &&
1633 ( $line [ "unread" ] != "t" && $line [ "unread" ] != "1" )) {
1635 $update_pic = "<img id='FUPDPIC- $id ' src= \" images/updated.png \"
1638 $update_pic = "<img id='FUPDPIC- $id ' src= \" images/blank_icon.gif \"
1642 if ( $line [ "unread" ] == "t" ||
$line [ "unread" ] == "1" ) {
1650 if ( $line [ "marked" ] == "t" ||
$line [ "marked" ] == "1" ) {
1651 $marked_pic = "<img id= \" FMARKPIC- $id\" src= \" images/mark_set.png \"
1652 alt= \" Reset mark \" onclick='javascript:toggleMark( $id )'>" ;
1654 $marked_pic = "<img id= \" FMARKPIC- $id\" src= \" images/mark_unset.png \"
1655 alt= \" Set mark \" onclick='javascript:toggleMark( $id )'>" ;
1658 $content_link = "<a href= \" javascript:view( $id , $feed_id ); \" >" .
1659 $line [ "title" ] . "</a>" ;
1661 if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
1662 $updated_fmt = smart_date_time ( strtotime ( $line [ "updated" ]));
1664 $short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
1665 $updated_fmt = date ( $short_date , strtotime ( $line [ "updated" ]));
1668 if ( get_pref ( $link , 'SHOW_CONTENT_PREVIEW' )) {
1669 $content_preview = truncate_string ( strip_tags ( $line [ "content_preview" ]),
1673 if (! get_pref ( $link , 'COMBINED_DISPLAY_MODE' )) {
1675 print "<tr class=' $class ' id='RROW- $id '>" ;
1677 print "<td class='hlUpdatePic'> $update_pic </td>" ;
1679 print "<td class='hlSelectRow'>
1680 <input type= \" checkbox \" onclick= \" toggleSelectRow(this) \"
1681 class= \" feedCheckBox \" id= \" RCHK- $id\" >
1684 print "<td class='hlMarkedPic'> $marked_pic </td>" ;
1686 if ( $line [ "feed_title" ]) {
1687 print "<td class='hlContent'> $content_link </td>" ;
1688 print "<td class='hlFeed'>
1689 <a href='javascript:viewfeed( $feed_id )'>" .
1690 $line [ "feed_title" ]. "</a> </td>" ;
1692 print "<td class='hlContent' valign='middle'>" ;
1694 print "<a href= \" javascript:view( $id , $feed_id ); \" >" .
1697 if ( get_pref ( $link , 'SHOW_CONTENT_PREVIEW' ) && ! $rtl_tag ) {
1698 if ( $content_preview ) {
1699 print "<span class= \" contentPreview \" > - $content_preview </span>" ;
1707 print "<td class= \" hlUpdated \" ><nobr> $updated_fmt </nobr></td>" ;
1714 $add_class = "Unread" ;
1719 print "<div class= \" cdmArticle $add_class\" id= \" RROW- $id\" >" ;
1721 print "<div class= \" cdmHeader \" >" ;
1723 print "<div style= \" float : right \" > $updated_fmt </div>" ;
1725 print "<a target= \" new \" href= \" " . $line [ "link" ]. " \" >" . $line [ "title" ]. "</a>" ;
1727 if ( $line [ "feed_title" ]) {
1728 print " (<a href='javascript:viewfeed( $feed_id )'>" . $line [ "feed_title" ]. "</a>)" ;
1733 print "<div class= \" cdmContent \" >" . $line [ "content_preview" ] . "</div>" ;
1735 print "<div style= \" float : right \" > $marked_pic </div>
1736 <div class= \" cdmFooter \" >
1737 <input type= \" checkbox \" onclick= \" toggleSelectRowById(this,
1738 'RROW- $id ') \" class= \" feedCheckBox \" id= \" RCHK- $id\" ></div>" ;
1747 if (! get_pref ( $link , 'COMBINED_DISPLAY_MODE' )) {
1751 print_headline_subtoolbar ( $link ,
1752 "javascript:catchupPage()" , "Mark page as read" , true );
1756 print "<div width='100%' align='center'>No articles found.</div>" ;
1761 print "<script type= \" text/javascript \" >
1762 document.onkeydown = hotkey_handler;
1763 // if (parent.daemon_enabled) parent.updateTitle(' $feed_title ');
1764 update_all_counters(' $feed ');
1768 <script type="text/javascript">
1770 function statechange() {
1771 if (document.readyState == "interactive") init();
1774 if (document.readyState) {
1775 if (document.readyState == "interactive" || document.readyState == "complete") {
1778 document.onreadystatechange = statechange;
1783 print "</body></html>" ;
1786 if ( $op == "pref-rpc" ) {
1788 $subop = $_GET [ "subop" ];
1790 if ( $subop == "unread" ) {
1791 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
1792 foreach ( $ids as $id ) {
1793 db_query ( $link , "UPDATE ttrss_user_entries SET unread = true
1794 WHERE feed_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1797 print "Marked selected feeds as unread." ;
1800 if ( $subop == "read" ) {
1801 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
1802 foreach ( $ids as $id ) {
1803 db_query ( $link , "UPDATE ttrss_user_entries
1804 SET unread = false,last_read = NOW() WHERE
1805 feed_id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
1808 print "Marked selected feeds as read." ;
1814 if ( $op == "pref-feeds" ) {
1816 $subop = $_REQUEST [ "subop" ];
1817 $quiet = $_REQUEST [ "quiet" ];
1819 if ( $subop == "massSubscribe" ) {
1820 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
1822 $subscribed = array ();
1824 foreach ( $ids as $id ) {
1825 $result = db_query ( $link , "SELECT feed_url,title FROM ttrss_feeds
1828 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
1829 $title = db_fetch_result ( $result , 0 , "title" );
1831 $result = db_query ( $link , "SELECT id FROM ttrss_feeds WHERE
1832 feed_url = ' $feed_url ' AND owner_uid = " . $_SESSION [ "uid" ]);
1834 if ( db_num_rows ( $result ) == 0 ) {
1835 $result = db_query ( $link ,
1836 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
1837 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed_url ', ' $title ', NULL)" );
1839 array_push ( $subscribed , $title );
1843 if ( count ( $subscribed ) > 0 ) {
1844 print "<div class= \" notice \" >" ;
1845 print "<b>Subscribed to feeds:</b>" ;
1846 print "<ul class= \" nomarks \" >" ;
1847 foreach ( $subscribed as $title ) {
1848 print "<li> $title </li>" ;
1855 if ( $subop == "browse" ) {
1857 if (! ENABLE_FEED_BROWSER
) {
1858 print "Feed browser is administratively disabled." ;
1862 print "<div class= \" infoBoxContents \" >" ;
1864 print "<h1>Feed browser</h1>" ;
1866 print "<p>Showing top 50 registered feeds, sorted by popularity:</p>" ;
1868 $result = db_query ( $link , "SELECT feed_url,count(id) AS subscribers
1870 WHERE auth_login = '' AND auth_pass = '' AND private = false
1871 GROUP BY feed_url ORDER BY subscribers DESC LIMIT 50" );
1873 print "<ul class='browseFeedList' id='browseFeedList'>" ;
1877 while ( $line = db_fetch_assoc ( $result )) {
1878 $feed_url = $line [ "feed_url" ];
1879 $subscribers = $line [ "subscribers" ];
1881 $sub_result = db_query ( $link , "SELECT id
1882 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' AND owner_uid =" .
1885 if ( db_num_rows ( $sub_result ) > 0 ) {
1886 continue ; // already subscribed
1889 $det_result = db_query ( $link , "SELECT site_url,title,id
1890 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
1892 $details = db_fetch_assoc ( $det_result );
1894 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
1896 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1897 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
1898 "/" . $details [ "id" ]. ".ico \" >" ;
1900 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
1903 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1904 type= \" checkbox \" id= \" FBCHK-" . $details [ "id" ] . " \" >" ;
1906 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
1908 print "<li class=' $class ' id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
1909 " $feed_icon " . db_unescape_string ( $details [ "title" ]) .
1910 " <span class='subscribers'>( $subscribers )</span></li>" ;
1915 if ( $feedctr == 0 ) {
1916 print "<li>No feeds found to subscribe.</li>" ;
1921 print "<div align='center'>
1922 <input type= \" submit \" class= \" button \"
1923 onclick= \" feedBrowserSubscribe() \" value= \" Subscribe \" >
1924 <input type='submit' class='button'
1925 onclick= \" closeInfoBox() \" value= \" Cancel \" ></div>" ;
1931 if ( $subop == "editfeed" ) {
1932 $feed_id = db_escape_string ( $_GET [ "id" ]);
1934 $result = db_query ( $link ,
1935 "SELECT * FROM ttrss_feeds WHERE id = ' $feed_id ' AND
1936 owner_uid = " . $_SESSION [ "uid" ]);
1938 $title = htmlspecialchars ( db_unescape_string ( db_fetch_result ( $result ,
1941 print "<div class= \" infoBoxContents \" >" ;
1943 $icon_file = ICONS_DIR
. "/ $feed_id .ico" ;
1945 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
1946 $feed_icon = "<img width= \" 16 \" height= \" 16 \"
1947 src= \" " . ICONS_URL
. "/ $feed_id .ico \" >" ;
1952 print "<h1> $feed_icon $title </h1>" ;
1954 print "<table width='100%'>" ;
1958 print "<tr class=' $row_class '><td>Title:</td>" ;
1959 print "<td><input id= \" iedit_title \" value= \" $title\" ></td></tr>" ;
1961 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
1962 $feed_url = htmlspecialchars ( db_unescape_string ( db_fetch_result ( $result ,
1964 $row_class = toggleEvenOdd ( $row_class );
1966 print "<tr class=' $row_class '><td>Feed URL:</td>" ;
1967 print "<td><input id= \" iedit_link \" value= \" $feed_url\" ></td></tr>" ;
1969 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
1971 $cat_id = db_fetch_result ( $result , 0 , "cat_id" );
1973 $row_class = toggleEvenOdd ( $row_class );
1975 print "<tr class=' $row_class '><td>Category:</td>" ;
1977 print "<select id= \" iedit_fcat \" >" ;
1978 print "<option id= \" 0 \" >Uncategorized</option>" ;
1980 $tmp_result = db_query ( $link , "SELECT id,title FROM ttrss_feed_categories
1981 WHERE owner_uid = " . $_SESSION [ "uid" ]. " ORDER BY title" );
1983 if ( db_num_rows ( $tmp_result ) > 0 ) {
1984 print "<option disabled>--------</option>" ;
1987 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
1988 if ( $tmp_line [ "id" ] == $cat_id ) {
1989 $is_selected = "selected" ;
1993 printf ( "<option $is_selected id=' %d '> %s </option>" ,
1994 $tmp_line [ "id" ], $tmp_line [ "title" ]);
1997 print "</select></td>" ;
2002 $update_interval = db_fetch_result ( $result , 0 , "update_interval" );
2003 $row_class = toggleEvenOdd ( $row_class );
2005 print "<tr class=' $row_class '><td>Update Interval:</td>" ;
2006 // print "<td><input id=\"iedit_updintl\"
2007 // value=\"$update_interval\"></td></tr>";
2011 print "<select id= \" iedit_updintl \" >" ;
2013 foreach ( array_keys ( $update_intervals ) as $i ) {
2015 if ( $i == $update_interval ) {
2016 $selected = "selected" ;
2020 print "<option $selected id= \" $i\" >" . $update_intervals [ $i ] . "</option>" ;
2027 $row_class = toggleEvenOdd ( $row_class );
2028 print "<tr class=' $row_class '><td>Link to:</td>" ;
2030 $tmp_result = db_query ( $link , "SELECT COUNT(id) AS count
2031 FROM ttrss_feeds WHERE parent_feed = ' $feed_id '" );
2033 $linked_count = db_fetch_result ( $tmp_result , 0 , "count" );
2035 $parent_feed = db_fetch_result ( $result , 0 , "parent_feed" );
2037 if ( $linked_count > 0 ) {
2038 $disabled = "disabled" ;
2041 print "<select $disabled id= \" iedit_parent_feed \" >" ;
2043 print "<option id= \" 0 \" >Not linked</option>" ;
2045 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
2047 $cat_qpart = "AND cat_id = ' $cat_id '" ;
2049 $cat_qpart = "AND cat_id IS NULL" ;
2053 $tmp_result = db_query ( $link , "SELECT id,title FROM ttrss_feeds
2054 WHERE id != ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]. "
2055 $cat_qpart ORDER BY title" );
2057 if ( db_num_rows ( $tmp_result ) > 0 ) {
2058 print "<option disabled>--------</option>" ;
2061 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
2062 if ( $tmp_line [ "id" ] == $parent_feed ) {
2063 $is_selected = "selected" ;
2067 printf ( "<option $is_selected id=' %d '> %s </option>" ,
2068 $tmp_line [ "id" ], $tmp_line [ "title" ]);
2071 print "</select></td>" ;
2074 $purge_interval = db_fetch_result ( $result , 0 , "purge_interval" );
2075 $row_class = toggleEvenOdd ( $row_class );
2077 print "<tr class=' $row_class '><td>Purge Days:</td>" ;
2078 // print "<td><input id=\"iedit_purgintl\"
2079 // value=\"$purge_interval\"></td></tr>";
2083 print "<select id= \" iedit_purgintl \" >" ;
2085 foreach ( array_keys ( $purge_intervals ) as $i ) {
2087 if ( $i == $purge_interval ) {
2088 $selected = "selected" ;
2092 print "<option $selected id= \" $i\" >" . $purge_intervals [ $i ] . "</option>" ;
2099 // print "<tr><td colspan=\"2\"><b>Authentication</b></td></tr>";
2101 $row_class = toggleEvenOdd ( $row_class );
2102 $auth_login = db_fetch_result ( $result , 0 , "auth_login" );
2104 print "<tr class=' $row_class '><td>Login:</td>" ;
2105 print "<td><input id= \" iedit_login \"
2106 value= \" $auth_login\" ></td></tr>" ;
2108 $row_class = toggleEvenOdd ( $row_class );
2109 $auth_pass = db_fetch_result ( $result , 0 , "auth_pass" );
2111 print "<tr class=' $row_class '><td>Password:</td>" ;
2112 print "<td><input type= \" password \" id= \" iedit_pass \"
2113 value= \" $auth_pass\" ></td></tr>" ;
2115 $row_class = toggleEvenOdd ( $row_class );
2116 $private = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "private" ));
2119 $checked = "checked" ;
2124 print "<tr class=' $row_class '><td valign='top'>Options:</td>" ;
2125 print "<td><input type= \" checkbox \" id= \" iedit_private \"
2126 $checked ><label for= \" iedit_private \" >Hide from feed browser</label>" ;
2128 $rtl_content = sql_bool_to_bool ( db_fetch_result ( $result , 0 , "rtl_content" ));
2131 $checked = "checked" ;
2136 print "<br><input type= \" checkbox \" id= \" iedit_rtl \"
2137 $checked ><label for= \" iedit_rtl \" >Right-to-left content</label>" ;
2144 print "<div align='center'>
2145 <input type= \" submit \" class= \" button \"
2146 onclick= \" feedEditSave() \" value= \" Save \" >
2147 <input type='submit' class='button'
2148 onclick= \" feedEditCancel() \" value= \" Cancel \" ></div>" ;
2152 if ( $subop == "editSave" ) {
2153 $feed_title = db_escape_string ( $_POST [ "t" ]);
2154 $feed_link = db_escape_string ( $_POST [ "l" ]);
2155 $upd_intl = db_escape_string ( $_POST [ "ui" ]);
2156 $purge_intl = db_escape_string ( $_POST [ "pi" ]);
2157 $feed_id = db_escape_string ( $_POST [ "id" ]);
2158 $cat_id = db_escape_string ( $_POST [ "catid" ]);
2159 $auth_login = db_escape_string ( $_POST [ "login" ]);
2160 $auth_pass = db_escape_string ( $_POST [ "pass" ]);
2161 $parent_feed = db_escape_string ( $_POST [ "pfeed" ]);
2162 $private = db_escape_string ( $_POST [ "is_pvt" ]);
2163 $rtl_content = db_escape_string ( $_POST [ "is_rtl" ]);
2165 if ( strtoupper ( $upd_intl ) == "DEFAULT" )
2168 if ( strtoupper ( $upd_intl ) == "DISABLED" )
2171 if ( strtoupper ( $purge_intl ) == "DEFAULT" )
2174 if ( strtoupper ( $purge_intl ) == "DISABLED" )
2178 $category_qpart = "cat_id = ' $cat_id '" ;
2180 $category_qpart = 'cat_id = NULL' ;
2183 if ( $parent_feed != 0 ) {
2184 $parent_qpart = "parent_feed = ' $parent_feed '" ;
2186 $parent_qpart = 'parent_feed = NULL' ;
2189 $result = db_query ( $link , "UPDATE ttrss_feeds SET
2192 title = ' $feed_title ', feed_url = ' $feed_link ',
2193 update_interval = ' $upd_intl ',
2194 purge_interval = ' $purge_intl ',
2195 auth_login = ' $auth_login ',
2196 auth_pass = ' $auth_pass ',
2198 rtl_content = $rtl_content
2199 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
2202 if ( $subop == "saveCat" ) {
2203 $cat_title = db_escape_string ( $_GET [ "title" ]);
2204 $cat_id = db_escape_string ( $_GET [ "id" ]);
2206 $result = db_query ( $link , "UPDATE ttrss_feed_categories SET
2207 title = ' $cat_title ' WHERE id = ' $cat_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
2211 if ( $subop == "remove" ) {
2213 if (! WEB_DEMO_MODE
) {
2215 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
2217 foreach ( $ids as $id ) {
2218 db_query ( $link , "DELETE FROM ttrss_feeds
2219 WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
2221 $icons_dir = ICONS_DIR
;
2223 if ( file_exists ( $icons_dir . "/ $id .ico" )) {
2224 unlink ( $icons_dir . "/ $id .ico" );
2230 if ( $subop == "add" ) {
2232 if (! WEB_DEMO_MODE
) {
2234 $feed_link = db_escape_string ( trim ( $_GET [ "link" ]));
2235 $cat_id = db_escape_string ( $_GET [ "cid" ]);
2237 if ( $cat_id == "0" ||
! $cat_id ) {
2238 $cat_qpart = "NULL" ;
2240 $cat_qpart = "' $cat_id '" ;
2243 $result = db_query ( $link ,
2244 "SELECT id FROM ttrss_feeds
2245 WHERE feed_url = ' $feed_link ' AND owner_uid = " . $_SESSION [ "uid" ]);
2247 if ( db_num_rows ( $result ) == 0 ) {
2249 $result = db_query ( $link ,
2250 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
2251 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed_link ',
2252 '[Unknown]', $cat_qpart )" );
2254 $result = db_query ( $link ,
2255 "SELECT id FROM ttrss_feeds WHERE feed_url = ' $feed_link '
2256 AND owner_uid = " . $_SESSION [ "uid" ]);
2258 $feed_id = db_fetch_result ( $result , 0 , "id" );
2261 update_rss_feed ( $link , $feed_link , $feed_id , true );
2265 print "<div class= \" warning \" >
2266 Feed <b> $feed_link </b> already exists in the database.
2272 if ( $subop == "addCat" ) {
2274 if (! WEB_DEMO_MODE
) {
2276 $feed_cat = db_escape_string ( trim ( $_GET [ "cat" ]));
2278 $result = db_query ( $link ,
2279 "SELECT id FROM ttrss_feed_categories
2280 WHERE title = ' $feed_cat ' AND owner_uid = " . $_SESSION [ "uid" ]);
2282 if ( db_num_rows ( $result ) == 0 ) {
2284 $result = db_query ( $link ,
2285 "INSERT INTO ttrss_feed_categories (owner_uid,title)
2286 VALUES ('" . $_SESSION [ "uid" ]. "', ' $feed_cat ')" );
2290 print "<div class= \" warning \" >
2291 Category <b> $feed_cat </b> already exists in the database.
2299 if ( $subop == "removeCats" ) {
2301 if (! WEB_DEMO_MODE
) {
2303 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
2305 foreach ( $ids as $id ) {
2307 db_query ( $link , "BEGIN" );
2309 $result = db_query ( $link ,
2310 "SELECT count(id) as num_feeds FROM ttrss_feeds
2311 WHERE cat_id = ' $id '" );
2313 $num_feeds = db_fetch_result ( $result , 0 , "num_feeds" );
2315 if ( $num_feeds == 0 ) {
2316 db_query ( $link , "DELETE FROM ttrss_feed_categories
2317 WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
2320 print "<div class= \" warning \" >
2321 Unable to delete non empty feed categories.</div>" ;
2325 db_query ( $link , "COMMIT" );
2330 if ( $subop == "categorize" ) {
2332 if (! WEB_DEMO_MODE
) {
2334 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
2336 $cat_id = db_escape_string ( $_GET [ "cat_id" ]);
2339 $cat_id_qpart = 'NULL' ;
2341 $cat_id_qpart = "' $cat_id '" ;
2344 db_query ( $link , "BEGIN" );
2346 foreach ( $ids as $id ) {
2348 db_query ( $link , "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
2349 WHERE id = ' $id ' AND owner_uid = " . $_SESSION [ "uid" ]);
2352 db_query ( $link , "COMMIT" );
2359 // print "<h3>Edit Feeds</h3>";
2361 $result = db_query ( $link , "SELECT id,title,feed_url,last_error
2362 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION [ "uid" ]);
2364 if ( db_num_rows ( $result ) > 0 ) {
2366 print "<div class= \" warning \" >" ;
2368 // print"<img class=\"closeButton\"
2369 // onclick=\"javascript:hideParentElement(this);\" src=\"images/close.png\">";
2371 print "<a href= \" javascript:showBlockElement('feedUpdateErrors') \" >
2372 <b>Feeds with update errors</b> (click to expand)</a>" ;
2374 print "<ul id= \" feedUpdateErrors \" class= \" nomarks \" >" ;
2376 while ( $line = db_fetch_assoc ( $result )) {
2377 print "<li>" . $line [ "title" ] . " (" . $line [ "feed_url" ] . "): " .
2378 $line [ "last_error" ];
2386 $feed_search = db_escape_string ( $_GET [ "search" ]);
2388 if ( array_key_exists ( "search" , $_GET )) {
2389 $_SESSION [ "prefs_feed_search" ] = $feed_search ;
2391 $feed_search = $_SESSION [ "prefs_feed_search" ];
2394 print "<table width='100%' class= \" prefGenericAddBox \"
2395 cellspacing='0' cellpadding='0'><tr>
2397 <input id= \" fadd_link \"
2398 onchange= \" javascript:addFeed() \"
2400 <input type= \" submit \" class= \" button \"
2401 onclick= \" javascript:addFeed() \" value= \" Add feed \" >" ;
2403 if ( ENABLE_FEED_BROWSER
) {
2404 print " (<a href='javascript:browseFeeds()'>Top 50</a>)" ;
2407 print "</td><td align='right'>
2408 <input id= \" feed_search \" size= \" 20 \"
2409 onchange= \" javascript:updateFeedList() \"
2410 value= \" $feed_search\" >
2411 <input type= \" submit \" class= \" button \"
2412 onclick= \" javascript:updateFeedList() \" value= \" Search \" >
2416 $feeds_sort = db_escape_string ( $_GET [ "sort" ]);
2418 if (! $feeds_sort ||
$feeds_sort == "undefined" ) {
2419 $feeds_sort = $_SESSION [ "pref_sort_feeds" ];
2420 if (! $feeds_sort ) $feeds_sort = "title" ;
2423 $_SESSION [ "pref_sort_feeds" ] = $feeds_sort ;
2426 $search_qpart = "(UPPER(F1.title) LIKE UPPER('% $feed_search %') OR
2427 UPPER(F1.feed_url) LIKE UPPER('% $feed_search %')) AND" ;
2432 $result = db_query ( $link , "SELECT
2436 substring(F1.last_updated,1,16) AS last_updated,
2441 F2.title AS parent_title,
2442 C1.title AS category
2445 LEFT JOIN ttrss_feeds AS F2
2446 ON (F1.parent_feed = F2.id)
2447 LEFT JOIN ttrss_feed_categories AS C1
2448 ON (F1.cat_id = C1.id)
2450 $search_qpart F1.owner_uid = '" . $_SESSION [ "uid" ]. "'
2451 ORDER by category, $feeds_sort ,title" );
2453 if ( db_num_rows ( $result ) != 0 ) {
2455 print "<div id= \" infoBoxShadow \" ><div id= \" infoBox \" >PLACEHOLDER</div></div>" ;
2457 print "<p><table width= \" 100% \" cellspacing= \" 0 \"
2458 class= \" prefFeedList \" id= \" prefFeedList \" >" ;
2459 print "<tr><td class= \" selectPrompt \" colspan= \" 8 \" >
2461 <a href= \" javascript:selectTableRowsByIdPrefix('prefFeedList',
2462 'FEEDR-', 'FRCHK-', true) \" >All</a>,
2463 <a href= \" javascript:selectTableRowsByIdPrefix('prefFeedList',
2464 'FEEDR-', 'FRCHK-', false) \" >None</a>
2467 if (! get_pref ( $link , 'ENABLE_FEED_CATS' )) {
2468 print "<tr class= \" title \" >
2469 <td width='5%' align='center'> </td>
2470 <td width='30%'><a href= \" javascript:updateFeedList('title') \" >Title</a></td>
2471 <td width='30%'><a href= \" javascript:updateFeedList('feed_url') \" >Feed</a></td>
2472 <td width='15%'><a href= \" javascript:updateFeedList('update_interval') \" >Update Interval</a></td>
2473 <td width='15%'><a href= \" javascript:updateFeedList('purge_interval') \" >Purge Interval</a></td></tr>" ;
2480 while ( $line = db_fetch_assoc ( $result )) {
2482 $feed_id = $line [ "id" ];
2483 $cat_id = $line [ "cat_id" ];
2485 $edit_title = htmlspecialchars ( db_unescape_string ( $line [ "title" ]));
2486 $edit_link = htmlspecialchars ( db_unescape_string ( $line [ "feed_url" ]));
2487 $edit_cat = htmlspecialchars ( db_unescape_string ( $line [ "category" ]));
2489 // if ($line["update_interval"] == "0") $line["update_interval"] = "Default";
2490 // if ($line["update_interval"] == "-1") $line["update_interval"] = "Disabled";
2491 // if ($line["purge_interval"] == "0") $line["purge_interval"] = "Default";
2492 // if ($line["purge_interval"] < 0) $line["purge_interval"] = "Disabled";
2494 if (! $edit_cat ) $edit_cat = "Uncategorized" ;
2496 if ( get_pref ( $link , 'ENABLE_FEED_CATS' ) && $cur_cat_id != $cat_id ) {
2499 print "<tr><td colspan= \" 6 \" class= \" feedEditCat \" > $edit_cat </td></tr>" ;
2501 print "<tr class= \" title \" >
2502 <td width='5%' align='center'> </td>
2503 <td width='30%'><a href= \" javascript:updateFeedList('title') \" >Title</a></td>
2504 <td width='30%'><a href= \" javascript:updateFeedList('feed_url') \" >Feed</a></td>
2505 <td width='15%'><a href= \" javascript:updateFeedList('update_interval') \" >Update Interval</a></td>
2506 <td width='15%'><a href= \" javascript:updateFeedList('purge_interval') \" >Purge Interval</a></td></tr>" ;
2508 $cur_cat_id = $cat_id ;
2511 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
2512 $this_row_id = "id= \" FEEDR- $feed_id\" " ;
2514 print "<tr class= \" $class\" $this_row_id >" ;
2516 $icon_file = ICONS_DIR
. "/ $feed_id .ico" ;
2518 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
2519 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
. "/ $feed_id .ico \" >" ;
2521 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
2523 // print "<td class='feedIcon'>$feed_icon</td>";
2525 print "<td class='feedSelect'><input onclick='toggleSelectRow(this);'
2526 type= \" checkbox \" id= \" FRCHK-" . $line [ "id" ]. " \" ></td>" ;
2528 $edit_title = truncate_string ( $edit_title , 40 );
2529 $edit_link = truncate_string ( $edit_link , 60 );
2531 $parent_title = $line [ "parent_title" ];
2532 if ( $parent_title ) {
2533 $parent_title = "<span class='groupPrompt'>(linked to
2534 $parent_title )</span>" ;
2537 print "<td><a href= \" javascript:editFeed( $feed_id ); \" >" .
2538 " $feed_icon $edit_title $parent_title " . "</a></td>" ;
2540 print "<td><a href= \" javascript:editFeed( $feed_id ); \" >" .
2541 $edit_link . "</a></td>" ;
2543 /* if (get_pref($link, 'ENABLE_FEED_CATS')) {
2544 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
2545 $edit_cat . "</a></td>";
2548 print "<td><a href= \" javascript:editFeed( $feed_id ); \" >" .
2549 $update_intervals [ $line [ "update_interval" ]] . "</a></td>" ;
2551 print "<td><a href= \" javascript:editFeed( $feed_id ); \" >" .
2552 $purge_intervals [ $line [ "purge_interval" ]] . "</a></td>" ;
2563 if ( $subop == "edit" ) {
2564 print "Edit feed:
2565 <input type= \" submit \" class= \" button \"
2566 onclick= \" javascript:feedEditCancel() \" value= \" Cancel \" >
2567 <input type= \" submit \" class= \" button \"
2568 onclick= \" javascript:feedEditSave() \" value= \" Save \" >" ;
2573 <input type= \" submit \" class= \" button \"
2574 onclick= \" javascript:selectedFeedDetails() \" value= \" Details \" >
2575 <input type= \" submit \" class= \" button \"
2576 onclick= \" javascript:editSelectedFeed() \" value= \" Edit \" >
2577 <input type= \" submit \" class= \" button \"
2578 onclick= \" javascript:removeSelectedFeeds() \" value= \" Remove \" >" ;
2580 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
2582 print " " ;
2584 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
2585 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
2588 print "<select id= \" sfeed_set_fcat \" >" ;
2589 print "<option id= \" 0 \" >Uncategorized</option>" ;
2591 if ( db_num_rows ( $result ) != 0 ) {
2593 print "<option disabled>--------</option>" ;
2595 while ( $line = db_fetch_assoc ( $result )) {
2596 printf ( "<option id=' %d '> %s </option>" ,
2597 $line [ "id" ], $line [ "title" ]);
2603 print " <input type= \" submit \" class= \" button \"
2604 onclick= \" javascript:categorizeSelectedFeeds() \" value= \" Set category \" >" ;
2608 if ( get_pref ( $link , 'ENABLE_PREFS_CATCHUP_UNCATCHUP' )) {
2610 <input type= \" submit \" class= \" button \"
2611 onclick= \" javascript:readSelectedFeeds(true) \" value= \" Mark as read \" >
2612 <input type= \" submit \" class= \" button \"
2613 onclick= \" javascript:readSelectedFeeds(false) \"
2614 value= \" Mark as unread \" > " ;
2618 All feeds: <input type= \" submit \"
2619 class= \" button \" onclick= \" gotoExportOpml() \"
2620 value= \" Export OPML \" >" ;
2624 print "<p>No feeds defined.</p>" ;
2628 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
2630 print "<h3>Edit Categories</h3>" ;
2632 // print "<h3>Categories</h3>";
2634 print "<div class= \" prefGenericAddBox \" >
2635 <input id= \" fadd_cat \"
2636 onchange= \" javascript:addFeedCat() \"
2639 type= \" submit \" class= \" button \"
2640 onclick= \" javascript:addFeedCat() \" value= \" Add category \" ></div>" ;
2642 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
2643 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
2646 if ( db_num_rows ( $result ) != 0 ) {
2648 print "<p><table width= \" 100% \" class= \" prefFeedCatList \"
2649 cellspacing= \" 0 \" id= \" prefFeedCatList \" >" ;
2651 print "<tr><td class= \" selectPrompt \" colspan= \" 8 \" >
2653 <a href= \" javascript:selectTableRowsByIdPrefix('prefFeedCatList',
2654 'FCATR-', 'FCCHK-', true) \" >All</a>,
2655 <a href= \" javascript:selectTableRowsByIdPrefix('prefFeedCatList',
2656 'FCATR-', 'FCCHK-', false) \" >None</a>
2659 print "<tr class= \" title \" >
2660 <td width= \" 5% \" ></td><td width= \" 80% \" >Title</td>
2665 while ( $line = db_fetch_assoc ( $result )) {
2667 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
2669 $cat_id = $line [ "id" ];
2671 $edit_cat_id = $_GET [ "id" ];
2673 if ( $subop == "editCat" && $cat_id != $edit_cat_id ) {
2677 $this_row_id = "id= \" FCATR- $cat_id\" " ;
2680 print "<tr class= \" $class\" $this_row_id >" ;
2682 $edit_title = htmlspecialchars ( db_unescape_string ( $line [ "title" ]));
2684 if (! $edit_cat_id ||
$subop != "editCat" ) {
2686 print "<td align='center'><input onclick='toggleSelectRow(this);'
2687 type= \" checkbox \" id= \" FCCHK-" . $line [ "id" ]. " \" ></td>" ;
2689 print "<td><a href= \" javascript:editFeedCat( $cat_id ); \" >" .
2690 $edit_title . "</a></td>" ;
2692 } else if ( $cat_id != $edit_cat_id ) {
2694 print "<td><input disabled= \" true \" type= \" checkbox \"
2695 id= \" FRCHK-" . $line [ "id" ]. " \" ></td>" ;
2697 print "<td> $edit_title </td>" ;
2701 print "<td><input disabled= \" true \" type= \" checkbox \" checked></td>" ;
2703 print "<td><input id= \" iedit_title \" value= \" $edit_title\" ></td>" ;
2716 if ( $subop == "editCat" ) {
2717 print "Edit category:
2718 <input type= \" submit \" class= \" button \"
2719 onclick= \" javascript:feedCatEditCancel() \" value= \" Cancel \" >
2720 <input type= \" submit \" class= \" button \"
2721 onclick= \" javascript:feedCatEditSave() \" value= \" Save \" >" ;
2726 <input type= \" submit \" class= \" button \"
2727 onclick= \" javascript:editSelectedFeedCat() \" value= \" Edit \" >
2728 <input type= \" submit \" class= \" button \"
2729 onclick= \" javascript:removeSelectedFeedCats() \" value= \" Remove \" >" ;
2734 print "<p>No feed categories defined.</p>" ;
2738 print "<h3>Import OPML</h3>
2739 <form enctype= \" multipart/form-data \" method= \" POST \" action= \" opml.php \" >
2740 File: <input id= \" opml_file \" name= \" opml_file \" type= \" file \" >
2741 <input class= \" button \" name= \" op \" onclick= \" return validateOpmlImport(); \"
2742 type= \" submit \" value= \" Import \" >
2747 if ( $op == "pref-filters" ) {
2749 $subop = $_GET [ "subop" ];
2750 $quiet = $_GET [ "quiet" ];
2752 if ( $subop == "editSave" ) {
2754 $regexp = db_escape_string ( $_GET [ "r" ]);
2755 $descr = db_escape_string ( $_GET [ "d" ]);
2756 $match = db_escape_string ( $_GET [ "m" ]);
2757 $filter_id = db_escape_string ( $_GET [ "id" ]);
2758 $feed_id = db_escape_string ( $_GET [ "fid" ]);
2759 $action_id = db_escape_string ( $_GET [ "aid" ]);
2764 $feed_id = sprintf ( "' %s '" , db_escape_string ( $feed_id ));
2767 $result = db_query ( $link , "UPDATE ttrss_filters SET
2768 reg_exp = ' $regexp ',
2769 description = ' $descr ',
2771 action_id = ' $action_id ',
2772 filter_type = (SELECT id FROM ttrss_filter_types WHERE
2773 description = ' $match ')
2774 WHERE id = ' $filter_id '" );
2777 if ( $subop == "remove" ) {
2779 if (! WEB_DEMO_MODE
) {
2781 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
2783 foreach ( $ids as $id ) {
2784 db_query ( $link , "DELETE FROM ttrss_filters WHERE id = ' $id '" );
2790 if ( $subop == "add" ) {
2792 if (! WEB_DEMO_MODE
) {
2794 $regexp = db_escape_string ( trim ( $_GET [ "regexp" ]));
2795 $match = db_escape_string ( trim ( $_GET [ "match" ]));
2796 $feed_id = db_escape_string ( $_GET [ "fid" ]);
2797 $action_id = db_escape_string ( $_GET [ "aid" ]);
2802 $feed_id = sprintf ( "' %s '" , db_escape_string ( $feed_id ));
2805 $result = db_query ( $link ,
2806 "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,
2809 (' $regexp ', (SELECT id FROM ttrss_filter_types WHERE
2810 description = ' $match '),'" . $_SESSION [ "uid" ]. "',
2811 $feed_id , ' $action_id ')" );
2817 $result = db_query ( $link , "SELECT description
2818 FROM ttrss_filter_types ORDER BY description" );
2820 $filter_types = array ();
2822 while ( $line = db_fetch_assoc ( $result )) {
2823 array_push ( $filter_types , $line [ "description" ]);
2826 print "<div class= \" prefGenericAddBox \" >
2827 <input id= \" fadd_regexp \" size= \" 40 \" > " ;
2829 print_select ( "fadd_match" , "Title" , $filter_types );
2831 print " <select id= \" fadd_feed \" >" ;
2833 print "<option selected id= \" 0 \" >All feeds</option>" ;
2835 $result = db_query ( $link , "SELECT id,title FROM ttrss_feeds
2836 WHERE owner_uid = " . $_SESSION [ "uid" ]. " ORDER BY title" );
2838 if ( db_num_rows ( $result ) > 0 ) {
2839 print "<option disabled>--------</option>" ;
2842 while ( $line = db_fetch_assoc ( $result )) {
2843 printf ( "<option id=' %d '> %s </option>" , $line [ "id" ], $line [ "title" ]);
2846 print "</select> " ;
2848 print " Action: " ;
2850 print "<select id= \" fadd_action \" >" ;
2852 $result = db_query ( $link , "SELECT id,description FROM ttrss_filter_actions
2855 while ( $line = db_fetch_assoc ( $result )) {
2856 printf ( "<option id=' %d '> %s </option>" , $line [ "id" ], $line [ "description" ]);
2859 print "</select> " ;
2861 print "<input type= \" submit \"
2862 class= \" button \" onclick= \" javascript:addFilter() \"
2863 value= \" Add filter \" >" ;
2867 $result = db_query ( $link , "SELECT
2868 ttrss_filters.id AS id,reg_exp,
2869 ttrss_filters.description AS description,
2870 ttrss_filter_types.name AS filter_type_name,
2871 ttrss_filter_types.description AS filter_type_descr,
2873 ttrss_filter_actions.description AS action_description,
2874 ttrss_feeds.title AS feed_title
2876 ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN
2877 ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id)
2879 filter_type = ttrss_filter_types.id AND
2880 ttrss_filter_actions.id = action_id AND
2881 ttrss_filters.owner_uid = " . $_SESSION [ "uid" ]. "
2884 if ( db_num_rows ( $result ) != 0 ) {
2886 print "<p><table width= \" 100% \" cellspacing= \" 0 \" class= \" prefFilterList \"
2887 id= \" prefFilterList \" >" ;
2889 print "<tr><td class= \" selectPrompt \" colspan= \" 8 \" >
2891 <a href= \" javascript:selectTableRowsByIdPrefix('prefFilterList',
2892 'FILRR-', 'FICHK-', true) \" >All</a>,
2893 <a href= \" javascript:selectTableRowsByIdPrefix('prefFilterList',
2894 'FILRR-', 'FICHK-', false) \" >None</a>
2897 print "<tr class= \" title \" >
2898 <td align='center' width= \" 5% \" > </td>
2899 <td width= \" 20% \" >Filter expression</td>
2900 <td width= \" 20% \" >Feed</td>
2901 <td width= \" 15% \" >Match</td>
2902 <td width= \" 15% \" >Action</td>
2903 <td width= \" 30% \" >Description</td></tr>" ;
2907 while ( $line = db_fetch_assoc ( $result )) {
2909 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
2911 $filter_id = $line [ "id" ];
2912 $edit_filter_id = $_GET [ "id" ];
2914 if ( $subop == "edit" && $filter_id != $edit_filter_id ) {
2918 $this_row_id = "id= \" FILRR- $filter_id\" " ;
2921 print "<tr class= \" $class\" $this_row_id >" ;
2923 $line [ "regexp" ] = htmlspecialchars ( $line [ "reg_exp" ]);
2924 $line [ "description" ] = htmlspecialchars ( $line [ "description" ]);
2926 if (! $line [ "feed_title" ]) $line [ "feed_title" ] = "All feeds" ;
2928 if (! $edit_filter_id ||
$subop != "edit" ) {
2930 if (! $line [ "description" ]) $line [ "description" ] = "[No description]" ;
2932 print "<td align='center'><input onclick='toggleSelectRow(this);'
2933 type= \" checkbox \" id= \" FICHK-" . $line [ "id" ]. " \" ></td>" ;
2935 print "<td><a href= \" javascript:editFilter( $filter_id ); \" >" .
2936 $line [ "reg_exp" ] . "</td>" ;
2938 print "<td><a href= \" javascript:editFilter( $filter_id ); \" >" .
2939 $line [ "feed_title" ] . "</td>" ;
2941 print "<td><a href= \" javascript:editFilter( $filter_id ); \" >" .
2942 $line [ "filter_type_descr" ] . "</td>" ;
2944 print "<td><a href= \" javascript:editFilter( $filter_id ); \" >" .
2945 $line [ "action_description" ] . "</td>" ;
2947 print "<td><a href= \" javascript:editFilter( $filter_id ); \" >" .
2948 $line [ "description" ] . "</td>" ;
2950 } else if ( $filter_id != $edit_filter_id ) {
2952 if (! $line [ "description" ]) $line [ "description" ] = "[No description]" ;
2954 print "<td><input disabled= \" true \" type= \" checkbox \"
2955 id= \" FICHK-" . $line [ "id" ]. " \" ></td>" ;
2957 print "<td>" . $line [ "reg_exp" ]. "</td>" ;
2958 print "<td>" . $line [ "feed_title" ]. "</td>" ;
2959 print "<td>" . $line [ "filter_type_descr" ]. "</td>" ;
2960 print "<td>" . $line [ "action_description" ]. "</td>" ;
2961 print "<td>" . $line [ "description" ]. "</td>" ;
2965 print "<td><input disabled= \" true \" type= \" checkbox \" checked></td>" ;
2967 print "<td><input id= \" iedit_regexp \" value= \" " . $line [ "reg_exp" ].
2971 print "<select id= \" iedit_feed \" >" ;
2972 print "<option id= \" 0 \" >All feeds</option>" ;
2974 $tmp_result = db_query ( $link , "SELECT id,title FROM ttrss_feeds
2975 WHERE owner_uid = " . $_SESSION [ "uid" ]. " ORDER BY title" );
2977 if ( db_num_rows ( $tmp_result ) > 0 ) {
2978 print "<option disabled>--------</option>" ;
2981 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
2982 if ( $tmp_line [ "id" ] == $line [ "feed_id" ]) {
2983 $is_selected = "selected" ;
2987 printf ( "<option $is_selected id=' %d '> %s </option>" ,
2988 $tmp_line [ "id" ], $tmp_line [ "title" ]);
2991 print "</select></td>" ;
2994 print_select ( "iedit_match" , $line [ "filter_type_descr" ], $filter_types );
2998 print "<select id= \" iedit_filter_action \" >" ;
3000 $tmp_result = db_query ( $link , "SELECT id,description FROM ttrss_filter_actions
3001 ORDER BY description" );
3003 while ( $tmp_line = db_fetch_assoc ( $tmp_result )) {
3004 if ( $tmp_line [ "description" ] == $line [ "action_description" ]) {
3005 $is_selected = "selected" ;
3009 printf ( "<option $is_selected id=' %d '> %s </option>" ,
3010 $tmp_line [ "id" ], $tmp_line [ "description" ]);
3013 print "</select></td>" ;
3016 print "<td><input id= \" iedit_descr \" value= \" " . $line [ "description" ].
3028 print "<tr><td colspan= \" 4 \" align= \" center \" >No filters defined.</td></tr>" ;
3035 if ( $subop == "edit" ) {
3037 <input type= \" submit \" class= \" button \"
3038 onclick= \" javascript:filterEditSave() \" value= \" Save \" >
3039 <input type= \" submit \" class= \" button \"
3040 onclick= \" javascript:filterEditCancel() \" value= \" Cancel \" >" ;
3046 <input type= \" submit \" class= \" button \"
3047 onclick= \" javascript:editSelectedFilter() \" value= \" Edit \" >
3048 <input type= \" submit \" class= \" button \"
3049 onclick= \" javascript:removeSelectedFilters() \" value= \" Remove \" >" ;
3054 print "<p>No filters defined.</p>" ;
3059 // We need to accept raw SQL data in label queries, so not everything is escaped
3060 // here, this is by design. If you don't like the whole idea, disable labels
3061 // altogether with GLOBAL_ENABLE_LABELS = false
3063 if ( $op == "pref-labels" ) {
3065 if (! GLOBAL_ENABLE_LABELS
) {
3069 $subop = $_GET [ "subop" ];
3071 if ( $subop == "test" ) {
3073 $expr = $_GET [ "expr" ];
3074 $descr = $_GET [ "descr" ];
3076 print "<div class='infoBoxContents'>" ;
3078 print "<h1>Label « $descr »</h1>" ;
3080 // print "<p><b>Expression</b>: $expr</p>";
3082 $result = db_query ( $link ,
3083 "SELECT count(id) AS num_matches
3084 FROM ttrss_entries,ttrss_user_entries
3086 ttrss_user_entries.ref_id = ttrss_entries.id AND
3087 owner_uid = " . $_SESSION [ "uid" ]);
3089 $num_matches = db_fetch_result ( $result , 0 , "num_matches" );;
3091 if ( $num_matches > 0 ) {
3093 print "<p>Query returned <b> $num_matches </b> matches, first 5 follow:</p>" ;
3095 $result = db_query ( $link ,
3097 (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
3098 FROM ttrss_entries,ttrss_user_entries
3100 ttrss_user_entries.ref_id = ttrss_entries.id
3101 AND owner_uid = " . $_SESSION [ "uid" ] . "
3102 ORDER BY date_entered DESC LIMIT 5" );
3104 print "<ul class= \" nomarks \" >" ;
3105 while ( $line = db_fetch_assoc ( $result )) {
3106 print "<li>" . $line [ "title" ].
3107 " <span class= \" insensitive \" >(" . $line [ "feed_title" ]. ")</span></li>" ;
3112 print "<p>Query didn't return any matches.</p>" ;
3117 print "<div align='center'>
3118 <input type='submit' class='button'
3119 onclick= \" closeInfoBox() \" value= \" Close this window \" ></div>" ;
3123 if ( $subop == "editSave" ) {
3125 $sql_exp = $_GET [ "s" ];
3126 $descr = $_GET [ "d" ];
3127 $label_id = db_escape_string ( $_GET [ "id" ]);
3129 // print "$sql_exp : $descr : $label_id";
3131 $result = db_query ( $link , "UPDATE ttrss_labels SET
3132 sql_exp = ' $sql_exp ',
3133 description = ' $descr '
3134 WHERE id = ' $label_id '" );
3137 if ( $subop == "remove" ) {
3139 if (! WEB_DEMO_MODE
) {
3141 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
3143 foreach ( $ids as $id ) {
3144 db_query ( $link , "DELETE FROM ttrss_labels WHERE id = ' $id '" );
3150 if ( $subop == "add" ) {
3152 if (! WEB_DEMO_MODE
) {
3154 // no escaping is done here on purpose
3155 $exp = trim ( $_GET [ "exp" ]);
3157 $result = db_query ( $link ,
3158 "INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
3159 VALUES (' $exp ', ' $exp ', '" . $_SESSION [ "uid" ]. "')" );
3163 print "<div class= \" prefGenericAddBox \" >
3164 <input size= \" 40 \" id= \" ladd_expr \" > " ;
3166 print "<input type= \" submit \" class= \" button \"
3167 onclick= \" javascript:addLabel() \" value= \" Add label \" ></div>" ;
3169 $result = db_query ( $link , "SELECT
3170 id,sql_exp,description
3174 owner_uid = " . $_SESSION [ "uid" ]. "
3175 ORDER by description" );
3177 print "<div id= \" infoBoxShadow \" ><div id= \" infoBox \" >PLACEHOLDER</div></div>" ;
3179 if ( db_num_rows ( $result ) != 0 ) {
3181 print "<p><table width= \" 100% \" cellspacing= \" 0 \"
3182 class= \" prefLabelList \" id= \" prefLabelList \" >" ;
3184 print "<tr><td class= \" selectPrompt \" colspan= \" 8 \" >
3186 <a href= \" javascript:selectTableRowsByIdPrefix('prefLabelList',
3187 'LILRR-', 'LICHK-', true) \" >All</a>,
3188 <a href= \" javascript:selectTableRowsByIdPrefix('prefLabelList',
3189 'LILRR-', 'LICHK-', false) \" >None</a>
3192 print "<tr class= \" title \" >
3193 <td align='center' width= \" 5% \" > </td>
3194 <td width= \" 40% \" >SQL expression
3195 <a class= \" helpLink \" href= \" javascript:displayHelpInfobox(1) \" >(?)</a>
3197 <td width= \" 40% \" >Caption</td></tr>" ;
3201 while ( $line = db_fetch_assoc ( $result )) {
3203 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
3205 $label_id = $line [ "id" ];
3206 $edit_label_id = $_GET [ "id" ];
3208 if ( $subop == "edit" && $label_id != $edit_label_id ) {
3212 $this_row_id = "id= \" LILRR- $label_id\" " ;
3215 print "<tr class= \" $class\" $this_row_id >" ;
3217 $line [ "sql_exp" ] = htmlspecialchars ( $line [ "sql_exp" ]);
3218 $line [ "description" ] = htmlspecialchars ( $line [ "description" ]);
3220 if (! $edit_label_id ||
$subop != "edit" ) {
3222 if (! $line [ "description" ]) $line [ "description" ] = "[No caption]" ;
3224 print "<td align='center'><input onclick='toggleSelectRow(this);'
3225 type= \" checkbox \" id= \" LICHK-" . $line [ "id" ]. " \" ></td>" ;
3227 print "<td><a href= \" javascript:editLabel( $label_id ); \" >" .
3228 $line [ "sql_exp" ] . "</td>" ;
3230 print "<td><a href= \" javascript:editLabel( $label_id ); \" >" .
3231 $line [ "description" ] . "</td>" ;
3233 } else if ( $label_id != $edit_label_id ) {
3235 if (! $line [ "description" ]) $line [ "description" ] = "[No description]" ;
3237 print "<td><input disabled= \" true \" type= \" checkbox \"
3238 id= \" LICHK-" . $line [ "id" ]. " \" ></td>" ;
3240 print "<td>" . $line [ "sql_exp" ]. "</td>" ;
3241 print "<td>" . $line [ "description" ]. "</td>" ;
3245 print "<td><input disabled= \" true \" type= \" checkbox \" checked></td>" ;
3247 print "<td><input id= \" iedit_expr \" value= \" " . $line [ "sql_exp" ].
3250 print "<td><input id= \" iedit_descr \" value= \" " . $line [ "description" ].
3262 print "<tr><td colspan= \" 4 \" align= \" center \" >No labels defined.</td></tr>" ;
3269 if ( $subop == "edit" ) {
3271 <input type= \" submit \" class= \" button \"
3272 onclick= \" javascript:labelTest() \" value= \" Test \" >
3273 <input type= \" submit \" class= \" button \"
3274 onclick= \" javascript:labelEditSave() \" value= \" Save \" >
3275 <input type= \" submit \" class= \" button \"
3276 onclick= \" javascript:labelEditCancel() \" value= \" Cancel \" >" ;
3282 <input type= \" submit \" class= \" button \"
3283 onclick= \" javascript:editSelectedLabel() \" value= \" Edit \" >
3284 <input type= \" submit \" class= \" button \"
3285 onclick= \" javascript:removeSelectedLabels() \" value= \" Remove \" >" ;
3288 print "<p>No labels defined.</p>" ;
3292 if ( $op == "error" ) {
3293 print "<div width= \" 100% \" align='center'>" ;
3294 $msg = $_GET [ "msg" ];
3299 if ( $op == "help" ) {
3300 if (! $_GET [ "noheaders" ]) {
3302 <title>Tiny Tiny RSS : Help</title>
3303 <link rel= \" stylesheet \" href= \" tt-rss.css \" type= \" text/css \" >
3304 <script type= \" text/javascript \" src= \" functions.js \" ></script>
3305 <meta http-equiv= \" Content-Type \" content= \" text/html; charset=utf-8 \" >
3309 $tid = sprintf ( " %d " , $_GET [ "tid" ]);
3311 print "<div class='infoBoxContents'>" ;
3313 if ( file_exists ( "help/ $tid .php" )) {
3314 include ( "help/ $tid .php" );
3316 print "<p>Help topic not found.</p>" ;
3321 print "<div align='center'>
3322 <input type='submit' class='button'
3323 onclick= \" closeInfoBox() \" value= \" Close this window \" ></div>" ;
3325 if (! $_GET [ "noheaders" ]) {
3326 print "</body></html>" ;
3333 $param = $_GET [ "param" ];
3335 if ( $id == "quickAddFeed" ) {
3338 onblur= \" javascript:enableHotkeys() \" onfocus= \" javascript:disableHotkeys() \"
3341 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
3342 $result = db_query ( $link , "SELECT title,id FROM ttrss_feed_categories
3343 WHERE owner_uid = " . $_SESSION [ "uid" ]. "
3346 print " <select id= \" qafCat \" >" ;
3347 print "<option id= \" 0 \" >Uncategorized</option>" ;
3349 if ( db_num_rows ( $result ) != 0 ) {
3351 print "<option disabled>--------</option>" ;
3353 while ( $line = db_fetch_assoc ( $result )) {
3354 printf ( "<option id=' %d '> %s </option>" ,
3355 $line [ "id" ], $line [ "title" ]);
3362 print " <input class= \" button \"
3363 type= \" submit \" onclick= \" javascript:qafAdd() \" value= \" Add feed \" >
3364 <input class= \" button \"
3365 type= \" submit \" onclick= \" javascript:closeDlg() \"
3369 if ( $id == "quickDelFeed" ) {
3371 $param = db_escape_string ( $param );
3373 $result = db_query ( $link , "SELECT title FROM ttrss_feeds WHERE id = ' $param '" );
3377 $f_title = db_fetch_result ( $result , 0 , "title" );
3379 print "Remove current feed (<b> $f_title </b>)?
3380 <input class= \" button \"
3381 type= \" submit \" onclick= \" javascript:qfdDelete( $param ) \" value= \" Remove \" >
3382 <input class= \" button \"
3383 type= \" submit \" onclick= \" javascript:closeDlg() \"
3386 print "Error: Feed $param not found.
3387 <input class= \" button \"
3388 type= \" submit \" onclick= \" javascript:closeDlg() \"
3393 if ( $id == "search" ) {
3395 $active_feed_id = db_escape_string ( $_GET [ "param" ]);
3397 print "<input id= \" searchbox \" class= \" extSearch \"
3398 onblur= \" javascript:enableHotkeys() \" onfocus= \" javascript:disableHotkeys() \"
3399 onchange= \" javascript:search() \" >
3400 <select id= \" searchmodebox \" >
3401 <option selected>All feeds</option>" ;
3403 if ( $active_feed_id ) {
3404 print "<option>This feed</option>" ;
3406 print "<option disabled>This feed</option>" ;
3409 if ( get_pref ( $link , 'ENABLE_FEED_CATS' )) {
3410 print "<option>This category</option>" ;
3414 <input type= \" submit \"
3415 class= \" button \" onclick= \" javascript:search() \" value= \" Search \" >
3416 <input class= \" button \"
3417 type= \" submit \" onclick= \" javascript:closeDlg() \"
3422 if ( $id == "quickAddFilter" ) {
3424 $result = db_query ( $link , "SELECT description
3425 FROM ttrss_filter_types ORDER BY description" );
3427 $filter_types = array ();
3429 while ( $line = db_fetch_assoc ( $result )) {
3430 array_push ( $filter_types , $line [ "description" ]);
3435 print "<tr><td>Match:</td><td><input id= \" fadd_regexp \" size= \" 40 \" > " ;
3437 print_select ( "fadd_match" , "Title" , $filter_types );
3440 print "<tr><td>Feed:</td><td><select id= \" fadd_feed \" >" ;
3442 print "<option selected id= \" 0 \" >All feeds</option>" ;
3444 $result = db_query ( $link , "SELECT id,title FROM ttrss_feeds
3445 WHERE owner_uid = " . $_SESSION [ "uid" ]. " ORDER BY title" );
3447 if ( db_num_rows ( $result ) > 0 ) {
3448 print "<option disabled>--------</option>" ;
3451 while ( $line = db_fetch_assoc ( $result )) {
3452 if ( $param == $line [ "id" ]) {
3453 $selected = "selected" ;
3457 printf ( "<option id=' %d ' %s > %s </option>" , $line [ "id" ], $selected , $line [ "title" ]);
3460 print "</select></td></tr>" ;
3462 print "<tr><td>Action:</td>" ;
3464 print "<td><select id= \" fadd_action \" >" ;
3466 $result = db_query ( $link , "SELECT id,description FROM ttrss_filter_actions
3469 while ( $line = db_fetch_assoc ( $result )) {
3470 printf ( "<option id=' %d '> %s </option>" , $line [ "id" ], $line [ "description" ]);
3475 print "</td></tr><tr><td colspan= \" 2 \" align= \" right \" >" ;
3477 print "<input type= \" submit \"
3478 class= \" button \" onclick= \" javascript:qaddFilter() \"
3479 value= \" Add filter \" > " ;
3481 print "<input class= \" button \"
3482 type= \" submit \" onclick= \" javascript:closeDlg() \"
3485 print "</td></tr></table>" ;
3489 // update feeds of all users, may be used anonymously
3490 if ( $op == "globalUpdateFeeds" ) {
3492 $result = db_query ( $link , "SELECT id FROM ttrss_users" );
3494 while ( $line = db_fetch_assoc ( $result )) {
3495 $user_id = $line [ "id" ];
3496 // print "<!-- updating feeds of uid $user_id -->";
3497 update_all_feeds ( $link , false , $user_id );
3501 <message msg= \" All feeds updated \" />
3506 if ( $op == "pref-prefs" ) {
3508 $subop = $_REQUEST [ "subop" ];
3510 if ( $subop == "Save configuration" ) {
3512 if ( WEB_DEMO_MODE
) {
3513 header ( "Location: prefs.php" );
3517 $_SESSION [ "prefs_op_result" ] = "save-config" ;
3519 $_SESSION [ "prefs_cache" ] = false ;
3521 foreach ( array_keys ( $_POST ) as $pref_name ) {
3523 $pref_name = db_escape_string ( $pref_name );
3524 $value = db_escape_string ( $_POST [ $pref_name ]);
3526 $result = db_query ( $link , "SELECT type_name
3527 FROM ttrss_prefs,ttrss_prefs_types
3528 WHERE pref_name = ' $pref_name ' AND type_id = ttrss_prefs_types.id" );
3530 if ( db_num_rows ( $result ) > 0 ) {
3532 $type_name = db_fetch_result ( $result , 0 , "type_name" );
3534 // print "$pref_name : $type_name : $value<br>";
3536 if ( $type_name == "bool" ) {
3537 if ( $value == "1" ) {
3542 } else if ( $type_name == "integer" ) {
3543 $value = sprintf ( " %d " , $value );
3546 // print "$pref_name : $type_name : $value<br>";
3548 db_query ( $link , "UPDATE ttrss_user_prefs SET value = ' $value '
3549 WHERE pref_name = ' $pref_name ' AND owner_uid = " . $_SESSION [ "uid" ]);
3553 header ( "Location: prefs.php" );
3557 } else if ( $subop == "getHelp" ) {
3559 $pref_name = db_escape_string ( $_GET [ "pn" ]);
3561 $result = db_query ( $link , "SELECT help_text FROM ttrss_prefs
3562 WHERE pref_name = ' $pref_name '" );
3564 if ( db_num_rows ( $result ) > 0 ) {
3565 $help_text = db_fetch_result ( $result , 0 , "help_text" );
3568 print "Unknown option: $pref_name " ;
3571 } else if ( $subop == "Change e-mail" ) {
3573 if ( WEB_DEMO_MODE
) {
3574 header ( "Location: prefs.php" );
3578 $email = db_escape_string ( $_GET [ "email" ]);
3579 $active_uid = $_SESSION [ "uid" ];
3582 db_query ( $link , "UPDATE ttrss_users SET email = ' $email '
3583 WHERE id = ' $active_uid '" );
3586 header ( "Location: prefs.php" );
3588 } else if ( $subop == "Change password" ) {
3590 if ( WEB_DEMO_MODE
) {
3591 header ( "Location: prefs.php" );
3595 $old_pw = $_POST [ "OLD_PASSWORD" ];
3596 $new_pw = $_POST [ "OLD_PASSWORD" ];
3598 $old_pw_hash = 'SHA1:' . sha1 ( $_POST [ "OLD_PASSWORD" ]);
3599 $new_pw_hash = 'SHA1:' . sha1 ( $_POST [ "NEW_PASSWORD" ]);
3601 $active_uid = $_SESSION [ "uid" ];
3603 if ( $old_pw && $new_pw ) {
3605 $login = db_escape_string ( $_SERVER [ 'PHP_AUTH_USER' ]);
3607 $result = db_query ( $link , "SELECT id FROM ttrss_users WHERE
3608 id = ' $active_uid ' AND (pwd_hash = ' $old_pw ' OR
3609 pwd_hash = ' $old_pw_hash ')" );
3611 if ( db_num_rows ( $result ) == 1 ) {
3612 db_query ( $link , "UPDATE ttrss_users SET pwd_hash = ' $new_pw_hash '
3613 WHERE id = ' $active_uid '" );
3615 $_SESSION [ "pwd_change_result" ] = "ok" ;
3617 $_SESSION [ "pwd_change_result" ] = "failed" ;
3621 header ( "Location: prefs.php" );
3623 } else if ( $subop == "Reset to defaults" ) {
3625 if ( WEB_DEMO_MODE
) {
3626 header ( "Location: prefs.php" );
3630 $_SESSION [ "prefs_op_result" ] = "reset-to-defaults" ;
3632 if ( DB_TYPE
== "pgsql" ) {
3633 db_query ( $link , "UPDATE ttrss_user_prefs
3634 SET value = ttrss_prefs.def_value
3635 WHERE owner_uid = '" . $_SESSION [ "uid" ]. "' AND
3636 ttrss_prefs.pref_name = ttrss_user_prefs.pref_name" );
3638 db_query ( $link , "DELETE FROM ttrss_user_prefs
3639 WHERE owner_uid = " . $_SESSION [ "uid" ]);
3640 initialize_user_prefs ( $link , $_SESSION [ "uid" ]);
3643 header ( "Location: prefs.php" );
3645 } else if ( $subop == "Change theme" ) {
3647 $theme = db_escape_string ( $_POST [ "theme" ]);
3649 if ( $theme == "Default" ) {
3650 $theme_qpart = 'NULL' ;
3652 $theme_qpart = "' $theme '" ;
3655 $result = db_query ( $link , "SELECT id,theme_path FROM ttrss_themes
3656 WHERE theme_name = ' $theme '" );
3658 if ( db_num_rows ( $result ) == 1 ) {
3659 $theme_id = db_fetch_result ( $result , 0 , "id" );
3660 $theme_path = db_fetch_result ( $result , 0 , "theme_path" );
3666 db_query ( $link , "UPDATE ttrss_users SET
3667 theme_id = $theme_id WHERE id = " . $_SESSION [ "uid" ]);
3669 $_SESSION [ "theme" ] = $theme_path ;
3671 header ( "Location: prefs.php" );
3675 if (! SINGLE_USER_MODE
) {
3677 $result = db_query ( $link , "SELECT id,email FROM ttrss_users
3678 WHERE id = " . $_SESSION [ "uid" ]. " AND (pwd_hash = 'password' OR
3679 pwd_hash = 'SHA1:" . sha1 ( "password" ). "')" );
3681 if ( db_num_rows ( $result ) != 0 ) {
3682 print "<div class= \" warning \" >
3683 Your password is at default value, please change it.
3687 if ( $_SESSION [ "pwd_change_result" ] == "failed" ) {
3688 print "<div class= \" warning \" >
3689 There was an error while changing your password.
3693 if ( $_SESSION [ "pwd_change_result" ] == "ok" ) {
3694 print "<div class= \" notice \" >
3695 Password changed successfully.
3699 $_SESSION [ "pwd_change_result" ] = "" ;
3701 if ( $_SESSION [ "prefs_op_result" ] == "reset-to-defaults" ) {
3702 print "<div class= \" notice \" >
3703 Your configuration was reset to defaults.
3707 if ( $_SESSION [ "prefs_op_result" ] == "save-config" ) {
3708 print "<div class= \" notice \" >
3709 Your configuration was saved successfully.
3713 $_SESSION [ "prefs_op_result" ] = "" ;
3715 print "<form action= \" backend.php \" method= \" GET \" >" ;
3717 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
3718 print "<tr><td colspan='3'><h3>Personal data</h3></tr></td>" ;
3720 $result = db_query ( $link , "SELECT email FROM ttrss_users
3721 WHERE id = " . $_SESSION [ "uid" ]);
3723 $email = db_fetch_result ( $result , 0 , "email" );
3725 print "<tr><td width= \" 40% \" >E-mail</td>" ;
3726 print "<td><input class= \" editbox \" name= \" email \"
3727 value= \" $email\" ></td></tr>" ;
3731 print "<input type= \" hidden \" name= \" op \" value= \" pref-prefs \" >" ;
3733 print "<p><input class= \" button \" type= \" submit \"
3734 value= \" Change e-mail \" name= \" subop \" >" ;
3738 print "<form action= \" backend.php \" method= \" POST \" >" ;
3740 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
3741 print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>" ;
3743 print "<tr><td width= \" 40% \" >Old password</td>" ;
3744 print "<td><input class= \" editbox \" type= \" password \"
3745 name= \" OLD_PASSWORD \" ></td></tr>" ;
3747 print "<tr><td width= \" 40% \" >New password</td>" ;
3749 print "<td><input class= \" editbox \" type= \" password \"
3750 name= \" NEW_PASSWORD \" ></td></tr>" ;
3754 print "<input type= \" hidden \" name= \" op \" value= \" pref-prefs \" >" ;
3756 print "<p><input class= \" button \" type= \" submit \"
3757 value= \" Change password \" name= \" subop \" >" ;
3763 $result = db_query ( $link , "SELECT
3764 theme_id FROM ttrss_users WHERE id = " . $_SESSION [ "uid" ]);
3766 $user_theme_id = db_fetch_result ( $result , 0 , "theme_id" );
3768 $result = db_query ( $link , "SELECT
3769 id,theme_name FROM ttrss_themes ORDER BY theme_name" );
3771 if ( db_num_rows ( $result ) > 0 ) {
3773 print "<form action= \" backend.php \" method= \" POST \" >" ;
3774 print "<table width= \" 100% \" class= \" prefPrefsList \" >" ;
3775 print "<tr><td colspan='3'><h3>Themes</h3></tr></td>" ;
3776 print "<tr><td width= \" 40% \" >Select theme</td>" ;
3777 print "<td><select name= \" theme \" >" ;
3778 print "<option>Default</option>" ;
3779 print "<option disabled>--------</option>" ;
3781 while ( $line = db_fetch_assoc ( $result )) {
3782 if ( $line [ "id" ] == $user_theme_id ) {
3783 $selected = "selected" ;
3787 print "<option $selected >" . $line [ "theme_name" ] . "</option>" ;
3789 print "</select></td></tr>" ;
3791 print "<input type= \" hidden \" name= \" op \" value= \" pref-prefs \" >" ;
3792 print "<p><input class= \" button \" type= \" submit \"
3793 value= \" Change theme \" name= \" subop \" >" ;
3797 $result = db_query ( $link , "SELECT
3798 ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
3799 section_name,def_value
3800 FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
3801 WHERE type_id = ttrss_prefs_types.id AND
3802 section_id = ttrss_prefs_sections.id AND
3803 ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
3804 owner_uid = " . $_SESSION [ "uid" ]. "
3805 ORDER BY section_id,short_desc" );
3807 print "<form action= \" backend.php \" method= \" POST \" >" ;
3811 $active_section = "" ;
3813 while ( $line = db_fetch_assoc ( $result )) {
3815 if ( $active_section != $line [ "section_name" ]) {
3817 if ( $active_section != "" ) {
3821 print "<p><table width= \" 100% \" class= \" prefPrefsList \" >" ;
3823 $active_section = $line [ "section_name" ];
3825 print "<tr><td colspan= \" 3 \" ><h3> $active_section </h3></td></tr>" ;
3826 // print "<tr class=\"title\">
3827 // <td width=\"25%\">Option</td><td>Value</td></tr>";
3832 // $class = ($lnum % 2) ? "even" : "odd";
3836 $type_name = $line [ "type_name" ];
3837 $pref_name = $line [ "pref_name" ];
3838 $value = $line [ "value" ];
3839 $def_value = $line [ "def_value" ];
3840 $help_text = $line [ "help_text" ];
3842 print "<td width= \" 40% \" id= \" $pref_name\" >" . $line [ "short_desc" ];
3844 if ( $help_text ) print "<div class= \" prefHelp \" > $help_text </div>" ;
3850 if ( $type_name == "bool" ) {
3851 // print_select($pref_name, $value, array("true", "false"));
3853 if ( $value == "true" ) {
3859 print_radio ( $pref_name , $value , array ( "Yes" , "No" ));
3862 print "<input class= \" editbox \" name= \" $pref_name\" value= \" $value\" >" ;
3874 print "<input type= \" hidden \" name= \" op \" value= \" pref-prefs \" >" ;
3876 print "<p><input class= \" button \" type= \" submit \"
3877 name= \" subop \" value= \" Save configuration \" >" ;
3879 print " <input class= \" button \" type= \" submit \"
3880 name= \" subop \" onclick= \" return validatePrefsReset() \"
3881 value= \" Reset to defaults \" ></p>" ;
3889 if ( $op == "pref-users" ) {
3891 $subop = $_GET [ "subop" ];
3893 if ( $subop == "editSave" ) {
3895 if (! WEB_DEMO_MODE
) {
3897 $login = db_escape_string ( $_GET [ "l" ]);
3898 $uid = db_escape_string ( $_GET [ "id" ]);
3899 $access_level = sprintf ( " %d " , $_GET [ "al" ]);
3900 $email = db_escape_string ( $_GET [ "e" ]);
3902 db_query ( $link , "UPDATE ttrss_users SET login = ' $login ',
3903 access_level = ' $access_level ', email = ' $email ' WHERE id = ' $uid '" );
3906 } else if ( $subop == "remove" ) {
3908 if (! WEB_DEMO_MODE
&& $_SESSION [ "access_level" ] >= 10 ) {
3910 $ids = split ( "," , db_escape_string ( $_GET [ "ids" ]));
3912 foreach ( $ids as $id ) {
3913 db_query ( $link , "DELETE FROM ttrss_users WHERE id = ' $id ' AND id != " . $_SESSION [ "uid" ]);
3917 } else if ( $subop == "add" ) {
3919 if (! WEB_DEMO_MODE
&& $_SESSION [ "access_level" ] >= 10 ) {
3921 $login = db_escape_string ( trim ( $_GET [ "login" ]));
3922 $tmp_user_pwd = make_password ( 8 );
3923 $pwd_hash = 'SHA1:' . sha1 ( $tmp_user_pwd );
3925 db_query ( $link , "INSERT INTO ttrss_users
3926 (login,pwd_hash,access_level,last_login)
3927 VALUES (' $login ', ' $pwd_hash ', 0, NOW())" );
3930 $result = db_query ( $link , "SELECT id FROM ttrss_users WHERE
3931 login = ' $login ' AND pwd_hash = ' $pwd_hash '" );
3933 if ( db_num_rows ( $result ) == 1 ) {
3935 $new_uid = db_fetch_result ( $result , 0 , "id" );
3937 print "<div class= \" notice \" >Added user <b>" . $_GET [ "login" ].
3938 "</b> with password <b> $tmp_user_pwd </b>.</div>" ;
3940 initialize_user ( $link , $new_uid );
3944 print "<div class= \" warning \" >Error while adding user <b>" .
3945 $_GET [ "login" ]. ".</b></div>" ;
3949 } else if ( $subop == "resetPass" ) {
3951 if (! WEB_DEMO_MODE
&& $_SESSION [ "access_level" ] >= 10 ) {
3953 $uid = db_escape_string ( $_GET [ "id" ]);
3955 $result = db_query ( $link , "SELECT login,email
3956 FROM ttrss_users WHERE id = ' $uid '" );
3958 $login = db_fetch_result ( $result , 0 , "login" );
3959 $email = db_fetch_result ( $result , 0 , "email" );
3960 $tmp_user_pwd = make_password ( 8 );
3961 $pwd_hash = 'SHA1:' . sha1 ( $tmp_user_pwd );
3963 db_query ( $link , "UPDATE ttrss_users SET pwd_hash = ' $pwd_hash '
3964 WHERE id = ' $uid '" );
3966 print "<div class= \" notice \" >Changed password of
3967 user <b> $login </b> to <b> $tmp_user_pwd </b>." ;
3969 if ( MAIL_RESET_PASS
&& $email ) {
3970 print " Notifying <b> $email </b>." ;
3972 mail ( " $login < $email >" , "Password reset notification" ,
3975 "Your password for this TT-RSS installation was reset by" .
3976 " an administrator. \n " .
3978 "Your new password is $tmp_user_pwd , please remember" .
3979 " it for later reference. \n " .
3981 "Sincerely, TT-RSS Mail Daemon." , "From: " . MAIL_FROM
);
3989 print "<div class= \" prefGenericAddBox \" >
3990 <input id= \" uadd_box \" onchange= \" javascript:addUser() \" size= \" 40 \" > " ;
3992 print "<input type= \" submit \" class= \" button \"
3993 onclick= \" javascript:addUser() \" value= \" Add user \" ></div>" ;
3995 $result = db_query ( $link , "SELECT
3996 id,login,access_level,email,
3997 SUBSTRING(last_login,1,16) as last_login
4002 print "<div id= \" infoBoxShadow \" ><div id= \" infoBox \" >PLACEHOLDER</div></div>" ;
4004 print "<p><table width= \" 100% \" cellspacing= \" 0 \"
4005 class= \" prefUserList \" id= \" prefUserList \" >" ;
4007 print "<tr><td class= \" selectPrompt \" colspan= \" 8 \" >
4009 <a href= \" javascript:selectTableRowsByIdPrefix('prefUserList',
4010 'UMRR-', 'UMCHK-', true) \" >All</a>,
4011 <a href= \" javascript:selectTableRowsByIdPrefix('prefUserList',
4012 'UMRR-', 'UMCHK-', false) \" >None</a>
4015 print "<tr class= \" title \" >
4016 <td align='center' width= \" 5% \" > </td>
4017 <td width='20%'>Username</td>
4018 <td width='20%'>E-mail</td>
4019 <td width='20%'>Access Level</td>
4020 <td width='20%'>Last login</td></tr>" ;
4024 while ( $line = db_fetch_assoc ( $result )) {
4026 $class = ( $lnum %
2 ) ?
"even" : "odd" ;
4029 $edit_uid = $_GET [ "id" ];
4031 if ( $subop == "edit" && $uid != $edit_uid ) {
4035 $this_row_id = "id= \" UMRR- $uid\" " ;
4038 print "<tr class= \" $class\" $this_row_id >" ;
4040 $line [ "login" ] = htmlspecialchars ( $line [ "login" ]);
4042 $line [ "last_login" ] = date ( get_pref ( $link , 'SHORT_DATE_FORMAT' ),
4043 strtotime ( $line [ "last_login" ]));
4045 $access_level_names = array ( 0 => "User" , 10 => "Administrator" );
4047 /* if ($uid == $_SESSION["uid"]) {
4049 print "<td align='center'><input disabled=\"true\" type=\"checkbox\"
4050 id=\"UMCHK-".$line["id"]."\"></td>";
4052 print "<td>".$line["login"]."</td>";
4053 print "<td>".$line["email"]."</td>";
4054 print "<td>".$line["access_level"]."</td>";
4056 } else */ if (! $edit_uid ||
$subop != "edit" ) {
4058 print "<td align='center'><input onclick='toggleSelectRow(this);'
4059 type= \" checkbox \" id= \" UMCHK- $uid\" ></td>" ;
4061 print "<td><a href= \" javascript:editUser( $uid ); \" >" .
4062 $line [ "login" ] . "</td>" ;
4064 print "<td><a href= \" javascript:editUser( $uid ); \" >" .
4065 $line [ "email" ] . "</td>" ;
4067 print "<td><a href= \" javascript:editUser( $uid ); \" >" .
4068 $access_level_names [ $line [ "access_level" ]] . "</td>" ;
4070 } else if ( $uid != $edit_uid ) {
4072 print "<td align='center'><input disabled= \" true \" type= \" checkbox \"
4073 id= \" UMCHK-" . $line [ "id" ]. " \" ></td>" ;
4075 print "<td>" . $line [ "login" ]. "</td>" ;
4076 print "<td>" . $line [ "email" ]. "</td>" ;
4077 print "<td>" . $access_level_names [ $line [ "access_level" ]]. "</td>" ;
4081 print "<td align='center'>
4082 <input disabled= \" true \" type= \" checkbox \" checked></td>" ;
4084 print "<td><input id= \" iedit_ulogin \" value= \" " . $line [ "login" ].
4087 print "<td><input id= \" iedit_email \" value= \" " . $line [ "email" ].
4090 // print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"].
4094 print "<select id= \" iedit_ulevel \" >" ;
4095 foreach ( array_keys ( $access_level_names ) as $al ) {
4096 if ( $al == $line [ "access_level" ]) {
4097 $selected = "selected" ;
4101 print "<option $selected id= \" $al\" >" .
4102 $access_level_names [ $al ] . "</option>" ;
4109 print "<td>" . $line [ "last_login" ]. "</td>" ;
4120 if ( $subop == "edit" ) {
4122 <input type= \" submit \" class= \" button \"
4123 onclick= \" javascript:userEditSave() \" value= \" Save \" >
4124 <input type= \" submit \" class= \" button \"
4125 onclick= \" javascript:userEditCancel() \" value= \" Cancel \" >" ;
4131 <input type= \" submit \" class= \" button \"
4132 onclick= \" javascript:selectedUserDetails() \" value= \" User details \" >
4133 <input type= \" submit \" class= \" button \"
4134 onclick= \" javascript:editSelectedUser() \" value= \" Edit \" >
4135 <input type= \" submit \" class= \" button \"
4136 onclick= \" javascript:removeSelectedUsers() \" value= \" Remove \" >
4137 <input type= \" submit \" class= \" button \"
4138 onclick= \" javascript:resetSelectedUserPass() \" value= \" Reset password \" >" ;
4143 if ( $op == "user-details" ) {
4145 if ( WEB_DEMO_MODE ||
$_SESSION [ "access_level" ] < 10 ) {
4149 /* print "<html><head>
4150 <title>Tiny Tiny RSS : User Details</title>
4151 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
4152 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
4155 $uid = sprintf ( " %d " , $_GET [ "id" ]);
4157 print "<div class='infoBoxContents'>" ;
4159 $result = db_query ( $link , "SELECT login,
4160 SUBSTRING(last_login,1,16) AS last_login,
4162 (SELECT COUNT(int_id) FROM ttrss_user_entries
4163 WHERE owner_uid = id) AS stored_articles
4165 WHERE id = ' $uid '" );
4167 if ( db_num_rows ( $result ) == 0 ) {
4168 print "<h1>User not found</h1>" ;
4172 print "<h1>User Details</h1>" ;
4174 print "<table width='100%'>" ;
4176 $login = db_fetch_result ( $result , 0 , "login" );
4177 $last_login = date ( get_pref ( $link , 'LONG_DATE_FORMAT' ),
4178 strtotime ( db_fetch_result ( $result , 0 , "last_login" )));
4179 $access_level = db_fetch_result ( $result , 0 , "access_level" );
4180 $stored_articles = db_fetch_result ( $result , 0 , "stored_articles" );
4182 print "<tr><td>Username</td><td> $login </td></tr>" ;
4183 print "<tr><td>Access level</td><td> $access_level </td></tr>" ;
4184 print "<tr><td>Last logged in</td><td> $last_login </td></tr>" ;
4185 print "<tr><td>Stored articles</td><td> $stored_articles </td></tr>" ;
4187 $result = db_query ( $link , "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
4188 WHERE owner_uid = ' $uid '" );
4190 $num_feeds = db_fetch_result ( $result , 0 , "num_feeds" );
4192 print "<tr><td>Subscribed feeds count</td><td> $num_feeds </td></tr>" ;
4194 /* $result = db_query($link, "SELECT
4195 SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size
4196 FROM ttrss_user_entries,ttrss_entries
4197 WHERE owner_uid = '$uid' AND ref_id = id");
4199 $db_size = round(db_fetch_result($result, 0, "db_size") / 1024);
4201 print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */
4205 print "<h1>Subscribed feeds</h1>" ;
4207 $result = db_query ( $link , "SELECT id,title,site_url FROM ttrss_feeds
4208 WHERE owner_uid = ' $uid ' ORDER BY title" );
4210 print "<ul class= \" userFeedList \" >" ;
4212 while ( $line = db_fetch_assoc ( $result )) {
4214 $icon_file = ICONS_URL
. "/" . $line [ "id" ]. ".ico" ;
4216 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
4217 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" $icon_file\" >" ;
4219 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
4222 print "<li> $feed_icon <a href= \" " . $line [ "site_url" ]. " \" >" . $line [ "title" ]. "</a></li>" ;
4225 if ( db_num_rows ( $result ) < $num_feeds ) {
4226 // FIXME - add link to show ALL subscribed feeds here somewhere
4228 class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" > ...</li>" ;
4235 print "<div align='center'>
4236 <input type='submit' class='button'
4237 onclick= \" closeInfoBox() \" value= \" Close this window \" ></div>" ;
4239 // print "</body></html>";
4243 if ( $op == "feed-details" ) {
4245 // $feed_id = $_GET["id"];
4247 $feed_ids = split ( "," , db_escape_string ( $_GET [ "id" ]));
4249 print "<div class= \" infoBoxContents \" >" ;
4251 foreach ( $feed_ids as $feed_id ) {
4253 $result = db_query ( $link ,
4256 SUBSTRING(last_updated,1,16) as last_updated,
4258 (SELECT COUNT(int_id) FROM ttrss_user_entries
4259 WHERE feed_id = id) AS total,
4260 (SELECT COUNT(int_id) FROM ttrss_user_entries
4261 WHERE feed_id = id AND unread = true) AS unread,
4262 (SELECT COUNT(int_id) FROM ttrss_user_entries
4263 WHERE feed_id = id AND marked = true) AS marked
4265 WHERE id = ' $feed_id ' AND owner_uid = " . $_SESSION [ "uid" ]);
4267 if ( db_num_rows ( $result ) == 0 ) return ;
4269 $title = db_unescape_string ( db_fetch_result ( $result , 0 , "title" ));
4270 $last_updated = date ( get_pref ( $link , 'LONG_DATE_FORMAT' ),
4271 strtotime ( db_fetch_result ( $result , 0 , "last_updated" )));
4272 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
4273 $icon_url = db_fetch_result ( $result , 0 , "icon_url" );
4274 $total = db_fetch_result ( $result , 0 , "total" );
4275 $unread = db_fetch_result ( $result , 0 , "unread" );
4276 $marked = db_fetch_result ( $result , 0 , "marked" );
4277 $site_url = db_fetch_result ( $result , 0 , "site_url" );
4279 $result = db_query ( $link , "SELECT COUNT(id) AS subscribed
4280 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' AND private = false" );
4282 $subscribed = db_fetch_result ( $result , 0 , "subscribed" );
4284 $icon_file = ICONS_DIR
. "/ $feed_id .ico" ;
4286 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
4287 $feed_icon = "<img width= \" 16 \" height= \" 16 \"
4288 src= \" " . ICONS_URL
. "/ $feed_id .ico \" >" ;
4293 print "<h1> $feed_icon $title </h1>" ;
4295 print "<table width='100%'>" ;
4298 print "<tr><td width='30%'>Link</td>
4299 <td><a href= \" $site_url\" > $site_url </a>
4300 <a href= \" $feed_url\" >(feed)</a></td>
4303 print "<tr><td width='30%'>Feed URL</td>
4304 <td><a href= \" $feed_url\" > $feed_url </a></td></tr>" ;
4306 print "<tr><td>Last updated</td><td> $last_updated </td></tr>" ;
4307 print "<tr><td>Total articles</td><td> $total </td></tr>" ;
4308 print "<tr><td>Unread articles</td><td> $unread </td></tr>" ;
4309 print "<tr><td>Starred articles</td><td> $marked </td></tr>" ;
4310 print "<tr><td>Subscribed users</td><td> $subscribed </td></tr>" ;
4314 /* $result = db_query($link, "SELECT title,
4315 SUBSTRING(updated,1,16) AS updated,unread
4316 FROM ttrss_entries,ttrss_user_entries
4317 WHERE ref_id = id AND feed_id = '$feed_id'
4318 ORDER BY date_entered DESC LIMIT 5");
4320 if (db_num_rows($result) > 0) {
4322 print "<h1>Latest headlines</h1>";
4324 print "<ul class=\"nomarks\">";
4326 while ($line = db_fetch_assoc($result)) {
4327 if ($line["unread"] == "t" || $line["unread"] == "1") {
4328 $line["title"] = "<b>" . $line["title"] . "</b>";
4330 print "<li>" . $line["title"].
4331 " <span class=\"insensitive\">(" .
4332 date(get_pref($link, 'SHORT_DATE_FORMAT'),
4333 strtotime($line["updated"])).
4344 print "<div align='center'>
4345 <input type='submit' class='button'
4346 onclick= \" closeInfoBox() \" value= \" Close this window \" ></div>" ;
4349 if ( $op == "pref-feed-browser" ) {
4351 if (! ENABLE_FEED_BROWSER
) {
4352 print "Feed browser is administratively disabled." ;
4356 $subop = $_REQUEST [ "subop" ];
4358 if ( $subop == "details" ) {
4359 $id = db_escape_string ( $_GET [ "id" ]);
4361 print "<div class= \" browserFeedInfo \" >" ;
4362 print "<b>Feed information:</b>" ;
4363 print "<div class= \" detailsPart \" >" ;
4365 $result = db_query ( $link , "SELECT
4367 SUBSTRING(last_updated,1,19) AS last_updated
4368 FROM ttrss_feeds WHERE id = ' $id '" );
4370 $feed_url = db_fetch_result ( $result , 0 , "feed_url" );
4371 $site_url = db_fetch_result ( $result , 0 , "site_url" );
4372 $last_updated = db_fetch_result ( $result , 0 , "last_updated" );
4374 if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
4375 $last_updated = smart_date_time ( strtotime ( $last_updated ));
4377 $short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
4378 $last_updated = date ( $short_date , strtotime ( $last_updated ));
4381 print "Site: <a href=' $site_url '> $site_url </a> " .
4382 "(<a href=' $feed_url '>feed</a>), " .
4383 "Last updated: $last_updated " ;
4387 $result = db_query ( $link , "SELECT
4388 ttrss_entries.title,
4390 substring(date_entered,1,19) as date_entered,
4391 substring(updated,1,19) as updated
4392 FROM ttrss_entries,ttrss_user_entries
4393 WHERE ttrss_entries.id = ref_id AND feed_id = ' $id '
4394 ORDER BY updated DESC LIMIT 5" );
4396 if ( db_num_rows ( $result ) > 0 ) {
4398 print "<b>Last headlines:</b><br>" ;
4400 print "<div class= \" detailsPart \" >" ;
4401 print "<ul class= \" compact \" >" ;
4402 while ( $line = db_fetch_assoc ( $result )) {
4404 if ( get_pref ( $link , 'HEADLINES_SMART_DATE' )) {
4405 $entry_dt = smart_date_time ( strtotime ( $line [ "updated" ]));
4407 $short_date = get_pref ( $link , 'SHORT_DATE_FORMAT' );
4408 $entry_dt = date ( $short_date , strtotime ( $line [ "updated" ]));
4411 print "<li>" . $line [ "title" ] .
4412 " <span class= \" insensitive \" >( $entry_dt )</span></li>" ;
4414 print "</ul></div>" ;
4422 $result = db_query ( $link , "SELECT feed_url,count(id) AS subscribers
4424 WHERE auth_login = '' AND auth_pass = '' AND private = false
4425 GROUP BY feed_url ORDER BY subscribers DESC LIMIT 100" );
4427 print "<ul class='nomarks' id='browseBigFeedList'>" ;
4431 while ( $line = db_fetch_assoc ( $result )) {
4432 $feed_url = $line [ "feed_url" ];
4433 $subscribers = $line [ "subscribers" ];
4435 $sub_result = db_query ( $link , "SELECT id
4436 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' AND owner_uid =" .
4439 if ( db_num_rows ( $sub_result ) > 0 ) {
4440 continue ; // already subscribed
4443 $det_result = db_query ( $link , "SELECT site_url,title,id
4444 FROM ttrss_feeds WHERE feed_url = ' $feed_url ' LIMIT 1" );
4446 $details = db_fetch_assoc ( $det_result );
4448 $icon_file = ICONS_DIR
. "/" . $details [ "id" ] . ".ico" ;
4450 if ( file_exists ( $icon_file ) && filesize ( $icon_file ) > 0 ) {
4451 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" " . ICONS_URL
.
4452 "/" . $details [ "id" ]. ".ico \" >" ;
4454 $feed_icon = "<img class= \" tinyFeedIcon \" src= \" images/blank_icon.gif \" >" ;
4457 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
4458 type= \" checkbox \" id= \" FBCHK-" . $details [ "id" ] . " \" >" ;
4460 $class = ( $feedctr %
2 ) ?
"even" : "odd" ;
4462 print "<li class=' $class ' id= \" FBROW-" . $details [ "id" ]. " \" > $check_box " .
4465 print "<a href= \" javascript:browserToggleExpand('" . $details [ "id" ]. "') \" >" .
4466 $details [ "title" ] . "</a> " .
4467 "<span class='subscribers'>( $subscribers )</span>" ;
4469 print "<div class= \" browserDetails \" id= \" BRDET-" . $details [ "id" ] . " \" >" ;
4477 if ( $feedctr == 0 ) {
4478 print "<li>No feeds found to subscribe.</li>" ;
4483 print "<p>Selection:
4484 <input type='submit' class='button' onclick= \" feedBrowserSubscribe() \"
4485 value= \" Subscribe \" ></p>" ;
4494 <!-- < ?
= sprintf ( "Backend execution time: %.4f seconds" , getmicrotime () - $script_started ) ?
> -->