Ryokotsusai
Posts: 248 Joined: 10/5/2005 Status: offline
|
[PHP]array_keys help - 8/29/2007 8:33:56
Hi, I have a function, that is a part of a "No Database Required" control panel, and is supposed to lock out an IP for 15 minutes after 3 failed attempts at logging in. It is based off of 2 txt files, one logs failed attempts to login with the time() and ip: 1188387663,65.32.58.50 and the other does the same, except the script is only supposed to record in the second if three failed attempts appear in the first in the last 15 min but the script for some reason dies out on an array_keys() search. Here is the code: # Now read files to array
$b = $p = 0;
$btxt = file($uco->btxt);
$ptxt = file($uco->ptxt);
foreach($btxt as $bun) { list($btime[$b], $bip[$b]) = explode(",",$bun); $b++; }
foreach($ptxt as $pun) { list($ptime[$p], $pip[$p]) = explode(",",$pun); $p++; }
unset($b,$p);
# Count Instances of your ip in the txt files
if(is_array($pip)) {$y = array_keys($pip,$ip);}
if(is_array($bip)) {$z = array_keys($bip,$ip);}
$p=0;
if(is_array($y)) {
foreach($y as $a) {
echo 'got this far';
echo $ptime[$a];
if($ptime[$a] > (time()-(15*60)))
{$p++;}
}
}
echo $p."\n<br>\n";
print_r($pip);
echo "\n<br>\n";
print_r($y);
echo "\n<br>\n";
print_r(array_keys($pip,$ip));
echo "<br>\n".$ip;
And Here is the output: 0
<br>
Array
(
[0] => 65.32.58.50
[1] => 65.32.58.50
[2] => 65.32.58.50
[3] => 65.32.58.50
[4] => 65.32.58.50
[5] => 65.32.58.50
[6] => 65.32.58.50
[7] => 65.32.58.50
[8] => 65.32.58.50
[9] => 65.32.58.50
[10] => 65.32.58.50
[11] => 65.32.58.50
[12] => 65.32.58.50
[13] => 65.32.58.50
[14] => 65.32.58.50
[15] => 65.32.58.50
[16] => 65.32.58.50
[17] => 65.32.58.50
[18] => 65.32.58.50
[19] => 65.32.58.50
[20] => 65.32.58.50
[21] => 65.32.58.50
[22] => 65.32.58.50
[23] => 65.32.58.50
[24] => 65.32.58.50
[25] => 65.32.58.50
[26] => 65.32.58.50
[27] => 65.32.58.50
[28] => 65.32.58.50
[29] => 65.32.58.50
[30] => 65.32.58.50
)
<br>
Array
(
)
<br>
Array
(
)
<br>
65.32.58.50 for some reason even though the only ip in there right now is mine, returns nothing when it searches the 'got this far' line doesn't show, when technically it should show 31x
< Message edited by Ryokotsusai -- 8/29/2007 19:07:36 >
_____________________________
The world is more like it is now than it ever has been before. --Dwight Eisenhower
|