#.htaccess
# password protect excluding specific ips
AuthName "Username and password required"
AuthUserFile /home/path/.htpasswd
AuthType Basic
Require valid-user
Order Deny,Allow
Deny from all
Allow from localhost
Allow from 44.0.0/8
Satisfy Any
----------------------------------------
Of course I don't mind sharing the code that looks at the source IP; and
if not 44/8, prompts for a passcode.
I used ip2long to convert 44.0.0.1, 44.255.255.255 and the source IP
into integers. I then used a 'nested if' statement in the program to
test if the source IP was greater than or equal to 44.0.0.1 and less
than or equal to 44.255.255.255; if so, it automatically provides the
passcode, if not, it prints an additional box, asking for a passcode.
{
$ip = $_SERVER['REMOTE_ADDR'];
$amprtop = "44.0.0.1";
$amprlow = "44.255.255.255";
$longip = ip2long($ip);
$rangetop = ip2long($amprtop);
$rangelow = ip2long($amprlow);
$code = 1234;
$access = $_GET['access'];
};
// (other portions removed)
If (($longip >= $rangetop) && ($longip <= $rangelow))
{
echo '';
}
else
{
echo ' Enter NonAMPR Access Code: ';
}
-KB3VWG