<%@ CodePage = 65001 LCID = 1040 %> <% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.addHeader "cache-control", "no-cache" Response.addHeader "cache-control", "no-store" Response.CacheControl = "no-cache" %> <% ewCurSec = 0 ' Initialise ' User levels Const ewAllowAdd = 1 Const ewAllowDelete = 2 Const ewAllowEdit = 4 Const ewAllowView = 8 Const ewAllowList = 8 Const ewAllowReport = 8 Const ewAllowSearch = 8 Const ewAllowAdmin = 16 %> <% If Session("lapinsitter_status") <> "login" Then Response.Redirect "login.asp" Else ' Restore Security Table - created in Login arrSecurity = Session("ewSecurity") ' Get Current Table Security sTmp1 = -1 For sTmp = 1 to UBound(arrSecurity, 2) If arrSecurity(0, sTmp) = "utenti" Then sTmp1 = sTmp Exit For End If Next ewCurLvl = Session("lapinsitter_status_UserLevel") If IsNumeric(ewCurLvl) And sTmp1 <> -1 Then If ewCurLvl = -1 Then ' System Administrator ewCurSec = 31 ElseIf ewCurLvl > 0 and ewCurLvl <= 1 Then ewCurSec = arrSecurity(ewCurLvl, sTmp1) End If End If If (ewCurSec And ewAllowdelete) <> ewAllowdelete Then Response.Redirect "utentilist.asp" If Session("lapinsitter_status_UserID") = "" And Session("lapinsitter_status_UserID") <> -1 Then Response.Redirect "login.asp" End If %> <% ' Initialize common variables x_IDutente = Null: ox_IDutente = Null x_Nome = Null: ox_Nome = Null x_Cognome = Null: ox_Cognome = Null x_password = Null: ox_password = Null x_login = Null: ox_login = Null x_livello = Null: ox_livello = Null x_email = Null: ox_email = Null %> <% Response.Buffer = True ' Load Key Parameters sKey = "": bSingleDelete = True x_IDutente = Request.QueryString("IDutente") If x_IDutente <> "" Then If sKey <> "" Then sKey = sKey & "," sKey = sKey & x_IDutente Else bSingleDelete = False End If If Not bSingleDelete Then sKey = Request.Form("key_d") End If If sKey = "" Or IsNull(sKey) Then Response.Redirect "utentilist.asp" arRecKey = Split(sKey&"", ",") i = 0 Do While i <= UBound(arRecKey) sDbWhere = sDbWhere & "(" ' Remove spaces sRecKey = Trim(arRecKey(i+0)) ' Build the SQL sDbWhere = sDbWhere & "[IDutente]=" & AdjustSql(sRecKey) & " AND " If Right(sDbWhere, 5) = " AND " Then sDbWhere = Left(sDbWhere, Len(sDbWhere)-5) & ") OR " i = i + 1 Loop If Right(sDbWhere, 4) = " OR " Then sDbWhere = Left(sDbWhere, Len(sDbWhere)-4) ' Get action sAction = Request.Form("a_delete") If sAction = "" Or IsNull(sAction) Then sAction = "I" ' Display record End If ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "I": ' Display If LoadRecordCount(sDbWhere) <= 0 Then conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "utentilist.asp" End If Case "D": ' Delete If DeleteData(sDbWhere) Then Session("ewmsg") = "Cancellazione riuscita" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "utentilist.asp" End If End Select %>

Cancella da TABELLA: utenti

Torna alla lista

<% nRecCount = 0 i = 0 Do While i <= UBound(arRecKey) nRecCount = nRecCount + 1 ' Set row color sItemRowClass = " bgcolor=""#FFFFFF""" ' Display alternate color for rows If nRecCount Mod 2 <> 0 Then sItemRowClass = " bgcolor=""#F5F5F5""" End If sRecKey = Trim(arRecKey(i+0)) x_IDutente = sRecKey If LoadData() Then %> > <% End If i = i + 1 Loop %>
ID elenco indirizzi Nome Cognome password nome per login livello e-mail
<% Response.Write x_IDutente %> <% Response.Write x_Nome %> <% Response.Write x_Cognome %> <% Response.Write x_password %> <% Response.Write x_login %> <% If (ewCurSec And ewAllowAdmin) = ewAllowAdmin Then ' System admin %> <% If Not IsNull(x_livello) Then sSqlWrk = "SELECT [livello] FROM [utenti]" sTmp = x_livello sSqlWrk = sSqlWrk & " WHERE [livello] = " & AdjustSql(sTmp) & "" Set rswrk = conn.Execute(sSqlWrk) If Not rswrk.Eof Then sTmp = rswrk("livello") End If rswrk.Close Set rswrk = Nothing Else sTmp = Null End If ox_livello = x_livello ' Backup Original Value x_livello = sTmp %> <% Response.Write x_livello %> <% x_livello = ox_livello ' Restore Original Value %> <% Else %> ******** <% End If %> <% Response.Write x_email %>

<% conn.Close ' Close Connection Set conn = Nothing %> <% '------------------------------------------------------------------------------- ' Function LoadData ' - Load Data based on Key Value ' - Variables setup: field variables Function LoadData() Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sSql = "SELECT * FROM [utenti]" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" If sWhere <> "" Then sWhere = sWhere & " AND " sWhere = sWhere & "([IDutente] = " & AdjustSql(x_IDutente) & ")" sSql = sSql & " WHERE " & sWhere If Session("lapinsitter_status_UserID") <> -1 And Session("lapinsitter_status_UserID") <> "" Then ' Non system admin sSql = sSql & " AND ([IDutente] = " & Session("lapinsitter_status_UserID") & ")" End If If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadData = False Else LoadData = True rs.MoveFirst ' Get the field contents x_IDutente = rs("IDutente") x_Nome = rs("Nome") x_Cognome = rs("Cognome") x_password = rs("password") x_login = rs("login") x_livello = rs("livello") x_email = rs("email") End If rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function LoadRecordCount ' - Load Record Count based on input sql criteria sqlKey Function LoadRecordCount(sqlKey) Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sSql = "SELECT * FROM [utenti]" sSql = sSql & " WHERE " & sqlKey sGroupBy = "" sHaving = "" sOrderBy = "" If Session("lapinsitter_status_UserID") <> -1 And Session("lapinsitter_status_UserID") <> "" Then ' Non system admin sSql = sSql & " AND ([IDutente] = " & Session("lapinsitter_status_UserID") & ")" End If If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 LoadRecordCount = rs.RecordCount rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function DeleteData ' - Delete Records based on input sql criteria sqlKey Function DeleteData(sqlKey) Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sSql = "SELECT * FROM [utenti]" sSql = sSql & " WHERE " & sqlKey sGroupBy = "" sHaving = "" sOrderBy = "" If Session("lapinsitter_status_UserID") <> -1 And Session("lapinsitter_status_UserID") <> "" Then ' Non system admin sSql = sSql & " AND ([IDutente] = " & Session("lapinsitter_status_UserID") & ")" End If If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 Do While Not rs.Eof rs.Delete rs.MoveNext Loop rs.Close Set rs = Nothing DeleteData = True End Function %>