Site Stats

Discussion in 'General Discussion' started by commander, Jun 12, 2005.

  1. commander

    commander Well-Known Member

    Posts:
    101
    Likes Received:
    0
    Joined:
    Dec 4, 2004
    I need a script for my site where it shows

    Total Unique Hits:
    Total Hits:
    Todays Total Hits:
    Todays Unique Hits;
    Users Online:

    I looked ever where but I can't find one that has those things all together. I got one that has everything except for users online. If you want the script its in the bottom. Can you please edit it so it has Users Online in it.

    Code:
    <style type="text/css">
    <!--
    .style1 {color: #FFFFFF}
    -->
    </style>
    <body>
    <font face="Verdana" size="1">
    <?php
    // Our log file;
    $counter = "includes/stats/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));
    
    ?>
    <? echo "
    [b]Page hits: [/b] " . $total_hits . "
    
    
    [b]Unique hits: [/b] " . $total_hosts_size . "
    
    
    [b]Todays Page hits: [/b] " . $daily_hits_size . "
    
    
    [b]Todays unique hits: [/b]" . $daily_hosts_size; 
    ?>
    
     
  2. Fate

    Fate Well-Known Member

    Age:
    32
    Posts:
    5,655
    Likes Received:
    0
    Joined:
    Dec 29, 2004
    Location:
    Manchester, UK
    Ive gave you this on codedfx already :)
     
  3. yourmomas

    yourmomas New Member

    Posts:
    1
    Likes Received:
    0
    Joined:
    Jun 12, 2005
    I'll try to find it
     

Share This Page