#!/usr/bin/perl #AUTHOR: Tekno Inform AS #Creation date: 28.02.03 $cmdstr=""; # Buffer for total htlm commands $fpath = $0; while (chop($fpath) ne '\\') {} $logdir ="./log/"; # Rel. position of log directory $totteller=0; # Global MAIN: { $savj=0;$savj0=0;$savj1=0;$savj2=0; # Global values require "$fpath/cgi-lib.pl"; &date(); print "Content-type: text/html\n\n"; print "Loglist at ".$date.", kl. ".$time.":
"; # Check IP ************************************************* my $myipfile=$logdir."ip-donot.log"; # IP's to not log if (open(FIL, "<$myipfile")) { $avoid_ip=; close(FIL); } $remote_host=$ENV{'REMOTE_HOST'}; # IP (Hostname of visitor) #my $temp=$avoid_ip; #$temp=~s/$remote_host//; # Remove his IP from string my $ip_check=0; if ($avoid_ip =~ /$remote_host/) {$ip_check=0;} # $remote_host is found in $avoid_ip else {$ip_check=1; } if ("$remote_host" ne "$avoid_ip") {$ip_check=1;} # Temp solution, till problem over solved else {$ip_check=0;} # End of ip check ******************************************* #print "IP not to log: ".$avoid_ip."
"; print "Your IP: $remote_host "; if ($ip_check == 0) {print "will not be logged

";} else { #print "will update file, will not be logged from now on...

"; #if (open(FIL, ">$myipfile")) { # print FIL $remote_host; # With newline # close(FIL); #} print "will be logged in the log file

"; } ; $cmdstr.=""; #$cmdstr.=""; # Alle #$cmdstr.=""; # Alle søk. #$cmdstr.=""; # Alle ex. infoteller #$cmdstr.=""; # Alle ex. infoteller #require "$fpath/c_bolig.info.log"; #$cmdstr.=""; $cmdstr.=""; &read_any("KurtNilsen.no:","KurtNilsen.no"); #$cmdstr.=""; $tot3=$totteller; # Save this value! # **************************************************** #require "$fpath/c_info.no.log"; $tot4=$totteller; # Save this value! $cmdstr=~s/xxxyyyxxx/$totteller/gi; # Substitute $cmdstr=~s/xxxyy3xxx/$tot3/gi; # Substitute $cmdstr=~s/xxxyy4xxx/$tot4/gi; # Substitute $infoteller=$totteller-$tot4; $cmdstr=~s/xxxyy5xxx/$infoteller/gi; # Subst. print $cmdstr; $cmdstr=""; $saveteller=$totteller; # Save totteller $j9=$totteller; $i=$totteller-$saveteller; $cmdstr.=""; $cmdstr.="
Totalt sider:xxxyyyxxx
Inn sider:xxxyy4xxx
Inn sider ex. info:xxxyy3xxx
Ut sider info:xxxyy5xxx
Bolig.info: ".&log_c_read("c_bolig.info.log")."
RessursSum1/3-14/5Hov.side(0)Plant(1)Ukens(2)
KurtNilsen.no: ".&log_c_read("c_kurtnilsen.no.log")."
TOTALT ALLE:".$j9."
"; $cmdstr=~s/xxyy33xx/$i/gi; # Substitute, insert %-vis. print $cmdstr; exit; } # Read calc data sub read_calc { $t = shift; # Text to read $n = shift; # Number to read $j=&log_c_read("c_calc.no_".$n.".log"); # Old $j1=&log_c_read("c_calc.no_".$n."_1.log"); # Mode 1 $j2=&log_c_read("c_calc.no_".$n."_2.log"); # Mode 2 $j0=&log_c_read("c_calc.no_".$n."_0.log"); # Mode 0 $jx=$j+$j0+$j1+$j2; $cmdstr.="$t ($n):$jx$j$j1$j2$j0"; $savj+=$j;$savj0+=$j0;$savj1+=$j1;$savj2+=$j2; # Save coloumns sum } # Read calc data sub read_any { $t = shift; # Text to print $f = shift; # File name $j=&log_c_read("c_".$f.".log"); # Old 1st.page $j0=&log_c_read("c_".$f."_0.log"); # New 1st page $j1=&log_c_read("c_".$f."_1.log"); # New 2nd page $j2=&log_c_read("c_".$f."_2.log"); # New 2nd page $jx=$j+$j0+$j1+$j2; $cmdstr.="$t:$jx$j$j0$j1$j2"; } sub date { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time+$addsecs); @months = ("01","02","03","04","05","06","07","08","09","10","11","12"); @days = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); if ($sec < 10) {$sec = "0$sec";} if ($min < 10) {$min = "0$min";} if ($hour < 10) {$hour = "0$hour";} if ($hour > 11) {$ap = "PM";} if ($hour < 12) {$ap = "AM";} if ($mday < 10) {$mday = "0$mday";} $year+=1900; #$date = "@days[$wday] @months[$mon]/$mday/$year"; #$time = "$hour:$min:$sec $ap"; $date = "$year-@months[$mon]-$mday @days[$wday] "; $time = "$hour:$min:$sec"; return; } ############################## sub log_c_read{ ############################## my $string=""; my $teller=0; # my $resource=$_[0]; #Ressursnr. my $filnavn=shift; #Ressursnr. $filnavn=$logdir.''.$filnavn; if (open(FIL, "<$filnavn")) { $string=; close(FIL); } if ($string ne "") {$teller=$string;} else {$teller=0;}; $totteller+=$teller; # Global Increment return $teller; } ############################## sub log_r_read{ # Rating ############################## my $string=""; # my $resource=$_[0]; #Ressursnr. my $filnavn=shift; #Ressursnr. $filnavn=$logdir.''.$filnavn; if (open(FIL, "<$filnavn")) { $avg=; # Rating $antall=; # Antall $string = $avg." (".$antall." stemmer)"; close(FIL); } return $string; }