From 5db7a0e53c7a9e415254bbda05496e31cf2f699c Mon Sep 17 00:00:00 2001 From: pb1dft Date: Fri, 27 Oct 2006 21:14:40 +0000 Subject: Strange error occured while commiting --- lib/class/stats.class.php | 28 ++++++++++++++++++++++++++++ lib/class/user.class.php | 14 ++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) (limited to 'lib/class') diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php index 057d2534..f06f8f9f 100644 --- a/lib/class/stats.class.php +++ b/lib/class/stats.class.php @@ -90,6 +90,34 @@ class Stats { } // get_top + /** + * get_ip_history + * This returns the ip_history from the + * last conf('user_ip_cardinality') days + */ + function get_ip_history($count,$type,$user) { + + $count = intval($count); + $type = $this->validate_type($type); + $date = time() - (86400*conf('user_ip_cardinality')); + + /* Select ip history */ + $sql = "SELECT ip,date FROM ip_history" . + " WHERE user='$user->username' AND date >= '$date'" . + " ORDER BY `date` DESC LIMIT $count"; + $db_results = mysql_query($sql, dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r; + } + + return $results; + + } // get_ip_history + + /** * get_user * This gets all stats for atype based on user with thresholds and all diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 66eb088e..efa5db8c 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -509,8 +509,8 @@ class User { else { $this->f_create_date = date("m\/d\/Y - H:i",$user->create_date); } /* Calculate their total Bandwidth Useage */ - $sql = "SELECT song.size FROM object_count LEFT JOIN song ON song.id=object_count.object_id " . - "WHERE object_count.userid='$this->uid' AND object_count.object_type='song'"; + $sql = "SELECT song.size FROM song LEFT JOIN object_count ON song.id=object_count.object_id " . + "WHERE object_count.user='$this->uid' AND object_count.object_type='song'"; $db_results = mysql_query($sql, dbh()); while ($r = mysql_fetch_assoc($db_results)) { @@ -533,6 +533,16 @@ class User { } // end switch $this->f_useage = round($total,2) . $name; + + /* Get Users Last ip */ + $sql = "SELECT ip FROM ip_history WHERE user = '$this->username' ORDER BY ip DESC LIMIT 1"; + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $this->ip_history = int2ip($r[ip]); + } + + } // format_user -- cgit