170 lines
4.1 KiB
PHP
170 lines
4.1 KiB
PHP
<?PHP
|
|
include_once("headerFile.php");
|
|
|
|
if ($_REQUEST['action'] == 'successful_login') {
|
|
$loginSpanDisplay = <<< display
|
|
<table width="100%" cellpadding="1" cellspacing="1" border="0" >
|
|
<tr>
|
|
<td>Welcome {$_SESSION['NAMA_USER']} to MIS</td>
|
|
</tr>
|
|
</table>
|
|
|
|
display;
|
|
|
|
echo $loginSpanDisplay;
|
|
} else if ($_REQUEST['action'] == 'logout') {
|
|
$loginSpanDisplay = <<< display
|
|
<table width="100%" cellpadding="1" cellspacing="1" border="0" >
|
|
<tr>
|
|
<td>Login ID : <input type="text" name="loginID" size="10" class="font10B" style="text-transform: uppercase;" > Password : <input type="password" name="passwd" size="10" class="font10B"></td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
display;
|
|
|
|
echo $loginSpanDisplay;
|
|
} else {
|
|
|
|
if (checkLogin()) {
|
|
$loginSpanDisplay = <<< display
|
|
<table width="100%" cellpadding="1" cellspacing="1" border="0" >
|
|
<tr>
|
|
<td>Welcome {$_SESSION['NAMA_USER']} to MIS</td>
|
|
</tr>
|
|
</table>
|
|
|
|
display;
|
|
|
|
|
|
$buttonDisplay = "Log OUT";
|
|
|
|
} else {
|
|
$loginSpanDisplay = <<< display
|
|
<table width="100%" cellpadding="1" cellspacing="1" border="0" >
|
|
<tr>
|
|
<td>Login ID : <input type="text" name="loginID" size="10" class="font10B" style="text-transform: uppercase;" > Password : <input type="password" name="passwd" size="10" class="font10B"></td>
|
|
</tr>
|
|
</table>
|
|
|
|
display;
|
|
|
|
|
|
$buttonDisplay = "Log IN";
|
|
|
|
|
|
}
|
|
|
|
$executorScriptName = basename($_SERVER['SCRIPT_NAME']);
|
|
|
|
$html = <<< html
|
|
<table width="100%" cellpadding="1" cellspacing="1" border="0" >
|
|
<tr><form name="loginForm" method="post" onsubmit="javascript:accessBtnClick();return false;">
|
|
<td style="text-align:right">
|
|
<span id="loginSpan">
|
|
$loginSpanDisplay
|
|
</span>
|
|
</td>
|
|
<td width="80">
|
|
<input type="submit" name="accessBtn" class="font10B" value="$buttonDisplay" style="border-style: dotted">
|
|
<!--button name="accessBtn" style="border-style: dotted" class="font10B">$buttonDisplay</button-->
|
|
</td>
|
|
</tr>
|
|
</form>
|
|
</table>
|
|
<script language="VBScript" type="text/vbscript">
|
|
function accessBtnclick()
|
|
if (document.getElementById("accessBtn").value = "Log IN") then
|
|
loginBtn()
|
|
else
|
|
logoutBtn()
|
|
end if
|
|
end function
|
|
|
|
|
|
function loginBtn()
|
|
dim md5
|
|
|
|
if ((Len(loginForm.loginID.value) > 0) and (Len(loginForm.passwd.value) > 0)) then
|
|
md5 = makeHash(loginForm.loginID.value,loginForm.passwd.value)
|
|
call AjaxLogin(loginForm.loginID.value,md5)
|
|
|
|
end if
|
|
loginBtn_onclick = false
|
|
end function
|
|
|
|
function logoutBtn()
|
|
AjaxLogout()
|
|
end function
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript" src="/js/ajax.js"></script>
|
|
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
|
|
var xmlHttp
|
|
var executorScript = "$executorScriptName";
|
|
var loginAjax = new sack();
|
|
|
|
function AjaxLogin(loginId,encPasswd){
|
|
var data="action=login";
|
|
data=data+"&loginid="+loginId;
|
|
data=data+"&passwd="+encPasswd;
|
|
data=data+"&sid="+Math.random();
|
|
|
|
loginAjax.requestFile = './ajax_login.php?'+data;
|
|
loginAjax.onCompletion = loginChanged;
|
|
loginAjax.runAJAX();
|
|
}
|
|
|
|
function loginChanged(){
|
|
|
|
if (loginAjax.response == -1) {
|
|
alert("Could not log you in at this time.");
|
|
} else if (loginAjax.response == 1) {
|
|
if (executorScript == "index.php") {
|
|
location.reload();
|
|
} else {
|
|
location.href("/index.php");
|
|
}
|
|
} else if (loginAjax.response == 2) {
|
|
alert("Wrong Password.");
|
|
} else if (loginAjax.response == 4) {
|
|
alert("Your Login ID is being DISABLED.");
|
|
} else if (loginAjax.response == 5) {
|
|
alert("Your Login ID is being LOCKED.");
|
|
} else if (loginAjax.response == 0) {
|
|
alert("Login ID is not registered.");
|
|
} else if (loginAjax.response == 6) {
|
|
alert("Password is expired, change it first");
|
|
window.location.href = "/change_password.php";
|
|
} else {
|
|
alert(loginAjax.response);
|
|
}
|
|
loginAjax.reset();
|
|
}
|
|
|
|
function AjaxLogout(){
|
|
var data="action=logout";
|
|
data=data+"&sid="+Math.random();
|
|
//alert(data);
|
|
loginAjax.requestFile = './ajax_login.php?'+data;
|
|
loginAjax.onCompletion = logoutChanged;
|
|
loginAjax.runAJAX();
|
|
}
|
|
|
|
function logoutChanged(){
|
|
if (loginAjax.response == 1) {
|
|
location.href="/index.php";
|
|
} else {
|
|
alert("ERROR: Could not log you out at this time.");
|
|
}
|
|
loginAjax.reset();
|
|
}
|
|
</SCRIPT>
|
|
|
|
html;
|
|
|
|
echo $html;
|
|
|
|
}
|
|
?>
|