<?php
// SuperSimpleLifeTracker 1.0
// Produces a combined feed from several RSS feeds as a DIV you can include
// Copyright 2010, David Hayes
// http://euri.ca/code/SuperSimpleLifeTracker
'http://url',
'http://url',
'http://url',
'http://url',
);
$cacheLocation = './cache'; //needs to be somewhere writeable
$cacheTimeInHours = 2;
$pathToSimplePie = 'simplepie_1.2/simplepie.inc';
$itemsPerRSSFeed = 2; //Looks best when this is about 15/sizeof($feeds)
/* This file is part of SuperSimpleLifeTracker.
SuperSimpleLifeTracker is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SuperSimpleLifeTracker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You may have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
//SimplePie 1.2 throws DEPRECATED about 100 times on PHP 5.2
function shorten($summary, $length=200) {
$summary = strip_tags($summary); //For XSS, I'm going to run everything we print out through here. if(strlen($summary) > $length) { $summary = substr($summary, 0, $length-3)."..."; }
return $summary;
}
require_once($pathToSimplePie);
$feed = new SimplePie();
$feed->set_feed_url($feeds);
$feed->enable_cache(true);
$feed->set_cache_location($cacheLocation );
$feed->set_cache_duration($cacheTimeInHours * 3600);
$feed->set_item_limit($itemsPerRSSFeed);
$feed->init();
$feed->handle_content_type();
if ($feed->error())
{
echo $feed->error();
}
?>
<style>
.rssitem img.favicon { height: 32px; width: 32px; border:0;}
.rssitem .rssdesc { font-size: 80%; color: #555; text-decoration: none !important;}
.rssitem a { text-decoration: none; color: #007; display: block; opacity: .5;}
.rssitem a:visited { color: #007; }
.rssitem a:hover { color: #00f; background-color: #ffd; opacity: 1.0 !important;}
.rssitem {margin-bottom: 8px; font-size: 80%; }
div.rssfeed { }
</style>
<h4>What I've said lately</h4>
<div class="rssfeed"><!-- SuperSimpleLifeTracker, http://euri.ca --> <?/* <-- Please leave this comment in if you use the script :) */?>
<?php
$opacity = 1;
$opacityDecrement = .95/(sizeof($feed->get_items())+1); foreach ($feed->get_items() as $item) {
$thisfeed = $item->get_feed();
$opacity -= $opacityDecrement;
?>
<div class="rssitem">
<a href="<?php echo shorten($item->get_permalink(),512); ?>" title="From <?php echo shorten($thisfeed->get_title()); ?>, <?php echo $item->get_date('j F Y, g:i a'); ?>"
style="opacity: <?php echo $opacity; ?>"
><img src="<?php echo $thisfeed->get_favicon(); ?>" alt="From <?php echo $thisfeed->get_title(); ?>" class='favicon' align="left" /> <?php echo shorten($item->get_title(), 140)?>
<?php if(shorten($item->get_description()) != shorten($item->get_title())) { /*aka: Twitter feeds */?>
<span class="rssdesc"><?php echo shorten($item->get_description(),80); ?></span>
<?php } ?>
</a>
</div>
<?php } ?>
</div>
<?
?>