#!/usr/bin/perl

# Counter directory
$cntdir="../counters/";
@fnames=('ozon','bolero','24x7','colibri','biblion','boomerang','total');
%snames=('ozon','Озон','bolero','Болеро','24x7','24x7','colibri','Колибри','biblion','Библион','boomerang','Бумеранг','total','Всего запросов');

$msg1= <<"(HEAD_BLOCK)";
<html>
<div align="center"><center><table border="0" width="170" cellspacing="0" cellpadding="0" bgcolor="#C0C0C0"><tr>
<td>
<table border="0" width="100%" cellspacing="1" cellpadding="2"><tr>
<td bgcolor="#f0f0f0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">

(HEAD_BLOCK)

   print("Pragma: no-cache\r\n");
   print("Cache: no-cache\r\n");
   print("Content-type: text/html; charset=windows-1251\n\n");

   print "$msg1";
   $totalj=0;

   foreach $fn (@fnames) {
     if ($fn eq 'total') { next;};
     $ffile=$cntdir.$fn;
     open (lfile1,$ffile);
      $curr=<lfile1>;
     close (lfile1);
     if(($curr < 10) && ($curr >0 )) {$curr='00'.$curr;};
     if(($curr < 100) && ($curr >9 )) {$curr='0'.$curr;};
     $cnt{$fn}=$curr;
     $totalj=$totalj+$curr;
   };
#   $totalj=$totalj-$curr;
   @t1=values %cnt;
   @t1=reverse sort @t1;
#print "<!-- $t1[0] -->\n";
#   foreach $tt (@t1) {
#print "<!-- $tt -->\n";
#   };
   $onep=100/$totalj;
   $ones=100/$t1[0];
   
   foreach $fn (@fnames) {
     $cw=int($ones* $cnt{$fn});
     $cp=int($onep* $cnt{$fn});
     if($fn eq 'total') { next;};
     print <<"(ONE_ROW)";
<tr>
<td width="70" align="left"><small>$snames{$fn}</small></td>
<td width="100" align="left"><img src="images/cl$fn.gif" width="$cw" height="14" alt="$cp%"></td>
</tr>

(ONE_ROW)

   };

$msg2= <<"(FOOT_BLOCK)";

</table>

</td>
</tr>
</table>

</td>
</tr>
</table>
</center>
</div>
</html>

(FOOT_BLOCK)

  print "$msg2\n";

