2013年10月22日 星期二

index.asp

' function login by AD
' check the password
' redirect to menu



<html>
<head>
<title>Logon Form</title>
<link href="http://www.company.com/assets/lib/files/css/company.css" rel="stylesheet" type="text/css" />
<link href="http://www.company.com/assets/lib/files/css/en.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<%
Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.Open "DSN=menu;UID=UserName;PWD=userPassword;Database=users"
Set SQLStmt = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject ("ADODB.Recordset")
strName = ucase(Request.ServerVariables("AUTH_USER"))
'q=ucase(request.querystring("q"))
%>
<%
p_username=Request.Form("User")
p_browserName=Request.Form("browserName")
session("s_browserName")=p_browserName
if p_username="" then
p_username=strName
end if
'response.write(p_username)
if p_username<>"" then
Validated = "OK"
usersTablePassword=""
SQLStmt.CommandText = "select * from users where userid='" & p_username &"'"
SQLStmt.CommandType = 1
Set SQLStmt.ActiveConnection = OBJdbConnection
RS.Open SQLStmt
if not RS.EOF then
realUserId=RS("userid")
realCompanyPermit=RS("CompanyPermit")
realDivisionPermit=RS("DivisionPermit")
realPermmssion=RS("permission")
userTablePassword=RS("password")
Session("companyReportMenuUserId") = realUserId
Session("companyReportMenuCompanyPermit") = realCompanyPermit
Session("companyReportMenuDivisionPermit") = realDivisionPermit
Response.cookies("companyReportMenuUserId") = realUserId
Response.cookies("companyReportMenuCompanyPermit") = realCompanyPermit
Response.cookies("companyReportMenuDivisionPermit") = realDivisionPermit
Response.cookies("companyReportMenuPermission") = realPermmssion
Response.cookies("companyReportMenuPermission").Expires=dateadd("m",1,now())
realSubMenuPermmssion=RS("menudetail")
Response.cookies("companySubMenuPermission") = realSubMenuPermmssion
Response.cookies("companySubMenuPermission").Expires=dateadd("m",1,now())
end if
Response.Write(realPermission)
if userTablePassword=Request.Form("password") then
Response.Write(realPermission)
if realPermmssion="useradd" then
Response.Cookies("ValidUser") = "AdminOK"
Response.cookies("ValidUser").Expires=dateadd("m",1,now())
Response.Redirect "useradd.asp"
Session("ValidUser")="AdminOK"
else
Response.Cookies("ValidUser") = Validated
Session("ValidUser")=Validated
if p_browserName= "IE" then
Response.Redirect "MenuH.asp"
else
Response.Redirect "MenuV.asp"
end if
end if
Else
If Request.Form("User") <> "" then
message = "Wrong Password"
Response.Write("<script language=VBScript>MsgBox """ + message + """</script>")
End if
End if
end if
%>
<link href="login-box.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#FFFFFF">
<FORM
id="accessControlForm"
onsubmit="return validateForm()"
ACTION=<%Response.Write "index.asp?"&Request.QueryString%> method="post">
<div style="padding: 100px 0 0 250px;">
<div id="login-box">
<H2>5Login</H2>
<div style="width:350px">
</div>
<div id="login-box-name" style="margin-top:20px;">User Name</div>
<div id="login-box-field" style="margin-top:20px;">
<input
autocomplete=off
name="User"
id="User"
class="form-login"
height="16px"
title="Server\Username" size="10" maxlength="2048"
value="<%=strName%>"
/>
</div>
<div id="login-box-name">Password:-</div><div id="login-box-field">
<input
id="password"
name="password" type="password" class="form-login" title="Password" value="" size="30" maxlength="2048" /></div>
<br />
<br />
<br />
<INPUT
id="logon"
autocomplete=off src="images/login-btn.png" width="103" height="42" style="margin-left:90px;"
TYPE="submit" VALUE="Logon"/>
<div id="returnMessage">
</div>
<br/>
<textarea style="display:none;" readonly cols="40" rows="3" id="browserName"  name="browserName" value=""/> </textarea>
</div>
</div>
</FORM>

<script>
function _refreshv(v_id,v_value,v_enable){
if (document.getElementById(v_id)){
document.getElementById(v_id).value=v_value;
}
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

$(function () {
s=navigator.userAgent;
if (navigator.userAgent.indexOf("MSIE 10") !=-1)
{
s="IE";
}
if (navigator.userAgent.indexOf("MSIE 8") !=-1)
{
s="IE";
}
if (navigator.userAgent.indexOf("MSIE") !=-1)
{
s="IE";
}
if (navigator.userAgent.indexOf("iPhone") !=-1)
{
s="IPHONE";
}
if (navigator.userAgent.indexOf("Firefox") !=-1)
{
s="FIREFOX";
}
if (navigator.userAgent.indexOf("Chrome") !=-1)
{
s="CHROME";
}
setCookie('browser', s);
_refreshv("browserName",s);
}
)

function _setfocus(oBject){
if (document.getElementById(oBject)){
document.getElementById(oBject).focus();
}
}

$(window).load(function(){
_setfocus('User')
})

function block(oEvent){
if(window.event){
oEvent = window.event;
oEvent.returnValue = false;  
}else
oEvent.preventDefault();  
}
document.oncontextmenu = block;

</script>
</body>
</html>

沒有留言:

張貼留言