diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-29 00:51:53 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-29 00:51:53 +0000 |
commit | 9cfb075df5c8fcd0f83f019dee67fa907dae6265 (patch) | |
tree | d4cbb031a0534715d9caec54c27945e234c7aea1 /lib | |
parent | 5038eb20d7322af95d1fef7035f6d533b49c25a6 (diff) | |
download | ampache-9cfb075df5c8fcd0f83f019dee67fa907dae6265.tar.gz ampache-9cfb075df5c8fcd0f83f019dee67fa907dae6265.tar.bz2 ampache-9cfb075df5c8fcd0f83f019dee67fa907dae6265.zip |
3.3.1-Alpha1 release
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/stats.class.php | 28 | ||||
-rw-r--r-- | lib/class/user.class.php | 48 | ||||
-rw-r--r-- | lib/init.php | 8 | ||||
-rw-r--r-- | lib/ui.lib.php | 34 |
4 files changed, 45 insertions, 73 deletions
diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php index f06f8f9f..057d2534 100644 --- a/lib/class/stats.class.php +++ b/lib/class/stats.class.php @@ -91,34 +91,6 @@ 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 * If full is passed, doesn't limit based on date diff --git a/lib/class/user.class.php b/lib/class/user.class.php index efa5db8c..80a88bd4 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -450,6 +450,12 @@ class User { $sql = "INSERT INTO ip_history (`ip`,`user`,`date`) VALUES ('$ip','$user','$date')"; $db_results = mysql_query($sql, dbh()); + /* Clean up old records */ + $date = time() - (86400*conf('user_ip_cardinality')); + + $sql = "DELETE FROM ip_history WHERE `date` < $date"; + $db_results = mysql_query($sql,dbh()); + return true; } // insert_ip_history @@ -535,14 +541,8 @@ class User { $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]); - } - - + $data = $this->get_ip_history(1); + $this->ip_history = int2ip($data['0']['ip']); } // format_user @@ -824,6 +824,38 @@ class User { } // get_recent + /** + * get_ip_history + * This returns the ip_history from the + * last conf('user_ip_cardinality') days + */ + function get_ip_history($count='',$distinct='') { + + $username = sql_escape($this->username); + + if ($count) { + $limit_sql = "LIMIT " . intval($count); + } + if ($distinct) { + $group_sql = "GROUP BY ip"; + } + + /* Select ip history */ + $sql = "SELECT ip,date FROM ip_history" . + " WHERE user='$username'" . + " $group_sql ORDER BY `date` DESC $limit_sql"; + $db_results = mysql_query($sql, dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r; + } + + return $results; + + } // get_ip_history + /*! @function activate_user @activates the user from public_registration diff --git a/lib/init.php b/lib/init.php index d5c6d560..dc6f79d3 100644 --- a/lib/init.php +++ b/lib/init.php @@ -73,7 +73,7 @@ if (!$results = read_config($configfile,0)) { } /** This is the version.... fluf nothing more... **/ -$results['version'] = '3.3.3-Alpha1 (Build 005)'; +$results['version'] = '3.3.3-Alpha1'; $results['raw_web_path'] = $results['web_path']; $results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path']; @@ -107,12 +107,14 @@ if (!$_SERVER['SERVER_NAME']) { $_SERVER['SERVER_NAME'] = ''; } if (!isset($results['auth_methods'])) { - $results['auth_methods'] = 'mysql'; + $results['auth_methods'] = array('mysql'); } if (!is_array($results['auth_methods'])) { $results['auth_methods'] = array($results['auth_methods']); } - +if (!$results['user_ip_cardinality']) { + $results['user_ip_cardinality'] = 42; +} /* Variables needed for vauth Module */ diff --git a/lib/ui.lib.php b/lib/ui.lib.php index a24b1ce0..2c7c0ecf 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -151,40 +151,6 @@ function show_users () { } // show_users() /** - * show_ip_history - * shows ip_history of specific user(admin function) - */ - -function show_ip_history (){ - - $dbh = dbh(); - if (conf('user_ip_cardinality')) { $cardinality = conf('user_ip_cardinality'); } else { $cardinality = '42'; } - $date = time() - (86400*$cardinality); - $sql = "SELECT ip,date FROM ip_history where user = '$_REQUEST[user]' and date >= '$cardinality' ORDER BY date DESC"; - $db_results = mysql_query($sql, $dbh); - - show_box_top(); -echo " <table class=\"tabledata\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n". - " <tr class=\"table-header\">\n". - " <td colspan=2>$_REQUEST[user]: IP History</td>\n". - " </tr>\n". - " <tr class=\"table-header\">\n". - " <td align=\"center\">\n". - " <b>Date</b>\n". - " </td>\n". - " <td align=\"center\">\n". - " <b>Ip Address</b>\n". - " </td>\n". - " </tr>\n"; - -while ($r = mysql_fetch_array($db_results)){ - echo "<tr class=". flip_class() .">\n <td>".date("m\/d\/Y-H:i",$r[date])."</td>\n <td>".int2ip($r[ip])."</td>\n</tr>\n"; - } -echo "</table>\n"; -show_box_bottom(); -} // show_ip_history - -/** * return_referer * returns the script part of the referer address passed by the web browser * this is not %100 accurate. Also because this is not passed by us we need |