<%--
Document : index
Created on :
Author : Eku
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
String ua = request.getHeader( "User-Agent" );
boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
response.setHeader( "Vary", "User-Agent" );
String hehe = "";
%>
<script language="JavaScript">
<!--
var nHist = window.history.length;
if(window.history[nHist] != window.location)
window.history.forward();
//-->
</script>
<%@ page import="sun.misc.BASE64Encoder" %>
<%@ page import="java.io.*" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Toll ReBilling System</title>
</head>
<body bgproperties="fixed" background="BGLOGO.jpg" topmargin=3 link="#7E7E7E" vlink="#000000" alink="#FF9D9D">
<BR><div id="Ulo" style="height:150px; width:100%" align="center">
<h1>Toll ReBilling System</h1>
<h2>Log-In Page</h2></div>
<div id="Katawan" style="height:375px; width:100%" align="center">
<form action="loginservlet?action=LOGIN" method="post">
<%String Username = null; int flag = 0;
String auth = request.getHeader("Authorization");
if (auth == null) {
response.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM");
return;
}
if (auth.startsWith("NTLM ")) {
byte[] msg =
new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
int off = 0, length, offset;
String s;
if (msg[8] == 1) {
off = 18;
byte z = 0;
byte[] msg1 =
{(byte)'N', (byte)'T', (byte)'L', (byte)'M', (byte)'S',
(byte)'S', (byte)'P', z,
(byte)2, z, z, z, z, z, z, z,
(byte)40, z, z, z, (byte)1, (byte)130, z, z,
z, (byte)2, (byte)2, (byte)2, z, z, z, z, //
z, z, z, z, z, z, z, z};
//
response.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM "
+ new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
return;
}
else if (msg[8] == 3) {
off = 30;
length = msg[off+17]*256 + msg[off+16];
offset = msg[off+19]*256 + msg[off+18];
s = new String(msg, offset, length);
}
else
return;
length = msg[off+1]*256 + msg[off];
offset = msg[off+3]*256 + msg[off+2];
s = new String(msg, offset, length);
length = msg[off+9]*256 + msg[off+8];
offset = msg[off+11]*256 + msg[off+10];
s = new String(msg, offset, length);
Username = s;
} //http://www.rgagnon.com/javadetails/java-0441.html
String line;
BufferedReader in = new BufferedReader(new FileReader("E:\\TRBS\\UsersData\\users.txt"));
flag = 0;
while ((line = in.readLine()) != null) {
if (Username.equalsIgnoreCase(line)){
flag = 1;
}else{
}
}
in.close();
String Message = (String) request.getAttribute("mess");
if (Username.equals(null)){
Message = "UNAUTHORIZED ACCESS";
hehe = "disabled";
} else if ((!Username.equals(null))&&(flag==1)){
Message = "<h2>Welcome " + Username
+ "</h2><BR><h5>Please press OK to continue</h5>"
+ "<input type=\"submit\" value=\" Ok \"/>";
}
if (!isMSIE){
Message = "Browser Not Supported";
hehe = "disabled";
}
%>
<table>
<tr>
<td><%=Message%></td>
<td><input type = "hidden" name="user" value = <%=Username%> ></td>
</tr>
</table>
</form>
</div>
<div id="ilalim" style="position:absolute; top:550px; width:100%">
<CENTER><a href="http://www.pldt.com.ph/" title="visit website">Philippine Long Distance Telephone Company (PLDT)</a>
2008 All rights reserved.</CENTER>
</div>
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
</body>
</html> |