home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
bombers.k12.ar.us
/
bombers.k12.ar.us.tar
/
bombers.k12.ar.us
/
survey_unconfigured
/
IPAddressListAction.asp
< prev
next >
Wrap
Text File
|
2006-10-25
|
6KB
|
160 lines
<!--#Include File="Include/Top_inc.asp"-->
<%
'***********************************************************************
' Application: SelectSurveyASP Advanced v8.1.11
' Author: Aaron Baril for ClassApps.com
' Page Description: This page saves all IP address ranges.
'
' COPYRIGHT NOTICE
'
' See attached Software License Agreement
'
' (c) Copyright 2002 - 2006 by ClassApps.com. All rights reserved.
'***********************************************************************
%>
<!--#Include File="Include/Config_inc.asp"-->
<!--#Include File="Include/Utility_inc.asp"-->
<!--#Include File="Include/adovbs_inc.asp"-->
<!--#Include File="Include/ID_inc.asp"-->
<!--#Include File="Include/CurrentUser_inc.asp"-->
<!--#Include File="Include/SurveySecurity_inc.asp"-->
<!--#Include File="Include/Constants_inc.asp"-->
<!--#Include File="Include/Collection_inc.asp"-->
<%
Dim strSQL
Dim conIPAddress
Dim rsIPAddressList
Dim lngSurveyID
Dim lngIPAddressID
Dim strRedirectPage
Dim strIPAddressFirst
Dim strIPAddressSecond
'Initialization
Set rsIPAddressList = Server.CreateObject("ADODB.Recordset")
Set conIPAddress = Server.CreateObject("ADODB.Connection")
conIPAddress.Open SURVEY_APP_CONNECTION
lngSurveyID = Request.Form("SurveyID")
'If the user clicked the "Delete" button, delete the IP address
If Request.Form("ActionAfterSave") = SUR_IP_ADDRESS_ACTION_DELETE Then
DeleteIPAddress Request.Form("IPAddressID")
End If
'Select a list of all of the IP address ID's for this user for this survey
strSQL = "SELECT ip_address_id " & _
"FROM sur_ip_address " & _
"WHERE survey_id = " & lngSurveyID & _
" ORDER BY ip_address_first, ip_address_second"
rsIPAddressList.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
'Make sure that there are items for this survey
If Not rsIPAddressList.EOF Then
rsIPAddressList.MoveFirst
'Loop through the IP Address and save each one
Do While Not rsIPAddressList.EOF
'Preserve the current IP address ID in a variable because it is used many times in this section
lngIPAddressID = rsIPAddressList("ip_address_id")
'Initialize the variables for each update
strIPAddressFirst = Request.Form("txtIPAddressFirst" & CStr(lngIPAddressID))
strIPAddressSecond = Request.Form("txtIPAddressSecond" & CStr(lngIPAddressID))
'Update the IP address
strSQL = "UPDATE sur_ip_address SET " & _
"ip_address_first = " & SQLEncode(strIPAddressFirst) & ", " & _
"ip_address_second = " & SQLEncode(strIPAddressSecond) & _
" WHERE ip_address_id = " & lngIPAddressID
conIPAddress.Execute ConvertSQL(strSQL), , adCmdText
'Move to the next IP address
rsIPAddressList.MoveNext
Loop
End If
'Clean up
rsIPAddressList.Close
conIPAddress.Close
Set rsIPAddressList = Nothing
Set conIPAddress = Nothing
'If the user clicked the "Insert New" button, add a new IP address
If Request.Form("ActionAfterSave") = SUR_IP_ADDRESS_ACTION_INSERT Then
InsertIPAddress lngSurveyID
strRedirectPage = "IPAddressList"
ElseIf Request.Form("ActionAfterSave") = SUR_IP_ADDRESS_ACTION_DELETE Then
'If the user clicked the "Delete" button, redirect back to the list of IP Address
strRedirectPage = "IPAddressList"
Else
strRedirectPage = "Survey"
End If
'Redirect back to the appropriate page
Response.Redirect strRedirectPage & ".asp?SurveyID=" & lngSurveyID & "&SurveyName=" & Request.Form("SurveyName")
'*****************************************************************************************
' Name: DeleteIPAddress
' Purpose: Deletes an existing IP address range
'
' Arguments: lngIPAddressID -- The ID of the IP address range to delete
'
' Notes:
'*****************************************************************************************
Sub DeleteIPAddress(lngIPAddressID)
Dim strSQL
Dim conDelete
'Initialization
Set conDelete = Server.CreateObject("ADODB.Connection")
conDelete.Open SURVEY_APP_CONNECTION
'Delete the IP address from the IP address table (SUR_IP_ADDRESS)
strSQL = "DELETE FROM sur_ip_address " & _
"WHERE ip_address_id = " & lngIPAddressID
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Clean up
conDelete.Close
Set conDelete = Nothing
End Sub
'*****************************************************************************************
' Name: InsertIPAddress
' Purpose: Inserts a new IP address range for the specified survey
'
' Arguments: lngSurveyID -- The ID of the survey that should have a new IP address range added to it
'
' Notes: Note that this routine writes the new IP address to the database, and
' sets all of the default values.
'*****************************************************************************************
Sub InsertIPAddress(lngSurveyID)
Dim strSQL
Dim conInsertIPAddress
Dim lngIPAddressID
'Initialization
Set conInsertIPAddress = Server.CreateObject("ADODB.Connection")
conInsertIPAddress.Open SURVEY_APP_CONNECTION
'Get the ID for a new IP address
lngIPAddressID = ID_GetNextAvailableID("SurveyGenerationIPAddress")
'Insert the new IP address into the database
strSQL = "INSERT INTO sur_ip_address(ip_address_id, survey_id, ip_address_first, ip_address_second) " & _
"VALUES(" & _
lngIPAddressID & ", " & _
lngSurveyID & ", " & _
"'1.1.1.1', '255.255.255.255')"
conInsertIPAddress.Execute ConvertSQL(strSQL), , adCmdText
'Clean up
conInsertIPAddress.Close
Set conInsertIPAddress = Nothing
End Sub
%>