Cheers Frank
I'm now using this:
$ip = $_SERVER["REMOTE_ADDR"];
$query = $db->write_query('SELECT filter FROM '.TABLE_PREFIX. 'banfilters');
while($result = $db->fetch_array($query))
{
$res .= $result['filter']."<br/>";
if ($ip == $res)
{
echo "<div style='width:956px; height:20px; background:#FF0000; margin:auto auto;'><strong>Banned! :-(</strong></div>";
}
else
{
echo "<div style='width:956px; height:20px; background:#00FF00; margin:auto auto;'><strong>Not Banned! :-D</strong></div>";
}
}
But it's still returning false, even if I'm banned.
Thanks
![Smile Smile](https://community.mybb.com/images/smilies/smile.gif)
Try this;
$ip = $_SERVER["REMOTE_ADDR"];
$query = $db->write_query('SELECT filter FROM '.TABLE_PREFIX. 'banfilters');
while($result = $db->fetch_array($query))
{
if ($ip == $result['filter'])
{
echo "<div style='width:956px; height:20px; background:#FF0000; margin:auto auto;'><strong>Banned! :-(</strong></div>";
}
else
{
echo "<div style='width:956px; height:20px; background:#00FF00; margin:auto auto;'><strong>Not Banned! :-D</strong></div>";
}
}
Cheers Yaldaram
It now shows I'm banned when I've banned my IP (which is correct), however when I unban myself, it doesn't return "Not Banned! :-D"
Thanks again!
![Smile Smile](https://community.mybb.com/images/smilies/smile.gif)
Actually this might work better:
$ip = $_SERVER["REMOTE_ADDR"];
$check = $db->query("SELECT filter FROM ".TABLE_PREFIX."banfilters WHERE filter='{$ip}'");
if(mysql_num_rows($check) != 0)
{
echo "<div style='width:956px; height:20px; background:#FF0000; margin:auto auto;'><strong>Banned! :-(</strong></div>";
}else{
echo "<div style='width:956px; height:20px; background:#00FF00; margin:auto auto;'><strong>Not Banned! :-D</strong></div>";
}
Replace all code with this, its clean and tested;
$ip = $_SERVER["REMOTE_ADDR"];
$query = $db->query("SELECT `filter` FROM ".TABLE_PREFIX."banfilters WHERE filter='{$ip}'");
$result = $db->fetch_field($query, "filter");
if ($result)
{
error("Your IP is banned.");
}
else
{
error("Its fine.");
}
Edit: Haven't seen Frank's post. I think his code will work too.
Cheers - seems to work perfectly!
One more question:
I'm using a script to help deter proxy servers which looks like this:
// Function to get the client ip address
if (!empty($_SERVER["HTTP_CLIENT_IP"]))
{
//check for ip from share internet
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
{
// Check for the Proxy User
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
else
{
$ip = $_SERVER["REMOTE_ADDR"];
}
However when I try echo $ip when not using a proxy, it echoes my IP correctly. However, when I try echo $ip when using a proxy server, it's formatted like this:
realip, proxyip
How could I remove the proxy IP from that?
Thanks
![Smile Smile](https://community.mybb.com/images/smilies/smile.gif)
Try This:
<?php
$y = $_SERVER["REMOTE_ADDR"];
$x = $_SERVER["HTTP_X_FORWARDED_FOR"];
if (empty($x))
{
echo "Not Using Proxy. Your IP address is: $y";
}else{
echo "Using Proxy. Your Proxy IP is $y. Your real IP address is: $x";
}
?>
Thanks Frank
It's telling me I'm using a proxy (which is the same ip as my real one) even when I'm not
Thanks
![Smile Smile](https://community.mybb.com/images/smilies/smile.gif)
Try this:
<?php
$y = $_SERVER["REMOTE_ADDR"];
$x = $_SERVER["HTTP_X_FORWARDED_FOR"];
if (!$x)
{
echo "Not Using Proxy. Your IP address is: $y";
}else{
echo "Using Proxy. Your Proxy IP is $y. Your real IP address is: $x";
}
?>