<?php
$ipaddress = $_SERVER["HTTP_X_REAL_IP"];
$hostname = gethostbyaddr($ipaddress);
if (strpos($hostname, 'cable-xdsl.tld') !== false) {
$data2write1 = "order deny,allow\n";
$data2write2 = "deny from all\n";
$data2write3 = "allow from ".$ipaddress;
$subdir1 = fopen("./subdir1/.htaccess","w");
$subdir2 = fopen("./subdir2/.htaccess","w");
fwrite($subdir1, $data2write1);
fwrite($subdir1, $data2write2);
fwrite($subdir1, $data2write3);
fwrite($subdir2, $data2write1);
fwrite($subdir2, $data2write2);
fwrite($subdir2, $data2write3);
print "OK...data written :-)";
}
else {
echo 'Error...you are not permitted to perform this action :-(';
}
?>