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.
<?
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$cutoff = 15; //online cut of time
$exists = 0;
$users = 0;
$user = "";
$fp = fopen ("online.txt","r+"); //if the file exists open it
while (!feof($fp))
{
$user[] = chop(fgets($fp,65536));
}
fseek($fp,0,SEEK_SET);
foreach ($user as $line)
{
list($oldip,$oldtime) = explode('|',$line);
if ($oldip == $ip) {$oldtime = $time;$exists = 1;} //check to see if the user is already in the text file
if ($time < $oldtime + ($cutoff * 60)) //see if the last time the user visited is past the cut off time
{
fputs($fp,"$oldip|$oldtime\n"); //write the old data to the text file
$users = $users + 1; // add one to the user count
}
}
if ($exists == 0) //if the user isn't in the text file already:
{
fputs($fp,"$ip|$time\n"); //write the new data to the text file
$users = $users + 1; //add one to the user count
}
fclose ($fp); //close the text file
//print "<p> </p>";
print "Онлайн потребители: <font color=red>$users</font>";
?>
<?$c = mysql_connect('survura', 'usera', 'pass-a') or die ('...');
@mysql_select('dbname',$c) or die ('greshka');
$sql = mysql_query("SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
FROM phpbb_users u, phpbb_sessions s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
$n=mysql_num_rows($sql);
ORDER BY u.username ASC, s.session_ip ASC") or die ("GReshka");
while($r=mysql_fetch_array($sql)){
$useri = $r['username'];
echo $useri;
}
echo "Общо: $n";
?>
ами да попълваш полетатаCek0Ff каза:Нещо не става.. отваря бяла страница.. нали на местото на "survara" пиша localhost ?
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<?
mysql_connect('***', '***', '***');
mysql_select_db('***');
$sql = mysql_query("SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
FROM phpbb_users u, phpbb_sessions s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
ORDER BY u.username ASC, s.session_ip ASC") or die ("GReshka");
$n=mysql_num_rows($sql);
while($r=mysql_fetch_array($sql)){
$useri = $r['username'];
echo $useri;
}
echo "Общо: $n";
?>
<?
mysql_connect('localhost', 'root', '');
mysql_select_db('phpbb');
$sql = mysql_query("SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
FROM phpbb_users u, phpbb_sessions s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
ORDER BY u.username ASC, s.session_ip ASC") or die ("GReshka");
$n=mysql_num_rows($sql);
while($r=mysql_fetch_array($sql)){
$useri = $r['username'];
if($xx=count($useri != "Anonymous")){
$i++;
echo $useri;
if($i==1){
echo ",";
$i=0;
}
}
}
echo "<br />Общо: ".$n-$xx."";
?>