Forum Moderators: coopster
$data = mysql_query("SELECT ip,points FROM information")
or die(mysql_error());
$ip = $_SERVER['REMOTE_ADDR'];
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $ip;
}
$ip = getIp();
while($info = mysql_fetch_array( $data ))
{
if($info['ip'] != null && $info['ip'] == ip2long($ip)){
Print "You have $info[points] points!";
break;
}
if($info['ip'] != null && $info['ip'] != ip2long($ip)){
mysql_query("INSERT INTO information VALUES ('INET6_ATON($ip)','0')");
Print "You have 0 points.";
break;
}
}
$data = mysql_query("SELECT ip,points FROM information")
or die(mysql_error());
function getIp() {
$ip = $_SERVER['REMOTE_ADDR'];
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $ip;
}
$ip = getIp();
die("|$ip|");
while($info = mysql_fetch_array( $data ))
{
if($info['ip'] != null && $info['ip'] == ip2long($ip)){
Print "You have $info[points] points!";
break;
}
if($info['ip'] != null && $info['ip'] != ip2long($ip)){
mysql_query("INSERT INTO information VALUES (INET6_ATON($ip),'0')") or die(mysql_error());
Print "You have 0 points.";
break;
}
}
Also, ip2long is for IPv4 addresses...
function getIp() {
$ip = $_SERVER['REMOTE_ADDR'];
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $ip;
}
$ip = getIp();
while($info = mysql_fetch_array( $data ))
{
if($info['ip'] != null){
if($info['ip'] == ip2long($ip)){
Print "You have $info[points] points!";
break;
}
if($info['ip'] != ip2long($ip)){
mysql_query("INSERT INTO information VALUES (INET_ATON('$ip'),'0')") or die(mysql_error());
Print "You have 0 points.";
break;
}
}
$info['ip'] != null
false
0
''
array()