Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-05-2008, 10:16 AM
New Pligger
 
Join Date: May 2008
Posts: 25
Thanks: 0
Thanked 2 Times in 1 Post
Online users in footer.tpl

A few people asked for a users online script/mod. This is how i did it for a friend. Btw it doesn't matter if you use pligg 1.1 or 9.9 it always works.

1. Make a sql base/table.

CREATE TABLE `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;

2. Make a directory in 3rdparty call it onlineusers, put in this directory the online.php script. Name the script below online.php and put it in onlineusers.

<?php
$dbhosta = "localhost";
$dbusera = "xxxxxxxxxxxxxxxxxxx"; // MySQL username
$dbpassa = "xxxxxxxxxxxxxxxxxxx"; // MySQL password
$dbnamea = "xxxxxxxxxxxxxxxxxxx"; // database name

@mysql_connect($dbhosta,$dbusera,$dbpassa);
@mysql_select_db($dbnamea) or die("Huh dude no dbase!");

$timeoutseconds = 120; //2 minutes = 120 seconds

$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
$ip = substr($_SERVER['REMOTE_ADDR'], 0, strrpos($_SERVER['REMOTE_ADDR'],"."));

$loopcap = 0;
while($loopcap<3 && @mysql_query("INSERT INTO useronline VALUES('". $timestamp ."','". $ip ."','". $_SERVER['PHP_SELF'] ."')"))
{ // In geval van error
$timestamp = $timestamp+$ip{0}; $loopcap++;
}

@mysql_query("DELETE FROM useronline WHERE timestamp<". $timeout);

$result = @mysql_query("SELECT DISTINCT ip FROM useronline");
$user = @mysql_num_rows($result);

mysql_free_result($result);

echo ($user == 1) ? $user ."" : $user ."";
?>

3. Edit online.php and give the right dbase info see xxxxxxxx

4. Open footer.tpl and put this line in it, you must edit it with your own path:
{php}include('/home/domainname/domains/domainname.com/public_html/3rdparty/onlineusers/online.php');{/php}

The reason why i use the footer so you get no conflict with sql Pligg. Hope you can use it. Bye!
Reply With Quote
The Following 2 Users Say Thank You to snok For This Useful Post:
  #2 (permalink)  
Old 06-05-2008, 10:42 AM
Casual Pligger
 
Join Date: Sep 2007
Posts: 47
Thanks: 3
Thanked 0 Times in 0 Posts
will try it, i was looking for this.
Reply With Quote
  #3 (permalink)  
Old 07-10-2008, 09:32 AM
New Pligger
 
Join Date: May 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
is good this module but i need to show the user name what is online, not the number..anybody?
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
How to know number of online users ?? mickscool General Help 2 08-08-2008 10:06 AM
No users on YGET Manage Users page JAPUNDIT Bug Report 2 08-02-2008 01:09 AM
View Online Users imzeeshan Modification Tutorials 0 11-08-2007 06:24 PM
How to sort top users by category in 'Top Users' page aaronpais General Help 0 05-16-2007 08:55 AM


Search Engine Friendly URLs by vBSEO 3.2.0