<?


  if (!include '../autorization.php')
  {
    echo 'Access denied!';
    exit ();
  }

  if (las2post_category != 'All')
  {
    $SQL1 = 'SELECT * FROM articles WHERE instr(category, \'' . las2post_category . '\') AND status=1 AND type<1 ORDER by tim DESC LIMIT ' . las2post_amount;
  }
  else
  {
    $SQL1 = 'SELECT * FROM articles WHERE status=1 AND type<1 ORDER by tim DESC LIMIT ' . las2post_amount;
  }

  if (!($result1 = mysql_query ($SQL1)))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $total = mysql_num_rows ($result1);
  for ($i = 0; $i < las2post_amount / las2post_column; ++$i)
  {
    if ($i < $total / las2post_column)
    {
      echo '		
		<table width="100%" border="0" cellspacing="3" background="images/back.gif"><tr>

		';
      for ($j = 0; $j < las2post_column; ++$j)
      {
        $row1 = mysql_fetch_array ($result1);
        echo '
		<td width="';
        echo 100 / las2post_column;
        echo '%" valign="top" ';
        if ($j < las2post_column - 1)
        {
          echo 'style="border-right: 1px dotted gray;"';
        }

        echo ' width="50%">
		<a href="javascript:" STYLE="color:';
        echo las2post_title_color;
        echo '; font-family:';
        echo las2post_title_font;
        echo '; font-size:';
        echo las2post_title_font_size;
        echo '; font-weight:';
        echo las2post_title_font_weight;
        echo ';">';
        echo $row1['title'];
        echo '</a><br>
		<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="5"></td></tr></table>

		';
        if ($dir = @opendir ('../../upload/thumbnails'))
        {
          while ($file = readdir ($dir) !== false)
          {
            if (strstr ($file, $row1['tim']))
            {
              echo '<a href="javascript:"><IMG SRC="../../upload/thumbnails/';
              echo $file;
              echo '" hspace="2" align="';
              echo las2post_tmb_align;
              echo '" ';
              if (las2post_tmb_width)
              {
                echo 'width="';
                echo las2post_tmb_width;
                echo '"';
              }

              echo ' ';
              if (las2post_tmb_height)
              {
                echo 'height="';
                echo las2post_tmb_height;
                echo '"';
              }

              echo ' style="border: 1px solid Black;"></a>';
              continue;
            }
          }

          closedir ($dir);
        }

        echo '		<font STYLE="color:';
        echo las2post_description_color;
        echo '; font-family:';
        echo las2post_description_font;
        echo '; font-size:';
        echo las2post_description_font_size;
        echo '; font-weight:';
        echo las2post_description_font_weight;
        echo ';">';
        echo $row1['description'];
        echo '</font>
		</td>
	';
      }

      echo '	</tr></table>';
      if ($i + 1 < $total / las2post_column)
      {
        echo '<table width="100%" border="0" cellspacing="0" style="border-bottom: 1px dotted gray;"><tr><td></td></tr></table>';
        continue;
      }

      continue;
    }
  }

?>
