Besökare online:
// Besökare online
##################################################
# Variablar
$server = "localhost"; // mySQL servern. Oftast "localhost", testa annars "127.0.0.1"
$databas = "bestonli_a"; // Databasnamn
$anvandare = "bestonli_per"; // Användarnamn
$losen = "PersSQL"; // Lösenord
$tiden = time()-3600; // Antal sekunder som varje IP skall behållas i databasen
##################################################
# Script
$conn_online = mysqli_connect("$server", "$anvandare", "$losen","$databas");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
$klockan = time();
$ip=getRealIpAddr();
mysqli_query($conn_online, "INSERT INTO useronline (klockan, ip) VALUES ('$klockan', '$ip')");
mysqli_query($conn_online, "DELETE FROM useronline WHERE klockan < '$tiden'");
$antal = mysqli_num_rows (mysqli_query ($conn_online, "SELECT DISTINCT klockan FROM useronline"));
//(mysqli_query ($conn_online, "SELECT DISTINCT ip FROM useronline"));
mysqli_close($conn_online);
echo "$antal";
?>
| |
|
|
Aktuell vecka:
$current = getdate();
$current["hours"] = $current["hours"] + 1;
if ($current["hours"] < 10) {
$current["hours"] = "0" . $current["hours"];
}
if ($current["minutes"] < 10) {
$current["minutes"] = "0" . $current["minutes"];
}
if ($current["seconds"] < 10) {
$current["seconds"] = "0" . $current["seconds"];
}
if ($current["mday"] < 10) {
$current["mday"] = "0" . $current["mday"];
}
$current_time = $current["hours"] . ":" . $current["minutes"] . ":" . $current ["seconds"] ;
$current_date = $current["month"] . " " . $current["mday"] . "," . " " . $current["year"];
print (strftime ("%V"));
?>
|