This function is what I used:

function getId ($ip) {
    $ipData = file('idData/ips.txt');
    $ipData = array_flip($ipData);

    $id = $ipData[$ip] + 1;
    return $id;
}

It is defined in idData.inc.php which is required in the file with the
problem (controlPanel.php).
I decided to ban a third IP just to see what would happen and when I
banned the third it worked fine, and it fixed the other banned IP.  So,
that just adds to the problem.  Why would it work with 1 and 3 banned IPs
but not 2...  Anyway here is the part of controlPanel.php where the
function is called...

<?php if(file_exists('idData/banned.txt')) {
    $bannedIps = file('idData/banned.txt'); ?>
    
<tr>
<td width="100% align="left" bgcolor="#3366CC" colspan="2">
 &nbsp;
</td></tr>

<tr>
<td width="100%" align="center" bgcolor="#000066" colspan="2">
<font face="courier, verdana, arial" color="#ffffff" size="-1">
Banned Users <?php if (count($bannedIps) >= 2) { ?> :: <a class="std"
href="controlPanel.php?action=unbanAll">Unban All</font> <?php } ?>
</font></td></tr>

<?php
foreach ($bannedIps as $bannedIp) {
    $id = getId($bannedIp); ?>

<tr>
<td width="100%" align="left" bgcolor="#000066" colspan="2">
<font face="courier, verdana, arial" color="#ffffff" size="-1">
<?php print $id . ' :: ' . $bannedIp . " :: <a class=\"std\"
href=\"controlPanel.php?action=unban&toUnban=" . $bannedIp . "\">Unban IP
Address</a><br />"; ?>
</font></td></tr>

<?php }
} ?> 

On Tue, 8 Jul 2003 08:00:35 -0500, "Jay Blanchard"
<[EMAIL PROTECTED]> said:
> [snip]
> But then it will go and do something like this:
> Array (
>   [0] => 172.170.69.74
>   [1] => 172.141.183.231 
>   [2] => 172.137.79.102 
>   [3] => 172.151.144.242 
>   [4] => 172.150.212.129 
>   [5] => 172.158.154.92 
> ) // correct array 
> 
> Array ( 
>   [172.170.69.74 ] => 0 
>   [172.141.183.231 ] => 1 
>   [172.137.79.102 ] => 2 
>   [172.151.144.242 ] => 3 
>   [172.150.212.129 ] => 4 
>   [172.158.154.92] => 5 
> ) // correct flipped
> 
> 172.151.144.242 // correct ip
> 
> // complete nothingness where $ipData[$ip] should equal 3
> 
> 1 // wrong $id, should be 4
> [/snip]
> 
> First of all this is probably not a bug.
> 
> Second, where is the code that tests for the condition? Do the other
> IP's in the array output their id properly in this same set? This info
> will help us to solve the problem.
> 
> Jay
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to