{VTS_USERS_ONLINE} Updated!!

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
JensZ
Posts: 136
Joined: Wed 16. Feb 2005, 12:18
Location: Stockholm, Sweden
Contact:

{VTS_USERS_ONLINE} Updated!!

Post 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
Last edited by JensZ on Tue 13. Sep 2005, 14:52, edited 1 time in total.
JensZ
Posts: 136
Joined: Wed 16. Feb 2005, 12:18
Location: Stockholm, Sweden
Contact:

Post 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]}
my_rockfish
Posts: 3
Joined: Sat 24. May 2008, 07:42

Re: {VTS_USERS_ONLINE} Updated!!

Post 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)
User avatar
bogus
Posts: 75
Joined: Tue 18. Jan 2005, 17:36

Re: {VTS_USERS_ONLINE} Updated!!

Post by bogus »

hi ;)

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

and how work that ?
Greetings

Bogus
Post Reply