Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parseTweet($str) {
- $str = preg_replace(
- '@(https?://([-\w\.]+)+(/([\w/_\.]*(\?\S+)?(#\S+)?)?)?)@',
- '<a href="$1">$1</a>',
- $str);
- $str = str_replace('>http://', '>', $str);
- $str = str_replace('>https://', '>', $str);
- $str = preg_replace(
- '/@(\w+)/',
- '<a href="http://twitter.com/$1">@$1</a>',
- $str);
- $str = preg_replace(
- '/\s+#(\w+)/',
- ' <a href="http://search.twitter.com/search?q=%23$1">#$1</a>',
- $str);
- return $str;
- }
- function daysAgo($time) {
- $now = time();
- $time_ago = $now - $time;
- $day = 60*60*24;
- $days_ago = floor($time_ago/$day);
- $result = "";
- if ($days_ago == 0) {
- $result = "Today";
- }
- else if ($days_ago == 1) {
- $result = "Yesterday";
- }
- else {
- $result = $days_ago . " days ago";
- }
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement