but iwant admins to be allow flooding and bad words
so i try add this code:
$adminip="48.70.9.28";
if ($visitors == $adminip) { exit; }
so it says to script if visitor ip is an admin ip stop dont ban
and somehow works ...(but only with one ip is listed)
Now i need to add 3 admin ips how can i do this?
i try this code but wont work ( it only reads and not ban the first ip)
$adminip="48.70.9.28","11.23.44.55","24.67.18.8";
if ($visitors == $adminip) { exit; }
i also try this . But wont work at all:
@adminip="123.44.33.55","11.23.44.55","24.67.18.8";
if ($visitors == @adminip) { exit; }
Can some one explain/show me how to do this
please advise thanks ;-)
[edited by: StopSpam at 3:15 pm (utc) on June 8, 2003]
if iuse one it works
some how more dont work ..
evenif i try like this;
$visitors = $ENV{'REMOTE_ADDR'};
$adminip2="1.2.3.4";
if ($visitors == $adminip2) { exit; }
$visitors = $ENV{'REMOTE_ADDR'};
$adminip3="5.6.7.8";
if ($visitors == $adminip3) { exit; }
$visitors = $ENV{'REMOTE_ADDR'};
$adminip4="7.6.7.8";
if ($visitors == $adminip4) { exit; }
$visitors = $ENV{'REMOTE_ADDR'};
$adminip5="8.6.r.28";
if ($visitors == $adminip5) { exit; }
Anyway, I'd probably solve the problem like this:
my @admin_ips = qw(48.70.9.28 48.70.9.29);
my $visitor_ip = "48.70.9.28";
exit if grep(($visitor_ip eq $_),@admin_ips);
The admin's IPs are held in an array, and the visitor's IP is held in a scalar. The grep function evaluates each element of the @admin_ips array, setting $_ to the value of each element in turn. If $visitor_ip is ever equal to $_, i.e. if it is an element of @admin_ips, the expression returns true; causing the script to exit.
Or:
my @admin_ips = qw(48.70.9.28 48.70.9.29);
my $visitor_ip = "48.70.9.28";
for (@admin_ips) { exit if $visitor_ip eq $_ };
If you had a far larger set of data, you'd be better off doing something like this:
my @admin_ips = qw(48.70.9.28 48.70.9.29);
my $visitor_ip = "48.70.9.28";
my %admin_ips = map { $_ => 1 } @admin_ips;
exit if $admin_ips{$visitor_ip};
Here, the map function iterates through the @admin_ips array, aliases $_ to each element it encounters, the evaluates the expression "$_ => 1", and returns the result. That's helpful because the lvalue is a hash, which expects two values in a key-value form. This results in a hash, %admin_ips, being created with the administrator IP addresses as the keys and '1' as the value. The last line causes the script to exit if $visitor_ip is a key of the hash.
inow use this code;
#######
my @admin_ips = qw(48.70.9.28 4 20.40.81.28 43.52.42.12);
my $visitor_ip = "$ENV{'REMOTE_ADDR'}";
exit if grep(($visitor_ip eq $_),@admin_ips);
#######
only problem is it returns a 501 but it wont ban admins
is there way not toget 501? i think the script exits or ends to rute?
I also assumed that snippet would be included within a larger script that would have already printed the correct Content-type, etc. As this is a CGI script, you'd probably want to end it with a message informing the administrators what happened and closing the, presumably, opened <body> and <html> tags. If so, you could define a subroutine that printed that message, closed the tags, and then exited the script. You would replace the original call to _exit_ with a call to this subroutine.
so your saying if ichange :
exit if grep(($visitor_ip eq $_),@admin_ips);
into something like:
my @admin_ips = qw(48.70.9.28 4 20.40.81.28
$close if grep(($visitor_ip eq $_),@admin_ips);
or
&close if grep(($visitor_ip eq $_),@admin_ips);
i can have it print a $ or run a sub &?
is that correct?