Log in

View Full Version : Users online / total hits



Nether$
04-12-2006, 04:42 PM
Can anyone get me/ link me to a tut where i can get a javascript to display the number of users currently online and a javascript to show the total hits?

ty + rep

also i want a script that will be keped on my site not an scr to another site

ty!

Bistrol
04-12-2006, 07:30 PM
try www.zymic.com

nets
04-12-2006, 08:16 PM
JavaScript alone cannot do this, your host will need to support some type of server-side scripting. If you have support for a language such as PHP, I'll write you a script.

Florx
07-12-2006, 12:29 PM
JavaScript alone cannot do this, your host will need to support some type of server-side scripting. If you have support for a language such as PHP, I'll write you a script.

I do please write it :)

beer
07-12-2006, 12:41 PM
total hits: http://www.phpjunkyard.com/php-text-hit-counter.php :D

Bistrol
07-12-2006, 03:09 PM
Nooo use my idea ZYMIC ok! guys im moving back onto Panther NOW :o

Mentor
07-12-2006, 08:52 PM
if u want a flat file one, heres a V old one i wrote
<?php

################################################## ################
# Thybag Users Online Now and to day script #
################################################## ################
# � Copyright Thybag.co.uk 2004 - 2005 #
################################################## ################
# This Script is FREE to use as long as this header remains #
# In tact. And realy since no one is ever going to see it is #
# there any point in removing it? #
################################################## ################

// Configuration
$timeoutseconds = 6000; // length of time user is considered online in seconds
$daylength = 86400; // lengh of day in seconds
$filename = "online.txt" ; // the file in wich to store information, chmod it to 777


//-----------------------------------------------------------------------------------------
# Unless you know what your doing its not advisable to edit beond this point
//-----------------------------------------------------------------------------------------

// Main Variables
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
$aday = $timestamp-$daylength;
$ip = getenv("REMOTE_ADDR");

// Run The Array Loops
$hits = file($filename);
foreach($hits as $Key => $Val)
{
$hittedinfo[$Key] = explode("|", $Val); //explode that data into a new array:
}
//Loop all me info
for($K = 0; $K < sizeof($hits); $K++) {

//Put any ips that arnt over a day old in to a string so they remain in the database
if($hittedinfo[$K][0] > $aday )
{
$hitstring .= $hittedinfo[$K][0]."|".$hittedinfo[$K][1]."";
}

$usedip[$K] = trim($hittedinfo[$K][1]); //Make an array of Ips in database

//Make array of all online users
if($hittedinfo[$K][0] > $timeout)
{
$onlinenow[$K] = "1";
}


// end the loop
}


$toenter ="";

// Dont dubble up
$usedip = array_unique($usedip) ;

//if the ip has already been counted dont add it to the database
if(in_array(trim($ip), $usedip))
{$toenter = $timestamp."|".$ip."\n" ;} //if it aint, write er in
else // its there, is it to old or shall we still use
{$K2 = array_search($ip, $usedip);
if($hittedinfo[$K2][0] < $timeout)
{$toenter = $timestamp."|".$ip."\n" ;}


}

//Write all the data we want to keep back to the file
$fp = fopen($filename , "w+");
fputs($fp , $hitstring."".$toenter);
fclose($fp);

//Now where done, set the output varibles with the numbers the need
$hitztoday = sizeof($usedip);
$usersonline = sizeof($onlinenow);

/*-----------------------------------------------------------------------------------------
$hitztoday - now contains the amount of unque hits for today
$usersonline - now contains the amount of users online

Include this file in to where ever you wish the stats varibales to be useable, make sure
you only include once per page to prevent errors.

Create and chmod to 777 a txt file called online or whatever you renamed the $filename vaible
to use, put in same directory as page this is being included into, unless you ad folder info
to the url.

To make this information appear on the page simply use the echo function
EG:
echo "Users Online: ";
echo $usersonline;


If you require any more assitance with the script feel free to ask at
<a href='http://thybag.co.uk/forum/' target='_blank'>http://thybag.co.uk/forum/</a> or email me at [email protected]
-----------------------------------------------------------------------------------------*/


// Beta - auto output vairibles
//echo "Today:".$hitztoday."<br>Online:".$usersonline;
?>

Nether$
08-12-2006, 08:10 AM
JavaScript alone cannot do this, your host will need to support some type of server-side scripting. If you have support for a language such as PHP, I'll write you a script.

im talking about a serverside include jscript btw

Want to hide these adverts? Register an account for free!