| Server IP : 216.92.14.13 / Your IP : 216.73.216.171 Web Server : Apache System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 User : rmlac2fmr ( 1040637) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/www/cgi-bin/ |
Upload File : |
#!/usr/local/bin/perl
#######################################################################
# Multicount Version 1.02 #
# Copyright 1998 by Matt Riffle All Rights Reserved. #
# Initial Full Release: 7/4/98 This Release: 2/20/99 #
# Riffnet Scripts Archive http://scripts.riffnet.com/ #
#######################################################################
# 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, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. It is included in #
# this distribution in the file "license.txt". #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #
# 02111-1307, USA. #
#######################################################################
## Set the variables below accordingly ##
# This is the directory in which the script will keep its data files.
# It should be chmod 777 to ensure the server can write to it.
$data_dir = "/usr/www/.mcount";
# If your system can use "flock" to lock data files, set this to 1.
# Otherwise, set it to zero. If you are unsure, try 1 first, and if
# the script is failing try setting it to 0
$flocking = 1;
# This is the format in which the output will be result. Put
# OVERALL where you want the total count, DAILY where you want the
# daily count, and WEEKLY where the weekly count should go. If you
# don't want a certain count, just omit its keyword.
$format = "OVERALL visits (DAILY today, WEEKLY this week)";
# If this is set to 1, the last IP address to access the counter will be
# cached to prevent one person from repeatedly updating the counter. If
# it is set to 0, one person can increment the counter multiple times in
# succession.
$ip_caching = 0;
### Do not edit below this line ###
&init; # Insure file exists, create if not
&update; # Update File
sub init {
if ((!$ENV{'DOCUMENT_URI'}) && (!$ENV{'REQUEST_URI'})) { &error(": Web Server Missing Vital ENV Vars! :("); }
if (!$ENV{'DOCUMENT_URI'}) { $ENV{'DOCUMENT_URI'} = $ENV{'REQUEST_URI'}; }
$ENV{'DOCUMENT_URI'} =~ s/[^\w]/_/g;
$prename = $ENV{'SERVER_NAME'} . $ENV{'DOCUMENT_URI'};
if (length($prename) > 240) {
$name = substr($prename,0,240);
} else {
$name = $prename;
}
$name .= ".count";
my $file = "$data_dir/$name";
if (!-e $file) {
open (FILE,">$file") || &error("creating file");
if ($flocking) { flock(FILE,2) || &error("locking file"); }
$dstamp = &dstamp;
$wstamp = &wstamp;
print FILE "1:1:1:$dstamp:$wstamp:$ENV{'REMOTE_ADDR'}";
if ($flocking) { flock(FILE,8) || &error(": unlocking file"); }
close (FILE) || &error(": closing file");
&report("1","1","1");
}
}
sub update {
# Get Data
my $file = "$data_dir/$name";
open (FILE,"<$file") || &error("reading file");
if ($flocking) { flock(FILE,2) || &error("locking file"); }
my $line = <FILE>;
if ($flocking) { flock(FILE,8) || &error("unlocking file"); }
close (FILE);
# Process Data
my ($overall,$daily,$weekly,$fdstamp,$fwstamp,$ip) = split(/:/,$line);
$fdstamp =~ s/^1910/200/;
$fwstamp =~ s/^1910/200/;
my $dstamp = &dstamp;
my $wstamp = &wstamp;
if ($fdstamp < $dstamp) { $daily = 0; $fdstamp = $dstamp; }
if ($fwstamp < $wstamp) { $weekly = 0; $fwstamp = $wstamp; }
if ((!$ip_caching) || ($ENV{'REMOTE_ADDR'} ne $ip)) {
$overall++; $daily++; $weekly++;
}
# Write Data
open (FILE,">$file") || &error("writing file");
if ($flocking) { flock(FILE,2) || &error("locking file"); }
print FILE "$overall:$daily:$weekly:$fdstamp:$fwstamp:$ENV{'REMOTE_ADDR'}";
if ($flocking) { flock(FILE,8) || &error("unlocking file"); }
close (FILE) || &error("closing file");
&report($overall,$daily,$weekly);
}
sub report {
my ($overall,$daily,$weekly) = @_;
print "Content-type: text/html \n\n";
$format =~ s/OVERALL/$overall/ig;
$format =~ s/DAILY/$daily/ig;
$format =~ s/WEEKLY/$weekly/ig;
print $format;
exit;
}
sub error {
my $error = @_[0];
print "Content-type: text/html \n\n";
print "[Error $error]";
exit;
}
sub dstamp {
local($day,$mon,$year,$z1,$z2,$pre);
$z1 = $z2 = "";
(undef,undef,undef,$day,$mon,$year,undef,undef,undef) = localtime(time);
$mon++;
if ($mon < 10) { $z1 = "0"; }
if ($day < 10) { $z2 = "0"; }
$year += 1900;
my $stamp = "$year$z1$mon$z2$day";
return $stamp;
}
sub wstamp {
local($check,$jump,$day,$mon,$year,$z1,$z2,$pre);
(undef,undef,undef,undef,undef,undef,$check,undef,undef) = localtime(time);
$check = 7 - $check;
$jump = $check * 86400;
$z1 = $z2 = "";
(undef,undef,undef,$day,$mon,$year,undef,undef,undef) = localtime(time+$jump);
$mon++;
if ($mon < 10) { $z1 = "0"; }
if ($day < 10) { $z2 = "0"; }
$year += 1900;
my $stamp = "$year$z1$mon$z2$day";
return $stamp;
}