<?

$ft = @file("tx/time.txt");

$ff1 = fopen("tx/time.txt", "w");

for ($i = 0; $i < count($ft); $i++) {

 $ar = explode("^", trim($ft[$i]));

 If ((integer) $ar[2] >= (integer) date("z") and (integer) $ar[3] >= (integer) date("Y")) {

  fwrite($ff1, trim($ft[$i]) . "\n");

 }

}

fclose($ff1);

$ft = @file("tx/time.txt");





If ($lst == "") {

 $lst = "1";

}





If ($inindex <> "true") {

 ?>

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

  <tr>

    <td width="100%" bgcolor="#9ace8b"><p><b>&gt;&gt; Рекомендуемые товары на <? echo date("d.m.Y") ?></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="0" width="100%" cellspacing="0" cellpadding="0">

        <tr>

<?

If ($inindex == "true") {

 $serv_const_lstcount = "10";

 echo "<td width='100%' bgcolor='#9ace8b' colspan='5'><p><b><span style='font-variant: small-caps'>Рекомендуемые товары</span></b></p></td>";

}

Else {

?>

           <td width="48%" bgcolor="#9ACE8B"><p>название</p></td>

           <td width="10%" bgcolor="#9ACE8B"><p>цена</p></td>

           <td width="10%" bgcolor="#9ACE8B"><p>добавлено</p></td>

           <td width="22%" bgcolor="#9ACE8B"><p>продавец</p></td>

           <td width="10%" bgcolor="#9ACE8B"></td>

        </tr>

<?

}



for ($t = 0; $t < count($ft); $t++) {

 $ar = explode("^", trim($ft[$t]));

 If ($ar[0] == "reccomend" and $ar[2] == date("z") and $ar[3] == date("Y")) {

  //$allgoods[] = $ar[4];

  $srtar[] = array(0 => $ar[1], 1 => $ar[4]);

 }

}





If (count($srtar) > 0) {

 rsort($srtar);

}



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

 $allgoods[$y] = $srtar[$y][1];

}







$lfrom = (integer) $lst * $serv_const_lstcount - $serv_const_lstcount;

$lto = (integer) $lst * $serv_const_lstcount;

If ($lto > count($allgoods)) {

 $lto = count($allgoods);

}





If (count($allgoods) <= 0) {

 echo "<tr><td><p>Рекомендуемых товаров не найдено.</p></td></tr>";

}





for ($r = $lfrom; $r < $lto; $r++) {



   price_min($allgoods[$r]);

   $fgoods = @file("goods/" . $allgoods[$r]);



   $edatear = explode(".", trim($fgoods[4]));

   $edate = "$edatear[0].$edatear[1].$edatear[2]";

   $fusr = @file("users/" . trim($fgoods[0]));

   $usrname = trim($fgoods[0]);



   $eusr = trim($fusr[1]);



   $ename = trim($fgoods[3]);



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

    $clr = "#EAEDFF";

   }

   Else {

    $clr = "#F9FBFF";

   }



   If (trim($fgoods[16]) <> "" and trim($fgoods[16]) <> "0") {

    $esumm = "<font style='text-decoration: line-through'>" . trim($fgoods[16]) . "</font>&nbsp;<font color='#FF0000'>" . trim($fgoods[1]) . "</font>";

   }

   Else {

    $esumm = trim($fgoods[1]);

   }





   If ($inindex <> true) {

    echo "

	<tr>

	<td width='48%' bgcolor='$clr'><p><a href='/buy.php?tovid=$allgoods[$r]' class='cap2'>$ename</a></p></td>

	<td width='10%' bgcolor='$clr'><p>$esumm</p></td>

	<td width='10%' bgcolor='$clr'><p>$edate</p></td>

	<td width='22%' bgcolor='$clr'><p><a href='/seller.php?name=$usrname' class='cap0'>$eusr</a></p></td>

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

	</tr>";

   }

   Else {

    echo "

	<tr>

	<td width='80%' bgcolor='$clr'><p><a href='/buy.php?tovid=$allgoods[$r]' class='cap2'>$ename</a></p></td>

	<td width='10%' bgcolor='$clr'><p>$esumm&nbsp;wm</p></td>

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

	</tr>";

   }

}

?>

      </table>

    </td>

  </tr>

<?

If ($inindex <> true) {

 echo "</table>";

}



If ($inindex <> true) {

 ?>

 <p>&nbsp;&nbsp;<b>Всего найдено: <? echo count($allgoods) ?></b></p>

 <?

}



If ($inindex <> true) {

 ?>

 <p>&nbsp;&nbsp;Страницы:

 <?

 //PAGES

 for ($c = 1; $c <= ceil(count($allgoods) / $serv_const_lstcount); $c++) {

  If ($lst == $c) {

   echo "<b><a href='/buy_recommend.php?lst=$c' class='cap3'>$c</a></b>";

  }

  Else {

   echo "<a href='/buy_recommend.php?lst=$c' class='cap4'>$c</a>";

  }

  If ($c <> ceil(count($allgoods) / $serv_const_lstcount)) {

   echo " | ";

  }

 }



 If (count($allgoods) <= 0) {

  echo "<b><font color='#FF0000'>1</font></b>";

 }

 ?>

 </p>

 <?

}

Else {

 If (count($allgoods) > $serv_const_lstcount) {

  echo "<tr><td colspan='5'><p align='right'><a href='/buy_recommend.php?lst=1' class='cap4'>Далее<img border='0' src='img/pic_arrow.gif' width='14' height='11' hspace='4'></a>&nbsp;&nbsp;</p></td></tr></table>";

 }

 Else {

  echo "</table>";

 }

}

?>