<?

If ($inindex <> "true") {

?>

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

  <tr>

    <td width="100%" bgcolor="#98bac3"><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="#98bac3" cellspacing="1">

  <tr>

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

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

        <tr>

<?

If ($inindex == "true") {

?>

<td width='100%' bgcolor='#98bac3' colspan='4'><p><b><span style='font-variant: small-caps'>Последние поступления</span></b></p></td>

<?

}

Else {

?>

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

          <td width="65%" bgcolor="#98bac3"><p>название товара</p></td>

          <td width="19%" bgcolor="#98bac3"><p>цена</p></td>

          <td width="10%" bgcolor="#98bac3"><p>дата&nbsp;добавления</p></td>

<?

}

?>

        </tr>

<?

$ar2 = array();

$ar = array();

$posi = 0;

$flg = "";



$d = dir("goods/");

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

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

  $ar2[] = $flg;

 }

}

$d->close();



for ($i = count($ar2)-1; $i >= 0; $i--) {

 $ar[] = $ar2[$i];

}





//rsort($ar);



$to = 20;

If ($inindex == "true") {

 $to = 10;

}

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

 $to = count($ar);

}





for ($y = 0; $y < $to; $y++) {

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



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

  $clr = "#EAEDFF";

 }

 Else {

  $clr = "#F9FBFF";

 }



 $posi = $y+1;

 If ($inindex == "true") {

  echo "

	<tr>

          <td width='80%' bgcolor='$clr'><p><a href='/buy.php?tovid=" . $ar[$y] . "' class='cap2'>" . trim($ff[3]) . "</a></p></td>

          <td width='10%' bgcolor='$clr'><p>" . trim($ff[1]) . " wm</p></td>

          <td width='10%' bgcolor='$clr'><p align='right'><a href='/buy.php?tovid=$ar[$y]' class='cap2'><img border='0' src='img/pic_buy.gif' alt='Купить!'></a></td>

	</tr>";

 }

 Else {

  echo "

	<tr>

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

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

          <td width='19%' bgcolor='$clr'><p>" . trim($ff[1]) . "</p></td>

          <td width='10%' bgcolor='$clr'><p>" . date("d.m.Y H:i", filectime("goods/" . $ar[$y])) . "</p></td>

	</tr>";

 }

}

?>

</table>

    </td>

  </tr>

</table>