PDA

View Full Version : very simple ..but not 4 me..HELP....


kab_184
08-17-2003, 07:41 PM
hi


just found this code

<%
dim iplg, logFile8
set iplg=createObject("scripting.FileSystemObject")
set logFile8=iplg.openTextFile(server.mappath("IPLOG.txt"),8)
logFile8.write Request.ServerVariables("Remote_Addr") & vbcrlf
logFile8.close
set logFile8=nothing
set iplg=nothing
%>


it saves the ip addres to iplog.txt file....now the problem is
my website address is

http://www22.brinkster.com/devilhits/index.html

the if i add this snippet to a file "index.asp" whose address is

http://www22.brinkster.com/devilhits/all/index.asp

then at what place the iplog.txt file will be saved??

will for every folder in my website a separate iplog.txt file will be created ??

can i make an absolute address i mean a single iplog.txt file for whole of my website...? how??help me on this...


there is a a folder db in my account provided by my webhost.

the folder address is www22.brinskter.com/devilhits/db/

what changes shall i have to make to save the iplog.txt file in the db folder ??


i dunt know what n where to change the lines in the following snippet
to achive this
can any one explain and write the snippet edited in reply

<%
dim iplg, logFile8
set iplg=createObject("scripting.FileSystemObject")
set logFile8=iplg.openTextFile(server.mappath("IPLOG.txt"),8)
logFile8.write Request.ServerVariables("Remote_Addr") & vbcrlf
logFile8.close
set logFile8=nothing
set iplg=nothing
%>


thanks.... iany help shall be really gr8ful


kab 184

oracleguy
08-17-2003, 08:10 PM
Right now that code with create/use the file that is the same folder as the webpage executing the code.

Let me break the code down for you.

<%
dim iplg, logFile8 'Dimension the variables
set iplg=createObject("scripting.FileSystemObject") 'Create the FSO Object
set logFile8=iplg.openTextFile(server.mappath("IPLOG.txt"),8) 'Open the text file
logFile8.write Request.ServerVariables("Remote_Addr") & vbcrlf 'Write the IP Address to the file
logFile8.close 'Close the FSO Object
set logFile8=nothing
set iplg=nothing
%>

Where it opens the file you can change the path to go into your db folder.

Just do: set logFile8=iplg.openTextFile(server.mappath("db\IPLOG.txt"),8)

And if the webpage is in a sub folder in the site, it would be set logFile8=iplg.openTextFile(server.mappath("..\db\IPLOG.txt"),8)

However you'd probably only want to run this script once when the visitor initially accesses your site because regardless if it was just ran on a previous page it will run again and insert the same IP address.

glenngv
08-18-2003, 03:38 AM
You have to put it in global.asa's Session_OnStart so that it will be executed once for every session.

Sub Session_OnStart

'codes here

End Sub

oracleguy
08-18-2003, 03:53 AM
http://www.w3schools.com/asp/asp_globalasa.asp

Here is a quick guide on the global.asa in case you are unfamiliar with it.