[advanced search]
11 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 05-09-2006, 01:33 PM   · #1
asgsoft
NamePros Regular
 
asgsoft's Avatar
 
Location: At Home
Trader Rating: (36)
Join Date: Sep 2005
Posts: 805
NP$: 981.10 (Donate)
asgsoft is just really niceasgsoft is just really niceasgsoft is just really niceasgsoft is just really niceasgsoft is just really nice
A stats script for my site.

I use this script for showing stats on my site, although some of it doesn't worl. The only section that doesn't work is showing todays unique viewers.

Here is what I use:

PHP Code:
<?php
// Our log file;
$counter = "stats.txt";

// Date logging;
$today = getdate();
$month = $today[month];
$mday = $today[mday];
$year = $today[year];
$current_date = $mday . $month . $year;


// Log visit;
$fp = fopen($counter, "a");
$line = $REMOTE_ADDR . "|" . $mday . $month . $year . "\n";
$size = strlen($line);
fputs($fp, $line, $size);
fclose($fp);

// Read log file into array;
$contents = file($counter);

// Total hits;
$total_hits = sizeof($contents);

// Total hosts;
$total_hosts = array();
for (
$i=0;$i<sizeof($contents);$i++) {
    
$entry = explode("|", $contents[$i]);
    
array_push($total_hosts, $entry[0]);
}
$total_hosts_size = sizeof(array_unique($total_hosts));

// Daily hits;
$daily_hits = array();
for (
$i=0;$i<sizeof($contents);$i++) {
    
$entry = explode("|", $contents[$i]);
    if (
$current_date == chop($entry[1])) {
        
array_push($daily_hits, $entry[0]);
    }
}
$daily_hits_size = sizeof($daily_hits);

// Daily hosts;
$daily_hosts = array();
for (
$i=0;$i<sizeof($contents);$i++) {
    
$entry = explode("|", $contents[$i]);
    if (
$current_date == chop($entry[1])) {
        
array_push($daily_hosts, $entry[0]);
    }
}
$daily_hosts_size = sizeof(array_unique($daily_hosts));

?>
<?php
echo"<tr>
                      <td width='75%'>Todays Unique:</td>
                      <td width='25%' bgcolor='#F4F4F4'>$daily_hosts_size</td>
                    </tr>
                    <tr>
                      <td>Todays Views:</td>
                      <td bgcolor='#F4F4F4'>$daily_hits_size</td>

                    </tr>
                    <tr>
                      <td>Total Unique:</td>
                      <td bgcolor='#F4F4F4'>$total_hosts_size</td>
                    </tr>"
;
?>


It all works except todays unique.


Please register or log-in into NamePros to hide ads
asgsoft 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
http://www.mobisitetrader.com/ http://www.mobisitetrader.com/ Custom Logo Design
Advertise your business at NamePros
All times are GMT -7. The time now is 11:52 PM.


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