diff --git a/fof-db.php b/fof-db.php index c391e54..c8c617b 100644 --- a/fof-db.php +++ b/fof-db.php @@ -34,9 +34,9 @@ function fof_db_connect() function fof_db_optimize() { - global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_TAG_TABLE, $FOF_USER_TABLE; - - fof_db_query("optimize table $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_TAG_TABLE, $FOF_USER_TABLE"); + /* Может быть, проблемы из-за этого? */ + /*global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_TAG_TABLE, $FOF_USER_TABLE;*/ + /*fof_db_query("optimize table $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_TAG_TABLE, $FOF_USER_TABLE");*/ } function fof_safe_query(/* $query, [$args...]*/) @@ -154,14 +154,14 @@ function fof_db_get_subscriptions($user_id) { global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_ITEM_TAG_TABLE; - return(fof_safe_query("select * from $FOF_FEED_TABLE, $FOF_SUBSCRIPTION_TABLE where $FOF_SUBSCRIPTION_TABLE.user_id = %d and $FOF_FEED_TABLE.feed_id = $FOF_SUBSCRIPTION_TABLE.feed_id order by feed_title", $user_id)); + return fof_safe_query("select * from $FOF_FEED_TABLE, $FOF_SUBSCRIPTION_TABLE where $FOF_SUBSCRIPTION_TABLE.user_id = %d and $FOF_FEED_TABLE.feed_id = $FOF_SUBSCRIPTION_TABLE.feed_id order by feed_title", $user_id); } function fof_db_get_feeds() { global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_ITEM_TAG_TABLE; - return(fof_db_query("select * from $FOF_FEED_TABLE order by feed_title")); + return fof_db_query("select * from $FOF_FEED_TABLE order by feed_title"); } function fof_db_get_item_by_id($item_id) @@ -221,21 +221,25 @@ function fof_db_get_feed_by_url($feed_url) $result = fof_safe_query("select * from $FOF_FEED_TABLE where feed_url='%s'", $feed_url); - if(mysql_num_rows($result) == 0) - { + if (mysql_num_rows($result) == 0) return NULL; - } $row = mysql_fetch_array($result); return $row; } -function fof_db_get_feed_by_id($feed_id) +function fof_db_get_feed_by_id($feed_id, $user_id = false) { - global $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_SUBSCRIPTION_TABLE, $FOF_ITEM_TAG_TABLE; + global $FOF_FEED_TABLE, $FOF_SUBSCRIPTION_TABLE; - $result = fof_safe_query("select * from $FOF_FEED_TABLE where feed_id=%d", $feed_id); + $j = ""; + if ($user_id) + $j = "JOIN $FOF_SUBSCRIPTION_TABLE s ON s.user_id=".intval($user_id)." AND s.feed_id=s.feed_id"; + $result = fof_safe_query("select * from $FOF_FEED_TABLE f $j where f.feed_id=%d", $feed_id); + + if (mysql_num_rows($result) == 0) + return NULL; $row = mysql_fetch_array($result); @@ -349,7 +353,7 @@ function fof_db_get_items($user_id=1, $feed=NULL, $what="unread", $when=NULL, $s } $args = array(); - $select = "SELECT i.* , f.* "; + $select = "SELECT i.* , f.*, s.subscription_prefs "; $from = "FROM $FOF_FEED_TABLE f, $FOF_ITEM_TABLE i, $FOF_SUBSCRIPTION_TABLE s "; $where = sprintf("WHERE s.user_id = %d AND s.feed_id = f.feed_id AND f.feed_id = i.feed_id ", $user_id); @@ -394,6 +398,7 @@ function fof_db_get_items($user_id=1, $feed=NULL, $what="unread", $when=NULL, $s while($row = mysql_fetch_assoc($result)) { + $row['prefs'] = unserialize($row['subscription_prefs']); $array[] = $row; } @@ -498,13 +503,13 @@ function fof_db_tag_feed($user_id, $feed_id, $tag_id) fof_db_set_subscription_prefs($user_id, $feed_id, $prefs); } -function fof_db_set_feed_filter($user_id, $feed_id, $filter) +function fof_db_set_feedprop($user_id, $feed_id, $prop, $value) { $chg = false; $prefs = fof_db_get_subscription_prefs($user_id, $feed_id); - if ($prefs['filter'] != $filter) + if ($prefs[$prop] != $value) { - $prefs['filter'] = $filter; + $prefs[$prop] = $value; $chg = true; } fof_db_set_subscription_prefs($user_id, $feed_id, $prefs); @@ -841,4 +846,18 @@ function fof_db_get_is_duplicate_item($item_id, $item_guid, $content_md5) return $users; } +function fof_db_set_feed_custom_title($user_id, $feed_id, $feed_title, $custom_title) +{ + global $FOF_FEED_TABLE, $FOF_SUBSCRIPTION_TABLE; + $prefs = fof_db_get_subscription_prefs($user_id, $feed_id); + if (!$prefs) + return false; + if (!$custom_title || $feed_title == $custom_title) + $r = $prefs['feed_title'] = ''; + else + $r = $prefs['feed_title'] = $custom_title; + fof_db_set_subscription_prefs($user_id, $feed_id, $prefs); + return $r; +} + ?> diff --git a/fof-main.php b/fof-main.php index 3643356..a143101 100644 --- a/fof-main.php +++ b/fof-main.php @@ -329,13 +329,13 @@ function fof_get_feeds($user_id, $order = 'feed_title', $direction = 'asc') $id = $row['feed_id']; $age = $row['feed_cache_date']; + $feeds[$i]['prefs'] = unserialize($row['subscription_prefs']); $feeds[$i]['feed_id'] = $id; $feeds[$i]['feed_url'] = $row['feed_url']; $feeds[$i]['feed_title'] = $row['feed_title']; $feeds[$i]['feed_link'] = $row['feed_link']; $feeds[$i]['feed_description'] = $row['feed_description']; $feeds[$i]['feed_image'] = $row['feed_image']; - $feeds[$i]['prefs'] = unserialize($row['subscription_prefs']); $feeds[$i]['feed_age'] = $age; list($agestr, $agestrabbr) = fof_nice_time_stamp($age); @@ -423,6 +423,18 @@ function fof_get_feeds($user_id, $order = 'feed_title', $direction = 'asc') return $feeds; } +function fof_feed_title($feed, $prefs = NULL) +{ + if (!$prefs) + $prefs = $feed['prefs']; + if (!$prefs) + $prefs = fof_db_get_subscription_prefs(fof_current_user(), $feed['feed_id']); + $t = $prefs['feed_title']; + if (!$t) + $t = $feed['feed_title']; + return $t; +} + function fof_view_title($feed=NULL, $what="new", $when=NULL, $start=NULL, $limit=NULL, $search=NULL) { $prefs = fof_prefs(); @@ -430,26 +442,38 @@ function fof_view_title($feed=NULL, $what="new", $when=NULL, $start=NULL, $limit if(!is_null($when) && $when != "") { - $title .= ' - ' . $when ; + $title .= ' - ' . $when; } - if(!is_null($feed) && $feed != "") + + if (!is_null($feed) && $feed != "" && + ($r = fof_db_get_feed_by_id($feed))) { - $r = fof_db_get_feed_by_id($feed); - $title .=' - ' . $r['feed_title']; + $title .= ' - ' . htmlspecialchars(fof_feed_title($r), ENT_QUOTES); } + if(is_numeric($start)) { if(!is_numeric($limit)) $limit = $prefs["howmany"]; $title .= " - items $start to " . ($start + $limit); } + if($what != "all") { - $title .=' - new items'; + $wh = array(); + $new = ''; + foreach(explode(',', $what) as $t) + { + if ($t == 'unread') + $new = ' new'; + else + $wh[] = $t; + } + $title .= ' -' . $new . ' items'; + if (count($wh)) + $title .= ' tagged '.implode(',', $wh); } else - { $title .= ' - all items'; - } if(isset($search)) { @@ -464,13 +488,11 @@ function fof_get_items($user_id, $feed=NULL, $what="unread", $when=NULL, $start= global $fof_item_filters; $items = fof_db_get_items($user_id, $feed, $what, $when, $start, $limit, $order, $search); - - for($i=0; $i$title "; @@ -642,7 +658,7 @@ function fof_subscribe($user_id, $url, $unread="today") return 'Subscribed.
'; } - $id = fof_add_feed($url, $rss->get_title(), $rss->get_link(), $rss->get_description() ); + $id = fof_add_feed($url, rss_feed_title($rss), $rss->get_link(), $rss->get_description() ); fof_update_feed($id); fof_db_add_subscription($user_id, $id); @@ -737,6 +753,11 @@ function fof_apply_tags($item) fof_mark_item_unread($item['feed_id'], $item['item_id'], $filtered); } +function rss_feed_title($rss) +{ + return html_entity_decode(strip_tags($rss->get_title()), ENT_QUOTES); +} + function fof_update_feed($id) { if(!$id) return 0; @@ -772,7 +793,7 @@ function fof_update_feed($id) $image_cache_date = time(); } - $title = $rss->get_title(); + $title = rss_feed_title($rss); if($title == "") $title = "[no title]"; fof_db_feed_update_metadata($id, $sub, $title, $rss->get_link(), $rss->get_description(), $image, $image_cache_date ); diff --git a/fof-render.php b/fof-render.php index 2abcf47..b773d9f 100644 --- a/fof-render.php +++ b/fof-render.php @@ -43,7 +43,6 @@ function do_highlight($full_body, $q, $class){ return $full_body_hl; } - function fof_render_item($item) { $items = true; @@ -93,7 +92,7 @@ function fof_render_item($item) id="c" value="checked" ondblclick='flag_upto("c");' - onclick='return checkbox(event);' + onclick='return checkbox(event);' title='shift-click or double-click to flag all items up to this one' /> @@ -157,27 +156,25 @@ function fof_render_item($item) - + - - +

- + - +

- on + on -
@@ -187,9 +184,7 @@ function fof_render_item($item) $widget "; - } ?> diff --git a/fof.css b/fof.css index 5d3806e..2573a97 100644 --- a/fof.css +++ b/fof.css @@ -100,25 +100,26 @@ p padding: 2px; } - .odd-row { background: #dddddd; } +.feedprefs { margin-bottom: 8px; } +.feedprefs input.editbox { border-color: lightgray; border-width: 0 0 1px 0; border-style: solid; } +.odd-row input.editbox { border-width: 0; } + .unread { font-weight: bold; color: red; } - .unread-item { font-weight: bold; } - #items { } diff --git a/fof.js b/fof.js index b306e63..2ecb16d 100644 --- a/fof.js +++ b/fof.js @@ -49,19 +49,19 @@ var getScrollY = function() { var getY = function(e) { var y = NaN; - + if (e.offsetParent) { y = e.offsetTop while (e = e.offsetParent) { y += e.offsetTop } } - + return y; } function getWindowHeight() -{ +{ if( typeof( window.innerHeight ) == 'number' ) { //Non-IE return window.innerHeight; @@ -72,7 +72,7 @@ function getWindowHeight() //IE 4 compatible return document.body.clientHeight; } - + return NaN; } @@ -103,13 +103,13 @@ function embed_wmedia(width, height, link) { function itemClicked(event) { - if(!event) event = window.event; + if(!event) event = window.event; target = window.event ? window.event.srcElement : event.target; - + if(event.altKey) { Event.stop(event); - + unselect(itemElement); while(target.parentNode) { @@ -119,13 +119,13 @@ function itemClicked(event) } target = target.parentNode; } - + if(itemElement == target) { itemElement = null; return false; } - + Element.addClassName(target, 'selected'); itemElement = target; @@ -144,43 +144,43 @@ function itemClicked(event) document.title = "Feed on Feeds - " + i + " of " + n; return false; } - + return true; } function checkbox(event) { - if(!event) event = window.event; + if(!event) event = window.event; target = window.event ? window.event.srcElement : event.target; - + if(!event.shiftKey) return true; - + flag_upto(target.id); - + return true; } function select(item) { Element.addClassName(item, 'selected'); - + y = getY(item); bar = $('item-display-controls').getHeight(); window.scrollTo(0, y - (bar + 10)); - + i = itemElements.indexOf(item); - + if(i == -1) { // in case page was partially loaded when itemElements was initialized itemElements = $$('.item'); i = itemElements.indexOf(item); } - + n = itemElements.length; i++; - + document.title = "Feed on Feeds - " + i + " of " + n; } @@ -193,20 +193,20 @@ function unselect(item) function show_enclosure(e) { - if (!e) e = window.event; + if (!e) e = window.event; target = window.event ? window.event.srcElement : e.target; Element.extend(target); div = target.nextSiblings().first(); Element.show(div); Element.hide(target); - + return false; } function keyboard(e) { if (!e) e = window.event; - + target = window.event ? window.event.srcElement : e.target; if(target != null && target.type != null && (target.type == "textarea" || target.type=="text" || target.type=="password")) @@ -216,13 +216,13 @@ function keyboard(e) if (e.keyCode) keycode=e.keyCode; else keycode=e.which; - + if(e.ctrlKey || e.altKey || e.metaKey) return true; - - key = String.fromCharCode(keycode); - + + key = String.fromCharCode(keycode); + if(!itemElements) itemElements = $$('.item'); - + windowHeight = getWindowHeight(); if(key == "H") @@ -233,15 +233,15 @@ function keyboard(e) Element.toggleClassName(i, "hidden"); } ); - + if(itemElement) select(itemElement); - + return false; } - + if(key == "h") - { + { if(itemElement) { Element.toggleClassName(itemElement, "shown"); @@ -250,7 +250,7 @@ function keyboard(e) return false; } } - + if(key == "s") { if(itemElement) @@ -260,7 +260,7 @@ function keyboard(e) return false; } } - + if(key == "f") { if(itemElement) @@ -270,7 +270,7 @@ function keyboard(e) return false; } } - + if(key == "F") { itemElements.each( @@ -284,7 +284,7 @@ function keyboard(e) checkbox.checked = true; } ); - + return false; } @@ -296,7 +296,7 @@ function keyboard(e) checkbox.checked = false; } ); - + return false; } @@ -304,14 +304,14 @@ function keyboard(e) { if(itemElement) { - // is the next element visible yet? scroll if not. - + // is the next element visible yet? scroll if not. + if(itemElement.nextSibling.id && itemElement.nextSibling.id != "end-of-items") { nextElement = itemElement.nextSibling; scrollHeight = getScrollY(); y = getY(nextElement); - + if(y > scrollHeight + windowHeight) { window.scrollTo(0, scrollHeight + (.8 * windowHeight)); @@ -324,7 +324,7 @@ function keyboard(e) checkbox.checked = true; next = itemElement.nextSibling; - + if(next.id && next.id != "end-of-items") { itemElement = next; @@ -334,14 +334,14 @@ function keyboard(e) scrollHeight = getScrollY(); e = $('end-of-items'); - + if (e.offsetParent) { y = e.offsetTop while (e = e.offsetParent) { y += e.offsetTop } } - + if(y - 10 > scrollHeight + windowHeight) { window.scrollTo(0, scrollHeight + (.8 * windowHeight)); @@ -357,17 +357,17 @@ function keyboard(e) { item = firstItem; itemElement = $(item); - select(itemElement); + select(itemElement); return false; } } } - + item = itemElement.id; itemElement = $(item); - + select(itemElement); - + return false; } else @@ -375,13 +375,13 @@ function keyboard(e) item = firstItem; itemElement = $(item); itemElements = $$('.item'); - + select(itemElement); - + return false; } } - + if(key == "J") { if(itemElement) @@ -391,7 +391,7 @@ function keyboard(e) checkbox.checked = true; next = itemElement.nextSibling; - + if(next.id) { itemElement = next; @@ -408,12 +408,12 @@ function keyboard(e) itemElement = $(item); } } - + item = itemElement.id; itemElement = $(item); - + select(itemElement); - + return false; } else @@ -421,9 +421,9 @@ function keyboard(e) item = firstItem; itemElement = $(item); itemElements = $$('.item'); - + select(itemElement); - + return false; } } @@ -433,9 +433,9 @@ function keyboard(e) if(itemElement) { unselect(itemElement); - + next = itemElement.nextSibling; - + if(next.id) { itemElement = next; @@ -445,12 +445,12 @@ function keyboard(e) item = firstItem; itemElement = $(item); } - + item = itemElement.id; itemElement = $(item); - + select(itemElement); - + return false; } else @@ -458,25 +458,25 @@ function keyboard(e) item = firstItem; itemElement = $(item); itemElements = $$('.item'); - + select(itemElement); - + return false; } } - + if(key == "N") { if(itemElement) unselect(itemElement); - + item = itemElements.last().id; itemElement = $(item); - + select(itemElement); - + return false; } - + if(key == "P") { if(itemElement) unselect(itemElement); @@ -484,20 +484,20 @@ function keyboard(e) item = firstItem; itemElement = $(item); itemElements = $$('.item'); - + select(itemElement); - + return false; } - + if(key == "p") { if(itemElement) { unselect(itemElement); - + next = itemElement.previousSibling; - + if(next.id) { itemElement = next; @@ -507,12 +507,12 @@ function keyboard(e) item = itemElements.last().id; itemElement = $(item); } - + item = itemElement.id; itemElement = $(item); - + select(itemElement); - + return false; } else @@ -520,13 +520,13 @@ function keyboard(e) itemElements = $$('.item'); item = itemElements.last().id; itemElement = $(item); - + select(itemElement); - + return false; } } - + return true; } @@ -535,9 +535,9 @@ function keyboard(e) function startResize(e) { if (!e) e = window.event; - + Event.stop(e); - + drag = true; curPos=e.clientX; curWidth=$('sidebar').offsetWidth; @@ -548,16 +548,16 @@ function startResize(e) function dragResize(e) { if (!e) e = window.event; - + if(drag) { Event.stop(e); - + newPos=e.clientX; var x=newPos-curPos; var w=curWidth+x; newWidth=(w<5?5:w); - + $('handle').style.left=newWidth+'px'; return false; @@ -571,14 +571,14 @@ function completeDrag(e) if(drag) { Event.stop(e); - + drag = false; - + newPos=e.clientX; var x=newPos-curPos; var w=curWidth+x; newWidth=(w<5?5:w); - + $('sidebar').style.width=newWidth+'px'; $('handle').style.left=newWidth+'px'; $('items').style.marginLeft=(newWidth+20)+'px'; @@ -590,15 +590,15 @@ function completeDrag(e) for(i=0;i -feed on feeds - installation - - - - - - - - -
Feed on Feeds - Installation

+ + feed on feeds - installation + + + + + + +
Feed on Feeds - Installation

OK! Setup complete! Login as admin, and start subscribing!
'; + $password_hash = md5($_GET['password'] . 'admin'); + fof_safe_query("insert into $FOF_USER_TABLE (user_id, user_name, user_password_hash, user_level) values (1, 'admin', '%s', 'admin')", $password_hash); + echo '
OK! Setup complete! Login as admin, and start subscribing!
'; } else { @@ -107,7 +93,6 @@ else { echo '
Passwords do not match!


'; } - ?> Checking compatibility... @@ -253,103 +238,67 @@ CREATE TABLE IF NOT EXISTS `$FOF_SUBSCRIPTION_TABLE` ( ) ENGINE=InnoDB; EOQ; - foreach($tables as $table) -{ - if(!fof_db_query($table, 1)) - { - exit ("Can't create table. MySQL says: " . mysql_error() . "
" ); - } -} + if(!fof_db_query($table, 1)) + exit("Can't create table. MySQL says: " . mysql_error() . "
"); ?> Tables exist.
+Upgrading schema... " . mysql_error() . "
"); -print "Upgrading schema..."; +if (!mysql_num_rows(fof_db_query("show columns from $FOF_USER_TABLE like 'user_password_hash'")) && + (!fof_db_query("ALTER TABLE $FOF_USER_TABLE CHANGE `user_password` `user_password_hash` VARCHAR( 32 ) NOT NULL") || + !fof_db_query("update $FOF_USER_TABLE set user_password_hash = md5(concat(user_password_hash, user_name))"))) + exit("Can't change column user_password to user_password_hash. MySQL says: " . mysql_error() . "
"); -fof_db_query("ALTER TABLE $FOF_FEED_TABLE ADD `feed_image_cache_date` INT( 11 ) DEFAULT '0' AFTER `feed_image` ;"); +if (!mysql_num_rows(fof_db_query("show columns from $FOF_FEED_TABLE like 'feed_cache_attempt_date'")) && + !fof_db_query("ALTER TABLE $FOF_FEED_TABLE ADD `feed_cache_attempt_date` INT( 11 ) DEFAULT '0' AFTER `feed_cache_date`;")) + exit("Can't add column feed_cache_attempt_date to table $FOF_FEED_TABLE. MySQL says: " . mysql_error() . "
"); -print "Done.
"; -} -?> - - -"; -} -?> - - -"; -} ?> +Schema up to date.
Inserting initial data... - - Done.
Checking cache directory... Can't create directory " . getcwd() . "/cache/.
You will need to create it yourself, and make it writeable by your PHP process.
Then, reload this page."; - echo ""; + $status = @mkdir("cache", 0755); + if (!$status) + { + echo "Can't create directory " . getcwd() . "/cache/.
You will need to create it yourself, and make it writeable by your PHP process.
Then, reload this page.
"; + echo ""; exit; - } + } } -if(!is_writable( "cache" )) +if(!is_writable("cache")) { - echo "The directory " . getcwd() . "/cache/ exists, but is not writable.
You will need to make it writeable by your PHP process.
Then, reload this page.
"; - echo ""; - exit; + echo "The directory " . getcwd() . "/cache/ exists, but is not writable.
You will need to make it writeable by your PHP process.
Then, reload this page.
"; + echo ""; + exit; } ?> - Cache directory exists and is writable.
- You now need to choose an initial password for the 'admin' account:
diff --git a/items.php b/items.php index 636fcb4..3d85d40 100644 --- a/items.php +++ b/items.php @@ -16,29 +16,19 @@ include_once("fof-main.php"); include_once("fof-render.php"); if($_GET['how'] == 'paged' && !isset($_GET['which'])) -{ $which = 0; -} else -{ $which = $_GET['which']; -} $order = $_GET['order']; if(!isset($_GET['what'])) -{ - $what = "unread"; -} + $what = "unread"; else -{ - $what = $_GET['what']; -} + $what = $_GET['what']; if(!isset($_GET['order'])) -{ $order = $fof_prefs_obj->get("order"); -} $how = $_GET['how']; $feed = $_GET['feed']; @@ -89,8 +79,6 @@ $noedit = $_GET['noedit'];
  • Hide all
  • - - @@ -98,16 +86,11 @@ $noedit = $_GET['noedit']; -
    - - +
    firstItem = 'i$item_id'; "; $first = false; - print '
    '; + print '
    '; fof_render_item($row); print '
    '; } @@ -128,9 +111,12 @@ if(count($result) == 0) echo "

    No items found.

    "; } +if($links) { ?> +
    - +
    - \ No newline at end of file + diff --git a/opml.php b/opml.php index 7d0edcf..ff77aa9 100644 --- a/opml.php +++ b/opml.php @@ -20,7 +20,7 @@ echo ''; - Feed on Feeds Subscriptions + Feed on Feeds Subscriptions + $url = htmlspecialchars($row['feed_url']); + $row['prefs'] = unserialize($row['subscription_prefs']); + $title = htmlspecialchars(fof_feed_title($row)); + $link = htmlspecialchars($row['feed_link']); + echo << HEYO; } ?> - diff --git a/prefs.php b/prefs.php index 390069b..0a5a9f3 100644 --- a/prefs.php +++ b/prefs.php @@ -33,46 +33,67 @@ if(isset($_POST['adminprefs'])) } } -if(isset($_REQUEST['tagfeeds'])) +if (isset($_REQUEST['tagfeeds'])) { + $allow_prop = array('untag' => 1, 'tag' => 1, 'filter' => 1, 'title' => 1, 'hide' => 1, 'orighide' => 1); foreach ($_REQUEST as $k => $v) { + list($prop, $feed_id) = explode('_', $k); + if (!$allow_prop[$prop]) + continue; + if (!($feed = fof_db_get_feed_by_id($feed_id))) + continue; // remove tags - if (substr($k, 0, 5) == 'untag') + if ($prop == 'untag') { - $feed_id = substr($k, 5); - if ($feed = fof_db_get_feed_by_id($feed_id)) + foreach ($v as $tag) { - foreach ($v as $tag) - { - fof_untag_feed(fof_current_user(), $feed_id, $tag); - $message[] = 'Dropped \''.$tag.'\' from \''.$feed['feed_title'].'\''; - } + fof_untag_feed(fof_current_user(), $feed_id, $tag); + $message[] = 'Dropped \''.$tag.'\' from \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\''; } } // add tags - else if (substr($k, 0, 3) == 'tag') + else if ($prop == 'tag') { - $feed_id = substr($k, 3); - if ($feed = fof_db_get_feed_by_id($feed_id)) + foreach (preg_split("/[\s,]*,[\s,]*/", $v) as $tag) { - foreach (preg_split("/[\s,]*,[\s,]*/", $v) as $tag) + if ($tag) { - if ($tag) - { - fof_tag_feed(fof_current_user(), $feed_id, $tag); - $message[] = 'Tagged \''.$feed['feed_title'].'\' as '.$tag; - } + fof_tag_feed(fof_current_user(), $feed_id, $tag); + $message[] = 'Tagged \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\' as '.htmlspecialchars($tag); } } } // change filter - else if (substr($k, 0, 6) == 'filter') + else if ($prop == 'filter') { - $feed_id = substr($k, 6); - if (($feed = fof_db_get_feed_by_id($feed_id)) && - fof_db_set_feed_filter(fof_current_user(), $feed_id, $v)) - $message[] = 'Set filter \''.$v.'\' for feed \''.$feed['feed_title'].'\''; + if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'filter', $v)) + $message[] = 'Set filter \''.htmlspecialchars($v).'\' for feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\''; + } + // rename feed + else if ($prop == 'title' && $v != $_POST['origtitle_'.$feed_id]) + { + if ($feed['feed_title'] == $v) + $v = ''; + if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'feed_title', $v)) + { + if ($v) + $message[] = 'Renamed feed \''.htmlspecialchars($feed['feed_title']).'\' to \''.htmlspecialchars($v).'\''; + else + $message[] = 'Feed title resetted for \''.htmlspecialchars($feed['feed_title']).'\''; + } + } + // show item content by default + else if ($prop == 'hide' && $v && !$_POST['orighide_'.$feed_id]) + { + if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'hide_content', true)) + $message[] = 'Items of feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\' will be shown collapsed by default'; + } + // hide item content by default + else if ($prop == 'orighide' && $v && !$_POST['hide_'.$feed_id]) + { + if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'hide_content', false)) + $message[] = 'Items of feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\' will be shown expanded by default'; } } } @@ -96,7 +117,7 @@ if(isset($_POST['prefs'])) if($_POST['password'] && ($_POST['password'] == $_POST['password2'])) { fof_db_change_password($fof_user_name, $_POST['password']); - setcookie ( "user_password_hash", md5($_POST['password'] . $fof_user_name), time()+60*60*24*365*10 ); + setcookie ("user_password_hash", md5($_POST['password'] . $fof_user_name), time()+60*60*24*365*10); $message = "Updated password."; } else if($_POST['password'] || $_POST['password2']) @@ -118,19 +139,13 @@ if(isset($_POST['plugins'])) $plugins = array(); $dirlist = opendir(FOF_DIR . "/plugins"); while($file=readdir($dirlist)) - { if(ereg('\.php$',$file)) - { - $plugins[] = substr($file, 0, -4); - } - } + $plugins[] = substr($file, 0, -4); closedir(); foreach($plugins as $plugin) - { $prefs->set("plugin_" . $plugin, $_POST[$plugin] != "on"); - } $prefs->save(fof_current_user()); @@ -224,7 +239,7 @@ URL to be linked on shared page: " get("plugin_" . $plugin)) echo "checked"; ?>> Enable plugin ?
    +get("plugin_" . $plugin)) echo "checked"; ?>> Enable plugin ?

    @@ -241,16 +256,24 @@ URL to be linked on shared page: * Check 'Hide' if you want to hide contents of items of the corresponding feed by default.
    +Click 'Filter' and enter a regular expression to filter out items matching it directly into "already read" state.
    +Don't forget to Save preferences after making changes :-)

    - - +
    FeedRemove tagsAdd tagsItem filter regexp
    + + + + + +'; - } else - { print ''; - } if($row['feed_image'] && $prefs->get('favicons')) { ?> - + - + - + "; - $title = htmlspecialchars($title);?> - + $flt = htmlspecialchars($row['prefs']['filter']); + ?> + + + +
    FeedRemove tagsAdd tags
    (separate with ,)
    Preferences
    ' width='16' height='16' border='0' />' width='16' height='16' border='0' />  $tag "; + print "$tag "; $i++; } } - - print " (separate tags with commas)
    + + /> | + + Filter +
    - +
    diff --git a/shared.php b/shared.php index 45545d6..f11bca5 100644 --- a/shared.php +++ b/shared.php @@ -40,13 +40,12 @@ $feed = NULL; if(isset($_GET['feed'])) { $feed = $_GET['feed']; - $r = fof_db_get_feed_by_id($feed); - $extratitle .= " from " . $r['feed_title'] . ""; + $r = fof_db_get_feed_by_id($feed, fof_current_user()); + $extratitle .= ' from ' . htmlspecialchars(fof_feed_title($r)) . ''; } $result = fof_get_items($user, $feed, $which, NULL, 0, 100); - $shared_feed = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . "?user=$user&format=atom"; $shared_link = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . "?user=$user"; @@ -62,7 +61,6 @@ if(isset($_GET['feed'])) $shared_link .= '&feed=' . $_GET['feed']; } - if($format == "atom") { header("Content-Type: application/atom+xml; charset=utf-8"); @@ -84,7 +82,7 @@ foreach($result as $item) { $feed_link = htmlspecialchars($item['feed_link']); $feed_url = htmlspecialchars(preg_replace('!^([a-z0-9_]+)://[^/]*:[^/]*@!is', '\1://', $item['feed_url'])); - $feed_title = htmlspecialchars($item['feed_title']); + $feed_title = htmlspecialchars(fof_feed_title($item)); $item_link = htmlspecialchars($item['item_link']); @@ -170,7 +168,7 @@ foreach($result as $item) print '
    '; $feed_link = $item['feed_link']; - $feed_title = $item['feed_title']; + $feed_title = fof_feed_title($item); $feed_image = $item['feed_image']; $feed_description = $item['feed_description']; @@ -189,28 +187,24 @@ foreach($result as $item) ?>
    -

    - -

    - - + +

    on GMT -
    -
    diff --git a/sidebar.php b/sidebar.php index 7c77dc7..0da30a6 100644 --- a/sidebar.php +++ b/sidebar.php @@ -68,7 +68,7 @@ else echo ""; ?> - +
  • >Unread
  • > Starred
  • >< Today
  • @@ -114,33 +114,27 @@ if($n) "; - } - else - { - print ""; - } + if($tag_id == 1 || $tag_id == 2) continue; - print ""; - if($unread) print "$unread/"; - print "$count"; - print "$tag_name"; - print "[x]"; + if(++$t % 2) + print ""; + else + print ""; - print ""; + print ""; + if ($unread) print "$unread/"; + print "$count"; + print "$tag_name"; + print "[x]"; + + print ""; } - - ?> @@ -151,7 +145,6 @@ foreach($tags as $tag) -
    @@ -184,9 +177,9 @@ foreach (array("feed_age", "max_date", "feed_unread", "feed_url", "feed_title") { $url = "return change_feed_order('$col', 'asc')"; } - + echo ""; - + if($col == "feed_unread") { echo "#"; @@ -195,12 +188,12 @@ foreach (array("feed_age", "max_date", "feed_unread", "feed_url", "feed_title") { echo $name[$col]; } - + if($col == $order) { echo ($direction == "asc") ? "↓" : "↑"; } - + echo ""; } @@ -213,74 +206,63 @@ foreach (array("feed_age", "max_date", "feed_unread", "feed_url", "feed_title") foreach($feeds as $row) { - $id = $row['feed_id']; - $url = $row['feed_url']; - $title = $row['feed_title']; - $link = $row['feed_link']; - $description = $row['feed_description']; - $age = $row['feed_age']; - $unread = $row['feed_unread']; - $starred = $row['feed_starred']; - $items = $row['feed_items']; - $agestr = $row['agestr']; - $agestrabbr = $row['agestrabbr']; - $lateststr = $row['lateststr']; - $lateststrabbr = $row['lateststrabbr']; + $id = $row['feed_id']; + $url = $row['feed_url']; + $title = fof_feed_title($row); + $link = $row['feed_link']; + $description = $row['feed_description']; + $age = $row['feed_age']; + $unread = $row['feed_unread']; + $starred = $row['feed_starred']; + $items = $row['feed_items']; + $agestr = $row['agestr']; + $agestrabbr = $row['agestrabbr']; + $lateststr = $row['lateststr']; + $lateststrabbr = $row['lateststrabbr']; + if(++$t % 2) + print ""; + else + print ""; - if(++$t % 2) - { - print ""; - } - else - { - print ""; - } + $u = ".?feed=$id"; + $u2 = ".?feed=$id&what=all&how=paged"; - $u = ".?feed=$id"; - $u2 = ".?feed=$id&what=all&how=paged"; + print "$agestrabbr"; - print "$agestrabbr"; + print "$lateststrabbr"; - print "$lateststrabbr"; + print ""; - print ""; + if($unread) + print "$unread/"; - if($unread) - { - print "$unread/"; - } + print "$items"; - print "$items"; + print ""; - print ""; + print ""; + if($row['feed_image'] && $fof_prefs_obj->get('favicons')) + print ""; + else + print ""; + print ""; - print ""; - if($row['feed_image'] && $fof_prefs_obj->get('favicons')) - { - print ""; - } - else - { - print ""; - } - print ""; + print ""; + print "".htmlspecialchars($title).""; + if ($link) + print " "; + print ""; + print ""; - print ""; - print "$title"; - if ($link) - print " "; - print ""; - print ""; + print "u"; + $stitle = addslashes($title); + print " m"; + print " d"; - print "u"; - $stitle = htmlspecialchars(addslashes($title)); - print " m"; - print " d"; - - print ""; + print ""; - print ""; + print ""; } ?> @@ -291,21 +273,15 @@ foreach($feeds as $row)
    - - diff --git a/update.php b/update.php index 81f9018..fe6f1b4 100644 --- a/update.php +++ b/update.php @@ -43,7 +43,7 @@ else { $title = $feed['feed_title']; list($timestamp, ) = fof_nice_time_stamp($feed['feed_cache_date']); - + print "$title was just updated $timestamp!
    "; } else @@ -56,12 +56,12 @@ else $feeds = fof_multi_sort($feeds, 'feed_cache_attempt_date', false); print(""); include("footer.php"); -?> +?>