<?

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

  echo '
';
  if (!($result = mysql_query ('SELECT * FROM categories')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $total = mysql_num_rows ($result);
  $table_rows = ceil ($total / 2);
  echo '		
		<table width="100%" border="0" cellspacing="5" cellpadding="0">
		';
  for ($i = 0; $i < $table_rows; ++$i)
  {
    $cat_title = mysql_fetch_array ($result);
    $r1 = $cat_title['name'];
    echo '		
		<tr>
			<td valign="top" bgcolor=';
    echo catlist_bg_color;
    echo ' width="50%">&nbsp;';
    if (catlist_bullet == 'yes')
    {
      echo '<img src="../../upload/Image/bullet.gif" border="0" valign="middle">&nbsp;';
    }

    echo '<font STYLE="color:';
    echo catlist_color;
    echo '; font-family:';
    echo catlist_font;
    echo '; font-size:';
    echo catlist_font_size;
    echo '; font-weight:';
    echo catlist_font_weight;
    echo ';">';
    echo $cat_title['name'];
    echo '</font></td>
			';
    $cat_title = mysql_fetch_array ($result);
    $r2 = $cat_title['name'];
    if ($r2)
    {
      echo '			<td bgcolor=';
      echo catlist_bg_color;
      echo ' width="50%">&nbsp;';
      if (catlist_bullet == 'yes')
      {
        echo '<img src="../../upload/Image/bullet.gif" border="0" valign="middle">&nbsp;';
      }

      echo '<font STYLE="color:';
      echo catlist_color;
      echo '; font-family:';
      echo catlist_font;
      echo '; font-size:';
      echo catlist_font_size;
      echo '; font-weight:';
      echo catlist_font_weight;
      echo ';">';
      echo $r2;
      echo '</font></td>
			';
    }

    echo '		</tr>
		
		<tr>
			<td valign="top">
					';
    if ($_GET['tim'])
    {
      $SQL1 = '' . 'SELECT * FROM articles WHERE instr(category, \'' . $r1 . '\') AND LENGTH(category)=LENGTH(\'' . $r1 . '\') AND status=1 AND tim<' . $_GET['tim'] . ' ORDER by tim DESC';
    }
    else
    {
      $SQL1 = '' . 'SELECT * FROM articles WHERE instr(category, \'' . $r1 . '\') AND LENGTH(category)=LENGTH(\'' . $r1 . '\') AND status=1 ORDER by tim DESC';
    }

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

    echo '					';
    for ($ii = 0; $ii < catlist_amount; ++$ii)
    {
      if ($article1 = mysql_fetch_array ($result1))
      {
        echo '&#8226;&nbsp;<a href="javascript:" STYLE="color:';
        echo catlist_title_color;
        echo '; font-family:';
        echo catlist_title_font;
        echo '; font-size:';
        echo catlist_title_font_size;
        echo '; font-weight:';
        echo catlist_title_font_weight;
        echo ';">';
        echo $article1['title'];
        echo '</a><br>';
        continue;
      }
    }

    echo '			</td>
			<td valign="top">
					';
    if ($_GET['tim'])
    {
      $SQL2 = '' . 'SELECT * FROM articles WHERE instr(category, \'' . $r2 . '\') AND LENGTH(category)=LENGTH(\'' . $r2 . '\') AND status=1 AND tim<' . $_GET['tim'] . ' ORDER by tim DESC';
    }
    else
    {
      $SQL2 = '' . 'SELECT * FROM articles WHERE instr(category, \'' . $r2 . '\') AND LENGTH(category)=LENGTH(\'' . $r2 . '\') AND status=1 ORDER by tim DESC';
    }

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

    echo '					';
    for ($ii = 0; $ii < catlist_amount; ++$ii)
    {
      if (($r2 AND $article2 = mysql_fetch_array ($result2)))
      {
        echo '&#8226;&nbsp;<a href="javascript:" STYLE="color:';
        echo catlist_title_color;
        echo '; font-family:';
        echo catlist_title_font;
        echo '; font-size:';
        echo catlist_title_font_size;
        echo '; font-weight:';
        echo catlist_title_font_weight;
        echo ';">';
        echo $article2['title'];
        echo '</a><br>';
        continue;
      }
    }

    echo '			</td>
		</tr>

		';
  }

  echo '		</table>';
?>
