<?
If ($inindex <> "true") {
?>
<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="0" width="98%" cellpadding="0" align="center" style="border: 1 solid #0000FF" 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='#FBC900' colspan='4'><p><b><span style='font-variant: small-caps'>Последние поступления</span></b></p></td>
<?
}
Else {
?>
          <td width="6%" bgcolor="#FBC900"><p align='center'>№</p></td>
          <td width="65%" bgcolor="#FBC900"><p>название товара</p></td>
          <td width="19%" bgcolor="#FBC900"><p>цена</p></td>
          <td width="10%" bgcolor="#FBC900"><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.phtml?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.phtml?tovid=$ar[$y]' class='cap2'><img border='0' src='/pic_buy.gif' width='16' height='16' 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.phtml?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>