IP Addresses Page 3

By ServerWatch Staff (Send Email)
Posted Nov 23, 1998

The sign in and sign out pages could be combined into one page, with a radio button selecting if you were signing in or out. To keep things simple, I have made different set of pages for signing in and out.

This page is an easy form post of two variables, one for the ID and one for the password.

<form method="POST" action="signout.asp">

<p>Id number:<input type="text" name="id" size="20"></p>

<p>Password:<input type="password" name="password" size="20"></p>

<center><p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>




This page posts the variables to the signin.asp which does most of the work. I have decided to store the user/password and ip address in files instead of a database. Just a point that not everything has to be done with database access.



in_id = request("id")
in_pass = request("password")   'store off the two incoming variables
set FileObject = server.CreateObject("Scripting.FileSystemObject")
in_file = "password.pas"   'the password file

'assume the password file is within the current directory. Find the
'Directory by trimming off the current file name from Path_info

i = len(temp) - 1
j = i
done = 0
do while done = 0
if mid(temp,i,1) = "\" then
   FTP_PATH = MID(TEMP,1, i)
  done = 1
  i = i - 1
  if i = 0 then
     done = 1
   end if
end if

file_name = FTP_PATH & in_file
on error resume next
Set InStream= FileObject.OpenTextFile (file_name, 1, False, False)
if err.number <> 0 then   ' if we cant find the password file then error out
   response.write ("Server error, login file not found")
   id =Trim( InStream.Readline )
   pass =Trim( InStream.Readline )
   if (in_id = id) and (in_pass = pass) then   'id and password match
       addr = Request.ServerVariables ( "REMOTE_ADDR") 'obtain ip addr
       file_name = ftp_path & "addr.ip"
       set a = FILEOBJECT.OPENTEXTFILE(file_name, 2) ' open for write
       if err.number <> 0 then  ' if error then file doesnt exist
          set a = FileObject.CreateTextFile (file_name, True) 'have to create it
       end if
       a.writeline "OUT"   'write the ip address
       a.writeline Now()  ' write the date/time
       set a = nothing
       line = "Signed out okay at " & Now()
       response.write (line)
      response.write("Security violation") 'id/password dont match
   end if
end if


Page 3 of 4

Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date