<table border="0" width="100%" cellspacing="0" cellpadding="0">

  <tr>

    <td width="100%" bgcolor="#F0F0F0"><p><b>&gt;&gt; TOP-20 Лидеров продаж</b></p></td>

  </tr>

</table>

<p>&nbsp;</p>



<table border="1" width="98%" cellpadding="0" align="center" style="border-collapse: collapse" bordercolor="#9ace8b" cellspacing="1">

  <tr>

    <td width="100%" valign="top">

      <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#F1FFED" style="border-collapse: collapse" bgcolor="#F1FFED">

        <tr>

          <td width="6%" bgcolor="#9ACE8B"><p align='center'>№</p></td>

          <td width="65%" bgcolor="#9ACE8B"><p>организация продавца</p></td>

          <td width="19%" bgcolor="#9ACE8B"><p>логин</p></td>

          <td width="10%" bgcolor="#9ACE8B"><p>количество&nbsp;продаж</p></td>

        </tr>

<?

$d2 = dir("users/");

while($flg = $d2->read()) {

 If ($flg <> "." and $flg <> ".." and $flg <> ".htaccess") {



  $prod = 0;

  $d = dir("goods/");

  while($tme = $d->read()) {

   If ($tme <> "." and $tme <> ".." and $tme <> ".htaccess") {

    $fr = @file("goods/$tme");

    If (trim($fr[0]) == $flg) {

     $prod = $prod + (integer) trim($fr[15]);

    }

   }

  }

  $d->close();



  If ($prod > 0) {

   $ar[] = array(0 => $prod, 1 => $flg);

  }



 }

}

$d2->close();





rsort($ar);



$to = 20;

if ($to > count($ar)) {

 $to = count($ar);

}

for ($y = 0; $y < count($ar); $y++) {

 $ff = @file("users/" . $ar[$y][1]);



 If ($clr == "#F9FBFF") { 

  $clr = "#EAEDFF";

 }

 Else {

  $clr = "#F9FBFF";

 }



 $posi = $y+1;

 If ($posi == 1) {

  $posi = "<img border='0' src='img/pic_place_first.gif' width='16' height='16'>";

 }

 ElseIf ($posi == 2) {

  $posi = "<img border='0' src='img/pic_place_second.gif' width='16' height='16'>";

 }

 ElseIf ($posi == 3) {

  $posi = "<img border='0' src='img/pic_place_third.gif' width='16' height='16'>";

 }



 echo "

	<tr>

          <td width='6%' bgcolor='$clr'><p align='center'>$posi</p></td>

          <td width='65%' bgcolor='$clr'><p><a href='/seller.php?name=" . $ar[$y][1] . "' class='cap2'>" . trim($ff[1]) . "</a></p></td>

          <td width='19%' bgcolor='$clr'><p>" . $ar[$y][1] . "</p></td>

          <td width='10%' bgcolor='$clr'><p>" . $ar[$y][0] . "</p></td>

	</tr>";

}

?>

</table>

    </td>

  </tr>

</table>