This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Adding ","

Website and forum-related announcements and discussion, and anything else that doesn't fit in the above forums.
Post Reply
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Adding ","

Post by iamdeath »

This might be out of the subject as here we deal with TCL issue but then I could not find help anywhere.

Code: Select all

<?
$ip = $_SERVER['REMOTE_ADDR'];
$adresi = array ("80.77.159.1","80.77.159.2","80.77.159.3","80.77.159.4","62.162.50.254","62.162.50.255");
$n = 0;
for($x=0;$x<count($adresi);$x++)
{
if ( $ip == $adresi[$x])
{ $n = 1 ;}
}
if ($n == 1) 
{ echo "";}
else { header('Location:http://www.url.com');}
?>
PLEASE SEE ORIGINAL FILE

As you see there are certain ip classes added in that file, What I need to do is add 2 or more classes such as: "88.85.112.1 til 250" and 88.85.113.1 til 250. Adding manually will be hell alot of time, do you think is there any other solution forit?.. do you think a TCL could do that for me?.. which will add ips alongwith "88.85.112.1","88.85.112.2" and so on.. I am attaching the original file here as well.

File

Your kind suggestions will be highly appreciated

Thanks
iamdeath
Forgive me for going out of topic.
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

Um, you could just mimic your for loop:

Code: Select all

for ($range = 1; $range < 251; $range++) {
  array/blah/foo/etc = "88.55.22.${range}"
}
Or maybe something like this, using range and foreach:

Code: Select all

foreach (range(1,250) as $number) {
  echo "80.77.159." . $number . "\n";
}
Edit: Looking at that further I don't see why you don't just regexp against the IP address you are matching against.

if {[regexp {88\.55\.22\.[1-250]} $ip]} { } so on and so forth. No need to check if it's in an enormous array. I guess in perl/php that'd be something like.. if ($ip =~ /88\.55\.22\.[1-250]/) or so. FYI if it's relevant, 255 is the endpoint, not 250.
Post Reply