/
/
home
/
u523034047
/
domains
Server: in-mum-web1112.main-hosting.eu (62.72.28.111)
You: 216.73.216.4
PHP 8.3.16
Dir:
/home/u523034047/domains
Edit:
/home/u523034047/domains/htaccess_watcher.php
<?php $baseDir = __DIR__ . '/domains'; // Adjust to your actual domains folder $logFile = __DIR__ . '/htaccess_monitor.log'; $alertEmail = "harish8313@gmail.com"; // Change to your email $domainDirs = glob($baseDir . '/*', GLOB_ONLYDIR); foreach ($domainDirs as $domainPath) { $htaccessPath = $domainPath . '/public_html/.htaccess'; $hashFilePath = $domainPath . '/.htaccess.hash'; if (!file_exists($htaccessPath)) { continue; // Skip if no .htaccess in this domain } $currentHash = hash_file('sha256', $htaccessPath); if (file_exists($hashFilePath)) { $savedHash = trim(file_get_contents($hashFilePath)); if ($currentHash !== $savedHash) { $message = "ALERT: .htaccess file modified in: {$htaccessPath} at " . date("Y-m-d H:i:s") . "\n"; file_put_contents($logFile, $message, FILE_APPEND); mail($alertEmail, "ALERT: .htaccess Modified ({$domainPath})", $message); // Update hash after alert file_put_contents($hashFilePath, $currentHash); } } else { // First time: save hash file_put_contents($hashFilePath, $currentHash); } } echo "✅ .htaccess check completed at " . date("Y-m-d H:i:s") . "\n"; ?>
Ukuran: 1.2 KB