2008-01-13 10:51:42 +00:00
< ? php
/*
2009-09-21 21:43:45 +00:00
* e107 website system
*
2010-05-15 17:33:11 +00:00
* Copyright ( C ) 2008 - 2010 e107 Inc ( e107 . org )
2009-09-21 21:43:45 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
2013-03-24 18:59:18 +01:00
* Online handler
2009-09-21 21:43:45 +00:00
*
2008-01-13 10:51:42 +00:00
*/
2009-12-28 17:53:11 +00:00
/**
* @ package e107
* @ subpackage e107_handlers
*
2009-12-28 21:36:13 +00:00
* Handler to keep track of online users
2009-12-28 17:53:11 +00:00
*/
/*
online_timestamp int ( 10 ) unsigned NOT NULL default '0' , Start of time period over which accesses counted
online_flag tinyint ( 3 ) unsigned NOT NULL default '0' , Not used ? ( displayed in admin log only )
online_user_id varchar ( 100 ) NOT NULL default '' ,
online_ip varchar ( 45 ) NOT NULL default '' ,
online_location text NOT NULL , Current page being accessed
online_pagecount tinyint ( 3 ) unsigned NOT NULL default '0' , Number of page accesses ( within most recent timeout interval ? )
online_active int ( 10 ) unsigned NOT NULL default '0' , Not used ? Actually added in the update routines , version 0.7 . 6. ( Also displayed in admin log )
online_agent varchar ( 255 ) NOT NULL default '' User agent - use for bot identification
2010-05-15 17:33:11 +00:00
2009-12-28 17:53:11 +00:00
Current count () queries :
a ) Total
b ) $sql -> db_Count ( 'online' , '(*)' , " WHERE `online_location` = ' { $page } ' " ));
2010-05-15 17:33:11 +00:00
2009-12-28 17:53:11 +00:00
Also forum_viewforum . php :
$member_users = $sql -> db_Count ( 'online' , '(*)' , " WHERE online_location REGEXP('viewforum.php.id= $forumId\ $ ') AND online_user_id != 0 " );
$guest_users = $sql -> db_Count ( 'online' , '(*)' , " WHERE online_location REGEXP('viewforum.php.id= $forumId\ $ ') AND online_user_id = 0 " );
Following single query gives two rows of data - one for members ( online_user_id != 0 ) and one for guests ( online_user_id == 0 )
SELECT COUNT ( `online_user_id` ) AS ol_count , `online_user_id` FROM `#online` GROUP BY ( `online_user_id` = 0 )
*/
/**
* @ todo Don ' t create list of online members by default - $listuserson used in forum , online_menu . php , online . php
* @ todo $member_list defined as MEMBER_LIST - used in online_shortcodes . php
* @ todo $members_online , defined as MEMBERS_ONLINE - used in online_menu . php , online_shortcodes . php , online_template . php , online . php , forum . php
* @ todo $total_online defined ( indirectly ) as GUESTS_ONLINE + MEMBERS_ONLINE - used in online_menu . php , online_shortcodes . php , online_template . php , online . php
* @ todo Possibly online_pagecount should be bigger than tinyint ( 3 )
* @ todo Possibly shouldn ' t log access to index . php - its usually a redirect - but not always !
* @ todo Can we distinguish between different users at same IP ? Browser sig , maybe ?
* @ todo Change queries to array access
* @ todo Eliminate other globals
* @ todo Can we simplify counts into one query ?
*/
2010-05-15 17:33:11 +00:00
class e_online
2008-01-13 10:51:42 +00:00
{
2012-12-04 21:02:47 -08:00
public $users = array ();
2013-01-15 18:01:51 -08:00
public $guests = array ();
2012-12-04 21:02:47 -08:00
function __construct ()
{
}
2010-05-15 17:33:11 +00:00
/**
* Go online
* @ param boolean $online_tracking
* @ param boolean $flood_control
* @ return void
*/
public function goOnline ( $online_tracking = false , $flood_control = false )
2008-01-13 10:51:42 +00:00
{
2010-05-15 17:33:11 +00:00
// global $pref, $e_event; // Not needed as globals
2009-12-28 17:53:11 +00:00
//global $online_timeout, $online_warncount, $online_bancount; // Not needed as globals
//global $members_online, $total_online; // Not needed as globals
2010-05-15 17:33:11 +00:00
global $listuserson ; // FIXME - remove it, make it property, call e_online signleton - e107::getOnline()
2008-01-13 10:51:42 +00:00
2020-05-23 15:49:40 +02:00
if ( $online_tracking == false || $flood_control == false )
2017-02-07 14:52:38 -08:00
{
define ( 'e_TRACKING_DISABLED' , true ); // Used in forum, online menu
define ( 'TOTAL_ONLINE' , '' );
define ( 'MEMBERS_ONLINE' , '' );
define ( 'GUESTS_ONLINE' , '' );
define ( 'ON_PAGE' , '' );
define ( 'MEMBER_LIST' , '' );
return null ;
}
2009-12-28 17:53:11 +00:00
$sql = e107 :: getDb ();
2010-05-15 17:33:11 +00:00
$user = e107 :: getUser ();
2020-05-02 15:35:30 -07:00
$dbg = e107 :: getDebug ();
2009-09-21 21:43:45 +00:00
2017-02-07 14:52:38 -08:00
$online_timeout = 300 ;
2010-05-15 17:33:11 +00:00
2017-02-07 14:52:38 -08:00
list ( $ban_access_guest , $ban_access_member ) = explode ( ',' , e107 :: getPref ( 'ban_max_online_access' , '100,200' ));
$online_bancount = max ( $ban_access_guest , 50 ); // Safety net for incorrect values
if ( $user -> isUser ())
{
$online_bancount = max ( $online_bancount , $ban_access_member );
}
2010-05-15 17:33:11 +00:00
2017-02-07 14:52:38 -08:00
$online_warncount = $online_bancount * 0.9 ; // Set warning threshold at 90% of ban threshold
2010-05-15 17:33:11 +00:00
//TODO Add support for all queries.
2011-11-25 17:36:40 +00:00
// $page = (strpos(e_SELF, 'forum_') !== FALSE) ? e_SELF.'.'.e_QUERY : e_SELF;
// $page = (strpos(e_SELF, 'comment') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
// $page = (strpos(e_SELF, 'content') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
$page = e_REQUEST_URI ; // mod rewrite & single entry support
// FIXME parse url, trigger registered e_online callbacks
2017-02-07 14:52:38 -08:00
// $page = e107::getParser()->toDB($page, true); /// @todo - try not to use toDB() - triggers prefilter
$page = filter_var ( $page , FILTER_SANITIZE_URL );
2012-01-02 22:06:22 +00:00
$ip = e107 :: getIPHandler () -> getIP ( FALSE );
2017-02-07 14:52:38 -08:00
2015-11-13 18:04:47 -08:00
$udata = ( $user -> isUser () && USER ? $user -> getId () . '.' . $user -> getName () : '0' ); // USER check required to make sure they logged in without an error.
2020-01-17 15:46:15 +01:00
$agent = isset ( $_SERVER [ 'HTTP_USER_AGENT' ]) ? $_SERVER [ 'HTTP_USER_AGENT' ] : '' ;
2010-05-15 17:33:11 +00:00
// XXX - more exceptions, e.g. hide online location for admins/users (pref), e_jlsib.php, etc
// XXX - more advanced flod timing when e_AJAX_REQUEST, e.g. $ban_access_ajax = 300
$update_page = deftrue ( 'e_AJAX_REQUEST' ) ? '' : " , online_location=' { $page } ' " ;
2009-12-24 10:00:30 +00:00
$insert_query = array (
'online_timestamp' => time (),
'online_flag' => 0 ,
'online_user_id' => $udata ,
'online_ip' => $ip ,
'online_location' => $page ,
'online_pagecount' => 1 ,
'online_active' => 0 ,
2015-11-18 20:28:41 -08:00
'online_agent' => $agent ,
'online_language' => e_LAN
2009-12-24 10:00:30 +00:00
);
2010-05-15 17:33:11 +00:00
// !deftrue('e_AJAX_REQUEST')
// TODO add option to hide users from online list? boolean online_hide field?
// don't do anything if main admin logged in as another user
2015-11-13 18:04:47 -08:00
if ( $user -> isUser () && ! $user -> getParentId ())
2009-02-03 21:16:29 +00:00
{
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (isUser)' );
2008-01-13 10:51:42 +00:00
// Find record that matches IP or visitor, or matches user info
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (db select)' );
2017-02-07 14:52:38 -08:00
if ( $sql -> select ( 'online' , '*' , " (`online_ip` = ' { $ip } ' AND `online_user_id` = '0') OR `online_user_id` = ' { $udata } ' LIMIT 1 " ))
2008-01-13 10:51:42 +00:00
{
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (db fetch)' );
2013-03-24 18:59:18 +01:00
$row = $sql -> fetch ();
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (db end)' );
2008-01-13 10:51:42 +00:00
2010-05-15 17:33:11 +00:00
if ( $row [ 'online_user_id' ] == $udata )
2009-12-28 17:53:11 +00:00
{
2008-01-13 10:51:42 +00:00
//Matching user record
2010-05-15 17:33:11 +00:00
if ( $row [ 'online_timestamp' ] < ( time () - $online_timeout ))
2009-12-28 17:53:11 +00:00
{
//It has been at least 'online_timeout' seconds since this user's info last logged
2008-01-13 10:51:42 +00:00
//Update user record with timestamp, current IP, current page and set pagecount to 1
2017-02-07 14:52:38 -08:00
// $query = "online_timestamp='".time()."', online_ip='{$ip}'{$update_page}, online_pagecount=1, `online_active` = 1 WHERE online_user_id='{$row['online_user_id']}'";
$query = array (
'online_timestamp' => time (),
'online_ip' => $ip ,
'online_pagecount' => 1 ,
'online_active' => 1 ,
'WHERE' => " online_user_id= " . intval ( $row [ 'online_user_id' ]) . " LIMIT 1 "
);
2010-05-15 17:33:11 +00:00
}
else
2009-12-28 17:53:11 +00:00
{
2010-05-15 17:33:11 +00:00
if ( ! $user -> isAdmin ())
2009-12-28 17:53:11 +00:00
{
2008-01-13 10:51:42 +00:00
$row [ 'online_pagecount' ] ++ ;
}
// Update user record with current IP, current page and increment pagecount
2017-02-07 14:52:38 -08:00
// $query = "online_ip='{$ip}'{$update_page}, `online_pagecount` = '".intval($row['online_pagecount'])."', `online_active` = 1 WHERE `online_user_id` = '{$row['online_user_id']}'";
$query = array (
'online_ip' => $ip ,
'online_pagecount' => intval ( $row [ 'online_pagecount' ]),
'online_active' => 1 ,
'WHERE' => " online_user_id= " . intval ( $row [ 'online_user_id' ]) . " LIMIT 1 "
);
2008-01-13 10:51:42 +00:00
}
2010-05-15 17:33:11 +00:00
}
else
2009-12-28 17:53:11 +00:00
{
2008-01-13 10:51:42 +00:00
//Found matching visitor record (ip only) for this user
2010-05-15 17:33:11 +00:00
if ( $row [ 'online_timestamp' ] < ( time () - $online_timeout ))
2009-12-28 17:53:11 +00:00
{
2008-01-13 10:51:42 +00:00
// It has been at least 'timeout' seconds since this user has connected
// Update record with timestamp, current IP, current page and set pagecount to 1
2017-02-07 14:52:38 -08:00
// $query = "`online_timestamp` = '".time()."', `online_user_id` = '{$udata}'{$update_page}, `online_pagecount` = 1, `online_active` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
$query = array (
'online_timestamp' => time (),
'online_user_id' => $udata ,
'online_pagecount' => 1 ,
'online_active' => 1 ,
'WHERE' => " online_ip = ' " . $ip . " ' AND online_user_id = '0' LIMIT 1 "
);
2010-05-15 17:33:11 +00:00
}
else
2009-12-28 17:53:11 +00:00
{ // Another visit within the timeout period
2010-05-15 17:33:11 +00:00
if ( ! $user -> isAdmin ())
2009-12-28 17:53:11 +00:00
{
2008-01-13 10:51:42 +00:00
$row [ 'online_pagecount' ] ++ ;
}
//Update record with current IP, current page and increment pagecount
2019-01-31 14:35:57 -08:00
// $query = "`online_user_id` = '{$udata}'{$update_page}, `online_pagecount` = ".intval($row['online_pagecount']).", `online_active` =1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
2017-02-07 14:52:38 -08:00
$query = array (
// 'online_timestamp' => time(),
'online_user_id' => $udata ,
'online_pagecount' => intval ( $row [ 'online_pagecount' ]),
'online_active' => 1 ,
'WHERE' => " online_ip = ' " . $ip . " ' AND online_user_id = '0' LIMIT 1 "
);
2008-01-13 10:51:42 +00:00
}
}
2017-02-07 14:52:38 -08:00
if ( ! empty ( $update_page ))
{
$query [ 'online_location' ] = $page ;
}
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (update) Line:' . __LINE__ );
2013-03-24 18:59:18 +01:00
$sql -> update ( 'online' , $query );
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (after update) Line:' . __LINE__ );
2017-02-07 14:52:38 -08:00
2010-05-15 17:33:11 +00:00
}
else
2008-01-13 10:51:42 +00:00
{
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (insert) Line: ' . __LINE__ );
2013-03-24 18:59:18 +01:00
$sql -> insert ( 'online' , $insert_query );
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (after insert) Line: ' . __LINE__ );
2008-01-13 10:51:42 +00:00
}
2018-01-13 14:11:46 -08:00
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (after isUser)' );
2009-02-03 21:16:29 +00:00
}
2010-05-15 17:33:11 +00:00
// don't do anything if main admin logged in as another user
elseif ( ! $user -> getParentId ())
2009-02-03 21:16:29 +00:00
{
2010-05-15 17:33:11 +00:00
//Current page request is from a guest
2015-11-13 18:04:47 -08:00
if ( $sql -> select ( 'online' , '*' , " `online_ip` = ' { $ip } ' AND `online_user_id` = '0' " ))
2009-12-28 17:53:11 +00:00
{ // Recent visitor
2013-03-24 18:59:18 +01:00
$row = $sql -> fetch ();
2008-01-13 10:51:42 +00:00
if ( $row [ 'online_timestamp' ] < ( time () - $online_timeout )) //It has been at least 'timeout' seconds since this ip has connected
{
//Update record with timestamp, current page, and set pagecount to 1
2013-05-24 22:40:10 +03:00
$query = " `online_timestamp` = ' " . time () . " ' { $update_page } , `online_pagecount` = 1 WHERE `online_ip` = ' { $ip } ' AND `online_user_id` = '0' " ;
2010-05-15 17:33:11 +00:00
}
else
2009-02-03 21:16:29 +00:00
{
2008-01-13 10:51:42 +00:00
//Update record with current page and increment pagecount
$row [ 'online_pagecount' ] ++ ;
// echo "here {$online_pagecount}";
2013-05-24 22:40:10 +03:00
$query = " `online_pagecount` = { $row [ 'online_pagecount' ] } { $update_page } WHERE `online_ip` = ' { $ip } ' AND `online_user_id` = '0' " ;
2008-01-13 10:51:42 +00:00
}
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (update) Line:' . __LINE__ );
2013-03-24 18:59:18 +01:00
$sql -> update ( 'online' , $query );
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (after update) Line:' . __LINE__ );
2010-05-15 17:33:11 +00:00
}
else
2009-12-28 17:53:11 +00:00
{ // New visitor
2013-03-24 18:59:18 +01:00
$sql -> insert ( 'online' , $insert_query );
2008-01-13 10:51:42 +00:00
}
2009-02-03 21:16:29 +00:00
}
2008-01-13 10:51:42 +00:00
2010-05-15 17:33:11 +00:00
if ( $user -> isAdmin () || ( e107 :: getPref ( 'autoban' ) != 1 && e107 :: getPref ( 'autoban' ) != 2 ) || ( ! isset ( $row [ 'online_pagecount' ]))) // Auto-Ban is switched off. (0 or 3)
2009-02-03 21:16:29 +00:00
{
$row [ 'online_pagecount' ] = 1 ;
}
2008-01-13 10:51:42 +00:00
2009-12-28 17:53:11 +00:00
// Always allow localhost - any problems are usually semi-intentional!
2021-01-24 10:42:53 -08:00
$onlineIP = varset ( $row [ 'online_ip' ]);
if (( $onlineIP !== '127.0.0.1' ) && ( $onlineIP !== e107 :: LOCALHOST_IP ) && ( $onlineIP != e107 :: LOCALHOST_IP2 ))
2008-01-13 10:51:42 +00:00
{
2009-12-28 17:53:11 +00:00
// Check for excessive access
if ( $row [ 'online_pagecount' ] > $online_bancount )
2009-02-03 21:16:29 +00:00
{
2015-04-12 23:11:13 -07:00
e107 :: lan ( 'core' , 'banlist' , true ); //e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_banlist.php'
$reason = e107 :: getParser () -> lanVars ( BANLAN_78 , $row [ 'online_pagecount' ]); // str_replace('--HITS--',$row['online_pagecount'], BANLAN_78)
2015-04-13 00:20:36 -07:00
2015-04-12 23:11:13 -07:00
if ( true === e107 :: getIPHandler () -> add_ban ( 2 , $reason , $ip , 0 ))
2009-12-28 17:53:11 +00:00
{
2015-02-09 20:11:16 -08:00
e107 :: getEvent () -> trigger ( 'flood' , $ip ); //BC
2015-02-12 16:52:30 -08:00
e107 :: getEvent () -> trigger ( 'user_ban_flood' , $ip );
2009-12-28 17:53:11 +00:00
exit ;
}
}
2010-05-15 17:33:11 +00:00
elseif ( $row [ 'online_pagecount' ] >= $online_warncount )
2009-12-28 17:53:11 +00:00
{
echo " <div style='text-align:center; font: 11px verdana, tahoma, arial, helvetica, sans-serif;'><b> " . LAN_WARNING . " </b><br /><br /> " . CORE_LAN6 . " <br /></div> " ;
2009-02-03 21:16:29 +00:00
exit ;
}
2008-01-13 10:51:42 +00:00
}
2009-12-28 17:53:11 +00:00
// Delete records for users (and guests) not seen for a while
2010-05-15 17:33:11 +00:00
// FIXME - DB optimization - mark records as deleted (online_deleted=1), delete once per hour (could be pref) via e_cron
// FIXME - Additional prefs for this (it does 2-3 more queries no matter someone need them), could be also separate method
// Speed up ajax requests
if ( ! deftrue ( 'e_AJAX_REQUEST' ))
2009-12-28 17:53:11 +00:00
{
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (delete) Line:' . __LINE__ );
2013-03-24 18:59:18 +01:00
$sql -> delete ( 'online' , '`online_timestamp` < ' . ( time () - $online_timeout ));
2010-05-15 17:33:11 +00:00
// FIXME - don't use constants below, save data in class vars, call e_online signleton - e107::getOnline()
2013-01-15 18:01:51 -08:00
// $total_online = $sql->db_Count('online'); // 1 less query! :-)
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (total_online) Line:' . __LINE__ );
2017-02-07 14:52:38 -08:00
if ( $total_online = $sql -> gen ( 'SELECT o.*,u.user_image FROM `#online` AS o LEFT JOIN `#user` AS u ON o.online_user_id = u.user_id WHERE o.online_pagecount > 0 ORDER BY o.online_timestamp DESC' ))
// if ($total_online = $sql->gen('SELECT o FROM `#online` WHERE o.online_pagecount > 0 ORDER BY o.online_timestamp DESC'))
2010-05-15 17:33:11 +00:00
{
$member_list = '' ;
2013-01-15 18:01:51 -08:00
$members_online = 0 ;
2010-05-15 17:33:11 +00:00
$listuserson = array ();
2017-02-07 14:52:38 -08:00
2020-05-02 15:35:30 -07:00
$dbg -> logTime ( 'Go online (db fetch) Line:' . __LINE__ );
2013-03-24 18:59:18 +01:00
while ( $row = $sql -> fetch ())
2010-05-15 17:33:11 +00:00
{
2017-02-07 14:52:38 -08:00
2012-12-04 21:02:47 -08:00
$row [ 'online_bot' ] = $this -> isBot ( $row [ 'online_agent' ]);
2013-01-15 18:01:51 -08:00
2012-12-04 21:02:47 -08:00
// Sort into usable format and add bot field.
$user = array (
'user_location' => $row [ 'online_location' ],
'user_bot' => $this -> isBot ( $row [ 'online_agent' ]),
'user_agent' => $row [ 'online_agent' ],
'user_ip' => $row [ 'online_ip' ],
'user_currentvisit' => $row [ 'online_timestamp' ],
'user_online' => $row [ 'online_flag' ],
'user_pagecount' => $row [ 'online_pagecount' ],
'user_active' => $row [ 'online_active' ],
2013-04-29 19:39:12 -07:00
'user_image' => vartrue ( $row [ 'user_image' ], false ),
2016-01-14 08:28:17 -08:00
'online_user_id' => $row [ 'online_user_id' ],
'user_language' => $row [ 'online_language' ]
2012-12-04 21:02:47 -08:00
);
2015-11-13 18:04:47 -08:00
if ( $row [ 'online_user_id' ] != 0 )
2013-01-15 18:01:51 -08:00
{
$vals = explode ( '.' , $row [ 'online_user_id' ], 2 );
2013-02-19 21:02:59 +00:00
$user [ 'user_id' ] = $vals [ 0 ];
$user [ 'user_name' ] = $vals [ 1 ];
2013-01-15 18:01:51 -08:00
$member_list .= " <a href=' " . SITEURL . " user.php?id. { $vals [ 0 ] } '> { $vals [ 1 ] } </a> " ;
$listuserson [ $row [ 'online_user_id' ]] = $row [ 'online_location' ];
2015-11-13 18:04:47 -08:00
$this -> users [] = $user ;
2013-01-15 18:01:51 -08:00
$members_online ++ ;
2015-11-13 18:04:47 -08:00
2013-01-15 18:01:51 -08:00
}
else
{
2013-02-19 21:02:59 +00:00
$user [ 'user_id' ] = 0 ;
$user [ 'user_name' ] = 'guest' ; // Maybe should just be an empty string?
2013-01-15 18:01:51 -08:00
$this -> guests [] = $user ;
}
2012-12-04 21:02:47 -08:00
2010-05-15 17:33:11 +00:00
}
}
2021-01-24 10:42:53 -08:00
if ( ! defined ( 'TOTAL_ONLINE' ))
{
define ( 'TOTAL_ONLINE' , $total_online );
define ( 'MEMBERS_ONLINE' , $members_online );
define ( 'GUESTS_ONLINE' , $total_online - $members_online );
$dbg -> logTime ( 'Go online (db count) Line:' . __LINE__ );
define ( 'ON_PAGE' , $sql -> count ( 'online' , '(*)' , " WHERE `online_location` = ' { $page } ' " ));
define ( 'MEMBER_LIST' , $member_list );
}
2010-05-15 17:33:11 +00:00
//update most ever online
$olCountPrefs = e107 :: getConfig ( 'history' ); // Get historic counts of members on line
2013-04-27 15:51:47 +03:00
$olCountPrefs -> setParam ( 'nologs' , true );
2017-02-07 14:52:38 -08:00
2010-05-15 17:33:11 +00:00
if ( $total_online > ( $olCountPrefs -> get ( 'most_members_online' ) + $olCountPrefs -> get ( 'most_guests_online' )))
2009-12-28 17:53:11 +00:00
{
2010-05-15 17:33:11 +00:00
$olCountPrefs -> set ( 'most_members_online' , MEMBERS_ONLINE );
$olCountPrefs -> set ( 'most_guests_online' , GUESTS_ONLINE );
$olCountPrefs -> set ( 'most_online_datestamp' , time ());
$olCountPrefs -> save ( false , true , false );
2008-01-13 10:51:42 +00:00
}
}
2017-02-07 14:52:38 -08:00
/* }
2008-01-13 10:51:42 +00:00
else
{
2009-12-28 17:53:11 +00:00
define ( 'e_TRACKING_DISABLED' , true ); // Used in forum, online menu
define ( 'TOTAL_ONLINE' , '' );
define ( 'MEMBERS_ONLINE' , '' );
define ( 'GUESTS_ONLINE' , '' );
define ( 'ON_PAGE' , '' );
define ( 'MEMBER_LIST' , '' );
2017-02-07 14:52:38 -08:00
} */
2008-01-13 10:51:42 +00:00
}
2012-12-04 21:02:47 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $debug
* @ return array | string
*/
2016-04-28 13:17:36 -07:00
function userList ( $debug = false )
2012-12-04 21:02:47 -08:00
{
2016-04-28 13:17:36 -07:00
if ( $debug === true )
{
//print_a($this->users);
2021-01-24 10:42:53 -08:00
return e107 :: getDb () -> retrieve ( 'user' , 'user_id,user_name,user_image, 1 as user_active, CONCAT_WS(".",user_id,user_name) as online_user_id' , " LIMIT 7 " , true );
2016-04-28 13:17:36 -07:00
}
2015-11-13 18:04:47 -08:00
return $this -> users ;
2012-12-04 21:02:47 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2013-01-15 18:01:51 -08:00
function guestList ()
{
2021-01-24 10:42:53 -08:00
return $this -> guests ;
2013-01-15 18:01:51 -08:00
}
2012-12-04 21:02:47 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $userAgent
* @ return bool
*/
2012-12-04 21:02:47 -08:00
function isBot ( $userAgent = '' )
{
2021-01-24 10:42:53 -08:00
return e107 :: getUser () -> isBot ( $userAgent );
2012-12-04 21:02:47 -08:00
}
2013-03-24 18:59:18 +01:00
}