Page 1 of 1

{VTS_USERS_ONLINE} Updated!!

Posted: Thu 9. Jun 2005, 13:01
by JensZ
Hi,

This script requires VTS to be installed. The replacement tag uses the VTS database tables to get the number of users currently online. There are probably other ways to do this, but this is the way I'm doing it...

Put the following code in frontend_render:

Code: Select all

<?php
// AUTHOR: Jens Zetterström
// USAGE: {VTS_USERS_ONLINE}

// Define how long the maximum amount of time (in minutes) the session can be inactive.
define("MAX_IDLE_TIME", 3);

// get users online by looking at vts database tables
function vts_GetUsersOnline()
{
	$count = 0;
		
	$sql = sprintf(
							"SELECT COUNT(DISTINCT(accesslog.accesslog_id)) AS num_visitors_online
							FROM 	%s accesslog,
									%s visitors
							WHERE visitors.client_id    = '%d'
							AND visitors.accesslog_id = accesslog.accesslog_id
							AND accesslog.timestamp   >= '%d'",
							DB_PREPEND . "pot_accesslog",
							DB_PREPEND . "pot_visitors",
							1,
							time() - (MAX_IDLE_TIME * 60)
						);
		  
	$result = mysql_query($sql, $GLOBALS["db"]);
				
	if(mysql_num_rows($result) > 0)
	{
		$row = mysql_fetch_assoc($result);
		$count = intval($row['num_visitors_online']);
	}
	
	if($count == 0)
	{
		$count = 1;
	}

	return $count;
}

// {VTS_USERS_ONLINE}
// most article sorted by popularity
if( ! ( strpos($content["all"],'{VTS_USERS_ONLINE}')===false ) ) 
{
   $content["all"] = preg_replace('/\{VTS_USERS_ONLINE\}/e','vts_GetUsersOnline();', $content["all"]);
}
?>
Cheers,

Jens

Posted: Tue 13. Sep 2005, 14:49
by JensZ
Hi,

For all you people that use VTS (visitor tracking system/phpOpenTracker), I have updated the set of replacement tags that use VTS. Now it can be used to show the number of people that have visited your website (specified by range "today", "current_month", etc), the number of visitors currently online, and the number of times a specific page has been viewed (also by range). These rep tags can, for example, be put in article templates.

The code is installed simply by putting the php file in frontend_render, however, it requires VTS (see different post). Download the file from here:

http://www.ikfrej.se/index.php?downloads

Rep tags included:
{VTS_USERS_ONLINE}
{VTS_UNIQUE_USERS}
{VTS_VISITS_TODAY}
{VTS_VISITS_TOTAL}
{VTS_GET:api_call:range}
{VTS_DOCUMENT[:range]}

Re: {VTS_USERS_ONLINE} Updated!!

Posted: Thu 31. Jul 2008, 12:10
by my_rockfish
Hi JensZ,

I'm using phpwcms 1.8.2, and i've been download vts_users_online.zip, but the script need :

require_once ('./include/inc_ext/phpOpenTracker/phpOpenTracker.php');

where i can get phpOpenTracker.php ? and how to install it ?

and what RT that i can use for user online in our website (like http://www.phpwcms-docu.de - Thursday, 31. July 2008|7 User online)

Re: {VTS_USERS_ONLINE} Updated!!

Posted: Fri 8. Aug 2008, 16:58
by bogus
hi ;)

you can get it here http://pear.phpopentracker.de/get/

and how work that ?