#!/usr/bin/perl
##########################################################################################################
# Easycount is a simple to setup and stable perl text counter that does NOT require Server Side Includes.#
# To run this script, simply copy and paste the JavaScript code below into your html file where you #
# want the counter to appearance. #
# #
# #
# #
# Setup easycount.pl #
# 1 - Set correct path to your perl in the first line of this script. #
# 2 - Define variables and save settings. #
# 3 - Copy easycount.pl to your cgi-bin directory, (make sure you do this in ASCII and chmod 755) #
# 4 - Done #
##########################################################################################################
# You may modify, use and distribute this software under the following conditions: #
# Redistributions of this software include this message and the copyright notice below. #
# #
# Copyright (c)2003 by Hans Versteeg, hansverst@easycount.nl #
# Homepage: http://www.easycount.nl #
# #
# Current version: v1.5, Last modify at Tuesday 20 May 2003 #
##########################################################################################################
###############################################################
# Define variables #
###############################################################
# Use domain check, 1 = yes / 0 = no (if no, anyone could run your script),
$domain_check='0';
# Set your domains and/or ip for domain check,
@domains=("http://www.easycount.nl", "80.60.203.85");
# Reproduce counter in the center of your website, 1 = yes / 0 - no
$center='0';
# Reproduce comments, 1 = yes / 0 = no, (reproduce counts only)
$comments='0';
# Set link to us, 1 = yes / 0 = no
$link='0';
# Set link page, (url to easycount homepage)
$url="http://www.easycount.nl";
###############################################################
# Comments before and after count. #
###############################################################
# Write your comment before the count,
$comment="This page has been accessed";
# Write your comment after the count,
$_comment="times.";
###############################################################
# Text style and colors. #
###############################################################
# Font face,
$font_face="Verdana";
# Font color,
$font_color="black";
# Font size,
$font_size='1';
# Bold, 1 = yes / 0 = no
$bold='0';
# Italic, 1 = yes / 0 = no
$italic='0';
# Counter color,
$counter_color="black";
###############################################################
# Background, border and colors. #
###############################################################
# Reproduce a background color, 1 = yes / 0 = no
$background_color='0';
# Background color,
$bgcolor="#008080";
# Reproduce a border around the counter, yes = 1-4 / 0 = no border
# To change border size, set value between 1 and 4
$border='0';
# Border color,
$border_color="#429195";
# Border style, 1 = dotted / 2 = dashed / 3 = solid / 4 = double / 5 = groove / 6 = ridge / 7 = inset / 8 = outset
$border_style='5';
###############################################################
# Done, do not change ANYTHING below. #
###############################################################
print "Content-Type: application/x-javascript\n\n";
# Check domain,
if ($domain_check ==1){
$true=0;
$RF=$ENV{'HTTP_REFERER'};
$RF=~tr/A-Z/a-z/;
foreach $ts (@domains) {if ($RF =~ /$ts/) {$true=1; }
}
if ( $true ==0) {
print "document.write(\'http://www.easycount.nl\');\n";
exit;
}
}
# open count.num,
open(COUNT, "count.num");
$counts = ;
close(COUNT);
$counts++;
# write new count,
open(COUNT,">count.num");
flock(COUNT, 2);
print COUNT "$counts";
flock(COUNT, 8);
close(COUNT);
# let's find out what style must be printed,
if ($border !=0){
if ($border ==1){$s="1.9pt";}
if ($border ==2){$s="2.7pt";}
if ($border ==3){$s="3.4pt";}
if ($border ==4){$s="4.2pt";}
if ($border >4){$s="4.2pt";}
if ($border_style ==1){$border_style="dotted";}
elsif ($border_style ==2){$border_style="dashed";}
elsif ($border_style ==3){$border_style="solid";}
elsif ($border_style ==4){$border_style="double";}
elsif ($border_style ==5){$border_style="groove";}
elsif ($border_style ==6){$border_style="ridge";}
elsif ($border_style ==7){$border_style="inset";}
elsif ($border_style ==8){$border_style="outset";}
$border="style=\"border: $s $border_style $border_color;\"";
} else {$border="";}
if ($background_color !=0){
$bgcolor="bgcolor=\"$bgcolor\"";}
else {$bgcolor="";}
if ($center !=0){
$center="
"; $_center="
";}
else {$center="";}
if ($bold !=0){
$bold=""; $_bold="";}
else {$bold=""; $_bold="";}
if ($italic !=0){
$italic=""; $_italic="";}
else {$italic=""; $_italic="";}
if ($link !=0){
$link=""; $_link="";}
else {$link=""; $_link="";}
if ($comments !=0){
$comment =~ s/'/\\'/g; $_comment =~ s/'/\\'/g; } else {print "document.write(\'$center