summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-02-28 05:44:49 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-02-28 05:44:49 +0000
commit31d5e782dedb0a09b5d73e7bac61dccfe25e73f1 (patch)
treeb46198c3cb0137a3c4d8e4faf99a9022a9d87f88
parent4626bc1ff1a2c2a8bc2b37f5aece23a2ee6d9104 (diff)
downloadampache-31d5e782dedb0a09b5d73e7bac61dccfe25e73f1.tar.gz
ampache-31d5e782dedb0a09b5d73e7bac61dccfe25e73f1.tar.bz2
ampache-31d5e782dedb0a09b5d73e7bac61dccfe25e73f1.zip
removed ip2int, int2ip custom functions fixed browse issues when adding filters in specific order
-rwxr-xr-xdocs/CHANGELOG2
-rw-r--r--lib/class/access.class.php10
-rw-r--r--lib/class/api.class.php4
-rw-r--r--lib/class/browse.class.php2
-rw-r--r--lib/class/stream.class.php2
-rw-r--r--lib/class/user.class.php16
-rw-r--r--lib/class/vauth.class.php6
-rw-r--r--lib/class/xmlrpcserver.class.php2
-rw-r--r--lib/general.lib.php25
-rw-r--r--templates/show_access_list.inc.php4
-rw-r--r--templates/show_edit_access.inc.php4
-rw-r--r--templates/show_ip_history.inc.php2
12 files changed, 29 insertions, 50 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 47f1331b..a138ab88 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,8 @@
--------------------------------------------------------------------------
v.3.4-Beta2
+ - Fixed browse issue when adding filters under specific conditions
+ - Removed ip2int, int2ip and replaced with standard PHP functions
- Updated Russian Translation and plural fixes ( Thx littlesavage )
- Fixed Sorting on Admin->Browse Users
- Fixed Shoutbox and shoutbox management (pb1dft)
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
*/
diff --git a/templates/show_access_list.inc.php b/templates/show_access_list.inc.php
index 0c3c1fee..8a128408 100644
--- a/templates/show_access_list.inc.php
+++ b/templates/show_access_list.inc.php
@@ -56,8 +56,8 @@ stream from this server.</p>
?>
<tr class="<?php echo flip_class(); ?>">
<td><?php echo scrub_out($access->name); ?></td>
- <td><?php echo int2ip($access->start); ?></td>
- <td><?php echo int2ip($access->end); ?></td>
+ <td><?php echo long2ip($access->start); ?></td>
+ <td><?php echo long2ip($access->end); ?></td>
<td><?php echo $access->get_level_name(); ?></td>
<td><?php echo $access->get_user_name(); ?></td>
<td><?php echo $access->key; ?></td>
diff --git a/templates/show_edit_access.inc.php b/templates/show_edit_access.inc.php
index c4825d2f..14848946 100644
--- a/templates/show_edit_access.inc.php
+++ b/templates/show_edit_access.inc.php
@@ -42,14 +42,14 @@
<tr>
<td><?php echo _('Start IP Address'); ?>:</td>
<td>
- <input type="text" name="start" value="<?php echo int2ip($access->start); ?>" size="20" maxlength="15" />
+ <input type="text" name="start" value="<?php echo long2ip($access->start); ?>" size="20" maxlength="15" />
<span class="information">(0.0.0.0)</span>
</td>
</tr>
<tr>
<td><?php echo _('End IP Address'); ?>:</td>
<td>
- <input type="text" name="end" value="<?php echo int2ip($access->end); ?>" size="20" maxlength="15" />
+ <input type="text" name="end" value="<?php echo long2ip($access->end); ?>" size="20" maxlength="15" />
<span class="information">(0.0.0.0)</span>
</td>
</tr>
diff --git a/templates/show_ip_history.inc.php b/templates/show_ip_history.inc.php
index 9b266772..801d51cd 100644
--- a/templates/show_ip_history.inc.php
+++ b/templates/show_ip_history.inc.php
@@ -43,7 +43,7 @@
<?php echo date("d/m/Y H\hi",$data['date']); ?>
</td>
<td class="cel_ipaddress">
- <?php echo int2ip($data['ip']); ?>
+ <?php echo long2ip($data['ip']); ?>
</td>
</tr>
<?php } ?>