In previous versions I used:
Code: Select all
<?php
// USERS ONLINE
// A Replacment tag to display the number of users online (within 20 minutes)
// save this script to... phpwcms_template/inc_script/frontent_render/usersonline.php
// USAGE.. {USERSONLINE}
/*
add this SQL to your database...
CREATE TABLE `modwcms_useronline` (
`timestamp` int(15) NOT NULL default '0',
`ip` varchar(40) NOT NULL default '',
`file` varchar(100) NOT NULL default '',
PRIMARY KEY (`timestamp`),
KEY `ip` (`ip`),
KEY `file` (`file`)
) TYPE=MyISAM;
*/
if( ! ( strpos($content["all"],'{USERSONLINE}')===false ) )
{
// Configuration
$timeoutseconds = 1200; // length of session, 20 minutes is the standard
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
$ip = substr($_SERVER['REMOTE_ADDR'], 0, strrpos($_SERVER['REMOTE_ADDR'],"."));
// Add this user to database
$loopcap = 0;
while ($loopcap<3 && @mysql_query("insert into modwcms_useronline values('$timestamp','$ip','$PHP_SELF')", $db))
{ // in case of collision
$timestamp = $timestamp+$ip{0};
$loopcap++;
}
// Delete users that have been online for more then "$timeoutseconds" seconds
@mysql_query("delete from modwcms_useronline where timestamp<$timeout", $db);
// Select users online
$result = @mysql_query("SELECT distinct ip FROM modwcms_useronline", $db);
$user = @mysql_num_rows($result);
mysql_free_result($result);
// Show all users online
if ($user==1) {$user = $user.' online';} else {$user = $user.' online';}
$content["all"] = str_replace("{USERSONLINE}", $user, $content["all"]);
}
?>
<div id="sidebar">
<strong>{USERSONLINE}</strong><br />
</div>
Database entry `modwcms_useronline` exists
I get a white page.
Does not work in PHP 7.0
Please help me