<?
/*
Author		: Cyrus_X
Version		: 1.00
Date		: 5th September 2001
Function	: Change password module
*/ 

session_start();
require("auth.php");
if ($Transmarco["accesslevel"] < $coadminlevel) {
	authfail();
}
if ($action=="Change") {
	$uid = $Transmarco["uid"];
	$sql = "select * from usersession where userid = '$uid'";
	$result = db_query($sql);
	$row = db_fetch_array($result,0);
	if ($row["password"] != md5($currentpass)) {
		$msg = "<b>*Current Password does not match.<br></b>";
	} else {
		if ($newpass != $confirmpass) {
			$msg = "<b>*New Password does not match.<br></b>";
		} else {
			$password = $row["password"];
			if (strlen($newpass) > 6) {
				$password = md5($newpass);
				$sql = "update usersession set password='$password' where userid=$uid";
				db_query($sql);
				$msg = "<b>*Password Changed!<br></b>";
			} else {
				$msg = "<b>*Password length is too short<br>&nbsp;(less than 6 characters)<br></b>";
			}
		}
	}
}

?>
<HTML>
<HEAD>
<TITLE>Change Password</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<? include($style); ?>
</HEAD>
<BODY bgcolor="#ffffff">
<FORM METHOD=POST ACTION="changepass.php">
  <p>&nbsp;</p><table width="360" border="0" cellspacing="0" cellpadding="8" align="center">
    <tr valign="top"> 
      <td><font class="sub"><b>Change Password</b></font></td>
    </tr>
  </table>
  <table class="bigbox" border="0" cellspacing="0" cellpadding="0" align="center" width="360">
    <tr> 
      <td width="16" height="16" valign="top" align="left"><img src="<? echo $images ?>a.gif" width="16" height="18"></td>
      <td width="363"><img src="<? echo $images ?>shim.gif" width="16" height="16"></td>
      <td width="17" height="16" align="right" valign="top"><img src="<? echo $images ?>b.gif" width="16" height="16"></td>
    </tr>
    <tr> 
      <td width="16">&nbsp;</td>
      <td valign="top" class="bgline"> 
        <table cellpadding="5" cellspacing="1" border="0" align="center" width="100%">
          <tr> 
            <td width="50%" height="39" class="highlights"><b>Current Password</b></td>
            <td width="50%" height="39" class="tdfill" align="center"> 
              <input type="password" name="currentpass" size="15" maxlength="12">
            </td>
          </tr>
          <tr> 
            <td width="50%" class="highlights"><b>New Password</b></td>
            <td width="50%" class="tdfill" align="center"> 
              <input type="password" name="newpass" size="15" maxlength="12">
            </td>
          </tr>
          <tr> 
            <td width="50%" class="highlights"><b>Reconfirm Password</b></td>
            <td width="50%" class="tdfill" align="center"> 
              <input type="password" name="confirmpass" size="15" maxlength="12">
            </td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="3">
          <tr> 
            <td class="highlights"><br>
              Password must be longer than 6 characters. <br>
              Make sure it is difficult for others to guess!<b> </b></td>
          </tr>
        </table>
      </td>
      <td width="17" align="right">&nbsp;</td>
    </tr>
    <tr> 
      <td width="16" valign="bottom" align="left"><img src="<? echo $images ?>c.gif" width="16" height="18"></td>
      <td width="363">&nbsp;</td>
      <td width="17" align="right" valign="bottom"><img src="<? echo $images ?>d.gif" width="16" height="16"></td>
    </tr>
  </table>
  <table width="360" border="0" cellspacing="0" cellpadding="14" align="center">
    <tr valign="top"> 
      <td width="249"> 
        <? if (isset($msg)) echo $msg ?>
      </td>
      <td align="right" width="55"> 
        <input type="submit" name="action" value="Change">
      </td>
    </tr>
  </table>
  </FORM>
<div align="center"></div>
</BODY>
</HTML>
