[advanced search]
Results from the most recent live auction are here.
27 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 08-28-2007, 01:34 PM   · #1
selfpleasured
Account Closed
 
selfpleasured's Avatar
 
Name: Appraisals-Script installs-Domains
Location: Florida
Trader Rating: (2)
Join Date: Jun 2007
Posts: 250
NP$: 0.95 (Donate)
selfpleasured is on a distinguished road
Thumbs up Find out how many Visitors Are online

very Simple make a page name it whos-online.php, insert this into the page nothing else

PHP Code:
<?php

/*You need php but no database for this as it uses a text file.
You can add a title, numbers of extra visitors, the refresh time and the text file.
Put this in your root dir. The text file is automatically created for you so you need to load 1 file.
Make sure the text file does not already exist.
You can include this in a page by using <?php include("what_you_named_it .php");?> for html or include("what_you_named_it.php"); for php
*/

/*This is the text you want to explain the number.
Something like;- Visitors on this page or leave blank if the text is going into your document
you need quotes " " and the semicolon ; even if this is empty */
$explain = " ";

/* Add online numbers. You can set this to 0 for actual numbers
but rather than visitors feeling lonely you can put a number in to show that nember plus the actuals
so if you put in 4 and have 2 actually on line the counter will show 6 */
$additions = 0;

/*This is the refresh time in minutes. For example if you use 5 your numbers
refresh every 5 minutes. The lower the number, the more accurate
it is not advisable to make this lower than 1 */
$timer = 10;

/* Name of the file where all the data will be saved.
Name this something creative but it must be a text file so xxx.txt.
make sure this name is not already in the directory. The script creates this file */
$filename = "howmanylog1.txt";

//Do not edit under this line

if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$space = " ";
$ip = $REMOTE_ADDR;
$string = "$ip|$time\n";
$a = fopen("$filename", "a+");
fputs($a, $string);
fclose($a);

$timeout = time()-(60*$timer);

$all = "";
$i = 0;
$datei = file($filename);
for (
$num = 0; $num < count($datei); $num++) {
$pieces = explode("|",$datei[$num]);

if (
$pieces[1] > $timeout) {
$all .= $pieces[0];
$all .= ",";
}
$i++;
}

$all = substr($all,0,strlen($all)-1);
$arraypieces = explode(",",$all);
$useronline = count(array_flip(array_flip($arraypieces)));

// display how many people where activ within $timeout
echo $explain;
echo
$space;
echo
$useronline+$additions;


// Delete
$dell = "";
for (
$numm = 0; $numm < count($datei); $numm++) {
$tiles = explode("|",$datei[$numm]);
if (
$tiles[1] > $timeout) {
$dell .= "$tiles[0]|$tiles[1]";
}
}

if (!
$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = $REMOTE_ADDR;
$string = "$dell";
$a = fopen("$filename", "w+");
fputs($a, $string);
fclose($a);
?>


upload to your server at the root add this to your webpage


PHP Code:
<?php
include ("whos-online.php");
?>


this will show you the amount of people online at that time, if you have subdomains off the root and you want to add it to them do so like this:

PHP Code:
<?php
include ("http://www.yourwebsite.com/whos-online.php");
?>


Have fun! if its helpful please say so in my rep Thanks

Added Syntax Highlighting (PHP BBCode) - Hitch


Please register or log-in into NamePros to hide ads

Last edited by Hitch : 08-29-2007 at 08:13 AM.
selfpleasured is offline   Reply With Quote
Old 08-29-2007, 08:01 AM   · #2
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 681.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
Could you put in [ PHP] [/PHP] tags please... (no space obviously) Makes me much easier to read.

Thanks!

P.S. Include a step saying the file it's writes to must be CHMOD'd so it is writable please .

Edit:
PHP Code:
include ("http://www.yourwebsite.com/whos-online.php");

at the bottom, would be better if it was
PHP Code:
include ("/home/absolute/path/to/the/directory/whos-online.php");


Edit: Please post where you got it from: http://forum.statcounter.com/vb/sho...524&postcount=5

Last edited by Danltn : 08-29-2007 at 08:16 AM.
Daniel is offline   Reply With Quote
Old 08-29-2007, 08:42 AM   · #3
selfpleasured
Account Closed
 
selfpleasured's Avatar
 
Name: Appraisals-Script installs-Domains
Location: Florida
Trader Rating: (2)
Join Date: Jun 2007
Posts: 250
NP$: 0.95 (Donate)
selfpleasured is on a distinguished road
I didnt get it from there. i didnt make it but its not from there a friend gave it to me
selfpleasured is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


Site Sponsors
Proof is in the Parking http://www.internetinvestments.com/ http://www.dnfinder.com
Advertise your business at NamePros
All times are GMT -7. The time now is 02:01 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0