#!/usr/bin/perl # using excessive system resources exit(); ###################################################################################### # WebO Trak System v3.01 # # # # Copyright RL Savage 1999, 2000, 2001 All Rights Reserved # # # ###################################################################################### # WEBhits # ###################################################################################### # **** COPYRIGHT NOTICE **** # # - do not remove - # # This application is part of the copyrighted WebO Trak System and # # is protected intelectual property of RL Savage and Webolium Network Services(TM), # # as outlined in US and International copyright laws. Our copyright is for the inte- # # grated system of scripts, code, graphic interface and operating procedures that # # makes up this system as a whole. It violates US & International to duplicate, copy # # sell or distribute this, or accompanying scripts, code, interface or operating # # procedures without our consent. Additionally, it is a violation of this copyright # # to alter or delete any portion of the accompanying scripts, code, interface or # # operating procedure, without written permission. This header must remain intact. # # Webolium Network Services(TM) will vigorously defend our legal rights concerning # # any violation of this copyright notice. # # The copyright does not extend to the exclusive protection or claim of ownership # # of any snippet of code or sub script within this application. Portions of code and # # many of the principals upon which this application has been developed with are # # readily available from bulliten boards, developer forums, public domain and other # # mediums promoting Open Source Software. Without which, this application, would not # # have been able to be developed and written in it's present form. # ###################################################################################### # If you are interested in writing and developing scripts for your own or company # # use, please research those sources to assist you in your efforts. This script uses # # code by Matt Wright, please visit his site at http://worldwidemart.com, and Solena # # http://www.extropia.com. Additional resources for code and scripting can be found # # at javascripts.com and cgi-resource.com. # ###################################################################################### # ---------------------------------------------------------------------------# # HTML Log Version 1.0 # # Copyright 1996 Matt Wright mattw@worldwidemart.com # # Created 10/25/95 Last Modified 10/26/95 # # Scripts Archive at: http://www.worldwidemart.com/scripts/ # # The file STAT_README contains more information. For Use With Counter 1.1.1 # # ---------------------------------------------------------------------------# # COPYRIGHT NOTICE # # Copyright 1996 Matthew M. Wright All Rights Reserved. # # # # HTML Log may be used and modified free of charge by anyone so long as # # this copyright notice and the comments above remain intact. By using this # # code you agree to indemnify Matthew M. Wright from any liability that # # might arise from it's use. # # # # Selling the code for this program without prior written consent is # # expressly forbidden. In other words, please ask first before you try and # # make money off of my program. # # # # Obtain permission before redistributing this software over the Internet or # # in any other medium. In all cases copyright and header must remain intact.# # ---------------------------------------------------------------------------# require "/WWW/tat2.net/cgi-bin/setup/WEBcount.setup"; require "$cgi_lib_location"; &parse_form_data(*from_browser); $style = $from_browser{'style'}; $pageref = $from_browser{'ref'}; $digits = $from_browser{'digits'}; $width = $from_browser{'w'}; $height = $from_browser{'h'}; $transparency = $from_browser{'t'}; $interlaced = $from_browser{'i'}; $frame_width = $from_browser{'fw'}; $frame_color = $from_browser{'fc'}; $invisible = $from_browser{'inv'}; $logo = $from_browser{'logo'}; $uselog = $from_browser{'log'}; if (!$from_browser{'style'}) {$style = "mred";} # default style else {$style = $from_browser{'style'};} # is 'mred' if (!$from_browser{'ref'}) {$pageref = "test";} # default ref else {$pageref = $from_browser{'ref'};} # is 'test' if (!$from_browser{'digits'}) {$digits = "6";} # default number else {$digits = $from_browser{'digits'};} # of digits = 5 if (!$from_browser{'w'}) {$width = "21";} # default width else {$width = $from_browser{'w'};} # = 21 pixels if (!$from_browser{'h'}) {$height = "24";} # default height else {$height = $from_browser{'h'};} # = 24 pixels if (!$from_browser{'t'}) {$transparency = "yes";} else {$transparency = $from_browser{'t'};} # default is 'yes' if (!$from_browser{'i'}) {$interlaced = "no";} else {$interlaced = $from_browser{'i'};} # default is 'no' if (!$from_browser{'fw'}) {$frame_width = "0";} else {$frame_width = $from_browser{'fw'};} # default is '0' if (!$from_browser{'fc'}) {$frame_color = "0,0,0";} else {$frame_color = $from_browser{'fc'};} # default is '0,0,0' if (!$from_browser{'inv'}) {$invisible = "no";} else {$invisible = $from_browser{'inv'};} # default is 'no' if (!$from_browser{'logo'}) {$logo = "X";} else {$logo = $from_browser{'logo'};} # default is 'X' if (!$from_browser{'log'}) {$uselog = "yes";} else {$uselog = $from_browser{'log'};} # default is 'yes' $lock = 2; $unlock = 8; if ($uselog eq "yes") { &get_date; } &check_referer; &update_counter; &secret_counter; $num = $length = length($count[$count_found]); while ($num > 0) { $CHAR{$num} = chop($count[$count_found]); $num--; } $img_width = (($width * $length) + ($frame_width * 2)); $img_height = (($frame_width * 2) + $height); open(FLY,">$fly_temp") || die "Can't Open In File For flock (FLY, $lock); FLY Commands: $!\n"; print FLY "new\n"; print FLY "size $img_width,$img_height\n"; &make_frame; $j = 1; while ($j <= $length) { print FLY "copy $insert_width,$insert_height,-1,-1,-1,-1,$digit_dir/$style/$CHAR{$j}$style\.gif\n"; $insert_width = ($insert_width + $width); $j++; } if ($transparency eq "yes" && $transparency =~ /.*,.*,.*/) { print FLY "transparent $transparency\n"; } if ($interlaced ne "no") { print FLY "interlace\n"; } flock (FLY, $unlock); close(FLY); &print_the_output; # ----------------------------------------------------------------------- sub check_referer { if (@referers && $ENV{'HTTP_REFERER'}) { foreach $referer (@referers) { if ($ENV{'HTTP_REFERER'} =~ /$referer/) { $ref = 1; last; } } } else { $ref = 1; } if ($ref != 1) { print "Location: $bad_referer_img\n\n"; if ($uselog == 1) { open(LOG,">>$error_log") || die "Can't Open User Error Log: flock (LOG, $lock); $!\n"; print LOG "$error_log: $ENV{'REMOTE_HOST'} [$date] $ENV{'HTTP_REFERER'} - $ENV{'HTTP_USER_AGENT'}\n"; flock (LOG, $unlock); close(LOG); } exit; } } # ----------------------------------------------------------------------- sub secret_counter { if ($invisible eq "yes") { open(FLY,">$fly_temp") || die "Can't Open In File For flock (FLY, $lock); FLY Commands: $!\n"; print FLY "new\n"; print FLY "size 1,1\n"; print FLY "fill 0,0,0,0,0\n"; print FLY "transparent 0,0,0\n"; flock (FLY, $unlock); close(FLY); &print_the_output; } elsif ($logo ne "X" && $logo =~ /.*tp:\/\//) { print "Location: $logo\n\n"; # --- log the hit if ($uselog eq "yes") { &log_access; } exit(0); } } # ----------------------------------------------------------------------- sub make_frame { $insert_width = $insert_height = $frame_width; $insert_frame = 0; while ($insert_frame < $frame_width) { $current_width = ($img_width - $insert_frame); $current_height = ($img_height - $insert_frame); print FLY "line 0,$insert_frame,$img_width,$insert_frame, $frame_color\n"; print FLY "line $insert_frame,0,$insert_frame,$img_height, $frame_color\n"; print FLY "line $current_width,0,$current_width,$img_height,$frame_color\n"; print FLY "line $current_height,0,$current_height,$img_width, $frame_color\n"; $insert_frame++; } } # ----------------------------------------------------------------------- sub log_access { open(LOG,">>$access_log") || die "Can't Open User Access Log: $!\n"; flock (LOG, $lock); print LOG "[$date_counter] $ENV{'HTTP_REFERER'} - $ENV{'REMOTE_HOST'} - $ENV{'HTTP_USER_AGENT'}\n"; flock (LOG, $unlock); close(LOG); } # ----------------------------------------------------------------------- sub update_counter { if (open (FILE, "<" . $count_file)) { flock (FILE, $lock); for ($loop=0; $loop < 3; $loop++) { $line[$loop] = ; $line[$loop] =~ s/\n$//; } @page = split("::", $line[0]); @count =split("::", $line[1]); flock (FILE, $unlock); close (FILE); for ($loop = 0; $loop <= $#page; $loop++) { if ($page[$loop] eq $pageref) { $count_found = $loop; last; } } if ($page[$loop]) { $count[$count_found]++; } if ($page[$loop] ne $pageref) { push(@page,$pageref); push(@count,0); } if ($reset_number != "") { $count[$count_found] = $reset_number; } if ($digits != "") { if ($page[$loop]) { $count[$count_found] = sprintf ("%0".$digits."d", $count[$count_found]); } else { $count[$count_found] = sprintf ("%06d", $count[$count_found]); } } if (open (FILE, ">" . $count_file)) { flock (FILE, $lock); print FILE join("::", @page), "\n"; print FILE join("::", @count), "\n"; flock (FILE, $unlock); close (FILE); } else { &return_error (500, "Counter File Error", "Cannot write to the Counter File $count_file."); } } else { &return_error (500, "Counter File Error", "Cannot read from the Counter File $count_file."); } } # ----------------------------------------------------------------------- sub print_the_output { print "Content-type: image/gif\n\n"; open(RUNFLY,"$flyprog -i $fly_temp |"); while() { print; } close(RUNFLY); unlink($fly_temp); if ($uselog eq "yes") { &log_access; } exit(0); } # -----------------------------------------------------------------------