RE: [PHP] another big, juicy, delicious bug

This is a discussion on RE: [PHP] another big, juicy, delicious bug within the PHP General forums, part of the PHP Programming Forums category; This function is what I used: function getId ($ip) { $ipData = file('idData/ips.txt'); $ipData = array_flip($ipData); $id = $ipData[$ip] + ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-08-2003
Kyle Babich
 
Posts: n/a
Default RE: [PHP] another big, juicy, delicious bug

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"
<jay.blanchard@niicommunications.com> 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
>

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:27 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0