Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Naming IP Addresses, current users online, etc.

    What I am trying to accomplish is creating a script that allows users to add their "name" to their IP address so when there is for example 5 viewers online the script will show names of those IP address who have supplied names, and just display the IP address of those who havn't. Here is the global script I am currently using to display how many visitors are currently online. I am wondering if there is a way to display what IP ADDRESSES are connected to the server. If someone could help me with getting the list of IP addresses that are currently connected instead of just a number # I can come up with the rest of the script. Thanks for your time. I'll post with any luck I have.


    Code:
    <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
    
    Sub Application_OnStart
    	' Set our user count to 0 when we start the server
    	Application("ActiveUsers") = 0
    End Sub
    
    Sub Session_OnStart
    	' Change Session Timeout to 20 minutes (if you need to)
    	Session.Timeout = 5
    	' Set a Session Start Time
    	' This is only important to assure we start a session
    	Session("Start") = Now
    	' Increase the active visitors count when we start the session
    	Application.Lock
    		Application("ActiveUsers") = Application("ActiveUsers") + 1
    	Application.UnLock
    End Sub
    
    Sub Session_OnEnd
    	' Decrease the active visitors count when the session ends.
    	Application.Lock
    		Application("ActiveUsers") = Application("ActiveUsers") - 1
    	Application.UnLock
    End Sub
    
    </SCRIPT>
    Code:
    <%= Application("ActiveUsers") %>
    Last edited by isaaclloyd; 09-27-2005 at 02:50 AM.
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #2
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perhaps I should break it down a little. Basically I am wondering if it's possible to see what IP addresses are viewing a website, perhaps using the Global.asp script. The script gives me a # of current viewers, why not their IP address. Thanks for your time.
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #3
    Regular Coder Freon22's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    287
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Awhile back I wanted to list the names of all the users at my site that had logged in. I had already used a global script very much like your were it would display how many visitors were at my site. So I wrote a script that would add the names of the users to the Application(UserName). I would add a comma at the end of each name so that when I displayed the list I would just replace the commas with a <br> and it worked great. That is until a user left the site, there is or should I say it is very hard to delete just one name and it being the right name out of Application(UserName). So I posted for help here on this board, the response was to use a dictionary. I did a little research on dictionary and found that I really had three choices, dictionary, database, text file. To try to use the global application is not the right way to do this.

    What I ended up doing was putting a timestamp field in my database so when someone logged in I would read the database by the timestamp and that would give me the list of current logged in users. I could display this anywhere on the site for anyone to see if I wanted to. But this didn’t help me with the visitors that were at my site that had not logged in. Sometimes I can see that there are 15 users online with 5 names displayed for the ones that are logged in. But I have nothing to see for these other 10 users that were there.

    What I am planning on doing is when they first load my page, and on Session_OnStart I am going to write their IP to a text file. This way I can display the text file anywhere I want for anyone that I want to see. But I don’t think it a good idea to display users IP to anyone. Then on Session_OnEnd I will delete their IP from the text file. What I should end up with is 5 names of logged in users and a list of 10 IP address. I know that after someone logs in I will have to delete their IP out of the text file so that I don't show the IPs of logged in users also.

    But by trade I am in air-conditioning I code because its fun and I love it. But with this hot summer we have been having this year I haven’t had the time to write the first line code to make this happen.

    Sorry I don’t have any code for you to see but I am hoping that this will give you some ideas on solving your problem. Global applications are great for something but I really don't think that this is one of them. So your choices are dictionary, database, text file.

  • #4
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I appreciate the long responce. I am planning on using textfiles, however I'm not sure how I would go about adding an IP addess to the textfile when a session starts and then removing it when that session ends... Any ideas on that one?

    What I am hoping for is a textfiles with 10 IP addresses when there are 10 people viewing the site. What I will then do is replace the IP addresses with the supplied names, or write "No Name" for the IP addresses that don't have a name. I'll use the ASP REPLACE command as well as other script for this.

    I think I could get this to work baced on two things:

    #1 I need to figure out how to APPEND the viwers IP address to a textfile when THEIR session starts.
    #2 I need to figure out how to remove THEIR IP address from that textfile when THEIR session ends, but leave everyone elses.

    Thanks for your time and ideas...
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •