Click to See Complete Forum and Search --> : Can someone help me with this script?
alexn817
12-10-2003, 10:33 PM
Does anyone know how to automatically get someone’s ip and send it to you without them knowing? Email me at alexn817@hotmail.com or click here. (http://www.anzwers.org/free/alexn817/messagebaord.html)
Also, I tried the script at this site (http://javascript.internet.com/user-details/visitor-monitor.html)
but it didn’t work.
I'll just post the answer here, thank you.
If your server supports PHP, you can get the IP like this:
<?PHP
echo $_SERVER['REMOTE_ADDR'];
?>
Or, if it supports SSI:
<!--#echo var="REMOTE_ADDR"-->
PeOfEo
12-10-2003, 11:01 PM
If it supports asp or asp.net it is
Response.write = request.ServerVariables("REMOTE_ADDR")
To automatically email you, you would need access to an smtp server, to try to use someones mail client not only will not work but it is not dependable because not everyone has a mail client, they could use webmail for example. But why would you want to get an ip in your email? Why not just log them in a data base or text file like me and other developers do. I can hook you up with some logging scripts if you would like if your server supports asp.net or asp
alexn817
12-11-2003, 04:00 PM
Ok PeOfEo
thanks
could you?
PeOfEo
12-11-2003, 06:09 PM
here is the code I used, this is asp.net
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat="server">
Sub Page_Load(Src As Object, E As EventArgs) 'this code will run when the page loads
dim ipaddress as string 'declares the variable to store the ip
dim srvrtime as date 'declare srvtime as a date type variables
dim timenow as date 'declare the variable we will use for local time
srvrtime = now() 'set srvtime = to the current system time on the server
timenow = dateadd(DateInterval.hour, -5, srvrtime) 'sets server time = to the time now, change this so it will match your local time through trial and error
ipaddress = request.ServerVariables("REMOTE_ADDR") 'this gets the users ip from the server
Dim DBInsert As New OleDbCommand 'the insert data base command
Dim DBConn As OleDbConnection 'declare the data base connection
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" & Server.MapPath("/ips.mdb;")) 'this is the path to the access data base
DBInsert.connection = dbconn 'sets the data base connection for the command
DBInsert.commandtext = "Insert Into tblips " _
& "(ip, timelogged) " _
& "values (" _
& "'" & Replace(ipaddress, "'", "'") & "', " _
& "'" & Replace(timenow, "'", "'") & "')"
' the code above first maps out which table this will be inserted into, then picks the feilds, then sets the values respectivly to those feilds
DBInsert.connection.open 'opens the connection
DBInsert.ExecuteNonQuery() 'inserts the stuff by executing the command
DBInsert.connection.close 'closes the connection
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ip logger</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
your ip was just logged
</body>
</html>
to see it in action go to
http://quasi-ke.servebeer.com/iplogging.aspx
here is my data base if you wish to download it
http://quasi-ke.servebeer.com/ips.mdb
I left comments on every line of the actual code, so it should be self explanitory, but if you have futher questions feel free to post them.