i am making a program that i need to make sure people cant access the staff area
so here is the sauce =) *spelled sauce on purpose*
[php]
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Label5.Text = GetExternalIP()
If IsConnectionAvailable() = False Then
MsgBox("Please connect to the internet before using this program.", 0 + 16, "Error")
Exit Sub
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim url As String
'this gets the founders ip from the server
url = "http://Yoursite.com/iplist.dat"
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream( ), System.Text.Encoding.GetEncoding("windows-1252"))
Dim Online As String
Online = sr.ReadToEnd()
'textbox3.text is invisable
TextBox3.Text = GetExternalIP()
If Online = TextBox3.Text And TextBox1.Text = My.Settings.user And TextBox2.Text = My.Settings.pass Then
MsgBox("Founder version")
'Show like admincp and normal options
Me.Hide()
Else
MsgBox("User version")
'show normal options or u can make it say "please use guest account" and have a button for guest that only loads normal
End
End If
End Sub
Private Function IsConnectionAvailable() As Boolean
' makes sure we have internetz before we go any farther
Dim url As New System.Uri("http://www.google.com/")
Dim req As System.Net.WebRequest
req = System.Net.WebRequest.Create(url)
Dim resp As System.Net.WebResponse
Try
resp = req.GetResponse()
resp.Close()
req = Nothing
Return True
Catch ex As Exception
req = Nothing
Return False
End Try
End Function
Public Function GetExternalIP() As String
' this is a weird method i found thanks to google, it's not my real ip but it works if u like to use it
' make sure you go to http://whatismyip.com/automation/n09230945.asp and get you ip for the .dat file
Try
Dim WC As New System.Net.WebClient
Dim ipStr As String = System.Text.Encoding.ASCII.GetString(WC.DownloadDa ta("http://whatismyip.com/automation/n09230945.asp"))
WC.Dispose()
Return (ipStr)
Catch
Return ("Error")
End Try
End Function
End Class
[/php]
basically it gets the ip from the website and hides it in textbox3 then makes sure its the one in the .dat file then makes sure it has the user name and pass, in Future release i will make the server sided also this is just a very simple release
Hope you have fun and flamers do your flamin ~ Chris
btw this was thought of for about an hour then coded in 10 miniuts so u cant say i don't put thought into my work =) muhahahahaha