Per-user feed rename support;

Support for hiding feed item content by default (also per-user);
Duplicate page navigation at the bottom of the page;
Correct item list title ("feed on feeds - vitaphoto checkins - items 0 to 50 - new items tagged Fun")
&how=paged in tag list links;
Fix a lot of ugly code.
master
vitalif 2010-01-25 17:30:38 +00:00
parent 1e0937a7b0
commit a1750d1989
12 changed files with 464 additions and 488 deletions

View File

@ -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)
@ -222,20 +222,24 @@ 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)
{
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;
}
?>

View File

@ -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();
@ -432,24 +444,36 @@ function fof_view_title($feed=NULL, $what="new", $when=NULL, $start=NULL, $limit
{
$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 < count($items); $i++)
{
foreach($fof_item_filters as $filter)
{
$items[$i]['item_content'] = $filter($items[$i]['item_content']);
}
$items[$i]['feed_title'] = fof_feed_title($items[$i]);
}
return $items;
@ -481,11 +503,9 @@ function fof_get_item($user_id, $item_id)
global $fof_item_filters;
$item = fof_db_get_item($user_id, $item_id);
foreach($fof_item_filters as $filter)
{
$item['item_content'] = $filter($item['item_content']);
}
$item['feed_title'] = fof_feed_title($item);
return $item;
}
@ -518,13 +538,9 @@ function fof_get_nav_links($feed=NULL, $what="new", $when=NULL, $start=NULL, $li
if(!is_null($when) && $when != "")
{
if($when == "today")
{
$whendate = fof_todays_date();
}
else
{
$whendate = $when;
}
$begin = strtotime($whendate);
@ -555,7 +571,7 @@ function fof_render_feed_link($row)
{
$link = $row['feed_link'];
$description = $row['feed_description'];
$title = $row['feed_title'];
$title = htmlspecialchars(fof_feed_title($row), ENT_QUOTES);
$url = $row['feed_url'];
$s = "<b><a href=\"$link\" title=\"$description\">$title</a></b> ";
@ -642,7 +658,7 @@ function fof_subscribe($user_id, $url, $unread="today")
return '<font color="green"><b>Subscribed.</b></font><!-- '.$feed['feed_id'].' --><br>';
}
$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 );

View File

@ -43,7 +43,6 @@ function do_highlight($full_body, $q, $class){
return $full_body_hl;
}
function fof_render_item($item)
{
$items = true;
@ -163,21 +162,19 @@ function fof_render_item($item)
<h2>
<?php $prefs = fof_prefs(); if($feed_image && $prefs['favicons']) { ?>
<a href="<?php echo $feed_link ?>" title='<?php echo $feed_description ?>'><img src="<?php echo $feed_image ?>" height="16" width="16" border="0" /></a>
<a href="<?=htmlspecialchars($feed_link)?>" title="<?=htmlspecialchars($feed_description)?>"><img src="<?=$feed_image?>" height="16" width="16" border="0" /></a>
<?php } ?>
<a href="<?php echo $feed_link ?>" title='<?php echo $feed_description ?>'><?php echo $feed_title ?></a>
<a href="<?=htmlspecialchars($feed_link)?>" title="<?=htmlspecialchars($feed_description)?>"><?=htmlspecialchars($feed_title)?></a>
</h2>
<span class="meta">on <?php echo $item_published ?></span>
</div>
<div class="body"><?php echo $item_content ?></div>
<?php
$widgets = fof_get_widgets($item);
if($widgets) {
?>
@ -187,9 +184,7 @@ function fof_render_item($item)
<?php
foreach($widgets as $widget)
{
echo "<span class='widget'>$widget</span> ";
}
?>
</div>

View File

@ -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
{
}

10
fof.js
View File

@ -907,3 +907,13 @@ function ajaxadd()
continueadd();
}
function show_filter(id)
{
var sp1 = document.getElementById('fspan'+id);
if (sp1)
sp1.style.display = '';
var sp2 = document.getElementById('ftspan'+id);
if (sp2)
sp2.style.display = 'none';
var a = document.getElementById('fa'+id);
}

View File

@ -24,17 +24,11 @@ fof_set_content_type();
function get_curl_version()
{
if (is_array($curl = curl_version()))
{
$curl = $curl['version'];
}
else if (preg_match('/curl\/(\S+)(\s|$)/', $curl, $match))
{
$curl = $match[1];
}
else
{
$curl = 0;
}
return $curl;
}
@ -52,7 +46,8 @@ $iconv_ok = extension_loaded('iconv');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>feed on feeds - installation</title>
<head>
<title>feed on feeds - installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="fof.css" media="screen" />
<script src="fof.js" type="text/javascript"></script>
@ -63,7 +58,6 @@ $iconv_ok = extension_loaded('iconv');
font-family: georgia;
font-size: 16px;
}
div
{
background: #eee;
@ -72,33 +66,25 @@ $iconv_ok = extension_loaded('iconv');
margin: 5em auto;
padding: 1.5em;
}
hr
{
height:0;
border:0;
border-top:1px solid #999;
}
.fail { color: red; }
.pass { color: green; }
.warn { color: #a60; }
</style>
</head>
<body><div><center style="font-size: 20px;"><a href="http://feedonfeeds.com/">Feed on Feeds</a> - Installation</center><br>
<?php
if($_GET['password'] && $_GET['password'] == $_GET['password2'] )
{
$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 '<center><b>OK! Setup complete! <a href=".">Login as admin</a>, and start subscribing!</center></b></div></body></html>';
}
else
@ -107,7 +93,6 @@ else
{
echo '<center><font color="red">Passwords do not match!</font></center><br><br>';
}
?>
Checking compatibility...
@ -253,70 +238,37 @@ 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: <b>" . mysql_error() . "</b><br>");
}
}
?>
Tables exist.<hr>
Upgrading schema...
<?php
$result = fof_db_query("show columns from $FOF_FEED_TABLE like 'feed_image_cache_date'");
if(mysql_num_rows($result) == 0)
{
if (!mysql_num_rows(fof_db_query("show columns from $FOF_FEED_TABLE like 'feed_image_cache_date'")) &&
!fof_db_query("ALTER TABLE $FOF_FEED_TABLE ADD `feed_image_cache_date` INT( 11 ) DEFAULT '0' AFTER `feed_image`;"))
exit("Can't add column feed_image_cache_date to table $FOF_FEED_TABLE. MySQL says: <b>" . mysql_error() . "</b><br>");
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: <b>" . mysql_error() . "</b><br>");
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: <b>" . mysql_error() . "</b><br>");
print "Done.<hr>";
}
?>
<?php
$result = fof_db_query("show columns from $FOF_USER_TABLE like 'user_password_hash'");
if(mysql_num_rows($result) == 0)
{
print "Upgrading schema...";
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))");
print "Done.<hr>";
}
?>
<?php
$result = fof_db_query("show columns from $FOF_FEED_TABLE like 'feed_cache_attempt_date'");
if(mysql_num_rows($result) == 0)
{
print "Upgrading schema...";
fof_db_query("ALTER TABLE $FOF_FEED_TABLE ADD `feed_cache_attempt_date` INT( 11 ) DEFAULT '0' AFTER `feed_cache_date` ;");
print "Done.<hr>";
}
?>
Schema up to date.<hr>
Inserting initial data...
<?php
fof_db_query("insert into $FOF_TAG_TABLE (tag_id, tag_name) values (1, 'unread')", 1);
fof_db_query("insert into $FOF_TAG_TABLE (tag_id, tag_name) values (2, 'star')", 1);
?>
Done.<hr>
Checking cache directory...
@ -325,7 +277,6 @@ Checking cache directory...
if (!file_exists("cache"))
{
$status = @mkdir("cache", 0755);
if (!$status)
{
echo "<font color='red'>Can't create directory <code>" . getcwd() . "/cache/</code>.<br>You will need to create it yourself, and make it writeable by your PHP process.<br>Then, reload this page.</font>";
@ -342,14 +293,12 @@ if(!is_writable( "cache" ))
}
?>
Cache directory exists and is writable.<hr>
<?php
$result = fof_db_query("select * from $FOF_USER_TABLE where user_name = 'admin'");
if(mysql_num_rows($result) == 0) {
?>
You now need to choose an initial password for the 'admin' account:<br>
<form>

View File

@ -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";
}
else
{
$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'];
<li><a href="javascript:hide_all()">Hide all</a></li>
</ul>
<!-- close this form to fix first item! -->
<form id="itemform" name="items" action="view-action.php" method="post" onSubmit="return false;">
@ -100,15 +88,10 @@ $noedit = $_GET['noedit'];
<?php
$links = fof_get_nav_links($_GET['feed'], $what, $_GET['when'], $which, $_GET['howmany']);
if($links)
{
?>
<center><?php echo $links ?></center>
<?php
if($links) { ?>
<center><?php echo $links ?></center><?php
}
$result = fof_get_items(fof_current_user(), $_GET['feed'], $what, $_GET['when'], $which, $_GET['howmany'], $order, $_GET['search']);
$first = true;
@ -118,7 +101,7 @@ foreach($result as $row)
$item_id = $row['item_id'];
if($first) print "<script>firstItem = 'i$item_id'; </script>";
$first = false;
print '<div class="item shown" id="i' . $item_id . '" onclick="return itemClicked(event)">';
print '<div class="item '.($row['prefs']['hide_content'] ? 'hidden' : 'shown').'" id="i' . $item_id . '" onclick="return itemClicked(event)">';
fof_render_item($row);
print '</div>';
}
@ -128,6 +111,9 @@ if(count($result) == 0)
echo "<p><i>No items found.</i></p>";
}
if($links) { ?>
<center><?php echo $links ?></center><?php
}
?>
</form>

View File

@ -29,7 +29,8 @@ $result = fof_db_get_subscriptions(fof_current_user());
while($row = fof_db_get_row($result))
{
$url = htmlspecialchars($row['feed_url']);
$title = htmlspecialchars($row['feed_title']);
$row['prefs'] = unserialize($row['subscription_prefs']);
$title = htmlspecialchars(fof_feed_title($row));
$link = htmlspecialchars($row['feed_link']);
echo <<<HEYO
@ -39,10 +40,8 @@ while($row = fof_db_get_row($result))
htmlUrl="$link"
xmlUrl="$url"
/>
HEYO;
}
?>
</body>
</opml>

106
prefs.php
View File

@ -35,44 +35,65 @@ if(isset($_POST['adminprefs']))
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')
{
$feed_id = substr($k, 5);
if ($feed = fof_db_get_feed_by_id($feed_id))
if ($prop == 'untag')
{
foreach ($v as $tag)
{
fof_untag_feed(fof_current_user(), $feed_id, $tag);
$message[] = 'Dropped \''.$tag.'\' from \''.$feed['feed_title'].'\'';
}
$message[] = 'Dropped \''.$tag.'\' from \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\'';
}
}
// add tags
else if (substr($k, 0, 3) == 'tag')
{
$feed_id = substr($k, 3);
if ($feed = fof_db_get_feed_by_id($feed_id))
else if ($prop == 'tag')
{
foreach (preg_split("/[\s,]*,[\s,]*/", $v) as $tag)
{
if ($tag)
{
fof_tag_feed(fof_current_user(), $feed_id, $tag);
$message[] = 'Tagged \''.$feed['feed_title'].'\' as '.$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';
}
}
}
@ -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);
}
}
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: <input type=string name=sharedurl value="<?php
?>
<?php foreach($plugins as $plugin) { ?>
<input type=checkbox name="<?php echo $plugin ?>" <?php if(!$prefs->get("plugin_" . $plugin)) echo "checked"; ?>> Enable plugin <tt><?php echo $plugin?></tt>?<br>
<input type="checkbox" name="<?php echo $plugin ?>" <?php if(!$prefs->get("plugin_" . $plugin)) echo "checked"; ?>> Enable plugin <tt><?php echo $plugin?></tt>?<br>
<?php } ?>
<br>
@ -241,16 +256,24 @@ URL to be linked on shared page: <input type=string name=sharedurl value="<?php
</form>
<br><h1>Feed on Feeds - Feeds, Tags and Filters</h1>
<p style="font-size: 90%"><font color=red>*</font> Check 'Hide' if you want to hide contents of items of the corresponding feed by default.<br />
Click 'Filter' and enter a regular expression to filter out items matching it directly into "already read" state.<br />
Don't forget to Save preferences after making changes :-)</p>
<div style="border: 1px solid black; margin: 10px; padding: 10px; font-size: 12px; font-family: verdana, arial;">
<form method="post" action="?tagfeeds=1">
<table cellpadding=3 cellspacing=0>
<tr><th colspan="2" align="left">Feed</th><th>Remove tags</th><th>Add tags</th><th>Item filter regexp</th></tr>
<table cellpadding="3" cellspacing="0" class="feedprefs">
<tr valign="top">
<th colspan="2" align="left">Feed</th>
<th>Remove tags</th>
<th>Add tags<br><small style='font-weight: normal'>(separate with ,)</small></th>
<th>Preferences</th>
</tr>
<?php
foreach($feeds as $row)
{
$id = $row['feed_id'];
$url = $row['feed_url'];
$title = $row['feed_title'];
$title = fof_feed_title($row);
$link = $row['feed_link'];
$description = $row['feed_description'];
$age = $row['feed_age'];
@ -264,21 +287,17 @@ foreach($feeds as $row)
$tags = $row['tags'];
if(++$t % 2)
{
print '<tr class="odd-row">';
}
else
{
print '<tr>';
}
if($row['feed_image'] && $prefs->get('favicons')) { ?>
<td><a href="<?=$url?>" title="feed"><img src='<?=$row['feed_image']?>' width='16' height='16' border='0' /></a></td>
<td><a href="<?=$url?>" title="<?=htmlspecialchars($row['feed_title'])?>"><img src='<?=$row['feed_image']?>' width='16' height='16' border='0' /></a></td>
<? } else { ?>
<td><a href="<?=$url?>" title="feed"><img src='image/feed-icon.png' width='16' height='16' border='0' /></a></td>
<td><a href="<?=$url?>" title="<?=htmlspecialchars($row['feed_title'])?>"><img src='image/feed-icon.png' width='16' height='16' border='0' /></a></td>
<? } ?>
<td><a href="<?=$link?>" title="home page"><?=$title?></a></td>
<td><input type="hidden" name="origtitle_<?=$id?>" value="<?=htmlspecialchars($title)?>" /><input class="editbox" type="text" name="title_<?=$id?>" value="<?=htmlspecialchars($title)?>" size="50" /> <a href="<?=$link?>" title="home page"><img src="image/external.png" alt=" " width="10" height="10" /></a</td>
<td align=right>
<?
@ -288,17 +307,24 @@ foreach($feeds as $row)
foreach($tags as $tag)
{
$utag = htmlspecialchars($tag);
print "<span id='t{$id}_{$i}'>$tag</span> <input onclick='document.getElementById(\"t{$id}_{$i}\").style.textDecoration=this.checked ? \"line-through\" : \"\"' type='checkbox' name='untag{$id}[]' value='$utag'>";
print "<span id='t{$id}_{$i}'>$tag</span> <input onclick='document.getElementById(\"t{$id}_{$i}\").style.textDecoration=this.checked ? \"line-through\" : \"\"' type='checkbox' name='untag_{$id}[]' value='$utag'>";
$i++;
}
}
print "</td>";
$title = htmlspecialchars($title);?>
<td><input type=hidden name=title value="<?=$title?>"><input type="text" name="tag<?=$id?>" /> <small><i>(separate tags with commas)</i></small></td><td><input type="text" name="filter<?=$id?>" value="<?=htmlspecialchars($row['prefs']['filter'])?>" /></td></tr>
$flt = htmlspecialchars($row['prefs']['filter']);
?>
</td>
<td><input class="editbox" type="text" name="tag_<?=$id?>" /></td>
<td>
<input type="hidden" name="orighide_<?=$id?>" value="<?=$row['prefs']['hide_content'] ? 1 : 0?>" />
<input type="checkbox" value="1" name="hide_<?=$id?>" title="Hide item content by default" <?=$row['prefs']['hide_content'] ? "checked" : ""?> /><label for="hide_<?=$id?>" title="Hide item content by default">Hide</label> |
<span id="fspan<?=$id?>" style="display:none">Filter: <input class="editbox" type="text" name="filter_<?=$id?>" value="<?=$flt?>" /></span>
<span id="ftspan<?=$id?>"><a id="fa<?=$id?>" href="javascript:show_filter('<?=$id?>')">Filter</a><?=$flt ? ": $flt" : ""?></span>
</td>
</tr>
<? } ?>
</table>
<input type="submit" value="Update tags and filters">
<input type="submit" value="Update tags and filters" />
</form>
</div>

View File

@ -40,13 +40,12 @@ $feed = NULL;
if(isset($_GET['feed']))
{
$feed = $_GET['feed'];
$r = fof_db_get_feed_by_id($feed);
$extratitle .= " from <a href='" . $r['feed_link'] . "'>" . $r['feed_title'] . "</a>";
$r = fof_db_get_feed_by_id($feed, fof_current_user());
$extratitle .= ' from <a href="' . htmlspecialchars($r['feed_link']) . '">' . htmlspecialchars(fof_feed_title($r)) . '</a>';
}
$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 '<div class="item shown" id="i' . $item_id . '">';
$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)
?>
<div class="header">
<h1>
<a href="<?php echo $item_link ?>">
<?php echo $item_title ?>
</a>
</h1>
<span class='dash'> - </span>
<h2>
<a href="<?php echo $feed_link ?>" title='<?php echo $feed_description ?>'><img src="<?php echo $feed_image ?>" height="16" width="16" border="0" /></a>
<a href="<?php echo $feed_link ?>" title='<?php echo $feed_description ?>'><?php echo $feed_title ?></a>
<a href="<?=htmlspecialchars($feed_link)?>" title="<?=htmlspecialchars($feed_description)?>"><img src="<?=htmlspecialchars($feed_image)?>" height="16" width="16" border="0" /></a>
<a href="<?=htmlspecialchars($feed_link)?>" title="<?=htmlspecialchars($feed_description)?>"><?=htmlspecialchars($feed_title)?></a>
</h2>
<span class="meta">on <?php echo $item_published ?> GMT</span>
</div>
<div class="body"><?php echo $item_content ?></div>
<div class="clearer"></div>

View File

@ -123,24 +123,18 @@ foreach($tags as $tag)
if($tag_id == 1 || $tag_id == 2) continue;
if(++$t % 2)
{
print "<tr class=\"odd-row\">";
}
else
{
print "<tr>";
}
print "<td>";
if ($unread) print "<a class='unread' href='.?what=$tag_name,unread'>$unread</a>/";
print "<a href='.?what=$tag_name'>$count</a></td>";
print "<td><b><a href='.?what=$tag_name'>$tag_name</a></b></td>";
print "<a href='.?what=$tag_name&how=paged'>$count</a></td>";
print "<td><b><a href='.?what=$tag_name".($unread?",unread":"&how=paged")."'>$tag_name</a></b></td>";
print "<td><a href=\"#\" title=\"untag all items\" onclick=\"if(confirm('Untag all [$tag_name] items --are you SURE?')) { delete_tag('$tag_name'); return false; } else { return false; }\">[x]</a></td>";
print "</tr>";
}
?>
</table>
@ -151,7 +145,6 @@ foreach($tags as $tag)
<?php } ?>
<div id="feeds">
<div id="feedlist">
@ -215,7 +208,7 @@ foreach($feeds as $row)
{
$id = $row['feed_id'];
$url = $row['feed_url'];
$title = $row['feed_title'];
$title = fof_feed_title($row);
$link = $row['feed_link'];
$description = $row['feed_description'];
$age = $row['feed_age'];
@ -227,15 +220,10 @@ foreach($feeds as $row)
$lateststr = $row['lateststr'];
$lateststrabbr = $row['lateststrabbr'];
if(++$t % 2)
{
print "<tr class=\"odd-row\">";
}
else
{
print "<tr>";
}
$u = ".?feed=$id";
$u2 = ".?feed=$id&amp;what=all&amp;how=paged";
@ -247,9 +235,7 @@ foreach($feeds as $row)
print "<td class=\"nowrap\" id=\"${id}-items\">";
if($unread)
{
print "<a class=\"unread\" title=\"new items\" href=\"$u\">$unread</a>/";
}
print "<a href=\"$u2\" title=\"all items\">$items</a>";
@ -257,24 +243,20 @@ foreach($feeds as $row)
print "<td align='center'>";
if($row['feed_image'] && $fof_prefs_obj->get('favicons'))
{
print "<a href=\"$url\" title=\"feed\"><img src='" . $row['feed_image'] . "' width='16' height='16' border='0' /></a>";
}
else
{
print "<a href=\"$url\" title=\"feed\"><img src='image/feed-icon.png' width='16' height='16' border='0' /></a>";
}
print "</td>";
print "<td>";
print "<a href=\"".($unread ? $u : $u2)."\" title=\"".($unread ? "unread" : "all")." items\"><b>$title</b></a>";
print "<a href=\"".($unread ? $u : $u2)."\" title=\"".($unread ? "unread" : "all")." items\"><b>".htmlspecialchars($title)."</b></a>";
if ($link)
print " <a href=\"$link\" title=\"home page\"><img style='border-width: 0px' src='image/external.png' /></a>";
print "</td>";
print "<td><nobr>";
print "<a href=\"update.php?feed=$id\" title=\"update\">u</a>";
$stitle = htmlspecialchars(addslashes($title));
$stitle = addslashes($title);
print " <a href=\"#\" title=\"mark all read\" onclick=\"if(confirm('Mark all [$stitle] items as read --are you SURE?')) { mark_feed_read($id); return false; } else { return false; }\">m</a>";
print " <a href=\"delete.php?feed=$id\" title=\"delete\" onclick=\"return confirm('Unsubscribe [$stitle] --are you SURE?')\">d</a>";
@ -291,21 +273,15 @@ foreach($feeds as $row)
</div>
<?php
$order = $_GET['order'];
$direction = $_GET['direction'];
if(!isset($order))
{
$order = "title";
}
if(!isset($direction))
{
$direction = "asc";
}
?>

View File

@ -69,5 +69,5 @@ print(join($feedjson, ", "));
print("];\n</script>");
include("footer.php");
?>
?>