Untitled

 avatar
unknown
plain_text
2 months ago
606 B
5
Indexable
<?php
$host = "localhost";
$dbname = "internet";
$username = "internet";
$password = "";

// Koble til MariaDB med MySQLi
$conn = new mysqli($host, $username, $password, $dbname);

// Sjekk tilkobling
if ($conn->connect_error) {
    die("Tilkoblingsfeil: " . $conn->connect_error);
}

// Sjekk internettstatus
$timestamp = date("Y-m-d H:i:s");
$status = (exec("ping -c 1 8.8.8.8") ? 1 : 0);

// Sett inn data
$sql = "INSERT INTO surveillance (timestamp, status) VALUES ('$timestamp', '$status')";
if (!$conn->query($sql)) {
    echo "Feil: " . $conn->error;
}

$conn->close();
?>
Editor is loading...
Leave a Comment