diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/access.class.php | 10 | ||||
-rw-r--r-- | lib/class/api.class.php | 4 | ||||
-rw-r--r-- | lib/class/browse.class.php | 2 | ||||
-rw-r--r-- | lib/class/stream.class.php | 2 | ||||
-rw-r--r-- | lib/class/user.class.php | 16 | ||||
-rw-r--r-- | lib/class/vauth.class.php | 6 | ||||
-rw-r--r-- | lib/class/xmlrpcserver.class.php | 2 | ||||
-rw-r--r-- | lib/general.lib.php | 25 |
8 files changed, 22 insertions, 45 deletions
diff --git a/lib/class/access.class.php b/lib/class/access.class.php index e2ed73ec..98fd0b39 100644 --- a/lib/class/access.class.php +++ b/lib/class/access.class.php @@ -80,8 +80,8 @@ class Access { $name = Dba::escape($data['name']); $type = self::validate_type($data['type']); - $start = ip2int($data['start']); - $end = ip2int($data['end']); + $start = ip2long($data['start']); + $end = ip2long($data['end']); $level = Dba::escape($data['level']); $user = $data['user'] ? Dba::escape($data['user']) : '-1'; $key = Dba::escape($data['key']); @@ -104,8 +104,8 @@ class Access { /* We need to verify the incomming data a littlebit */ - $start = ip2int($data['start']); - $end = ip2int($data['end']); + $start = ip2long($data['start']); + $end = ip2long($data['end']); $name = Dba::escape($data['name']); $key = Dba::escape($data['key']); $user = $data['user'] ? Dba::escape($data['user']) : '-1'; @@ -170,7 +170,7 @@ class Access { } // Clean incomming variables - $ip = ip2int($ip); + $ip = ip2long($ip); $user = Dba::escape($user); $key = Dba::escape($key); $level = Dba::escape($level); diff --git a/lib/class/api.class.php b/lib/class/api.class.php index 8e15c136..f1ff7a33 100644 --- a/lib/class/api.class.php +++ b/lib/class/api.class.php @@ -65,10 +65,10 @@ class Api { // Clean incomming variables $user_id = Dba::escape($user_id); $timestamp = intval($timestamp); - $ip = ip2int($ip); + $ip = ip2long($ip); // Log this attempt - debug_event('API','Login Attempt, IP:' . int2ip($ip) . ' Time:' . $timestamp . ' User:' . $user_id . ' Auth:' . $passphrase,'1'); + debug_event('API','Login Attempt, IP:' . long2ip($ip) . ' Time:' . $timestamp . ' User:' . $user_id . ' Auth:' . $passphrase,'1'); // Run the query and return the passphrases as we'll have to mangle them // to figure out if they match what we've got diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index bf72bbe9..cf5644b5 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -433,7 +433,7 @@ class Browse { } // if filters // Now Add the Order - $order_sql = "ORDER BY "; + $order_sql = " ORDER BY "; // If we don't have a sort, then go ahead and return it now if (!is_array($_SESSION['browse']['sort'])) { return $sql; } diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 1f802bd7..80d05654 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -188,7 +188,7 @@ class Stream { $expire = time() + Config::get('stream_length'); $sid = Dba::escape($sid); $agent = Dba::escape($_SERVER['HTTP_USER_AGENT']); - $ip = ip2int($_SERVER['REMOTE_ADDR']); + $ip = ip2long($_SERVER['REMOTE_ADDR']); $uid = Dba::escape($uid); $sql = "UPDATE `session_stream` SET `expire`='$expire', `agent`='$agent', `ip`='$ip' " . diff --git a/lib/class/user.class.php b/lib/class/user.class.php index d548f1f3..5c7a2124 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -553,7 +553,7 @@ class User { $sip = $_SERVER['REMOTE_ADDR']; debug_event('User Ip', 'Login from ip adress: ' . $sip,'3'); } - $ip = ip2int($sip); + $ip = ip2long($sip); $date = time(); $user = $this->id; @@ -658,16 +658,16 @@ class User { /* Get Users Last ip */ $data = $this->get_ip_history(1); - $this->ip_history = int2ip($data['0']['ip']); + $this->ip_history = long2ip($data['0']['ip']); } // format_user - /*! - @function format_favorites - @discussion takes an array of objects and formats them corrrectly - and returns a simply array with just <a href values - */ - function format_favorites($items) { + /** + * format_favorites + * takes an array of objects and formats them corrrectly + * and returns a simply array with just <a href values + */ + public function format_favorites($items) { // The length of the longest item $maxlen = strlen($items[0]->count); diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php index a7d2dc91..5f67e442 100644 --- a/lib/class/vauth.class.php +++ b/lib/class/vauth.class.php @@ -264,7 +264,7 @@ class vauth { } // end switch on data type $username = Dba::escape($data['username']); - $ip = $_SERVER['REMOTE_ADDR'] ? Dba::escape(ip2int($_SERVER['REMOTE_ADDR'])) : '0'; + $ip = $_SERVER['REMOTE_ADDR'] ? Dba::escape(ip2long($_SERVER['REMOTE_ADDR'])) : '0'; $type = Dba::escape($data['type']); $value = Dba::escape($data['value']); $agent = Dba::escape(substr($_SERVER['HTTP_USER_AGENT'],0,254)); @@ -365,7 +365,7 @@ class vauth { break; case 'stream': $key = Dba::escape($key); - $ip = ip2int($data['ip']); + $ip = ip2long($data['ip']); $agent = Dba::escape($data['agent']); $sql = "SELECT * FROM `session_stream` WHERE `id`='$key' AND `expire` > '$time' AND `ip`='$ip' AND `agent`='$agent'"; $db_results = Dba::query($sql); @@ -511,7 +511,7 @@ class vauth { if (Config::get('prevent_multiple_logins')) { $client = new User($results['id']); $current_ip = $client->is_logged_in(); - if ($current_ip != ip2int($_SERVER['REMOTE_ADDR'])) { + if ($current_ip != ip2long($_SERVER['REMOTE_ADDR'])) { Error::add('general','User Already Logged in'); return false; } diff --git a/lib/class/xmlrpcserver.class.php b/lib/class/xmlrpcserver.class.php index e5f3eff3..6cb08451 100644 --- a/lib/class/xmlrpcserver.class.php +++ b/lib/class/xmlrpcserver.class.php @@ -146,7 +146,7 @@ class xmlRpcServer { debug_event('XMLSERVER','Login Attempt, IP: ' . $_SERVER['REMOTE_ADDR'] . ' Time: ' . $timestamp . ' Hash:' . $encoded_key,'5'); // Convert the IP Address to an int - $ip = ip2int($_SERVER['REMOTE_ADDR']); + $ip = ip2long($_SERVER['REMOTE_ADDR']); // Run the query and return the key's for ACLs of type RPC that would match this IP $sql = "SELECT * FROM `access_list` WHERE `type`='rpc' AND `start` <= '$ip' AND `end` >= '$ip'"; diff --git a/lib/general.lib.php b/lib/general.lib.php index e43736e5..5c80606b 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2007 Ampache.org + Copyright (c) 2001 - 2008 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -21,29 +21,6 @@ /** - * ip2int - * turns a dotted quad ip into an int - */ -function ip2int($ip) { - - $a=explode(".",$ip); - return $a[0]*256*256*256+$a[1]*256*256+$a[2]*256+$a[3]; - -} // ip2int - -/*! - @function int2ip - @discussion turns a int into a dotted quad -*/ -function int2ip($i) { - $d[0]=(int)($i/256/256/256); - $d[1]=(int)(($i-$d[0]*256*256*256)/256/256); - $d[2]=(int)(($i-$d[0]*256*256*256-$d[1]*256*256)/256); - $d[3]=$i-$d[0]*256*256*256-$d[1]*256*256-$d[2]*256; - return "$d[0].$d[1].$d[2].$d[3]"; -} // int2ip - -/** * session_exists * checks to make sure they've specified a valid session, can handle xmlrpc */ |