Imports System.Net
Imports CharterDotCom.CommonEntities.Library

Partial Class Order_CPAbuseReporting
    Inherits CharterCMSPage

    Protected Sub btnSubmit1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit1.Click
        Dim sb As New StringBuilder
        Dim encoding As New System.Text.ASCIIEncoding


        sb.Append("ai=6258&di=23342" & _
                "&fromaddr=" & "CharterDotCom@Chartercom.com" & _
                "&subject=Child_Pornography_Reporting" & _
                "&mailmessagetext=") '& "ddlCountry-" & Server.UrlEncode(ddlCountry.SelectedValue.ToString() & "<BR/>ddlIncedentDayOfWeek-" & Server.UrlEncode(ddlIncedentDayOfWeek.SelectedValue.ToString() & "<BR/>ddlIncidentLocationCountry-" & Server.UrlEncode(ddlIncidentLocationCountry.SelectedValue.ToString() & "<BR/>ddlIncidentLocationReportedLawEnforcement-" & Server.UrlEncode(ddlIncidentLocationReportedLawEnforcement.SelectedValue.ToString() & "<BR/>ddlIncidentLocationReportedNCMEC-" & Server.UrlEncode(ddlIncidentLocationReportedNCMEC.SelectedValue.ToString() & "<BR/>ddlIncidentLocationState-" & Server.UrlEncode(ddlIncidentLocationState.SelectedValue.ToString() & "<BR/>ddlIncidentLocationState-" & Server.UrlEncode(ddlIncidentLocationState.SelectedValue.ToString() & "<BR/>ddlIncidentTimeHour-" & Server.UrlEncode(ddlIncidentTimeHour.SelectedValue.ToString() & "<BR/>ddlIncidentTimeMinte-" & Server.UrlEncode(ddlIncidentTimeMinte.SelectedValue.ToString() & "<BR/>ddlIncidentTimeOfDay-" & Server.UrlEncode(ddlIncidentTimeOfDay.SelectedValue.ToString() & "<BR/>ddlIncidentTimeZone-" & Server.UrlEncode(ddlIncidentTimeZone.SelectedValue.ToString() & "<BR/>ddlIncidentYear-" & Server.UrlEncode(ddlIncidentYear.SelectedValue.ToString() & "<BR/>ddlIncidentMonth-" & Server.UrlEncode(ddlIncidentMonth.SelectedValue.ToString() & "<BR/>ddlIncidentType-" & Server.UrlEncode(ddlIncidentType.SelectedValue.ToString() & "<BR/>ddlIncidentInformationInternetLocation-" & Server.UrlEncode(ddlIncidentInformationInternetLocation.SelectedValue.ToString() & "<BR/>ddlState-" & Server.UrlEncode(ddlState.SelectedValue.ToString() & "<BR/>txtAdditionalInformation-" & Server.UrlEncode(txtAdditionalInformation.Text.ToString() & "<br/>txtChatroom-" & Server.UrlEncode(txtChatroom.Text.ToString() & "<br/>txtCity-" & Server.UrlEncode(txtCity.Text.ToString() & "<br/>txtEmailNewsgroupHeader-" & Server.UrlEncode(txtEmailNewsgroupHeader.Text.ToString() & "<br/>txtFirstName-" & Server.UrlEncode(txtFirstName.Text.ToString() & "<br/>txtFServeTrigger-" & Server.UrlEncode(txtFServeTrigger.Text.ToString() & "<br/>txtFTPLogin-" & Server.UrlEncode(txtFTPLogin.Text.ToString() & "<br/>txtFTPPassword-" & Server.UrlEncode(txtFTPPassword.Text.ToString() & "<br/>txtIncidentCity-" & Server.UrlEncode(txtIncidentCity.Text.ToString() & "<br/>txtIRCChannelName-" & Server.UrlEncode(txtIRCChannelName.Text.ToString() & "<br/>txtIRCServerName-" & Server.UrlEncode(txtIRCServerName.Text.ToString() & "<br/>txtLastName-" & Server.UrlEncode(txtLastName.Text.ToString() & "<br/>txtOfficerName-" & Server.UrlEncode(txtOfficerName.Text.ToString() & "<br/>txtOfficerTelephone-" & Server.UrlEncode(txtOfficerTelephone.Text.ToString() & "<br/>txtReporterCallbackTime-" & Server.UrlEncode(txtReporterCallbackTime.Text.ToString() & "<br/>txtReporterContactPhoneNumber-" & Server.UrlEncode(txtReporterContactPhoneNumber.Text.ToString() & "<br/>txtReporterEmailAddress-" & Server.UrlEncode(txtReporterEmailAddress.Text.ToString() & "<br/>txtReporterPostalCode-" & Server.UrlEncode(txtReporterPostalCode.Text.ToString() & "<br/>txtReporterRelationshipToChild-" & Server.UrlEncode(txtReporterRelationshipToChild.Text.ToString() & "<br/>txtSiteURL-" & Server.UrlEncode(txtSiteURL.Text.ToString() & "<br/>txtStreetAddress-" & Server.UrlEncode(txtStreetAddress.Text.ToString() & "<br/>txtAdditionalInformation-" & Server.UrlEncode(txtAdditionalInformation.Text.ToString()))

        If txtReporterEmailAddress.Text.ToString().Trim() <> "" Then
            sb.Append("txtReporterEmailAddress-" & Server.UrlEncode(txtReporterEmailAddress.Text.ToString()) & vbCrLf)
        End If
        If txtFirstName.Text.ToString().Trim() <> "" Then
            sb.Append("txtFirstName-" & Server.UrlEncode(txtFirstName.Text.ToString()) & vbCrLf)
        End If
        If txtLastName.Text.ToString().Trim() <> "" Then
            sb.Append("txtLastName-" & Server.UrlEncode(txtLastName.Text.ToString()) & vbCrLf)
        End If
        If txtStreetAddress.Text.ToString().Trim() <> "" Then
            sb.Append("txtStreetAddress-" & Server.UrlEncode(txtStreetAddress.Text.ToString()) & vbCrLf)
        End If
        If txtCity.Text.ToString().Trim() <> "" Then
            sb.Append("txtCity-" & Server.UrlEncode(txtCity.Text.ToString()) & vbCrLf)
        End If
        If ddlState.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlState-" & Server.UrlEncode(ddlState.SelectedValue.ToString()) & vbCrLf)
        End If
        If txtReporterPostalCode.Text.ToString().Trim() <> "" Then
            sb.Append("txtReporterPostalCode-" & Server.UrlEncode(txtReporterPostalCode.Text.ToString()) & vbCrLf)
        End If
        If ddlIncidentLocationCountry.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentLocationCountry-" & Server.UrlEncode(ddlIncidentLocationCountry.SelectedValue.ToString()) & vbCrLf)
        End If
        If txtReporterContactPhoneNumber.Text.ToString().Trim() <> "" Then
            sb.Append("txtReporterContactPhoneNumber-" & Server.UrlEncode(txtReporterContactPhoneNumber.Text.ToString()) & vbCrLf)
        End If
        If txtReporterCallbackTime.Text.ToString().Trim() <> "" Then
            sb.Append("txtReporterCallbackTime-" & Server.UrlEncode(txtReporterCallbackTime.Text.ToString()) & vbCrLf)
        End If
        If txtReporterEmailAddress.Text.ToString().Trim() <> "" Then
            sb.Append("txtReporterEmailAddress-" & Server.UrlEncode(txtReporterEmailAddress.Text.ToString()) & vbCrLf)
        End If
        If txtReporterRelationshipToChild.Text.ToString().Trim() <> "" Then
            sb.Append("txtReporterRelationshipToChild-" & Server.UrlEncode(txtReporterRelationshipToChild.Text.ToString()) & vbCrLf)
        End If
        If ddlIncidentMonth.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentMonth-" & Server.UrlEncode(ddlIncidentMonth.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncedentDay.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncedentDay-" & Server.UrlEncode(ddlIncedentDay.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentYear.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentYear-" & Server.UrlEncode(ddlIncidentYear.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentTimeHour.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentTimeHour-" & Server.UrlEncode(ddlIncidentTimeHour.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentTimeMinte.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentTimeMinte-" & Server.UrlEncode(ddlIncidentTimeMinte.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentTimeOfDay.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentTimeOfDay-" & Server.UrlEncode(ddlIncidentTimeOfDay.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentTimeZone.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentTimeZone-" & Server.UrlEncode(ddlIncidentTimeZone.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentType.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentType-" & Server.UrlEncode(ddlIncidentType.SelectedValue.ToString()) & vbCrLf)
        End If
        If txtIncidentCity.Text.ToString().Trim() <> "" Then
            sb.Append("txtIncidentCity-" & Server.UrlEncode(txtIncidentCity.Text.ToString()) & vbCrLf)
        End If
        If ddlIncidentLocationState.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentLocationState-" & Server.UrlEncode(ddlIncidentLocationState.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentInformationInternetLocation.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentInformationInternetLocation-" & Server.UrlEncode(ddlIncidentInformationInternetLocation.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlCountry.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlCountry-" & Server.UrlEncode(ddlCountry.SelectedValue.ToString()) & vbCrLf)
        End If
        If txtSiteURL.Text.ToString().Trim() <> "" Then
            sb.Append("txtSiteURL-" & Server.UrlEncode(txtSiteURL.Text.ToString()) & vbCrLf)
        End If
        If txtChatroom.Text.ToString().Trim() <> "" Then
            sb.Append("txtChatroom-" & Server.UrlEncode(txtChatroom.Text.ToString()) & vbCrLf)
        End If
        If txtIRCChannelName.Text.ToString().Trim() <> "" Then
            sb.Append("txtIRCChannelName-" & Server.UrlEncode(txtIRCChannelName.Text.ToString()) & vbCrLf)
        End If
        If txtIRCServerName.Text.ToString().Trim() <> "" Then
            sb.Append("txtIRCServerName-" & Server.UrlEncode(txtIRCServerName.Text.ToString()) & vbCrLf)
        End If
        If txtFServeTrigger.Text.ToString().Trim() <> "" Then
            sb.Append("txtFServeTrigger-" & Server.UrlEncode(txtFServeTrigger.Text.ToString()) & vbCrLf)
        End If
        If txtFTPLogin.Text.ToString().Trim() <> "" Then
            sb.Append("txtFTPLogin-" & Server.UrlEncode(txtFTPLogin.Text.ToString()) & vbCrLf)
        End If
        If txtFTPPassword.Text.ToString().Trim() <> "" Then
            sb.Append("txtFTPPassword-" & Server.UrlEncode(txtFTPPassword.Text.ToString()) & vbCrLf)
        End If
        If txtEmailNewsgroupHeader.Text.ToString().Trim() <> "" Then
            sb.Append("txtEmailNewsgroupHeader-" & Server.UrlEncode(txtEmailNewsgroupHeader.Text.ToString()) & vbCrLf)
        End If
        If ddlIncidentLocationReportedNCMEC.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentLocationReportedNCMEC-" & Server.UrlEncode(ddlIncidentLocationReportedNCMEC.SelectedValue.ToString()) & vbCrLf)
        End If
        If ddlIncidentLocationReportedLawEnforcement.SelectedValue.ToString().Trim() <> "" Then
            sb.Append("ddlIncidentLocationReportedLawEnforcement-" & Server.UrlEncode(ddlIncidentLocationReportedLawEnforcement.SelectedValue.ToString()) & vbCrLf)
        End If
        If txtOfficerName.Text.ToString().Trim() <> "" Then
            sb.Append("txtOfficerName-" & Server.UrlEncode(txtOfficerName.Text.ToString()) & vbCrLf)
        End If
        If txtOfficerTelephone.Text.ToString().Trim() <> "" Then
            sb.Append("txtOfficerTelephone-" & Server.UrlEncode(txtOfficerTelephone.Text.ToString()) & vbCrLf)
        End If
        If txtAdditionalInformation.Text.ToString().Trim() <> "" Then
            sb.Append("txtAdditionalInformation-" & Server.UrlEncode(txtAdditionalInformation.Text.ToString()) & vbCrLf)
        End If





























 





    



        Dim data As Byte() = encoding.GetBytes(sb.ToString)

        Dim MyRequest As System.Net.HttpWebRequest = HttpWebRequest.Create("https://admin.instantservice.com/servlet/MailMessagePost")
        MyRequest.Method = "POST"
        MyRequest.ContentType = "application/x-www-form-urlencoded"
        MyRequest.ContentLength = data.Length

        Dim newstream As System.IO.Stream = MyRequest.GetRequestStream
        newstream.Write(data, 0, data.Length)
        newstream.Close()

        Dim myResponse As WebResponse
        Dim strResponse As System.IO.Stream
        Dim strResult As String
        myResponse = MyRequest.GetResponse

        With myResponse
            '-- read the response into byte array 
            Dim strArr(100) As Byte
            strResponse = myResponse.GetResponseStream
            strResponse.Read(strArr, 0, strArr.Length)
            strResponse.Close()

            '-- convert response to string 
            strResult = encoding.GetString(strArr).Trim
            '-- parse response 

        End With

        Try
            'SEND EMAIL HERE
            Dim iMail As ISupportProvider = CType(Activator.GetObject(GetType(ISupportProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_SupportProvider"))), ISupportProvider)
            ' issue 17858 
            ' use config setting for From-Address in this form's email
            iMail.SendEMail(Application("CPREPORTING_FROM_EMAILADDRESS"), Application("CPREPORTING_EMAILADDRESS"), "Child Pornography Reporting has a message in queue 23342", "Child Pornography Reporting has a message in queue 23342", True)
        Catch ex As Exception
            '
        End Try



        If InStr(strResult, "100") > 0 Then
            ' success!
            pnlThankyou.Visible = True
            pnlMainForm.Visible = False
        Else
            ' fail!
            Page.Validators(0).ErrorMessage = "We were unable to process your request at this time. Please try back later. IS:" & strResult
            Page.Validators(0).IsValid = False
        End If
    End Sub

    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        Response.Redirect("CPAbuseReporting.aspx")
    End Sub
End Class
