#!/usr/bin/perl
#############################################################
##            ExchangeVisits    Version  3.00              ##
##            February 2003  Ust-Nera  Russia              ##
##            All rights  ScriptZaWM&RuScript              ##
##            Web  http://www.script.zawm.biz              ##
##            Support scripts script@zawm.biz              ##
#############################################################
require "config.pl";
if($ENV{'REQUEST_METHOD'} eq 'GET'){$query=$ENV{'QUERY_STRING'}}
elsif($ENV{'REQUEST_METHOD'} eq 'POST'){sysread(STDIN,$query,$ENV{'CONTENT_LENGTH'})}
@formfields=split(/&/,$query);
sub urldecode{local($val)=@_;
$val=~s/\+/ /g;
$val=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
return $val;
}
foreach (@formfields){chomp($_);
($f_n,$f_v)=split(/=/,$_);
$f_n=&urldecode($f_n);
$f_v=&urldecode($f_v);
$in{$f_n}=$f_v;
}
@month = ("01", "02", "03", "04", "05", "06", "07","08", "09", "10", "11", "12");
($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear, $DayOfWeek,
$DayOfYear, $IsDST) = localtime(time);
$Year = $ShortYear + 1900;$Year=~s/^..//;
$Date = "$DayInMonth.$month[$Month].$Year<time>$Hours:$Minutes:$Seconds";
$today = "$DayInMonth.$month[$Month].$Year";
print "Content-Type: text/html; charset=windows-1251\n\n";
open(STAT,"./system/sysstat.pl");
if ($flock eq "1")
{flock(STAT, 2);}
@stat=<STAT>;
close(STAT);chomp(@stat);
($d6,$kol6) = split(/\|/,$stat[6]);
if($d6 eq $today){$stat[6] = $kol6}else{$stat[6] = '0'}
($d7,$kol7) = split(/\|/,$stat[7]);
if($d7 eq $today){$stat[7] = $kol7}else{$stat[7] = '0'}
($d8,$kol8) = split(/\|/,$stat[8]);
if($d8 eq $today){$stat[8] = $kol8}else{$stat[8] = '0'}
($d9,$kol9) = split(/\|/,$stat[9]);
if($d9 eq $today){$stat[9] = $kol9}else{$stat[9] = '0'}
($d10,$kol10) = split(/\|/,$stat[10]);
if($d10 eq $today){$stat[10] = $kol10}else{$stat[10] = '0'}
($d12,$kol12) = split(/\|/,$stat[12]);
if($d12 eq $today){$stat[12] = $kol12}else{$stat[12] = '0'}
$allusers=0;$newtoday=0;$active=0;$blocked=0;$jobtoday=0;$online=0;
if ($stat[0] eq ''){$stat[0] = "0";}
if ($stat[4] eq ''){$stat[4] = "0";}
if ($stat[5] eq ''){$stat[5] = "0";}
if ($stat[11] eq ''){$stat[11] = "0";}
if ($stat[12] eq ''){$stat[12] = "0";}
if ($kol12 eq ''){$kol12 = "0";}
open(PWD,"userdat.pl");
if ($flock eq "1")
{flock(PWD, 2);}
@users = <PWD>;
close(PWD);chomp(@users);
foreach (@users){
($login,$pwd,$id,$status,$dr,$dc)=split(/\|/,$_);
if($status eq 'B'){$blocked++}
($dmy,$hms) = split(/<time>/,$dr);
if($today eq $dmy){$newtoday++}}
open(TSTAT,"./system/today.stat");
if ($flock eq "1")
{flock(TSTAT, 2);}
@tstat = <TSTAT>;
close(TSTAT);chomp(@tstat);
foreach (@tstat){
($login,$id,$dcc)=split(/\|/,$_);
($dmyc,$hmsc) = split(/<time>/,$dcc);
if($dmyc eq $today){$jobtoday++}
($hc,$hm,$hs) = split(/:/,$hmsc);
$lastcome = $hc*60*60 + $hm*60 + $hs;
$now = $Hours*60*60 + $Minutes*60 + $Seconds;
if(($now - $lastcome) <= 900 && $dmyc eq $today){$online++}}
$allusers = $#users;$allusers++;
open(URLID,"./urls/urlid.txt");
if ($flock eq "1")
{flock(URLID, 2);}
$urlid = <URLID>;
close(URLID);
$sites=$urlid;
print qq~
<table border=0 cellpadding="0" cellspacing="0" width="140">
<tr>
<td width="93"><font face="Arial" size="1">
&nbsp;Пользователей<br>
&nbsp;Сегодня новых<br>
&nbsp;Сегодня работало<br>
&nbsp;Сейчас работают<br>
&nbsp;Сайтов в системе<br>
&nbsp;Показано сайтов<br>
&nbsp;Сегодня показано<br>
</font> </td><td align="right" width=""> <font color="#008080" face="Arial" size="1">
$allusers&nbsp;<br>
$newtoday&nbsp;<br>
$jobtoday&nbsp;<br>
$online&nbsp;<br>
$sites&nbsp;<br>
$stat[11]&nbsp;<br>
$kol12&nbsp;<br>
</font></td>
</tr>
</table>
~;
