Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
UBBDev.com
UBBWiki.com
Who's Online
2 registered (Gizmo, SteveS), 38 Guests and 14 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 06/07/07
Posts: 4
Top Posters (30 Days)
Ruben 50
DennyP 24
Gizmo 23
Dunny 15
SteveS 13
AllenAyres 12
dbremer 10
SD 10
drkknght00 9
doug 8
Latest Photos
OK Corral Shoot Out
Testing
Basildon Train Station
Basildon Town Centre looking from the rounderbout
Basildon Town Square
Topic Options
#238741 - 08/19/10 12:51 PM Hit Counter in a custom island - how do I?
Shield Offline
stranger
Registered: 06/06/06
Posts: 2
I have a hit counter that's working just fine in my overall footer. Copying and pasting into a custom island I cannot get to work.

Can anyone help? Here's the code:

Php Code:

<?php
#####################################################################
# PHP Web Counter, version 1.0									  #
#																   #
# A simple and light web hits counter							   #
#																   #
# This is a Free Software under Gnu/GPL license					 #
#																   #
# C 2006-2007 - Andre Bertelli Araujo <bertelli.andre@gmail.com>	#
#			   Joao Eriberto Mota Filho <eriberto@eriberto.pro.br> #
#			   Marcos Patricio do Santos <marpasan@ig.com.br>	  #
#																   #
# URL: http://phpwebcounter.sourceforge.net						 #
#####################################################################


##############################
##############################
### Part 1 - Configuration ###
##############################
##############################

require("/home/sparky3/etc/phpwebcounter/phpwebcounter.config.php");

##########################
##########################
### Part 2 - The code! ###
##########################
##########################

function hits_webcounter($webcounter_id=0, $hits_file=null, $vis=null, $path_images=null, $counter_pad, $step) 
{
	if (is_null($hits_file))
		$hits_file = $path_hits_file;
	if (is_null($vis))
		$vis = $visible;

	$counter = read_webcounter($webcounter_id, $hits_file);
	increment_webcounter($webcounter_id, $counter, $step, $hits_file);
	
	if (!$vis) return;
	if (is_null($path_images)) {
		echo $counter;
	} else {
		show_webcounter($counter, $path_images, $counter_pad);
	}
}

function show_webcounter($counter, $path_images, $counter_pad=6)
{
	echo "<SPAN>";
		$counter = str_pad($counter, $counter_pad, '305611', STR_PAD_LEFT);
		for ($i=0; $i< strlen($counter) ; $i++) {
			$digit=$counter[$i];
			echo "<IMG src='$path_images/$digit.png' alt='$digit' />";
		}
	echo "</SPAN>";
}

function read_webcounter($webcounter_id, $hits_file=null)
{
	if (is_null($hits_file))
		$hits_file = $path_hits_file;

	$file="$hits_file/hits_webcounter.$webcounter_id";
	$fp = fopen($file, 'a+');
	$counter= fread($fp,1024);
	fclose($fp);
	return $counter;
}

function increment_webcounter($webcounter_id, $counter, $step=1, $hits_file=null)
{
	if (is_null($hits_file))
		$hits_file = $path_hits_file;

	$file="$hits_file/hits_webcounter.$webcounter_id";
	$fp = fopen($file, 'w');
	fwrite($fp,$counter+$step);
	fclose($fp);
}

########################
########################
### Part 3 - Running ###
########################
########################

hits_webcounter($webcounter_id,$path_hits_file,$visible,$path_images,$counter_pad, $step);

if ($banner == '1') { 
	echo '<br><a href="http://phpwebcounter.sourceforge.net"><font size=1px>PHP Web Counter</a></font size><br>';
	}
?>




Edited by Gizmo (08/19/10 02:03 PM)
Edit Reason: [code] tags
Top
Express Hosting
Express Hosting "We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
#238746 - 08/19/10 07:29 PM Re: Hit Counter in a custom island - how do I? [Re: Shield]
Rick Offline
Post-a-holic
Registered: 06/04/06
Posts: 10164
Loc: Aberdeen, WA
Off the top of my head, I think what you should do is put all of the functions into a single file. Then in the custom island you'd do something like:

Php Code:

require("/home/sparky3/etc/phpwebcounter/phpwebcounter.config.php");
require("/path/to/functions/file.php");

hits_webcounter($webcounter_id,$path_hits_file,$visible,$path_images,$counter_pad, $step);

if ($banner == '1') {
$body = <<<EOF
<br><a href="http://phpwebcounter.sourceforge.net"><font size=1px>PHP Web Counter</a></font size><br>
EOF;
}
 
Top
#238749 - 08/19/10 07:59 PM Re: Hit Counter in a custom island - how do I? [Re: Shield]
SD Offline
Registered: 04/19/07
Posts: 4056
Loc: SoCal, USA
hehe.. i'd do <br /> instead of <br> tho.. and maybe a little larger font size :yikes @ 1px:

damn, i'm a html syntax nazi laugh

/me hangs head in shame...
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
#238758 - 08/20/10 09:35 AM Re: Hit Counter in a custom island - how do I? [Re: SD]
Shield Offline
stranger
Registered: 06/06/06
Posts: 2
Well, I emailed the authors of the hit counter. They told me to do this, which worked perfectly!

<div style="text-align: center;">
<?php require("../../etc/phpwebcounter/phpwebcounter.php"); ?></div>
Top
#238759 - 08/20/10 10:17 AM Re: Hit Counter in a custom island - how do I? [Re: Shield]
Rick Offline
Post-a-holic
Registered: 06/04/06
Posts: 10164
Loc: Aberdeen, WA
Nice and simple wink
Top



Moderator:  AllenAyres, Harold, Ian, Ron M 
Shout Box

Today's Birthdays
No Birthdays
Recent Topics
Temporary Password email not being received
by
05/24/12 10:02 PM
Ability to "like" individual posts (not Facebook "likes)
by doug
05/23/12 09:03 AM
Island Permissions
by ThreadsUser
05/22/12 03:03 PM
streaming video
by prkrgrp
05/20/12 07:02 PM
New Posts Corrupted? Can someone help?
by PianoWorld
05/19/12 09:41 AM
Forum Stats
10492 Members
36 Forums
33842 Topics
181709 Posts

Max Online: 978 @ 06/24/07 11:19 PM
Random Image