Post: [VB.NET][CLASS] IP_API Fixed
04-03-2012, 02:09 PM #1
fill0botto95
You talkin to me?
(adsbygoogle = window.adsbygoogle || []).push({});
I noticed that our old IP_API.dll stopped working an year ago as the site where the info were grabbed is not longer accepting connections from vb.net integrated explorer. Maybe was just me but I decided to do the class again. I edited it a little. Whenever you want, you can change map type, map serching method etc...

Credits go to the creator, Coleak
I edited it and got it working Smile

Weird vB syntax error
|
\/

    
Imports System.Net
Public Class IP

    
Public Shared contents As String

Public Shared Function GetMap(ByVal width As Integer, ByVal height As Integer, ByVal zoom As Integer) As Object
Dim num As Integer = New Random().Next(1, &H3B9AC9FF)
Dim instance As New WebClient
Dim dati As Byte() = instance.DownloadData(String.Format("https://maps.googleapis.com/maps/api/staticmap?center={0},{1}&zoom={2}&size={3}x{4}&maptype=hybrid&sensor=false", IP.Latitude, IP.Longitude, zoom, width, height))
Return New Bitmap(New IO.MemoryStream(dati))
End Function

Public Shared Function City() As Object
Dim contents As String = IP.contents
Dim str2 As String = "City:</th><td>"
Dim str As String = "</td></tr>"
Dim str4 As String = Conversions.ToString(14)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function AreaCode() As Object
Dim contents As String = IP.contents
Dim str2 As String = "Area Code:</th><td>"
Dim str As String = "</td></tr>"
Dim str4 As String = Conversions.ToString(&H13)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function StateOrRegion() As Object
Dim contents As String = IP.contents
Dim str2 As String = "State/Region:</th><td>"
Dim str As String = "</td></tr>"
Dim str4 As String = Conversions.ToString(&H16)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Sub NewIP(ByVal ip As Object)
Dim uri As New Uri("https://whatismyipaddress.com/ip/" & ip)
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (FM Scene 4.6.1) "
request.Method = WebRequestMethods.Http.Get
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New IO.StreamReader(response.GetResponseStream())
Dim tmp As String = reader.ReadToEnd()
response.Close()
contents = tmp
End If
End Sub

Public Shared Function MyIP() As Object
Dim obj2 As Object
Dim client As New WebClient
Try
obj2 = client.DownloadString("https://www.coleak.com/ip")
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
Dim exception As Exception = exception1
obj2 = "Error in downloading MyIP string. Check your internet."
ProjectData.ClearProjectError()
End Try
Return obj2
End Function

Public Shared Function Longitude() As Object
Dim contents As String = IP.contents
Dim str2 As String = "Longitude:</th><td>"
Dim str As String = "</td></tr>"
Dim str4 As String = Conversions.ToString(&H13)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function Latitude() As Object
Dim contents As String = IP.contents
Dim str2 As String = "Latitude:</th><td>"
Dim str As String = "</td></tr>"
Dim str4 As String = Conversions.ToString(&H12)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function IPDecimal() As Object
If (IP.contents = "") Then
Return "NewIP function failed to gather IP info."
End If
Dim contents As String = IP.contents
Dim str2 As String = "Decimal:</th><td>"
Dim str As String = "</td></tr><tr><th>Hostname:"
Dim str4 As String = Conversions.ToString(&H11)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function IPType() As Object
Dim contents As String = IP.contents
Dim str2 As String = "Assignment:</th><td><a href='/dynamic-static'>"
Dim str As String = "</a></td></tr><tr><th>Blacklist:"
Dim str4 As String = Conversions.ToString(&H2E)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function InternetType() As Object
Dim contents As String = IP.contents
Dim str2 As String = "Type:</th><td><a href='/broadband'>"
Dim str As String = "</a></td></tr><tr><th>Assignment:"
Dim str4 As String = Conversions.ToString(&H23)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function InternetServiceProvider() As Object
Dim contents As String = IP.contents
Dim str2 As String = "ISP:</th><td>"
Dim str As String = "</td></tr><tr><th>Organization:"
Dim str4 As String = Conversions.ToString(13)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function Hostname() As Object
Dim contents As String = IP.contents
Dim str2 As String = "Hostname:</th><td>"
Dim str As String = "</td></tr><tr><th>ISP:"
Dim str4 As String = Conversions.ToString(&H12)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

Public Shared Function Country() As Object
Dim contents As String = IP.contents
Dim str2 As String = "Country:</th><td>"
Dim str As String = "<img src="
Dim str4 As String = Conversions.ToString(&H11)
If String.IsNullOrEmpty(contents) Then
Return String.Empty
End If
If Not contents.Contains(str2) Then
Return "Error parsing."
End If
Dim str6 As String = contents.Substring(CInt(Math.Round(CDbl((contents.IndexOf(str2) + Conversions.ToDouble(str4))
If (str6.Contains(str) AndAlso Not String.IsNullOrEmpty(str)) Then
str6 = str6.Substring(0, str6.IndexOf(str))
End If
Return str6
End Function

[LEFT]End Class[/LEFT]

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo