From 8a8b37b1ed87197f69ee460b8b072bdc572e5e16 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 1 Mar 2011 21:26:04 +1100 Subject: [PATCH] Fix IPv6-IPv4 bug --- inc/functions.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 1b324a79..96f11f2a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -62,7 +62,7 @@ // ::ffff:0.0.0.0 if(preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) - $_SERVER['REMOTE_ADDR'] = $m[1]; + $_SERVER['REMOTE_ADDR'] = $m[2]; } } @@ -145,6 +145,23 @@ } } + function ago($timestamp) { + $difference = time() - $timestamp; + if($difference < 60) { + return $difference . ' second' . ($difference != 1 ? 's' : ''); + } elseif($difference < 60*60) { + return ($num = round($difference/(60))) . ' minute' . ($num != 1 ? 's' : ''); + } elseif($difference < 60*60*24) { + return ($num = round($difference/(60*60))) . ' hour' . ($num != 1 ? 's' : ''); + } elseif($difference < 60*60*24*7) { + return ($num = round($difference/(60*60*24))) . ' day' . ($num != 1 ? 's' : ''); + } elseif($difference < 60*60*24*365) { + return ($num = round($difference/(60*60*24*7))) . ' week' . ($num != 1 ? 's' : ''); + } else { + return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : ''); + } + } + function formatDate($timestamp) { return date('jS F, Y', $timestamp); }