Free web development scripts for the webmasterDevelopment Scripts


 social media marketing services
 Site Navigation
Clicky Web Analytics
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 1 user online
 o Most users online: 67
 o Home
  o PHP
   o Online Communities
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Paper Free Invoicing
 o Tutorials
 o Expired Domain Crawler

Users Online (Rated 0)

Description:

Shows the amount of users online at a time.

Written by CyberKill3r at Tutorial Forums

Code starts here


<?php
//vars
$file_name = "whois_online.dat.php";
$c_time = time();
$timeout = 300;
$time = $c_time - $timeout;
$ip = getenv("REMOTE_ADDR");

if(!
file_exists($file_name)){
$fp = fopen($file_name, "w");
fwrite($fp, "<?php die('Restricted File');?> \n");
fclose($fp);
}

//write to file
$fp = fopen($file_name, "a");
$write = $ip."||".$c_time."\n";
fwrite($fp, $write);
fclose($fp);

//open file to as array, to count online
$file_array = file($file_name);
$online_array = array();
for(
$x = 1; $x < count($file_array); $x++){
list(
$ip, $ip_time) = explode("||", $file_array[$x]);
if(
$ip_time >= $time){
array_push($online_array, $ip);
}
}
//end for

$online = array_unique($online_array);
$online = count($online);
if(
$online == "1"){
print
"User online: $online"."<br>";
}else{
print
"Users online: $online"."<br>";
}
?>

Last Edited: August 8, 2003, 5:35 pm


Submitted by Devscripts on 08-08-2003 17:35


Recent Additions (from all categories)

(PHP) T Shirt Printing Software

(PHP) Youtube Video Organizer Script

(PHP) MP3z - MP3 Search Engine Script

(PHP) Recipez- PHP Recipe Script

(ASP) Stop image hotlinking and downloading. Web image protection is easy with Image Trapper.

Top Rated Scripts

(Javascripts) Javascript Delayed Redirection Rating: 5

(PHP) Random Links and images with PHP & MySQL Rating: 5

(PHP) RSS/XML news feed headline grabber! Rating: 5

(PHP) Random Signatures/Avatars Rating: 5

(Javascripts) Detecting Client Web Browser Rating: 5

© Copyright 2003 - Devscripts.net  Web Analytics