I have an app that is a long time in the making and has had a lot of excellent input from others on. It runs great on 64 bit machines, but breaks down on any of the 32 machines I've run it on.
The app is designed to log on to the OpenDNS website, and then pull the history of URL visits from my router. It then dumps this to a CSV file, then saves it to Excel after sorting and removing fluff.
Because testing this requires an OpenDNS account, it may be hard for you all to test. But I'm hoping someone can look at the code, and see if they see anything that would be different for 64 bit vs 32 bit machines.
It appears to get through the first call to GetUrlData (data = GetUrlData(URL & "/signin", "GET", "")), but then doesn't come up with any data on the second call (data = GetUrlData(URL & "/signin", "POST", "formtoken= " & token & "&username= " & strUser & "&password= " & strPW & "&sign_in_submi t=foo")). Therefore, I get the message "Please check your username and password.").
Here is the main sub...
And here is the GetUrlData Function...
The app is designed to log on to the OpenDNS website, and then pull the history of URL visits from my router. It then dumps this to a CSV file, then saves it to Excel after sorting and removing fluff.
Because testing this requires an OpenDNS account, it may be hard for you all to test. But I'm hoping someone can look at the code, and see if they see anything that would be different for 64 bit vs 32 bit machines.
It appears to get through the first call to GetUrlData (data = GetUrlData(URL & "/signin", "GET", "")), but then doesn't come up with any data on the second call (data = GetUrlData(URL & "/signin", "POST", "formtoken= " & token & "&username= " & strUser & "&password= " & strPW & "&sign_in_submi t=foo")). Therefore, I get the message "Please check your username and password.").
Here is the main sub...
Code:
Private Sub btnFetch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFetch.Click
My.Settings.Save()
btnFetch.Text = "Processing"
Dim strUser As String = txtUser.Text
Dim strNet As String = txtNetwork.Text
Dim strBDate As String = txtBDate.Text
Dim strEDate As String = txtEDate.Text
Dim strPW As String = RC4(txtPW.Text, strK)
Dim DateRange As String = strBDate & "to" & strEDate
Dim page As Integer = 1
Dim objWriter As New System.IO.StreamWriter(CurPath & "DNLD.csv", False)
Dim i As Integer = 1
data = GetUrlData(URL & "/signin", "GET", "")
MsgBox(i)
i = i + 1
Dim Matches As Match = Regex.Match(data, ".*name=""formtoken"" value=""([0-9a-f]*)"".*")
Dim token As String = Matches.Value.Substring(Matches.Value.IndexOf("formtoken") + 18)
token = token.Substring(0, token.IndexOf(Chr(34)))
data = GetUrlData(URL & "/signin", "POST", "formtoken=" & token & "&username=" & strUser & "&password=" & strPW & "&sign_in_submit=foo")
MsgBox(i)
i = i + 1
If Len(data) <> 0 Then
MsgBox("Please check your username and password.")
Me.btnFetch.Text = Nothing
Exit Sub
End If
Do While True
data = GetUrlData(URL & "/stats/" & strNet & "/topdomains/" & DateRange & "/page" & page & ".csv", "GET", "")
MsgBox(i)
If page = 1 Then
If Len(data) = 0 Then
MsgBox("Please check your network." & strNet & vbCrLf)
Me.btnFetch.Text = Nothing
Exit Sub
ElseIf InStr(data, "<!DOCTYPE") Then
MsgBox("Error retrieving data. Date range may be outside of available data.")
Me.btnFetch.Text = Nothing
Exit Sub
End If
Else
data = Mid(data, InStr(data, vbLf) + 1)
End If
If Len(Trim(data)) = 0 Then
Exit Do
End If
objWriter.WriteLine(data)
page = page + 1
i = i + 1
Loop
objWriter.Close()
Call ProcessExcel(CurPath)
'The Excel Module closes the application after finish.
End Sub
And here is the GetUrlData Function...
Code:
Private Function GetUrlData(ByVal strUrl, ByVal strMethod, ByVal strData)
objHTTP.Open(strMethod, strUrl)
If strMethod = "POST" Then
objHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
End If
objHTTP.Option(6) = False
objHTTP.Send(strData)
If Err.Number <> 0 Then
GetUrlData = "ERROR: " & Err.Description & vbCrLf & Err.Source & " (" & Err.Number & ")"
Else
GetUrlData = objHTTP.ResponseText
End If
End Function
Comment