Permalink
Browse files

First version

  • Loading branch information...
0 parents commit 5b036118f2bbd0cdee37bf346211f206f409ea0f Gerrit van Aaken committed Mar 22, 2010
Showing with 15,612 additions and 0 deletions.
  1. +150 −0 cache/0f1f4a38168074df15ae9effd5cd5cac.spc
  2. +364 −0 cache/3518fd9af4843e230f4310e9279a0461.spc
  3. +37 −0 index.php
  4. +53 −0 lib/functions.php
  5. +15,001 −0 lib/simplepie.inc
  6. +7 −0 readme.txt
@@ -0,0 +1,37 @@
+<?php
+// Get functions;
+require_once('lib/functions.php');
+require_once('lib/simplepie.inc');
+
+// Get Flick feed
+$feed = new SimplePie('http://api.flickr.com/services/feeds/photos_public.gne?id=44285591@N04&lang=de-de&format=rss_200&limit=5','cache',300);
+$feed->handle_content_type();
+
+// Get Twitter feed
+$tweets = new SimplePie('http://twitter.com/statuses/user_timeline/57088055.rss','cache',300);
+$tweets->handle_content_type();
+?>
+
+
+
+<!-- Show Flickr Images -->
+<div id="flickr">
+ <ul>
+ <?php for ($i = 0; $i < 5; $i++): ?>
+ <li><?php $item = $feed->get_item($i); print $item->get_description(); ?></li>
+ <?php endfor; ?>
+ </ul>
+</div>
+
+
+<!-- Show Twitter messages -->
+<div id="twitter">
+ <ul>
+ <?php foreach ($tweets->get_items() as $tweet): ?>
+ <li>
+ <strong><a class="permalink" href="<?php echo $tweet->get_permalink(); ?>"><?php echo reldate(strtotime($tweet->get_date())); ?></a></strong>
+ <?php print preparetweet( $tweet->get_description() ); ?>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+</div>
@@ -0,0 +1,53 @@
+<?php
+
+// Prepare tweets and auto-detect hyperlinks, hashtags and usernames
+function preparetweet($ret) {
+ $ret = substr($ret, strpos($ret, ": ")+1);
+ $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/\-=?@\[\](+]|[.,;:](?![\s<])|(?(1)\)(?![\s<])|\)))+)#is', 'clickable_url', $ret);
+ $ret = preg_replace_callback('|(#[a-zA-Z0-9_ŠšŸ€…†§]*)|is', 'clickable_hashtag', $ret);
+ $ret = preg_replace_callback('|(@[a-zA-Z0-9_ŠšŸ€…†§]*)|is', 'clickable_username', $ret);
+ return trim($ret);
+}
+
+function clickable_hashtag($matches) {
+ $origin = trim($matches[0]);
+ return '<a target="_blank" class="hashtag" href="http://search.twitter.com/search?q=&tag='.substr($origin, 1).'">'.$origin.'</a>';
+}
+
+function clickable_username($matches) {
+ $origin = trim($matches[0]);
+ return '<a target="_blank" class="username" href="http://twitter.com/'.substr($origin, 1).'">'.$origin.'</a>';
+}
+
+function clickable_url($matches) {
+ $url = $matches[2];
+ if ( empty($url) )
+ return $matches[0];
+ return $matches[1] . "<a class='link' href=\"$url\">$url</a>";
+}
+
+// Turn date to relative string
+function reldate($input, $now = false) {
+ if (!$now) { $now = time(); }
+ $diff = $now - $input;
+ if ($diff < 3600) {
+ $value = floor($diff / 60);
+ $unit = "Minute";
+ $unit2 = "Minuten";
+ } elseif ($diff < 86400) {
+ $value = floor($diff / 3600);
+ $unit = "Stunde";
+ $unit2 = "Stunden";
+ } else {
+ $value = floor($diff / 86400);
+ $unit = "Tag";
+ $unit2 = "Tagen";
+ }
+ if ($value == 1) {
+ return "vor ".$value." ".$unit;
+ } else {
+ return "vor ".$value." ".$unit2;
+ }
+}
+
+?>
Oops, something went wrong. Retry.

0 comments on commit 5b03611

Please sign in to comment.