<?



  $bad_words = array ('select', 'insert', 'delete', 'update', 'drop table', 'union', 'null');
  for ($i = 0; $i < sizeof ($_GET); ++$i)
  {
    for ($j = 0; $j < sizeof ($bad_words); ++$j)
    {
      if (preg_match ('/' . $bad_words[$j] . '/', $_GET[key ($_GET)]))
      {
        $temp = key ($_GET);
        $_GET[$temp] = '';
        continue;
      }
    }

    next ($_GET);
  }

  if (include 'key.php')
  {
    if (md5 ($domain) != $key1)
    {
      echo '<b>Invalid or expired license.</b><br><br>Please contact <a href="mailto:support@newsphp.com">support@newsphp.com</a>';
      exit ();
    }

    if (md5 ($key1) != $key2)
    {
      echo '<b>Invalid or expired license.</b><br><br>Please contact <a href="mailto:support@newsphp.com">support@newsphp.com</a>';
      exit ();
    }
  }
  else
  {
    echo '<br><br><b>Invalid or expired license.</b><br><br>Please contact <a href="mailto:support@newsphp.com">support@newsphp.com</a>';
    exit ();
  }

  include_once 'config.inc.php';
  if ($_GET['cat_id'] != '')
  {
    $SQL = '' . 'SELECT * FROM categories WHERE instr(\'' . $_GET['cat_id'] . '\',name)';
    if (!($result = mysql_query ($SQL)))
    {
      exit ('<b>Error:</b>' . mysql_error ());
      ;
    }

    $row000 = mysql_fetch_array ($result);
  }

  if (($_GET['id'] != '' AND !$_GET['words']))
  {
    $SQL2 = '' . 'SELECT * FROM articles WHERE id=' . $_GET['id'];
    if (!($result2 = mysql_query ($SQL2)))
    {
      exit ('<b>Error:</b>' . mysql_error ());
      ;
    }

    $row2 = mysql_fetch_array ($result2);
    $SQL = '' . 'SELECT * FROM categories WHERE instr(\'' . $row2['category'] . '\',name)';
    if (!($result = mysql_query ($SQL)))
    {
      exit ('<b>Error:</b>' . mysql_error ());
      ;
    }

    $row000 = mysql_fetch_array ($result);
  }

  if (($_POST['username'] AND $_POST['password']))
  {
    if (!($result = mysql_query ('select * from visitors')))
    {
      exit ('Invalid query');
      ;
    }

    while ($row = mysql_fetch_array ($result))
    {
      if (($row['username'] == $_POST['username'] AND $row['password'] == md5 ($_POST['password'])))
      {
        $TMP = split ('
', $row['allowed']);
        if (in_array ($_POST['visitor_allow'], $TMP))
        {
          setcookie ('autorized', md5 (md5 ($row['username'] . $row['password'])));
          header ('Location: index.php?cat_id=' . urlencode ($_POST['cat_id']) . ('' . '&id=' . $_POST['id']));
          continue;
        }

        continue;
      }
    }
  }

  include_once 'inc/main.php';
  if (!($result1 = mysql_query ('select * from properties')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $row1 = mysql_fetch_row ($result1);
  for ($i = 0; $i < sizeof ($row1); ++$i)
  {
    define (mysql_field_name ($result1, $i), $row1[$i]);
  }

  if (!($result2 = mysql_query ('select * from styles WHERE active=\'yes\'')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $row2 = mysql_fetch_array ($result2);
  echo '
';
  if (txt_direction == 'LTR')
  {
    echo '<html>';
  }
  else
  {
    echo '<html dir="rtl">';
  }

  echo '<head>
<title>';
  echo title;
  echo '</title>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=';
  echo encoding;
  echo '">
	<META NAME="keywords" CONTENT="';
  echo keywords;
  echo '">
	<META NAME="description" CONTENT="';
  echo description;
  echo '">
</head>
';
  echo bodytagset;
  echo '
';
  if (($row000['protect'] == 'on' AND !$_COOKIE['autorized']))
  {
  }
  else
  {
    echo '<form>';
  }

  include_once '' . 'upload/templates/' . $row2['skin'];
  if (($row000['protect'] == 'on' AND !$_COOKIE['autorized']))
  {
  }
  else
  {
    echo '</form>';
  }

  echo '</body></html>';
?>
