31556926, 'months' => 2629743, 'weeks' => 604800, 'days' => 86400, 'hours' => 3600, 'minutes' => 60, 'seconds' => 1 ); } // Loop $seconds = (float) $seconds; foreach ($periods as $period => $value) { $count = floor($seconds / $value); if ($count == 0) { continue; } $values[$period] = $count; $seconds = $seconds % $value; } // Return if (empty($values)) { $values = null; } return $values; } /** * Return a string of time periods. * * @package Duration * @param mixed $duration An array of named segments * @return string */ function array2string ($duration) { if (!is_array($duration)) { return false; } foreach ($duration as $key => $value) { $segment_name = substr($key, 0, -1); $segment = $value . ' ' . $segment_name; // Plural if ($value != 1) { $segment .= 's'; } $array[] = $segment; } $str = implode(', ', $array); return $str; } } if ( $_SESSION['admin'] == 1 ) { $sql = "SELECT * FROM `usrlist` ORDER BY `time` DESC"; $result = mysql_query ( $sql ) or die ( mysql_error() ); while ( $row = mysql_fetch_assoc ( $result ) ) { $tago = Duration::toString( time() - $row['time'] ); if ( $row['username'] == "Anonymous" | $row['username'] == $null ) { echo 'A user visited this site '. $tago. ' ago. Their IP address was '. $row['ip']. '.


'; } else { echo $row['username']. ' visited this site '. $tago. ' ago. His/Her IP address was '. $row['ip']. '.


'; } } } ?>