<%@ 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 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 %> <% sExport = Request.QueryString("export") ' Load Export Request If sExport = "excel" Then Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment; filename=utenti.xls" End If If sExport = "word" Then Response.ContentType = "application/vnd.ms-word" Response.AddHeader "Content-Disposition:", "attachment; filename=utenti.doc" End If %> <% nStartRec = 0 nStopRec = 0 nTotalRecs = 0 nRecCount = 0 nRecActual = 0 sDbWhereMaster = "" sDbWhereDetail = "" sSrchAdvanced = "" sSrchBasic = "" sSrchWhere = "" sDbWhere = "" sDefaultOrderBy = "" sDefaultFilter = "" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" sSqlMasterBase = "" sSqlMaster = "" nDisplayRecs = 20 nRecRange = 10 ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str ' Handle Reset Command ResetCmd() ' Get Search Criteria for Basic Search SetUpBasicSearch() ' Build Search Criteria If sSrchAdvanced <> "" Then sSrchWhere = sSrchAdvanced ' Advanced Search ElseIf sSrchBasic <> "" Then sSrchWhere = sSrchBasic ' Basic Search End If ' Save Search Criteria If sSrchWhere <> "" Then Session("utenti_searchwhere") = sSrchWhere ' Reset start record counter (new search) nStartRec = 1 Session("utenti_REC") = nStartRec Else sSrchWhere = Session("utenti_searchwhere") End If ' Build SQL sSql = "SELECT * FROM [utenti]" ' Load Default Filter sDefaultFilter = "" sGroupBy = "" sHaving = "" ' Load Default Order sDefaultOrderBy = "" ' Build WHERE condition sDbWhere = "" If (ewCurSec And ewAllowList) <> ewAllowList Then sDbWhere = sDbWhere & "(0=1) AND " End If If Session("lapinsitter_status_UserID") <> -1 And Session("lapinsitter_status_UserID") <> "" Then ' Non system admin sDbWhere = sDbWhere & "([IDutente] = " & Session("lapinsitter_status_UserID") & ") AND " End If If sDbWhereDetail <> "" Then sDbWhere = sDbWhere & "(" & sDbWhereDetail & ") AND " End If If sSrchWhere <> "" Then sDbWhere = sDbWhere & "(" & sSrchWhere & ") AND " End If If Len(sDbWhere) > 5 Then sDbWhere = Mid(sDbWhere, 1, Len(sDbWhere)-5) ' Trim rightmost AND End If sWhere = "" If sDefaultFilter <> "" Then sWhere = sWhere & "(" & sDefaultFilter & ") AND " End If If sDbWhere <> "" Then sWhere = sWhere & "(" & sDbWhere & ") AND " End If If Right(sWhere, 5) = " AND " Then sWhere = Left(sWhere, Len(sWhere)-5) If sWhere <> "" Then sSql = sSql & " WHERE " & sWhere End If If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If ' Set Up Sorting Order sOrderBy = "" SetUpSortOrder() If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If 'Response.Write sSql ' Uncomment to show SQL for debugging %> <% If sExport <> "word" And sExport <> "excel" Then %> <% End If %> <% ' Set up Record Set Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 nTotalRecs = rs.RecordCount If nDisplayRecs <= 0 Then ' Display All Records nDisplayRecs = nTotalRecs End If nStartRec = 1 SetUpStartRec() ' Set Up Start Record Position %>

TABELLA: utenti <% If sExport = "" Then %>   Esporta in Excel   Esporta in Word <% End If %>

<% If sExport = "" Then %>
   Tutti i Record  
Frase esatta  Tutte le parole  Ogni parola
<% End If %> <% If (ewCurSec And ewAllowAdd) = ewAllowAdd Then %> <% If sExport = "" Then %>
Aggiungi

<% End If %> <% End If %> <% If Session("ewmsg") <> "" Then %>

<%= Session("ewmsg") %>

<% Session("ewmsg") = "" ' Clear message End If %> <% If sExport = "" Then %>
<% ' Display page numbers If nTotalRecs > 0 Then rsEof = (nTotalRecs < (nStartRec + nDisplayRecs)) If CLng(nTotalRecs) > CLng(nDisplayRecs) Then ' Find out if there should be Backward or Forward Buttons on the TABLE. If nStartRec = 1 Then isPrev = False Else isPrev = True PrevStart = nStartRec - nDisplayRecs If PrevStart < 1 Then PrevStart = 1 %> Prev <% End If If (isPrev Or (Not rsEof)) Then x = 1 y = 1 dx1 = ((nStartRec-1)\(nDisplayRecs*nRecRange))*nDisplayRecs*nRecRange+1 dy1 = ((nStartRec-1)\(nDisplayRecs*nRecRange))*nRecRange+1 If (dx1+nDisplayRecs*nRecRange-1) > nTotalRecs Then dx2 = (nTotalRecs\nDisplayRecs)*nDisplayRecs+1 dy2 = (nTotalRecs\nDisplayRecs)+1 Else dx2 = dx1+nDisplayRecs*nRecRange-1 dy2 = dy1+nRecRange-1 End If While x <= nTotalRecs If x >= dx1 And x <= dx2 Then If CLng(nStartRec) = CLng(x) Then %> <%=y%> <% Else %> <%=y%> <% End If x = x + nDisplayRecs y = y + 1 ElseIf x >= (dx1-nDisplayRecs*nRecRange) And x <= (dx2+nDisplayRecs*nRecRange) Then If x+nRecRange*nDisplayRecs < nTotalRecs Then %> <%=y%>-<%=y+nRecRange-1%> <% Else ny=(nTotalRecs-1)\nDisplayRecs+1 If ny = y Then %> <%=y%> <% Else %> <%=y%>-<%=ny%> <% End If End If x=x+nRecRange*nDisplayRecs y=y+nRecRange Else x=x+nRecRange*nDisplayRecs y=y+nRecRange End If Wend End If ' Next link If NOT rsEof Then NextStart = nStartRec + nDisplayRecs isMore = True %> Avanti <% Else isMore = False End If %>
<% End If If CLng(nStartRec) > CLng(nTotalRecs) Then nStartRec = nTotalRecs nStopRec = nStartRec + nDisplayRecs - 1 nRecCount = nTotalRecs - 1 If rsEof Then nRecCount = nTotalRecs If nStopRec > nRecCount Then nStopRec = nRecCount %> Records <%= nStartRec %> a <%= nStopRec %> di <%= nTotalRecs %> <% Else %> <% If (ewCurSec And ewAllowList) = ewAllowList Then %> Nessun Record trovato <% Else %> Nessun Permesso <% End If %> <% End If %>
<% End If %> <% If nTotalRecs > 0 Then %>
<% If sExport = "" Then %> <% If (ewCurSec And ewAllowView) = ewAllowView Then %> <% End If %> <% If (ewCurSec And ewAllowEdit) = ewAllowEdit Then %> <% End If %> <% If (ewCurSec And ewAllowDelete) = ewAllowDelete Then %> <% End If %> <% End If %> <% ' Avoid starting record > total records If CLng(nStartRec) > CLng(nTotalRecs) Then nStartRec = nTotalRecs End If ' Set the last record to display nStopRec = nStartRec + nDisplayRecs - 1 ' Move to first record directly for performance reason nRecCount = nStartRec - 1 If Not rs.Eof Then rs.MoveFirst rs.Move nStartRec - 1 End If nRecActual = 0 Do While (Not rs.Eof) And (nRecCount < nStopRec) nRecCount = nRecCount + 1 If CLng(nRecCount) >= CLng(nStartRec) Then nRecActual = nRecActual + 1 ' Set row color sItemRowClass = " bgcolor=""#FFFFFF""" sListTrJs = " onmouseover='ew_mouseover(this);' onmouseout='ew_mouseout(this);' onclick='ew_click(this);'" ' Display alternate color for rows If nRecCount Mod 2 <> 1 Then sItemRowClass = " bgcolor=""#F5F5F5""" End If 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") %> <%=sListTrJs%>> <% If sExport = "" Then %> <% If (ewCurSec And ewAllowView) = ewAllowView Then %> <% End If %> <% If (ewCurSec And ewAllowEdit) = ewAllowEdit Then %> <% End If %> <% If (ewCurSec And ewAllowDelete) = ewAllowDelete Then %> <% End If %> <% End If %> <% End If rs.MoveNext Loop %>
<% If sExport <> "" Then %> ID elenco indirizzi <% Else %> " class="lapinsitter" style="color: #FFFFFF;" onMouseDown="ewsort(event, this.href);">ID elenco indirizzi<% If Session("utenti_x_IDutente_Sort") = "ASC" Then %><% ElseIf Session("utenti_x_IDutente_Sort") = "DESC" Then %><% End If %> <% End If %> <% If sExport <> "" Then %> Nome <% Else %> " class="lapinsitter" style="color: #FFFFFF;" onMouseDown="ewsort(event, this.href);">Nome (*)<% If Session("utenti_x_Nome_Sort") = "ASC" Then %><% ElseIf Session("utenti_x_Nome_Sort") = "DESC" Then %><% End If %> <% End If %> <% If sExport <> "" Then %> Cognome <% Else %> " class="lapinsitter" style="color: #FFFFFF;" onMouseDown="ewsort(event, this.href);">Cognome (*)<% If Session("utenti_x_Cognome_Sort") = "ASC" Then %><% ElseIf Session("utenti_x_Cognome_Sort") = "DESC" Then %><% End If %> <% End If %> <% If sExport <> "" Then %> password <% Else %> " class="lapinsitter" style="color: #FFFFFF;" onMouseDown="ewsort(event, this.href);">password (*)<% If Session("utenti_x_password_Sort") = "ASC" Then %><% ElseIf Session("utenti_x_password_Sort") = "DESC" Then %><% End If %> <% End If %> <% If sExport <> "" Then %> nome per login <% Else %> " class="lapinsitter" style="color: #FFFFFF;" onMouseDown="ewsort(event, this.href);">nome per login (*)<% If Session("utenti_x_login_Sort") = "ASC" Then %><% ElseIf Session("utenti_x_login_Sort") = "DESC" Then %><% End If %> <% End If %> <% If sExport <> "" Then %> livello <% Else %> " class="lapinsitter" style="color: #FFFFFF;" onMouseDown="ewsort(event, this.href);">livello<% If Session("utenti_x_livello_Sort") = "ASC" Then %><% ElseIf Session("utenti_x_livello_Sort") = "DESC" Then %><% End If %> <% End If %> <% If sExport <> "" Then %> e-mail <% Else %> " class="lapinsitter" style="color: #FFFFFF;" onMouseDown="ewsort(event, this.href);">e-mail (*)<% If Session("utenti_x_email_Sort") = "ASC" Then %><% ElseIf Session("utenti_x_email_Sort") = "DESC" Then %><% End If %> <% End If %>    
<% 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 %> ">Vedi">Modifica">Cancella
<% End If %> <% ' Close recordset and connection rs.Close Set rs = Nothing conn.Close Set conn = Nothing %> <% If sExport <> "word" And sExport <> "excel" Then %> <% End If %> <% '------------------------------------------------------------------------------- ' Function BasicSearchSQL ' - Build WHERE clause for a keyword Function BasicSearchSQL(Keyword) Dim sKeyword sKeyword = AdjustSql(Keyword) BasicSearchSQL = "" BasicSearchSQL = BasicSearchSQL & "[Nome] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[Cognome] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[password] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[login] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[email] LIKE '%" & sKeyword & "%' OR " If Right(BasicSearchSQL, 4) = " OR " Then BasicSearchSQL = Left(BasicSearchSQL, Len(BasicSearchSQL)-4) End Function '------------------------------------------------------------------------------- ' Function SetUpBasicSearch ' - Set up Basic Search parameter based on form elements pSearch & pSearchType ' - Variables setup: sSrchBasic Sub SetUpBasicSearch() Dim sSearch, sSearchType, arKeyword, sKeyword sSearch = Request.QueryString("psearch") sSearchType = Request.QueryString("psearchType") If sSearch <> "" Then If sSearchType <> "" Then While InStr(sSearch, " ") > 0 sSearch = Replace(sSearch, " ", " ") Wend arKeyword = Split(Trim(sSearch), " ") For Each sKeyword In arKeyword sSrchBasic = sSrchBasic & "(" & BasicSearchSQL(sKeyword) & ") " & sSearchType & " " Next Else sSrchBasic = BasicSearchSQL(sSearch) End If End If If Right(sSrchBasic, 4) = " OR " Then sSrchBasic = Left(sSrchBasic, Len(sSrchBasic)-4) If Right(sSrchBasic, 5) = " AND " Then sSrchBasic = Left(sSrchBasic, Len(sSrchBasic)-5) End Sub '------------------------------------------------------------------------------- ' Function SetUpSortOrder ' - Set up Sort parameters based on Sort Links clicked ' - Variables setup: sOrderBy, Session("Table_OrderBy"), Session("Table_Field_Sort") Sub SetUpSortOrder() Dim sOrder, sSortField, sLastSort, sThisSort Dim bCtrl ' Check for Ctrl pressed If Request.QueryString("ctrl").Count > 0 Then bCtrl = True Else bCtrl = False End If ' Check for an Order parameter If Request.QueryString("order").Count > 0 Then sOrder = Request.QueryString("order") ' Field IDutente If sOrder = "IDutente" Then sSortField = "[IDutente]" sLastSort = Session("utenti_x_IDutente_Sort") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session("utenti_x_IDutente_Sort") = sThisSort Else If Not bCtrl And Session("utenti_x_IDutente_Sort") <> "" Then Session("utenti_x_IDutente_Sort") = "" End If ' Field Nome If sOrder = "Nome" Then sSortField = "[Nome]" sLastSort = Session("utenti_x_Nome_Sort") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session("utenti_x_Nome_Sort") = sThisSort Else If Not bCtrl And Session("utenti_x_Nome_Sort") <> "" Then Session("utenti_x_Nome_Sort") = "" End If ' Field Cognome If sOrder = "Cognome" Then sSortField = "[Cognome]" sLastSort = Session("utenti_x_Cognome_Sort") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session("utenti_x_Cognome_Sort") = sThisSort Else If Not bCtrl And Session("utenti_x_Cognome_Sort") <> "" Then Session("utenti_x_Cognome_Sort") = "" End If ' Field password If sOrder = "password" Then sSortField = "[password]" sLastSort = Session("utenti_x_password_Sort") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session("utenti_x_password_Sort") = sThisSort Else If Not bCtrl And Session("utenti_x_password_Sort") <> "" Then Session("utenti_x_password_Sort") = "" End If ' Field login If sOrder = "login" Then sSortField = "[login]" sLastSort = Session("utenti_x_login_Sort") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session("utenti_x_login_Sort") = sThisSort Else If Not bCtrl And Session("utenti_x_login_Sort") <> "" Then Session("utenti_x_login_Sort") = "" End If ' Field livello If sOrder = "livello" Then sSortField = "[livello]" sLastSort = Session("utenti_x_livello_Sort") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session("utenti_x_livello_Sort") = sThisSort Else If Not bCtrl And Session("utenti_x_livello_Sort") <> "" Then Session("utenti_x_livello_Sort") = "" End If ' Field email If sOrder = "email" Then sSortField = "[email]" sLastSort = Session("utenti_x_email_Sort") If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" Session("utenti_x_email_Sort") = sThisSort Else If Not bCtrl And Session("utenti_x_email_Sort") <> "" Then Session("utenti_x_email_Sort") = "" End If If bCtrl Then sOrderBy = Session("utenti_OrderBy") If InStr(sOrderBy, sSortField & " " & sLastSort) > 0 Then sOrderBy = Replace(sOrderBy, sSortField & " " & sLastSort, sSortField & " " & sThisSort) Else If sOrderBy <> "" Then sOrderBy = sOrderBy & ", " sOrderBy = sOrderBy & sSortField & " " & sThisSort End If Session("utenti_OrderBy") = sOrderBy Else Session("utenti_OrderBy") = sSortField & " " & sThisSort End If Session("utenti_REC") = 1 End If sOrderBy = Session("utenti_OrderBy") If sOrderBy = "" Then sOrderBy = sDefaultOrderBy Session("utenti_OrderBy") = sOrderBy End If End Sub '------------------------------------------------------------------------------- ' Function SetUpStartRec ' - Set up Starting Record parameters based on Pager Navigation ' - Variables setup: nStartRec Sub SetUpStartRec() Dim nPageNo ' Check for a START parameter If Request.QueryString("start").Count > 0 Then nStartRec = Request.QueryString("start") Session("utenti_REC") = nStartRec ElseIf Request.QueryString("pageno").Count > 0 Then nPageNo = Request.QueryString("pageno") If IsNumeric(nPageNo) Then nStartRec = (nPageNo-1)*nDisplayRecs+1 If nStartRec <= 0 Then nStartRec = 1 ElseIf nStartRec >= ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 Then nStartRec = ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1 End If Session("utenti_REC") = nStartRec Else nStartRec = Session("utenti_REC") If Not IsNumeric(nStartRec) Or nStartRec = "" Then nStartRec = 1 ' Reset start record counter Session("utenti_REC") = nStartRec End If End If Else nStartRec = Session("utenti_REC") If Not IsNumeric(nStartRec) Or nStartRec = "" Then nStartRec = 1 'Reset start record counter Session("utenti_REC") = nStartRec End If End If End Sub '------------------------------------------------------------------------------- ' Function ResetCmd ' - Clear list page parameters ' - RESET: reset search parameters ' - RESETALL: reset search & master/detail parameters ' - RESETSORT: reset sort parameters Sub ResetCmd() Dim sCmd ' Get Reset Cmd If Request.QueryString("cmd").Count > 0 Then sCmd = Request.QueryString("cmd") ' Reset Search Criteria If UCase(sCmd) = "RESET" Then sSrchWhere = "" Session("utenti_searchwhere") = sSrchWhere ' Reset Search Criteria & Session Keys ElseIf UCase(sCmd) = "RESETALL" Then sSrchWhere = "" Session("utenti_searchwhere") = sSrchWhere ' Reset Sort Criteria ElseIf UCase(sCmd) = "RESETSORT" Then sOrderBy = "" Session("utenti_OrderBy") = sOrderBy If Session("utenti_x_IDutente_Sort") <> "" Then Session("utenti_x_IDutente_Sort") = "" If Session("utenti_x_Nome_Sort") <> "" Then Session("utenti_x_Nome_Sort") = "" If Session("utenti_x_Cognome_Sort") <> "" Then Session("utenti_x_Cognome_Sort") = "" If Session("utenti_x_password_Sort") <> "" Then Session("utenti_x_password_Sort") = "" If Session("utenti_x_login_Sort") <> "" Then Session("utenti_x_login_Sort") = "" If Session("utenti_x_livello_Sort") <> "" Then Session("utenti_x_livello_Sort") = "" If Session("utenti_x_email_Sort") <> "" Then Session("utenti_x_email_Sort") = "" End If ' Reset Start Position (Reset Command) nStartRec = 1 Session("utenti_REC") = nStartRec End If End Sub %>