<?


  function rating_result ($ID)
  {
    include '../../lang/' . language;
    if (!($result = mysql_query ('' . 'select * from rating where id=\'' . $ID . '\'')))
    {
      exit ('<b>Error:</b>' . mysql_error ());
      ;
    }

    if ($row = mysql_fetch_array ($result))
    {
      $RATE = $row['rating'] / $row['amount'];
      echo '' . '<font style="color: navy; font-family:arial; font-size:11px;"><b>' . $text__Rating . ' ';
      for ($i = 0; $i < floor ($RATE); ++$i)
      {
        echo '<img src="../../inc/images/star.gif" border="0" align="absmiddle">';
      }

      if (floor ($RATE) < round ($RATE, 0))
      {
        echo '<img src="../../inc/images/halfstar.gif" border="0" align="absmiddle">';
      }

      for ($i = 0; $i < sizeof ($article_vote_options) - round ($RATE, 0); ++$i)
      {
        echo '<img src="../../inc/images/emptystar.gif" border="0" align="absmiddle">';
      }

      echo ' <font color="#800000">' . round ($RATE, 2) . '</font> / ' . sizeof ($article_vote_options) . ('' . '</b> (' . $row['amount'] . ' ' . $text__votes . ')</font>&nbsp;&nbsp;');
    }
    else
    {
      echo '<font style="color: navy; font-family:tahoma; font-size:11px;">';
      echo $text__Rating;
      echo '</font>';
      for ($i = 0; $i < sizeof ($article_vote_options); ++$i)
      {
        echo '<img src="../../inc/images/emptystar.gif" border="0" align="absmiddle">';
      }

      echo '<font style="color: navy; font-family:tahoma; font-size:11px;"> (0 ';
      echo $text__votes;
      echo ')</font>';
    }

  }

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

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

  $row0 = mysql_fetch_array ($result0);
  $_GET['id'] = $row0['id'];
  include '../../lang/' . language;
  if (!($result = mysql_query ('' . 'select * from articles where id=\'' . $_GET['id'] . '\'')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $row = mysql_fetch_array ($result);
  if ($row['id'])
  {
    if ($dir = @opendir ('../../upload/cat_images'))
    {
      while ($file = readdir ($dir) !== false)
      {
        if (strstr ($file, $row['category']))
        {
          echo '<IMG SRC="../../upload/cat_images/';
          echo $file;
          echo '" BORDER="0">';
          continue;
        }
      }

      closedir ($dir);
    }

    echo '<table width="100%" border="0"><tr><td height=5></td></tr></table>
<font STYLE="color:';
    echo title_color;
    echo '; font-family:';
    echo title_font;
    echo '; font-size:';
    echo title_font_size;
    echo '; font-weight:';
    echo title_font_weight;
    echo ';">';
    echo $row['title'];
    echo '</font>

<table width="100%" border="0" style="border-bottom: 1px solid Silver;"><tr><td height=5></td></tr></table>
<table border="0" cellspacing="0" cellpadding="1">
<tr>
	<td align="left">
		';
    echo '		';
    echo '<s';
    echo 'elect name="rate">
		';
    for ($i = 0; $i < sizeof ($article_vote_options); ++$i)
    {
      echo '<option value="';
      echo sizeof ($article_vote_options) - $i;
      echo '">';
      echo $article_vote_options[$i];
      echo '</option>';
    }

    echo '		</select>
		<input type="hidden" name="id" value="';
    echo $row['id'];
    echo '"><input type="submit" name="article_rate" value="';
    echo $text__Rate;
    echo '">
		';
    echo '	</td>
	<td align="left">';
    rating_result ($_GET['id']);
    echo '</td>
	<td align="right">
	<a href="javascript:"><img src="../../inc/images/printer.gif" border="0" alt="';
    echo $text__Printable;
    echo '" align="left"></a>
	<a href="javascript:"><img src="../../inc/images/email.gif" border="0" alt="';
    echo $text__email;
    echo '" align="left"></a>
	<a href="javascript:"><img src="../../inc/images/forum.gif" border="0" alt="';
    echo $text__discuss;
    echo '" align="left"></a>
	</td>
	<td align="right"><a href="javascript:"><img src="../../inc/images/xml.gif" border="0"></a></td>
</tr>
</table>
<table width="100%" border="0" style="border-top: 1px solid Silver;"><tr><td height=5></td></tr></table>

<table border="0" cellspacing="0" cellpadding="5" align="right"><tr><td valign="top">


			';
    if ($dir = @opendir ('../../upload/images'))
    {
      while ($file = readdir ($dir) !== false)
      {
        if (strstr ($file, $row['tim']))
        {
          echo '<IMG SRC="../../upload/images/';
          echo $file;
          echo '" ';
          if (image_width)
          {
            echo 'width="';
            echo image_width;
            echo '"';
          }

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

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

      closedir ($dir);
    }

    echo '
</td></tr><tr><td>



';
    if (!($result_related = mysql_query ('' . 'select * from articles where type=0 AND status=1 AND id!=' . $row['id'] . ' AND category=\'' . addslashes ($row['category']) . '\' ORDER by tim DESC LIMIT ' . headlines_amount)))
    {
      exit ('<b>Error:</b>' . mysql_error ());
      ;
    }

    $total = mysql_num_rows ($result_related);
    if ($total)
    {
      echo '
<table width="';
      if (image_width)
      {
        echo image_width;
      }
      else
      {
        echo '150';
      }

      echo '" border="0" cellspacing="0" cellpadding="7" style="border: ';
      if (headlines_border == 1)
      {
        echo 1;
      }
      else
      {
        echo 0;
      }

      echo 'px solid ';
      echo headlines_border_color;
      echo '; background: ';
      echo headlines_bg_color;
      echo ';">
<tr>
	<td align="center" bgcolor="';
      echo headlines__bg__color;
      echo '"><font STYLE="color:';
      echo headlines__color;
      echo '; font-family:';
      echo headlines__font;
      echo '; font-size:';
      echo headlines__font__size;
      echo '; font-weight:';
      echo headlines__font__weight;
      echo ';">';
      echo $text__Releated_articles;
      echo '</font></td>
</tr>
<tr>
	<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
';
      while ($row_related = mysql_fetch_array ($result_related))
      {
        echo '<tr><td>
				<a href="javascript:" STYLE="color:';
        echo headlines_title_color;
        echo '; font-family:';
        echo headlines_title_font;
        echo '; font-size:';
        echo headlines_title_font_size;
        echo '; font-weight:';
        echo headlines_title_font_weight;
        echo ';">';
        echo $row_related['title'];
        echo '</a>
				';
        if (headlines_tmb == 'yes')
        {
          if ($dir = @opendir ('../../upload/thumbnails/'))
          {
            while ($file = readdir ($dir) !== false)
            {
              if (strstr ($file, $row_related['tim']))
              {
                echo '<a href="javascript:"><IMG SRC="../../upload/thumbnails/';
                echo $file;
                echo '" vspace="5" align="';
                echo tmb_align;
                echo '" ';
                if (tmb_width)
                {
                  echo 'width="';
                  echo tmb_width;
                  echo '"';
                }

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

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

            closedir ($dir);
          }
        }

        echo '<br><font STYLE="color:';
        echo headlines_description_color;
        echo '; font-family:';
        echo headlines_description_font;
        echo '; font-size:';
        echo headlines_description_font_size;
        echo '; font-weight:';
        echo headlines_description_font_weight;
        echo ';">&#8226;&nbsp;';
        echo $row_related['description'];
        echo '</font>';
        echo '</td></tr>';
      }

      echo '</table>

	</td>
</tr>
</table>
';
    }

    echo '

</td></tr></table>
				
				
<font style="color: navy; font-family:tahoma; font-size:11px;"><u>';
    echo '' . $text__Posted . ' ' . date ('Y ', $row['tim']) . $month[date ('m', $row['tim']) - 1] . date (' d', $row['tim']) . ' - ' . date ('H:i', $row['tim']);
    echo '</u></FONT><br>
&#8226;&nbsp;<font STYLE="color:';
    echo description_color;
    echo '; font-family:';
    echo description_font;
    echo '; font-size:';
    echo description_font_size;
    echo '; font-weight:';
    echo description_font_weight;
    echo ';">';
    echo $row['description'];
    echo '</font><br><br>';
    if ($dir = @opendir ('upload/multimedia'))
    {
      while ($file = readdir ($dir) !== false)
      {
        if (strstr ($file, $row['tim']))
        {
          echo '<A HREF="upload/multimedia/';
          echo $file;
          echo '" BORDER="0"><img src="inc/images/wmedia.gif" vspace="5" alt="';
          echo $text__Multimedia;
          echo '" align="left" border="0"></A>';
          $image_size = getimagesize ('' . 'upload/images/' . $file);
          continue;
        }
      }

      closedir ($dir);
    }

    echo $row['body'];
  }

?>
