help

This is a discussion on help within the PHP Language forums, part of the PHP Programming Forums category; <?php $ip = $_SERVER['REMOTE_ADDR']; $bestand = "ipblock.txt"; $iparray = file("ipblock.txt"); $ans = array_search($ip, $iparray); ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-03-2003
FiremanSAM
 
Posts: n/a
Default help

<?php
$ip = $_SERVER['REMOTE_ADDR'];

$bestand = "ipblock.txt";
$iparray = file("ipblock.txt");

$ans = array_search($ip, $iparray);

if ($ans == $ip) {

print(" ");
print("<div align='center'><font face='Geneva, Arial, Helvetica,
sans-serif'><strong>Your ip [$ip] has
been suspended as a result of your actions on this
website</strong></font></div>");
print ("<div align='center'><font face='Geneva, Arial, Helvetica,
sans-serif'><strong>--------------------------------------------------------
-</strong></font></div>");
}
else {

$db = mysql_connect("localhost","user","password");
....etc

Why does this not work?? And in which format must i add ip adresses into the
file??

FiremanSAM


Reply With Quote
  #2 (permalink)  
Old 10-03-2003
Pedro
 
Posts: n/a
Default Re: help

FiremanSAM wrote:
[...]
> $ans = array_search($ip, $iparray);
>
> if ($ans == $ip) {

[...]
>Why does this not work?? And in which format must i add ip adresses into the
>file??


After reading http://www.php.net/array_search the first reason that
comes to mind is that you're comparing the array index ($ans) to the
array value ($ip). Check that you compare "comparable" things!

I think the file should have something like
10.11.12.13
10.43.76.109



Happy Coding :-)


--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
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 12:27 AM.


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