/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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!
URL: http://forums.pligg.com/pligg-mods/13629-online-users-footer-tpl.html