home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet 1996 World Exposition
/
park.org.s3.amazonaws.com.7z
/
park.org.s3.amazonaws.com
/
Guests
/
Beethoven
/
CGI
/
counter.cgi
< prev
next >
Wrap
Text File
|
2017-09-21
|
4KB
|
319 lines
#!/usr/local/bin/perl
#Counter CGI script.
#For Multimedia Beethoven WebSite.
#(C) Copyright by Alex Bronshtein, 1996.
$change = 1000;
$param = 0;
$reslt = 0;
sub floor {
if (($param >= 0) && ($param <= 1)) { $reslt = 0; }
if (($param >= 1) && ($param <= 2)) { $reslt = 1; }
if (($param >= 2) && ($param <= 3)) { $reslt = 2; }
if (($param >= 3) && ($param <= 4)) { $reslt = 3; }
if (($param >= 4) && ($param <= 5)) { $reslt = 4; }
if (($param >= 5) && ($param <= 6)) { $reslt = 5; }
if (($param >= 6) && ($param <= 7)) { $reslt = 6; }
if (($param >= 7) && ($param <= 8)) { $reslt = 7; }
if (($param >= 8) && ($param <= 9)) { $reslt = 8; }
if (($param >= 9) && ($param < 10)) { $reslt = 9; }
}
if (($ARGV [0] > 0) && ($ARGV [0] <= 10)) {
$change = $ARGV [0];
}
else {
if (($ARGV [1] > 0) && ($ARGV [1] <= 10)) {
$change = $ARGV [1];
}
else {
if (($ARGV [2] > 0) && ($ARGV [2] <= 10)) {
$change = $ARGV [2];
}
else {
if (($ARGV [3] > 0) && ($ARGV [3] <= 10)) {
$change = $ARGV [3];
}
else {
if (($ARGV [4] > 0) && ($ARGV [4] <= 10)) {
$change = $ARGV [4];
}
else {
$change = 1000;
}
}
}
}
}
open (COUNT, "counter");
$counter = <COUNT>;
if ($change eq 1) {
++$counter;
open (COUNT, ">counter"); # open "countf" for 'output'
print COUNT "$counter\n";
close (COUNT); # close file
}
@dig [10];
$dig [1] = 0;
$dig [2] = 0;
$dig [3] = 0;
$dig [4] = 0;
$dig [5] = 0;
$size = 0;
if (($counter >= 0) && (counter < 10)) {
$dig [1] = $counter;
$size = 1;
}
if (($counter >= 10) && (counter < 100)) {
$param = $counter / 10;
&floor;
$dig [1] = $reslt;
$dig [2] = $counter % 10;
$size = 2;
}
if (($counter >= 100) && (counter < 1000)) {
$param = $counter / 100;
&floor;
$dig [1] = $reslt;
$param = ($counter % 100) / 10;
&floor;
$dig [2] = $reslt;
$dig [3] = (($counter % 100) % 10);
$size = 3;
}
if (($counter >= 1000) && (counter < 10000)) {
$param = $counter / 1000;
&floor;
$dig [1] = $reslt;
$param = ($counter % 1000) / 100;
&floor;
$dig [2] = $reslt;
$param = (($counter % 1000) % 100) / 10;
&floor;
$dig [3] = $reslt;
$dig [4] = (($counter % 1000) % 100) % 10;
$size = 4;
}
if (($counter >= 10000) && (counter < 100000)) {
$param = $counter / 10000;
&floor;
$dig [1] = $reslt;
$param = ($counter % 10000) / 1000;
&floor;
$dig [2] = $reslt;
$param = (($counter % 10000) % 1000) / 100;
&floor;
$dig [3] = $reslt;
$param = ((($counter % 10000) % 1000) % 100) / 10;
&floor;
$dig [4] = $reslt;
$dig [5] = ((($counter % 10000) % 1000) % 100) % 10;
$size = 5;
}
if ($change eq 1) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (time);
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
if ($mon < 10) { $monc = "0$mon"; }
$date = "$hour\:$min\:$sec $mon/$mday/$year";
open (LOG,">>countlog");
print LOG "[$date] Referrer: ";
print LOG $ENV{'HTTP_REFERER'};
print LOG " User ";
print LOG $ENV {'REMOTE_USER'};
print LOG " from ";
print LOG $ENV{'REMOTE_HOST'};
print LOG " (";
print LOG $ENV {'REMOTE_ADDR'};
print LOG ") HTTP Agent ";
print LOG $ENV{'HTTP_USER_AGENT'};
print LOG " -- Counter: ";
print LOG $counter;
print LOG "\n";
close (LOG);
}
#print "Content-Type: image/gif\n\n";
if (($change ne 1000) && ($change<=$size)) {
print "Location: ";
print "/Guests/Beethoven/CGI/";
print $dig [$change];
print ".gif\n\n";
}
else {
print "/Guests/Beethoven/CGI/empty.gif";
}