<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function onInsert()
{ 
		if(form2.pwd1.value =="")
		{
			alert("You not fill first password!");
			form2.pwd1.focus();
			return false;
		}
		else if(form2.pwd2.value =="")
		{
			alert("You not fill second password!");
			form2.pwd2.focus();
			return false;
		}
		else if(form2.pwd1.value != form2.pwd2.value)
		{
			alert("Password doesn't match!");
			form2.pwd2.value = "";
			form2.pwd2.focus();
			return false;
		}
		else
		{
			return true; 
		}	 
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fish landing data management system</title>
<style type="text/css">
<!--
.stylewhite {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #FFFFFF;
}
.stylegreen {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #00661F;
}
.styleblack {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #000000;
}
.style1 {
font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #FF0000;
}
.stylewhite1 {	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	font-weight: bold;
	color: #FFFFFF;
}
-->
</style>
</head>

<body onload="form1.usr.focus();">
<?
if($_POST[submit2])
	{
	$edtpwd = trim($_POST["pwd1"]);
	$uid = "admin";
	require_once("usr_function.php");
	ChangePasswordAdmin($edtpwd);
	$tlog = "Set Admin Password";
	require_once("usr_function.php");
	addLog($_SESSION['myusername'],$tlog);
	}	
	?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?
include "connect.inc.php";
$sqlchkpass = "select * from sysuser where uname = 'admin'";
$qrychkpass = mysql_query($sqlchkpass);
$reschkpass = mysql_fetch_array($qrychkpass);
$pass = $reschkpass["pwd"];
if($pass == NULL)
{
?>
<form action="index.php" method="post" name="form2" id="form2" onsubmit="return onInsert()">
  <table width="35%" height="161" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="19" colspan="2" background="images/index_01.gif"><div align="center"><span class="stylewhite1">Set Your Password</span> </div>
          <div align="right"></div></td>
    </tr>
    <tr>
      <td height="14" colspan="2" bgcolor="#ADCE4C" class="style1"><label> &nbsp;</label></td>
    </tr>
    <tr>
      <td width="51%" height="12" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">User Name </span>&nbsp; </div></td>
      <td width="49%" height="12" bgcolor="#ADCE4C" class="styleblack">admin</td>
    </tr>
    <tr>
      <td height="13" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Password&nbsp;&nbsp; </span></div></td>
      <td width="49%" height="13" bgcolor="#ADCE4C"><input name="pwd1" type="password" id="pwd1" size="10" maxlength="10" /></td>
    </tr>
    <tr>
      <td height="25" valign="top" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Re-Password </span>&nbsp; </div></td>
      <td height="25" bgcolor="#ADCE4C"><label>
        <input name="pwd2" type="password" id="pwd2" size="10" maxlength="10" />
      </label></td>
    </tr>
    <tr>
      <td height="34" colspan="2" bgcolor="#ADCE4C"><label> </label>
          <div align="center">
            <input name="submit2" type="submit" class="styleblack" id="submit2" value="Set Password" />
        </div></td>
    </tr>
    <tr>
      <td height="19" colspan="2" bgcolor="#6B716F"><div align="right"></div></td>
    </tr>
  </table>
</form>
<?
}
else
{
?>
<form id="form1" name="form1" method="post" action="check_valid_user.php">
  <table width="25%" height="182" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="19" colspan="2" bgcolor="#6B716F"><span class="style5">&nbsp;</span><span class="stylewhite">Fish Landing Data Management System</span>        <div align="right"></div></td>
    </tr>
    <tr>
      <td height="34" colspan="2" bgcolor="#ADCE4C" class="style1">
        <div align="left"><span class="stylewhite">&nbsp; Log in</span>&nbsp; &nbsp;</div>
      </td>
    </tr>
    <tr>
      <td width="47%" height="25" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Username</span>&nbsp; </div></td>
      <td width="53%" height="25" bgcolor="#ADCE4C"><input name="usr" type="text" class="styleblack" id="usr" size="10" maxlength="10" /></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#ADCE4C" class="style1"><div align="right"><span class="stylegreen">Password</span>&nbsp; </div></td>
      <td height="25" bgcolor="#ADCE4C"><label>
        <input name="pwd" type="password" class="styleblack" id="pwd" size="10" maxlength="10" />
      </label></td>
    </tr>
    <tr>
      <td height="34" colspan="2" bgcolor="#ADCE4C"><label>
        
        <div align="center"><span class="style24 style1">
          <?php
						if($_GET['err']==1)
						{
							echo "username or password invalid"."<br>"."please try again!";
						} 
						?>
        </span> </div>
        <div align="center">
          <input name="submit" type="submit" class="styleblack" id="submit" value="Submit" />
          <input name="Cancel" type="reset" class="styleblack" id="Cancel" value="Cancel" />
          </div>
      </label></td>
    </tr>
    <tr>
      <td height="19" colspan="2" bgcolor="#6B716F"><div align="right"><span class="style4"><span class="styleblack">@SEAFDEC 2012</span>&nbsp; </span></div></td>
    </tr>
  </table>
</form>
<?
}
?>
</body>
</html>
