<?


  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 ();
  }

  if ($_GET['logout'])
  {
    setcookie ('autorized', '');
    setcookie ('root', '');
    setcookie ('editor', '');
    header ('Location: index.php');
  }

  if ($_POST['login'])
  {
    require '../config.inc.php';
    if (!($result = mysql_query ('select * from users')))
    {
      exit ('Invalid query');
      ;
    }

    while ($row = mysql_fetch_array ($result))
    {
      if (($row['username'] == $_POST['username'] AND $row['password'] == md5 ($_POST['password'])))
      {
        setcookie ('autorized', md5 (md5 ($row['username'] . $row['password'])));
        setcookie ('catselect', md5 (md5 ($row['password'])));
        if ($row['root'] == 0)
        {
          setcookie ('root', md5 (md5 ($row['username'] . $row['password'])));
        }

        if ($row['root'] == 1)
        {
          setcookie ('editor', md5 (md5 ($row['username'] . $row['password'])));
        }

        header ('Location: http://' . $_SERVER['HTTP_HOST'] . dirname ($_SERVER['PHP_SELF']) . '/frameset.php');
        continue;
      }
    }
  }

  echo '
<HTML><HEAD><title>NewsPHP Administration Login Screen</title></HEAD><BODY><BR><BR><BR><BR><BR>
<FORM ACTION="index.php" name="LOG_IN" METHOD=post>
<TABLE WIDTH=320 BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><TR><TD><IMG SRC="images/login_01.jpg"></TD></TR><TR><TD height=160 BACKGROUND="images/login_02.gif">

<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 ALIGN=center>
<TR>
	<TD ALIGN=right><FONT STYLE="color';
  echo ': Navy; font-family: Tahoma; font-size: 12px;">Username:</FONT></TD>
	<TD> <INPUT TYPE=text NAME="username" STYLE="font-family: Tahoma; font-size: 11px; color: Navy;"></TD>
</TR>
<TR>
	<TD ALIGN=right><FONT STYLE="color: Navy; font-family: Tahoma; font-size: 12px;">Password:</FONT></TD>
	<TD><INPUT TYPE=password NAME="password" STYLE="font-family: Tahoma; font-size: 11px; color: Navy;"></TD>
</TR>
<TR>
	<T';
  echo 'D ALIGN=right></TD>
	<TD>
		<INPUT TYPE=submit NAME="login" VALUE="Login" STYLE="width: 70px;"><br>
		<!-- <a href="reminder.php" style="font-family:Tahoma; font-size:11; color:blue;">Forgot your password?</a> -->
	</TD>
</TR>
</TABLE>

</TD></TR><TR><TD><IMG SRC="images/login_03.gif"></TD></TR></TABLE>
';
  echo '<S';
  echo 'CRIPT LANGUAGE="JavaScript" TYPE="text/javascript">if(document.LOG_IN.username.value == \'\'){document.LOG_IN.username.focus();}else{document.LOG_IN.password.focus();}</SCRIPT>
</FORM>
</BODY></HTML>';
?>
