This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gerrit van Aaken
authored and
Gerrit van Aaken
committed
Mar 22, 2010
0 parents
commit 5b03611
Showing
6 changed files
with
15,612 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.