Hostname prüfen und IP in .htaccess in Unterverzeichnis schreiben

<?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 :-(';
}
?>

Honeypot

honeypot.php

<?php
$timestamp = date("d.m.Y H:i:s");
$ip = $_SERVER["REMOTE_ADDR"];
$host = gethostbyaddr($_SERVER['HTTP_X_REAL_IP']);
$reqtype = $_SERVER['REQUEST_METHOD'];
$file = $_SERVER['REQUEST_URI'];
$browser = $_SERVER["HTTP_USER_AGENT"];

$filename="logging/logfile.txt";

$header = array("Timestamp", "IP", "Hostname", "RequestType", "File", "Browser");
$infos = array($timestamp, $ip, $host, $reqtype, $file, $browser);

$entry = implode("\t", $infos);

$write_header = !file_exists($filename);

$file=fopen($filename,"a");

if($write_header) {
$heading = implode("\t", $header);
fwrite($file, $heading."\n");
}

fwrite($file,$entry."\n");
fclose($file);
?>

xmlrpc.php / wp-login.php #1:

<?php include 'honeypot.php'; ?>

include: HTTP-Header mit Cache-Control

httpheader.php:

<?php
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header('Content-Type: text/html; charset=ISO-8859-1');
?>

index.php #1:

<?php include 'httpheader.php'; ?>

Array: Datum mit ausgeschriebenem Monat

<?php $monate = array(1=>"Januar",
                2=>"Februar",
                3=>"Maerz",
                4=>"April",
                5=>"Mai",
                6=>"Juni",
                7=>"Juli",
                8=>"August",
                9=>"September",
                10=>"Oktober",
                11=>"November",
                12=>"Dezember");
$monat = date("n");
$tag = date("d");
$jahr = date("Y");
?>

<p><b>Datum: <?php echo $tag,". ",$monate[$monat]," ",$jahr;?></b></p>