<?

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

  $SQL = 'SELECT * FROM articles WHERE type=1 AND status=1 ORDER by tim DESC';
  if (!($result = mysql_query ($SQL)))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $row = mysql_fetch_array ($result);
  $SQL = 'SELECT * FROM articles WHERE type=2 AND status=1 ORDER by tim DESC LIMIT ' . head_day_amount;
  if (!($result1 = mysql_query ($SQL)))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  echo '			<table width="468" border="1" class="border" cellspacing="0" cellpadding="5" style="border-bottom: 1px dotted gray;"><tr>
			<td width="300" valign="top">
';
  if ($dir = @opendir ('../../upload/images'))
  {
    while ($file = readdir ($dir) !== false)
    {
      if (strstr ($file, $row['tim']))
      {
        echo '<a href="javascript:"><IMG SRC="../../upload/images/';
        echo $file;
        echo '" ';
        if (day_image_width)
        {
          echo 'width="';
          echo day_image_width;
          echo '"';
        }

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

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

    closedir ($dir);
  }

  echo '				<a href="javascript:" STYLE="color:';
  echo day_title_color;
  echo '; font-family:';
  echo day_title_font;
  echo '; font-size:';
  echo day_title_font_size;
  echo '; font-weight:';
  echo day_title_font_weight;
  echo ';">';
  echo $row['title'];
  echo '</a><br>
				<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="5"></td></tr></table>
				<font STYLE="color:';
  echo day_description_color;
  echo '; font-family:';
  echo day_description_font;
  echo '; font-size:';
  echo day_description_font_size;
  echo '; font-weight:';
  echo day_description_font_weight;
  echo ';">';
  echo $row['description'];
  echo '</font>
			
			</td>
			<td width="170" valign="top" style="border-left: 1px dotted gray;">

			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			';
  while ($row1 = mysql_fetch_array ($result1))
  {
    echo '			<tr><td>
			<font color="';
    echo head_day_title_color;
    echo '">&#8226;&nbsp;</font><a href="javascript:" STYLE="color:';
    echo head_day_title_color;
    echo '; font-family:';
    echo head_day_title_font;
    echo '; font-size:';
    echo head_day_title_font_size;
    echo '; font-weight:';
    echo head_day_title_font_weight;
    echo ';">';
    echo $row1['title'];
    echo '</a>
			<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="5"></td></tr></table>
			';
    if (head_day_tmb == 'yes')
    {
      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 '" align="';
            echo head_day_tmb_align;
            echo '" ';
            if (head_day_tmb_align)
            {
              echo 'width="';
              echo head_day_tmb_width;
              echo '"';
            }

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

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

        closedir ($dir);
      }
    }

    echo '					
				<font STYLE="color:';
    echo head_day_description_color;
    echo '; font-family:';
    echo head_day_description_font;
    echo '; font-size:';
    echo head_day_description_font_size;
    echo '; font-weight:';
    echo head_day_description_font_weight;
    echo ';">';
    echo $row1['description'];
    echo '</font><br>
				</td></tr>
				';
  }

  echo '			</table>
			</td>

			</tr></table>
';
?>
