Most popular feed suggestion option

master
vitalif 2010-01-28 13:49:32 +00:00
parent cd35d028a6
commit e616d0e1a2
5 changed files with 65 additions and 23 deletions

47
add.php
View File

@ -73,32 +73,51 @@ if($_SERVER["HTTPS"] == "on")
$add_feed_url .= "://" . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"];
?>
<div style="background: #eee; border: 1px solid black; padding: 1.5em; margin: 1.5em;">If your browser is cool, you can <a href='javascript:window.navigator.registerContentHandler("application/vnd.mozilla.maybe.feed", "<?php echo $add_feed_url ?>?basic_login=%25user%25&do=1&rss_url=%s", "Feed on Feeds")'>register Feed on Feeds as a Feed Reader</a>. If it is not cool, you can still use the <a href="javascript:void(location.href='<?php echo $add_feed_url ?>?basic_login=%25user%25&do=1&rss_url='+escape(location))">FoF subscribe</a> bookmarklet to subscribe to any page with a feed. Just add it as a bookmark and then click on it when you are at a page you'd like to subscribe to!</div>
<div class="fof-add-feeds">
<form method="post" action="opml.php">
<h1>Use FeedOnFeeds for reading feeds always</h1>
<input type="submit" value="Export subscriptions as OPML">
</form>
<br>
<div style="background: #eee; border: 1px solid black; padding: 1.5em; margin: 1em;">
If your browser is cool, you can <a href='javascript:window.navigator.registerContentHandler("application/vnd.mozilla.maybe.feed", "<?php echo $add_feed_url ?>?basic_login=%25user%25&do=1&rss_url=%s", "Feed on Feeds")'>register Feed on Feeds as a Feed Reader</a>.
If it is not cool, you can still use the <a href="javascript:void(location.href='<?php echo $add_feed_url ?>?basic_login=%25user%25&do=1&rss_url='+escape(location))">FoF subscribe</a> bookmarklet to subscribe to any page with a feed.
Just add it as a bookmark and then click on it when you are at a page you'd like to subscribe to!
</div>
<form method="post" name="addform" action="add.php" enctype="multipart/form-data">
When adding feeds, mark <select name="unread"><option value=today <?= $unread == "today" ? "selected" : "" ?> >today's</option><option value=all <?= $unread == "all" ? "selected" : "" ?> >all</option><option value=no <?= $unread == "no" ? "selected" : "" ?> >no</option></select> items as unread<br><br>
When adding feeds, mark <select name="unread"><option value=today <?= $unread == "today" ? "selected" : "" ?> >today's</option><option value=all <?= $unread == "all" ? "selected" : "" ?> >all</option><option value=no <?= $unread == "no" ? "selected" : "" ?> >no</option></select> items as unread<br />
Login: <input type="text" name="basic_login" value="<?= htmlspecialchars($login) ?>"> Password: <input type="password" name="basic_password" value="<?= htmlspecialchars($password) ?>"> (optional) for password-protected feeds<br><br>
<h1>Enter URL manually</h1>
RSS or weblog URL: <input type="text" name="rss_url" size="40" value="<?= htmlspecialchars($url) ?>"><input name="do" type="Submit" value="Add a feed"><br><br>
<p>
Login: <input type="text" name="basic_login" value="<?= htmlspecialchars($login) ?>" /> Password: <input type="password" name="basic_password" value="<?= htmlspecialchars($password) ?>" /> (optional) for password-protected feeds<br>
RSS or weblog URL: <input type="text" name="rss_url" size="40" value="<?= htmlspecialchars($url) ?>" /> <input name="do" type="Submit" value="Add a feed" /><br>
</p>
OPML URL: <input type="hidden" name="MAX_FILE_SIZE" value="100000">
<h1>OPML import</h1>
<input type="text" name="opml_url" size="40" value="<?= htmlspecialchars($opml) ?>"><input name="do" type="Submit" value="Add feeds from OPML file on the Internet"><br><br>
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
OPML filename: <input type="file" name="opml_file" size="40" value="<?= htmlspecialchars($file) ?>"><input name="do" type="Submit" value="Upload an OPML file">
<p>
OPML URL: <input type="text" name="opml_url" size="40" value="<?= htmlspecialchars($opml) ?>" /> <input name="do" type="Submit" value="Add feeds from OPML file on the Internet" /><br>
OPML filename: <input type="hidden" name="MAX_FILE_SIZE" value="100000" /><input type="file" name="opml_file" size="40" value="<?= htmlspecialchars($file) ?>" /> <input name="do" type="Submit" value="Upload an OPML file" />
</p>
</form>
<h1>OPML export</h1>
<form style="margin: 1em" method="post" action="opml.php"><input type="submit" value="Export subscriptions as OPML"></form>
<?php if (!count($feeds) && $fof_prefs_obj && ($suggest = intval($fof_prefs_obj->admin_prefs['suggestadd'])) &&
count($suggest = fof_db_get_most_popular_feeds($suggest))) { ?>
<h1>Most popular feeds</h1>
<p>
<?php foreach ($suggest as $feed) { ?>
<a href="<?=htmlspecialchars('?do=1&rss_url='.urlencode($feed['feed_url']))?>"><?=htmlspecialchars($feed['feed_title'])?></a><a href="<?=htmlspecialchars($feed['feed_link'])?>"><img src="image/external.png" alt=" " width="10" height="10" /></a><br />
<?php } ?>
</p>
<?php } ?>
</div>
<?php
if(count($feeds))
{

View File

@ -882,4 +882,19 @@ function fof_db_get_top_readers($days, $count = NULL)
return $readers;
}
function fof_db_get_most_popular_feeds($count = NULL)
{
global $FOF_SUBSCRIPTION_TABLE, $FOF_FEED_TABLE;
$result = fof_db_query(
"select *, count(u.user_id) readers from $FOF_FEED_TABLE f join $FOF_SUBSCRIPTION_TABLE u on u.feed_id=f.feed_id
left join $FOF_SUBSCRIPTION_TABLE s on s.feed_id=f.feed_id and s.user_id=".fof_current_user()."
where s.feed_id is null and f.feed_url not regexp '^[a-z]+://[^/]+:[^/]*@'
group by f.feed_id having readers>1 order by readers desc
".(!is_null($count) ? "limit $count" : ""));
$feeds = array();
while ($row = mysql_fetch_assoc($result))
$feeds[] = $row;
return $feeds;
}
?>

View File

@ -1,3 +1,5 @@
img { border-width: 0; }
p
{
margin: 0;
@ -374,3 +376,7 @@ display: block;
padding: 2px 5px;
}
.fof-add-feeds { margin: 0.5em; }
.fof-add-feeds form { margin: 0; }
.fof-add-feeds h1 { border-width: 0 0 2px; border-color: #ddd; border-style: solid; margin: 1em 0 0 0; padding: 0 0.5em; }
.fof-add-feeds p { line-height: 2; margin: 0.5em; }

View File

@ -21,9 +21,10 @@ if (fof_is_admin() && isset($_POST['adminprefs']))
$prefs->set('purge', $_POST['purge']);
$prefs->set('manualtimeout', $_POST['manualtimeout']);
$prefs->set('autotimeout', $_POST['autotimeout']);
$prefs->set('logging', $_POST['logging']);
$prefs->set('topreaders_days', $_POST['topreaders_days']);
$prefs->set('topreaders_count', $_POST['topreaders_count']);
$prefs->set('logging', $_POST['logging'] && 1);
$prefs->set('suggestadd', intval($_POST['suggestadd']));
$prefs->set('topreaders_days', intval($_POST['topreaders_days']));
$prefs->set('topreaders_count', intval($_POST['topreaders_count']));
$prefs->save();
@ -334,12 +335,13 @@ foreach($feeds as $row)
<br><h1>Feed on Feeds - Admin Options</h1>
<form method="post" action="prefs.php" style="border: 1px solid black; margin: 10px; padding: 10px;">
Enable logging? <input type=checkbox name=logging <?php if($prefs->get('logging')) echo "checked" ?>><br><br>
Purge read items after <input size=4 type=string name=purge value="<?php echo $prefs->get('purge')?>"> days (leave blank to never purge)<br><br>
Allow automatic feed updates every <input size=4 type=string name=autotimeout value="<?php echo $prefs->get('autotimeout')?>"> minutes<br><br>
Allow manual feed updates every <input size=4 type=string name=manualtimeout value="<?php echo $prefs->get('manualtimeout')?>"> minutes<br><br>
Enable logging? <input type=checkbox name=logging <?php if($prefs->get('logging')) echo "checked" ?> /><br><br>
Purge read items after <input size=4 type=string name=purge value="<?php echo $prefs->get('purge')?>" /> days (leave blank to never purge)<br><br>
Allow automatic feed updates every <input size=4 type=string name=autotimeout value="<?php echo $prefs->get('autotimeout')?>" /> minutes<br><br>
Allow manual feed updates every <input size=4 type=string name=manualtimeout value="<?php echo $prefs->get('manualtimeout')?>" /> minutes<br><br>
Show <b>Top <input size=3 type=string name=topreaders_count value="<?=intval($prefs->get('topreaders_count'))?>" /> readers in last <input size=3 type=string name=topreaders_days value="<?=intval($prefs->get('topreaders_days'))?>" /> days</b> statistics on the login page<br><br>
<input type=submit name=adminprefs value="Save Options">
Suggest users to subscribe to <input size=3 type=string name=suggestadd value="<?=intval($prefs->get('suggestadd'))?>" /> most popular feeds<br><br>
<input type=submit name=adminprefs value="Save Options" />
</form>
<br><h1>Add User</h1>

View File

@ -251,7 +251,7 @@ foreach($feeds as $row)
print "<td>";
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 " <a href=\"$link\" title=\"home page\"><img width=\"10\" height=\"10\" alt='home page' src='image/external.png' /></a>";
print "</td>";
print "<td><nobr>";