in this codes (<?php
// index.php

// Error reporting for debugging (remove in production)
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Function to log messages
function logMessage($message) {
    $logFile = 'change_detector.log';
    $timestamp = date('Y-m-d H:i:s');
    file_put_contents($logFile, "[$timestamp] $message\n", FILE_APPEND);
}

// Function to get the last check time from the log
function getLastCheckTime() {
    $logFile = 'change_detector.log';
    if (file_exists($logFile)) {
        $lines = file($logFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        if (!empty($lines)) {
            $lastLine = end($lines);
            preg_match('/\[(.*?)\]/', $lastLine, $matches);
            if (isset($matches[1])) {
                return $matches[1];
            }
        }
    }
    return 'Never';
}

// Function to check for changes on the page
function checkForChanges($url) {
    // Initialize cURL session
    $ch = curl_init();

    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');

    // Execute cURL request and get the response
    $response = curl_exec($ch);

    // Check for cURL errors
    if (curl_errno($ch)) {
        logMessage("cURL Error: " . curl_error($ch));
        return ['error' => 'Error: ' . curl_error($ch)];
    }

    // Close cURL session
    curl_close($ch);

    // Generate a hash of the entire page content
    $currentHash = md5($response);

    // Compare with previous hash
    $previousHash = '';
    if (file_exists('previous_hash.txt')) {
        $previousHash = file_get_contents('previous_hash.txt');
    }

    if ($currentHash !== $previousHash) {
        // Save the new hash
        file_put_contents('previous_hash.txt', $currentHash);

        logMessage("Changes detected. New hash: " . $currentHash);

        return [
            'changed' => true,
            'oldHash' => $previousHash,
            'newHash' => $currentHash
        ];
    }

    logMessage("No changes detected");
    return ['changed' => false];
}

// Main code
$url = 'https://longevacare.com/the-longeva-concept/';
$lastCheckTime = getLastCheckTime();
$changeStatus = 'No changes detected';
$hashInfo = '';
$changesDetected = false;

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['check_status'])) {
    try {
        $result = checkForChanges($url);
        $lastCheckTime = date('Y-m-d H:i:s');

        if (isset($result['error'])) {
            $changeStatus = $result['error'];
            logMessage("Error occurred: " . $result['error']);
        } elseif ($result['changed']) {
            $changeStatus = 'Changes detected!';
            $hashInfo = "Old Hash: " . substr($result['oldHash'], 0, 8) . "...<br>New Hash: " . substr($result['newHash'], 0, 8) . "...";
            logMessage("Changes detected on the page");
            $changesDetected = true;
        } else {
            $changeStatus = 'No changes detected';
            logMessage("No changes detected on the page");
            $changesDetected = false;
        }
    } catch (Exception $e) {
        $changeStatus = 'Error: ' . $e->getMessage();
        logMessage("Exception occurred: " . $e->getMessage());
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Longeva Care Page Change Detector</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Roboto', sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f0f0f0;
            color: #333;
        }
        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
        }
        .container {
            background-color: #ffffff;
            border-radius: 8px;
            padding: 30px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .status {
            font-size: 24px;
            font-weight: bold;
            margin: 20px 0;
            text-align: center;
            padding: 15px;
            border-radius: 5px;
        }
        .changes {
            background-color: #e74c3c;
            color: white;
        }
        .no-changes {
            background-color: #2ecc71;
            color: white;
        }
        .error {
            background-color: #f39c12;
            color: white;
        }
        .last-check {
            font-style: italic;
            color: #7f8c8d;
            text-align: center;
            margin-bottom: 20px;
        }
        form {
            text-align: center;
            margin-top: 30px;
        }
        button {
            padding: 12px 24px;
            font-size: 16px;
            cursor: pointer;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #2980b9;
        }
        .hash-info {
            margin-top: 20px;
            border: 1px solid #bdc3c7;
            padding: 15px;
            font-family: monospace;
            background-color: #ecf0f1;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Longeva Care Page Change Detector</h1>
        <div id="statusContainer" class="status <?php echo strtolower(str_replace(' ', '-', $changeStatus)); ?>">
            <?php echo $changeStatus; ?>
        </div>
        <div id="lastCheckContainer" class="last-check">
            Last checked: <?php echo $lastCheckTime; ?>
        </div>
        <form id="checkForm" method="post">
            <button type="submit" name="check_status">Check for Changes Now</button>
        </form>

        <div id="hashInfoContainer" class="hash-info" style="display: <?php echo !empty($hashInfo) ? 'block' : 'none'; ?>">
            <h2>Hash Information:</h2>
            <div id="hashInfoContent"><?php echo $hashInfo; ?></div>
        </div>
    </div>

    <audio id="alarmAudio" loop>
        <source src="alarm_1.mp3" type="audio/mpeg">
        Your browser does not support the audio element.
    </audio>

    <script>
    document.addEventListener('DOMContentLoaded', function() {
        var audio = document.getElementById('alarmAudio');
        var checkForm = document.getElementById('checkForm');
        var statusContainer = document.getElementById('statusContainer');
        var lastCheckContainer = document.getElementById('lastCheckContainer');
        var hashInfoContainer = document.getElementById('hashInfoContainer');
        var hashInfoContent = document.getElementById('hashInfoContent');
        var changesDetected = <?php echo json_encode($changesDetected); ?>;
        var audioPlaying = false;
        var checkInterval = null;

        function startCheckingLoop() {
            // Start checking for changes on the page every 10 seconds
            if (!changesDetected && !checkInterval) {
                checkInterval = setInterval(checkForChanges, 10000); // Check every 10 seconds
            }
        }

        function stopCheckingLoop() {
            // Stop checking
            if (checkInterval) {
                clearInterval(checkInterval);
                checkInterval = null;
            }
        }

        function playAlarm() {
            if (!audioPlaying) {
                audio.currentTime = 0; // Reset audio
                audio.play();
                audioPlaying = true;
                
                // Set timeout to stop the alarm after 10 minutes
                setTimeout(() => {
                    audio.pause();
                    audioPlaying = false;
                }, 600000); // 10 minutes
            }
        }

        function checkForChanges() {
            // Simulate the change check and trigger the alarm
            // This can be extended to an AJAX call to check for changes
            if (changesDetected) {
                playAlarm();
                stopCheckingLoop();
            }
        }

        // Start the checking loop on page load
        startCheckingLoop();
    });
    </script>
</body>
</html>
) i need fix and working well, and every 10sec refresh the page and with checking detected and if found detected play audio alarm_1.mp3 for 5mins loop and type full codes with great designa