%
' 连接数据库
Function connect_db
Set conn = Server.CreateObject("ADODB.Connection")
'conn.Open "Driver={SQL Server}; server=" & db_host & "; uid=" & db_username & "; pwd=" & db_password & "; database=" & db_name
conn.Open "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("/data/cmc_sdfjwe1tiue3rjdkfghw2efg8h.mdb")
End Function
' 添加管理员操作日志
Function create_admin_operate_log(operation_name, operation_detail)
Dim rs_operation
sql = "insert into admin_operation_log " &_
"(" &_
"admin_username, operate, detail, creation_time" &_
") values (" &_
"'" & replaceSQLString(Session("strUsername")) & "', " &_
"'" & replaceSQLString(operation_name) & "', " &_
"'" & replaceSQLString(operation_detail) & "', " &_
"'" & Now() & "'" &_
")"
Set rs_operation = Server.CreateObject("ADODB.Recordset")
rs_operation.Open sql, conn, 2, 1
Set rs_operation = Nothing
End Function
Function initPage(objRs, intPagesize, intCurrentpage)
objRs.PageSize = intPagesize
If Not IsNumeric(intCurrentpage) Then
intCurrentpage = 1
End If
intCurrentpage = CInt(intCurrentpage)
If intCurrentpage > objRs.PageCount Then
intCurrentpage = objRs.PageCount
End If
If intCurrentpage < 1 Then
intCurrentpage = 1
End If
initPage = intCurrentpage
End Function
Function check_admin_login
If Session("strUsername") = "" Or Session("strChecksum") = "" Then
%>
<%
Response.End
End If
sql = "select id from admin_login_log where " &_
"admin_username = '" & replaceSQLString(Session("strUsername")) & "' " &_
"and checksum = '" & replaceSQLString(Session("strChecksum")) & "' " &_
"and remote_addr = '" & replaceSQLString(remote_addr) & "' " &_
"and flag = 0"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 3
If rs.BOF And rs.EOF Then
Set rs = Nothing
Set conn = Nothing
%>
<%
Response.End
End If
Set rs = Nothing
End Function
Function check_admin_task(task_name)
If Session("strUsername") = "" then
Set conn = Nothing
%>
<%
Response.End
End If
sql = "select root from admins where admin_username = '" & replaceSQLString(Session("strUsername")) & "'"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 3
If rs.BOF And rs.EOF Then
%>
<%
Response.End
End If
If rs("root") = 1 Then
Set rs = Nothing
Exit Function
End If
sql = "select b.flag as flag1, c.flag as flag2 from admin_task a, tasks b, admins c where " &_
"b.task_name = '" & replaceSQLString(task_name) & "' " &_
"and c.admin_username = '" & replaceSQLString(Session("strUsername")) & "' " &_
"and a.admin_id = c.id " &_
"and a.task_id = b.id"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 3
If rs.BOF And rs.EOF Then
Response.Write "对不起,您没有操作此模块的权限!"
Set rs = Nothing
Set conn = Nothing
Response.End
End If
If rs("flag1") <> "0" Then
Response.Write "对不起,此模块已被冻结!"
Set rs = Nothing
Set conn = Nothing
Response.End
End If
If rs("flag2") <> "0" Then
Response.Write "对不起,此帐号已被冻结!"
Set rs = Nothing
Set conn = Nothing
Response.End
End If
Set rs = Nothing
End Function
%>