#!/usr/local/bin/perl # (Path to PERL, CHANGE THIS IF YOU NEED TO) ################################# # Nether-Log Personal Version 1.0 Beta # # Nethernet Inc (http://www.nethernet.com) ############################### # # Copyright © 1998 Ben Congleton / Nethernet. (http://www.nethernet.com) # # This script can be destributed for free as long as the header remains the same.. # and the user-site provides a link to Nethernet.com. # # if you use Nether-Log We would appreciate it if you mailed # root@nethernet.com so we can point to you on our examples page # ################################################################## # # How to Install: # # 1) Put the nether-log.pl in it's own directory under your CGI-BIN # # 2) Chmod the directory it is into 777 ("CHMOD 777") # # 3) chmod the executeable to "755" # # 4) You did it, now just goto nether-log.pl?docs # for information on using the program for your # statistics. # # Variables: #----------------- #Password $password="pryputniewicz"; # Image file to show $imagefile='http://www.wpi.edu/~chslt/fill.gif'; # Amount of Referers/Days to show $showtotal=60; # Only allow local addresses to use stats? $serveronly=1; # Sort the Referrer's by number of referrals? (1=yes 0=no) $sort_ref=1; ################################ &readparse; if($FORM{'password'} eq "$password"){ print "Set-Cookie: admin=1; expires=Wednesday, 09-Nov-99 23:12:40 GMT;\n"; } $auth=1 if ($ENV{HTTP_COOKIE} =~ /admin=1/ig); ############## # Log Files @files=('hits.txt','refer.txt','hitinfo.txt',"hours.txt","otherdays.txt"); ################################################ @array=split(/\./,$ENV{'SERVER_NAME'}); unless($ENV{'HTTP_REFERER'} =~ /$array[1]/ig || $ENV{'HTTP_REFERER'} eq "" ||!$serveronly ) { exit; } #$ENV{QUERY_STRING} = "checkit"; # time-out for LOCK routine $kill=5; $page=$FORM{page}; $pass2=$FORM{'password'}; $ss=$ENV{'HTTP_REFERER'}; $page=$ENV{'HTTP_REFERER'} if ($ENV{'HTTP_REFERER'}); $page =~ s/(\/|\:)/-/g; if($ENV{QUERY_STRING} !~ /(checkit|docs|reset|resset)/i) { print "Location: $imagefile\n\n"; &logit; } elsif($ENV{QUERY_STRING} =~ /docs/ig) { &docs; } elsif($ENV{QUERY_STRING} =~ /reset/ig && $auth) { &reset; } else { if($ENV{QUERY_STRING} =~ /resset/ig && $auth) { &resset; } print < Nether-Log by Nethernet
HIT open(DATA,"$page\_$files[1]"); @refer=; close(DATA); print <

Nether-Log
Your Own Statistics

Documentation | Reset | Upgrade to Professional

URL: $ss HEADER &get_info; } sub logit { # from jscript #&bn=MSIE&bv=400&ss=1024*768&sc=16&dt=13&sv=12&ja=y&rf=bookmark&ln=&pl= $browser=$FORM{bn}; $browserversion=$FORM{bv}; $screensize=$FORM{ss}; $screencolor=$FORM{sc}; $hour=$FORM{dt}; $scriptversion=$FORM{sv}; $java=$FORM{ja}; $refer=$FORM{rf}; $language=$FORM{ln}; $page=$FORM{dl}; $page =~ s/(\/|\:)/-/g; #from ENV $ip_ad=$ENV{'REMOTE_ADDR'}; $remote_host=$ENV{'REMOTE_HOST'}; #$page=$ENV{'HTTP_REFERER'}=~ s/(\/|:)/_/g; $time=localtime(time); ########################## # Time to save some info open(DATA,"$page\_ips.txt"); @count=; close(DATA); if("@count" =~ /$ip_ad/ig){ exit;} &lock("$page\_date.log",1); @time=localtime(time); $time[4]++; $timr="$time[4]\_$time[3]"; #print "$timr"; open(DD,"$page\_date.log"); $timee=
; close(DD); $timee=0 if(!$timee); if("$timr" ne "$timee") { $newday=1; open(DD,">$page\_date.log"); print DD "$timr"; close(DD); } &lock("$page\_date.log",0); &lock("$page\_ips.txt",1); open(DATA,">>$page\_ips.txt") ||open(DATA,">$page\_ips.txt"); open(DATA,">$page\_ips.txt") if($newday); print DATA "$ip_ad\n"; close(DATA); &lock("$page\_ips.txt",0); &lock("$page\_$files[0]",1); open(DATA,"$page\_$files[0]"); $count=; close(DATA); if (!$newday) { open(DATA,">$page\_$files[0]"); print DATA ++$count; close(DATA); } else { open(DATA,">$page\_$files[0]"); print DATA "1"; close(DATA); open(DATA,">>$page\_$files[4]"); print DATA "$timr;;$count\n"; close(DATA); } &lock("$page\_$files[0]",0); &lock("$page\_$files[1]",1); open(DATA,"$page\_$files[1]"); @refer=; close(DATA); open(DATA,">$page\_$files[1]"); chomp(@refer); foreach $ref (@refer) { ($ref,$value)=split(/;;/,$ref,2); $REFER{$ref}=$value; } $REFER{$refer}++; foreach $ref (keys %REFER) { print DATA "$ref;;$REFER{$ref}\n" if ($REFER{$ref}); } close(DATA); &lock("$page\_$files[1]",0); &lock("$page\_$files[2]",1); open(DATA,">>$page\_$files[2]") || open(DATA,">$page\_$files[2]"); print DATA "$browser;;$browserversion;;$screensize;;$screencolor;;$scriptversion;;$java;;$language;;$ip_ad;;$remote_host;;$time\n"; close(DATA); &lock("$page\_$files[2]",0); &lock("$page\_$files[3]",1); open(DATA,"$page\_$files[3]"); @hour=; close(DATA); open(DATA,">$page\_$files[3]"); chomp(@hour); foreach $ref (@hour) { ($ref,$value)=split(/;;/,$ref,2); $HOUR{$ref}=$value; } $HOUR{$hour}++; foreach $key (sort keys %HOUR) { print DATA "$key;;$HOUR{$key}\n" if($key && $HOUR{$key}); } close(DATA); &lock("$page\_$files[3]",0); } #-------------------------------------------------------------- sub get_info { open(DATA,"$page\_$files[0]"); $count=; close(DATA); print <Total Hits Today: $count
Internet Site Referers:
REF @refer=reverse sort it @refer if($sort_ref); @refer=sort @refer if(!$sort_ref); foreach $ref (@refer) { ($ref,$value)=split(/;;/,$ref,2); print < TAb } print <

$value

$ref
Hits Per Hour:
HITS open(DATA,"$page\_$files[3]"); @hour=; close(DATA); $yy=0; foreach $hour (sort sh @hour) { ($ref,$value)=split(/;;/,$hour,2); $l=$value; $l=$value/400 if ($value > 400); print < BOB } sub sh { ($aa,$ss)=split(/;;/,$a,2); ($bb,$ss)=split(/;;/,$b,2); return $aa <=> $bb; } print <

$ref

$value hits --------------
Hits in the Last 30 Days:
DAL open(DATA,"$page\_$files[4]"); @hour=; close(DATA); $total=0; foreach $ref (sort @hour) { ($reff,$value)=split(/;;/,$ref); $reff =~ s/_/\//gi; $total+=$value; $l=$value; $l=$value/400 if ($value > 400); print < BOB } $total+=$count; print <

Total Hits: $total TT open(DATA,"$page\_$files[2]"); @data=; close(DATA); chomp(@data); foreach $line (@data) { ($browser,$browserversion,$screensize,$screencolor,$scriptversion,$java,$language,$ip_ad,$remote_host,$time)=split(/;;/g,$line); $SCREEN{$screensize}++; $BROWSER{"$browser;;$browserversion"}++; $SCREENS{$screensize}++; $SCRIPTV{$scriptversion}++; $JAVA{$java}++; $lang{$language}++; push(@visits,"$ip_ad;;$remote_host;;$time"); #print "
$browser;;$browserversion;;$screensize;;$screencolor;;$scriptversion;;$java;;$language;;$ip_ad;;$remote_host;;$time\n"; } %SCREEN=&average(%SCREEN); %BROWSER=&average(%BROWSER); %SCREENS=&average(%SCREENS); %SCRIPTV=&average(%SCRIPTV); %JAVA=&average(%JAVA); %lang=&average(%lang); #screen colors print <

$reff

$value hits --------------
Browser Version:
BLO foreach $key (keys %BROWSER) { ($browser,$ver)=split(/;;/g,$key); $ver = $ver * .01; print < BRO } print <

$BROWSER{$key}%

$browser $ver --------------
Screen Size
SS foreach $key (keys %SCREENS) { print < BOB } print <

$SCREENS{$key}%

$key --------------
JavaScript Version:
BL foreach $key (keys %SCRIPTV) { $key1 = $key *.1 if ($key >10); print < BL } print <

$SCRIPTV{$key}%

JavaScript $key1 --------------
Users Surfing with JAVA on:
JV #screen colors print "

Have Java?"; foreach $key (keys %JAVA) { print <

BL } #screen colors print <

$JAVA{$key}%

JAVA = $key --------------
Languages:
JJ foreach $key (keys %lang) { print < BL } print <

$lang{$key}%

$key --------------
Last 30 Visitors:
JJ $con=0; foreach $visit (reverse @visits) { @arr=split(/;;/,$visit); if ($con < $showtotal) { print < LL } $con++; } print <

*

$arr[2] - $arr[1] - $arr[0]

Powered by Nethernet, this and many more free scripts as well as custom CGI coding at Nethernet.com  

BOB } sub average { my(%items); %items=@_; foreach $key (keys %items) { $items{$key}=$items{$key} /$total; $items{$key}=int($items{$key}*100); } return %items; } #-=============================--------------------=-=-=-=-= sub docs { $page=$FORM{page}; print < Nether-Log by Nethernet

Nether-Log
Your Own Statistics

Documentation | Reset | Upgrade to Professional

Documentation

The Nether-log system is relatively easy to use, and can be used on multiple sites, servers, pages, and more with out any additional configuration. It was built as a way to provide the stats for every page in a site, in an easy to use method.

SETUP:
This script requires very little setup, but there are few basic requirements in order for it to work. As well as some more advanced options for power users.
The First step is to CHMOD 777 the directory where Nether-Log is stored. We recommend that you place it in a seperate directory away from the rest of your files if possible.
Now just add the below code to the page you want to check the stats for and you are on your way.
CODE:



POWER USERS:
Do you want more power? Do you want to take the plunge and edit the CGI yourself?
there are a few variables that power users should mess with they are
+ \$password - (Lets you reset your hits by going to http://$ENV{'HTTP_HOST'}$ENV{SCRIPT_NAME}?checkit&password=YOUR_PASSWORD
+ \$imagefile - (defines which image to show as the stat image)
+ \$showtotal - (Defines the number of referers and last visits to display on the page
+ \$serveronly - (Only let's local addresses use the stats program) (1 is yes 0 is no) (yes by default)
+ \$sort_ref - (Sorts the referrer by number of referrals) (1 is yes 0 is no) (yes by default)

Well That's it I hope you enjoy Nether-Log please Mail me and I will add you to our users list.

Powered by Nethernet, this and many more free scripts as well as custom CGI coding at Nethernet.com  

BOB } sub reset { $page=$FORM{page}; print < Nether-Log by Nethernet - Reset

Nether-Log
Your Own Statistics

Documentation | Reset | Upgrade to Professional

Warning You are just about to Reset your counter
All infomation stored in it will be lost, and it will start over from scratch. If this is a mistake press Back Now

If not click here.

Powered by Nethernet, this and many more free scripts as well as custom CGI coding at Nethernet.com  

BOB } sub resset { foreach $file (@files) { unlink("$page\_$file"); } unlink("$page\_date.log"); unlink("$page\_ips.log"); } #-------------------------------------------------------------- sub lock { my($file,$type,$count); $count=0; ($file,$type)=@_; if($type && -e "$file.lock") { while(-e "$file.lock" && $count < $kill){ sleep(1); $count++; } &lock($file,$type); } elsif($type && !(-e "$file.lock")) { open(LOCK,">$file.lock"); print LOCK "locked"; close(LOCK); } elsif(!$type) { unlink("$file.lock"); } } sub it { $aa=$a; $bb=$b; ($w,$bb)=split(/;;/,$bb); ($w,$aa)=split(/;;/,$aa); return ($aa <=> $bb); } #******** END BODY************************ sub readparse { read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'}); if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}}; $user_string =~ s/\+/ /g; @name_value_pairs = split(/&/,$user_string); foreach $name_value_pair (@name_value_pairs) { ($keyword,$value) = split(/=/,$name_value_pair); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; $FORM{$keyword} = $value; } }