Jump to content

Resolved - Eliminate Bots data in Users Online?


Dirty Butter

Recommended Posts

/* BSMITHER IGNORE BOTS HACK */
if (isset($_GET['bots']) && $_GET['bots']=='true') {
    $filter = '';
    $GLOBALS['smarty']->assign('BOTS', true);
} else {
    $filter = '(S.session_last > S.session_start) AND ';
    $GLOBALS['smarty']->assign('BOTS', false);
}

$thisBotStringArray = array('alexa','appie','archiver','ask jeeves','baiduspider','bot','crawl','crawler','curl','eventbox','facebookexternal','fast',
'firefly','froogle','gigabot','girafabot','google','googlebot','infoseek','inktomi','java','larbin','looksmart','mechanize','monitor','msnbot','nambu',
'nationaldirectory','novarra','pear','perl','python','rabaz','radian','rankivabot','scooter','slurp','sogou web spider','spade','sphere','spider','technoratisnoop',
'tecnoseek','teoma','toolbar','transcoder','twitt','url_spider_sql','webalta','webbug','webfindbot','wordpress','www.galaxy.com','yahoo','yandex','zyborg',);
$query  = sprintf("SELECT S.*, C.first_name, C.last_name FROM %1\$sCubeCart_sessions AS S LEFT JOIN %1\$sCubeCart_customer AS C ON S.customer_id = C.customer_id WHERE ".$filter."S.session_last>".$timeLimit." ORDER BY S.session_last DESC", $glob['dbprefix']);
if (($results = $GLOBALS['db']->query($query)) !== false) {

$GLOBALS['main']->addTabControl($lang['statistics']['title_customers_active'], 'stats_online', false, false, count($smarty_data['users_online']));
    $GLOBALS['smarty']->assign('USERS_ONLINE', $smarty_data['users_online']);
    $smarty_data['users_online'] = array();
   foreach ($results as $user) { $user_agentstring = $user['useragent'];
        $foundBots = array_filter($thisBotStringArray, function($str) use ($user_agentstring){ return (false !== strpos($user_agentstring,$str)); });
        if (!empty($foundBots)) continue;
        $user['is_admin']  = ((int)$user['admin_id'] > 0) ? 1 : 0;
//END BSMITHER IGNORE BOTS HACK 

Did I mess up the code?

Link to comment
Share on other sites

Change:
if (!empty($foundBots)) continue;
To:
if (!empty($foundBots) && !empty($filter)) continue;

In this same area of making edits, find and delete:

$GLOBALS['main']->addTabControl($lang['statistics']['title_customers_active'], 'stats_online', false, false, count($results));
Add the new line seen here just above the existing line (that is, do not move the existing line):
/* NEW */ $GLOBALS['main']->addTabControl($lang['statistics']['title_customers_active'], 'stats_online', false, false, count($smarty_data['users_online']));
    $GLOBALS['smarty']->assign('USERS_ONLINE', $smarty_data['users_online']);

 

Link to comment
Share on other sites

Still no count.

/* BSMITHER IGNORE BOTS HACK */
if (isset($_GET['bots']) && $_GET['bots']=='true') {
    $filter = '';
    $GLOBALS['smarty']->assign('BOTS', true);
} else {
    $filter = '(S.session_last > S.session_start) AND ';
    $GLOBALS['smarty']->assign('BOTS', false);
}

$thisBotStringArray = array('alexa','appie','archiver','ask jeeves','baiduspider','bot','crawl','crawler','curl','eventbox','facebookexternal','fast',
'firefly','froogle','gigabot','girafabot','google','googlebot','infoseek','inktomi','java','larbin','looksmart','mechanize','monitor','msnbot','nambu',
'nationaldirectory','novarra','pear','perl','python','rabaz','radian','rankivabot','scooter','slurp','sogou web spider','spade','sphere','spider','technoratisnoop',
'tecnoseek','teoma','toolbar','transcoder','twitt','url_spider_sql','webalta','webbug','webfindbot','wordpress','www.galaxy.com','yahoo','yandex','zyborg',);
$query  = sprintf("SELECT S.*, C.first_name, C.last_name FROM %1\$sCubeCart_sessions AS S LEFT JOIN %1\$sCubeCart_customer AS C ON S.customer_id = C.customer_id WHERE ".$filter."S.session_last>".$timeLimit." ORDER BY S.session_last DESC", $glob['dbprefix']);
if (($results = $GLOBALS['db']->query($query)) !== false) {

$GLOBALS['main']->addTabControl($lang['statistics']['title_customers_active'], 'stats_online', false, false, count($smarty_data['users_online']));
    $GLOBALS['smarty']->assign('USERS_ONLINE', $smarty_data['users_online']);
    $smarty_data['users_online'] = array();
   foreach ($results as $user) { $user_agentstring = $user['useragent'];
        $foundBots = array_filter($thisBotStringArray, function($str) use ($user_agentstring){ return (false !== strpos($user_agentstring,$str)); });
        if (!empty($foundBots) && !empty($filter)) continue;
        $user['is_admin']  = ((int)$user['admin_id'] > 0) ? 1 : 0;
//END BSMITHER IGNORE BOTS HACK 

 

Link to comment
Share on other sites

In the original, untouched file, notice the following code at the bottom:

        $smarty_data['users_online'][] = $user;
    }
    $GLOBALS['smarty']->assign('USERS_ONLINE', $smarty_data['users_online']);
}
$GLOBALS['smarty']->assign('GRAPH_DATA',$g_graph_data);
$page_content = $GLOBALS['smarty']->fetch('templates/statistics.index.php');
Just above where you see this in the untouched file:
    $GLOBALS['smarty']->assign('USERS_ONLINE', $smarty_data['users_online']);
 
is where:
$GLOBALS['main']->addTabControl($lang['statistics']['title_customers_active'], 'stats_online', false, false, count($smarty_data['users_online']));
gets added.
In your current file, as it stands:
$GLOBALS['main']->addTabControl($lang['statistics']['title_customers_active'], 'stats_online', false, false, count($smarty_data['users_online']));
    $GLOBALS['smarty']->assign('USERS_ONLINE', $smarty_data['users_online']);

is in the wrong place, so move the pair of lines down to where the 'assign' statement is supposed to be.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...