Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
CREATE TABLE useronline (
timestamp int(15) DEFAULT '0' NOT NULL,
ip varchar(40) NOT NULL,
file varchar(100) NOT NULL,
PRIMARY KEY (timestamp),
KEY ip (ip),
KEY file (file)
);
<?php
$server = "localhost";
$db_user = "username";
$db_pass = "password";
$database = "users";
$timeoutseconds = 300;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
mysql_connect($server, $db_user, $db_pass);
$insert = mysql_db_query($database, "INSERT INTO useronline VALUES
('$timestamp','$REMOTE_ADDR','$PHP_SELF')");
if(!($insert)) {
print "Useronline Insert Failed > ";
}
$delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout");
if(!($delete)) {
print "Useronline Delete Failed > ";
}
$result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'");
if(!($result)) {
print "Useronline Select Error > ";
}
$user = mysql_num_rows($result);
mysql_close();
if($user == 1) {
print("$user user online\n");
} else {
print("$user users online\n");
}
?>
<?
$file = "db.txt";
$expire = "30";
$ip = $_SERVER['REMOTE_ADDR'];
if (!$open = fopen($file,'a')) { echo "No database"; }
$a = file($file);
$open = fopen($file,'w');
if (count($a) == "0") { fwrite($open, "$ip|" . time() . "n"); }
else {
foreach($a as $show) {
$part = explode("|", $show);
if ($part[1]+$expire <= time()) { }
else {
if ($ip == $part[0]) { }
else { fwrite($open, "$show"); }
}
}
fwrite($open, "$ip|" . time() . "n");
}
fclose($open);
echo "" . count(file($file)) . " user(s) online";
?>
gogato93 каза:Искам да показва само броя на регистрираните и броя на гостите!Не толко сложно ако може![]()
gogato93 каза:Да имам интеграция с phpbb2 :lol: