Added State and City to IP Geolocation API

This commit is contained in:
brotoskyj
2024-12-30 23:30:22 -05:00
parent 7af15f39d6
commit 0be48fb9d9
+7 -19
View File
@@ -1317,12 +1317,12 @@ $Form1.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$Form1.MaximizeBox = $false $Form1.MaximizeBox = $false
$Form1.Name = "Form1" $Form1.Name = "Form1"
$Form1.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterParent $Form1.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterParent
$Form1.Text = "CHAMP - 20241231" $Form1.Text = "CHAMP - 2024.09.01"
Function preflight () { Function preflight () {
$preflightCounter = [int] 0 $preflightCounter = [int] 0
$preflightDependancies = "" $preflightDependancies = ""
Write-Host "Running Pre-Flight checks...`n" Write-Host "Running Pre-Flight checks...`n"
$currentVersion = "20241231" $currentVersion = "2024.09.01"
$version = Invoke-WebRequest -URI https://git.racooncity.org/brotoskyj/CHAMP/raw/branch/master/version.txt | Select-Object -ExpandProperty Content $version = Invoke-WebRequest -URI https://git.racooncity.org/brotoskyj/CHAMP/raw/branch/master/version.txt | Select-Object -ExpandProperty Content
Write-Host "Version Check:" Write-Host "Version Check:"
Write-Host "Local Version: $currentVersion" Write-Host "Local Version: $currentVersion"
@@ -1348,7 +1348,7 @@ Function preflight () {
$preflightCounter++ $preflightCounter++
} }
Start-Sleep 1 Start-Sleep 1
if ( $preflightCounter -eq 2 ) { if ( $preflightCounter -eq 1 ) {
Write-Host -ForegroundColor "Green" "Pre-Flight Checks are a go... Launching CHAMP" Write-Host -ForegroundColor "Green" "Pre-Flight Checks are a go... Launching CHAMP"
Start-Sleep 1 Start-Sleep 1
$devFlag = 0 $devFlag = 0
@@ -2177,19 +2177,7 @@ function geoLocationForm() {
$countryTextBox.Location = New-Object System.Drawing.Point(275, 60) $countryTextBox.Location = New-Object System.Drawing.Point(275, 60)
$countryTextLabel = New-Object System.Windows.Forms.Label $countryTextLabel = New-Object System.Windows.Forms.Label
$countryTextLabel.Text = "Country: " $countryTextLabel.Text = "Country: "
$countryTextLabel.Location = New-Object System.Drawing.Point(225, 60) $countryTextLabel.Location = New-Object System.Drawing.Size(225, 60)
$stateTextBox = New-Object System.Windows.Forms.TextBox
$stateTextBox.Size = New-Object System.Drawing.Size(165, 35)
$stateTextBox.Location = New-Object System.Drawing.Point(275,100)
$stateTextLabel = New-Object System.Windows.Forms.Label
$stateTextLabel.Text = "State:"
$stateTextLabel.Location = New-Object System.Drawing.Point(225, 100)
$cityTextBox = New-Object System.Windows.Forms.TextBox
$cityTextBox.Size = New-Object System.Drawing.Size(165, 35)
$cityTextBox.Location = New-Object System.Drawing.Point(275,140)
$cityTextLabel = New-Object System.Windows.Forms.Label
$cityTextLabel.Text = "City:"
$cityTextLabel.Location = New-Object System.Drawing.Point(225, 140)
$ipLocationSearchButton = New-Object System.Windows.Forms.Button $ipLocationSearchButton = New-Object System.Windows.Forms.Button
$ipLocationSearchButton.Size = New-Object System.Drawing.Size(50, 23) $ipLocationSearchButton.Size = New-Object System.Drawing.Size(50, 23)
$ipLocationSearchButton.Location = New-Object System.Drawing.Size(10, 75) $ipLocationSearchButton.Location = New-Object System.Drawing.Size(10, 75)
@@ -2222,9 +2210,9 @@ function geoLocationForm() {
$ispTextBox.Clear() $ispTextBox.Clear()
$countryTextBox.Clear() $countryTextBox.Clear()
$ipToSearch = $ipSearchBox.Text $ipToSearch = $ipSearchBox.Text
$response = Invoke-RestMethod -Method GET -URI "https://api.iplocation.net/?ip=$ipToSearch" $response = Invoke-RestMethod -Method GET -URI "http://ip-api.com/json/$ipToSearch"
$ispTextBox.Text = $response.ISP $ispTextBox.Text = $response.isp
$countryTextBox.Text = $response.Country_Name $countryTextBox.Text = $response.country
} }
$geoLocationFormBox.ShowDialog() $geoLocationFormBox.ShowDialog()