Author |
Topic  |
Lord Maverick
New Member

Norway
92 Posts |
Posted - 09 August 2000 : 05:10:53
|
For anyone that is interested in having the forum show how many viewers they have online on their forum, here is one way to do it. I must say that the coding in global.asa is not my coding originally (dont remember where I got it), and I've left in the comments for you all. I'm not using global.asa to anything else, but if you are you should be able to figure out how to include this one...
I'm using this on my forum as a separate line in the statistics page. I'm using this on a MS IIS 4.0 server with MS Access 2000.
For anyone interested here is how I do it:
1. make a file called <font color=red>global.asa</font id=red> and place it on the very root of your site. The global.asa file should look like this (you could of course delete the comments in this file):
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> Sub Application_OnStart ' Sub Application_OnStart is the procedure that fires ' everytime your server starts up.
' Here you want to define the time that the user ' will be valid as on-line. (If no activity occurs ' for x minutes, then log the user off (erase his ' session variable instances)) Session.Timeout = 3
' The .Lock method locks the Application variable so that ' you can work on it. If you don't lock it there won't be ' any changes on the variable "WhosOn" Application.Lock
' Start the variable at 0, Application("WhosOn") = 0
' You now need to unlock the application Application.UnLock End Sub Sub Session_OnStart ' Sub Session_OnStart is the procedure that works ' everytime a new user enters in your page
' Here is the place where you increment the number ' of users on your page (don't forget to Lock/Unlock ' your Application variable!) :) Application.Lock Application("WhosOn") = Application("WhosOn") + 1 Application.UnLock End Sub Sub Session_OnEnd ' Sub Session_OnEnd is the procedure that works ' everytime a user quits the page, this is defined n ' minutes after he quits. ' This n minutes are defined by the Session:Timeout in ' Sub Application_OnStart
' So... when a user quits there will be one less user, so we ' decrement one on the "WhosOn" variable (don't ' forget to Lock/Unlock your application variable! :) Application.Lock Application("WhosOn") = Application("WhosOn") - 1 Application.UnLock End Sub </SCRIPT> <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
The Session.Timeout variable is important as it defines the length for non-activity for a user before he is not counted as an active user anymore.You could increase this variable to 20, but then any user will be shown as a online user to your forum for 20 minutes, regardless of how long time he really stays on. On the other hand, if you set this to 1 (minute) a user that is reading on your page (most people do!) is not accounted for as a active user after 1 minute with no activity on the server. I myself think 3 minutes is the best for my forum.
2. If you wanna use this in the statistics.asp that animedj has posted as I do, I've added this code at the very last lines of animedjs statistics.asp
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> <tr> <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>"> <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">There are currently <b><% response.write Application("WhosOn")%></b> visitors to this forum.</font> </td> </tr> <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
But you can print the number of users online in any .asp page by including the <b><% response.write Application("WhosOn")%></b>
Edited by - Lord Maverick on 09 August 2000 05:12:41 |
|
slemieux
Junior Member
 
USA
234 Posts |
Posted - 09 August 2000 : 05:36:41
|
pier gave me similiar code the other day and this was discussed in some detail before we lost all the posts.
Of course everyone knows the problem with using sesions and a busy server. It would be great to have something similiar to the UBB hack which uses cookies and then writes the users info to a flat file which is then read. Then I do believe after a certain period of time, if that users information hasn't been updated in the file it is deleted.
Since the information is already available through cookies (of course something would have to be set for people who are not logged in) this seems like the way to go.
This one may be a bit out of my league. If someone else wants to tackle it that would be great! If not, I'll see what I can do.
Hey I got a special title <img src=icon_smile.gif border=0 align=middle> Just now saw that!
Edited by - slemieux on 09 August 2000 05:38:00 |
 |
|
Kal Corp
Average Member
  
USA
878 Posts |
Posted - 10 August 2000 : 00:22:53
|
If you have more than one forum and the global.asa is in the root.
Text should read " in All Forums"
I have this running with all the other mods if and one needs them. There is a download of V3 Final + all MODS
cookies might be the batter way to go <img src=icon_smile.gif border=0 align=middle>
Testing forums - 2 Forums same database + mod's http://vasserver.dyndns.org/forums_2000/forum1/default.asp
Edited by - kal corp on 10 August 2000 00:23:59 |
 |
|
James
Average Member
  
USA
539 Posts |
Posted - 15 September 2000 : 20:59:49
|
Did anyone ever code a cookie solution?
|
 |
|
ISJX_YICK
New Member

France
68 Posts |
|
slemieux
Junior Member
 
USA
234 Posts |
Posted - 20 September 2000 : 18:59:47
|
Ok I think I've got this Who's Online thing working. This stores a member name or guests IP in a seperate table. No session variable pretty small code.
One problem, periodically, a page will timeout and I do believe it is related to something in this code. If you could help me debug it that would be great <img src=icon_smile.gif border=0 align=middle>
zip: http://www.thepercussionist.com/adf/whosonline.zip Demo: http://www.thepercussionist.com/community/forums/default.asp
I hope I have everything in the zip, if not let me know!!
Scott LeMieux |
 |
|
pier
Starting Member
Italy
22 Posts |
Posted - 21 September 2000 : 03:18:41
|
We miss the online2.asp code
10x pier
|
 |
|
slemieux
Junior Member
 
USA
234 Posts |
Posted - 21 September 2000 : 04:16:22
|
Oops... A few files were missing. Thanks for the heads up pier <img src=icon_smile.gif border=0 align=middle>
Scott LeMieux |
 |
|
James
Average Member
  
USA
539 Posts |
Posted - 08 October 2000 : 00:19:09
|
Can someone come up with the code for a small <b>whos_online_setup.asp</b> file that will create the table and fields and add them to the database for those of us who don't have access to Access?
I know animedj had done something similar with his <i>last post</i> add-on that modified a table in the database.
- <font color=red>*</font id=red><font color=blue>Interested in <b>Radio Control</b> </font id=blue><font color=red>-</font id=red> http://www.rcwebboard.com/<font color=red>*</font id=red> |
 |
|
RichardKinser
Snitz Forums Admin
    
USA
16655 Posts |
|
Kal Corp
Average Member
  
USA
878 Posts |
Posted - 08 October 2000 : 11:26:52
|
I keep getting File already in use when I add this <img src=icon_smile_sad.gif border=0 align=middle> |
 |
|
James
Average Member
  
USA
539 Posts |
Posted - 08 October 2000 : 14:00:25
|
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> Here you go:
Just unzip the file into your forum directory and run it from the address bar in your browser.
http://www1.domaindlx.com/dssdbs/files/whos_online_setup.zip <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
OK, that created the table, but now I get a new problem. When I add this mod to my site, I get an error that says: <b> Provider error '80020005' Type mismatch.
/forum/online2.asp, line 33 </b>
Line 33 in online2.asp is: <b> objRS2("UserID") = User</b>
Any ideas?
- <font color=red>*</font id=red><font color=blue>Interested in <b>Radio Control</b> </font id=blue><font color=red>-</font id=red> http://www.rcwebboard.com/<font color=red>*</font id=red> |
 |
|
RichardKinser
Snitz Forums Admin
    
USA
16655 Posts |
Posted - 08 October 2000 : 17:55:12
|
If you already downloaded the Database setup file that I provided a link to in an earlier message download this file and overwrite the earlier <b>whos_online_setup.asp</b> in your forum directory.
http://www1.domaindlx.com/dssdbs/files/whos_online_setup_fix.zip
If you have not yet downloaded this setup file, I corrected the original file so you will only need the first file, not the fixed file. |
 |
|
James
Average Member
  
USA
539 Posts |
Posted - 08 October 2000 : 22:02:32
|
Thanks Richard, that did the trick. I had to change the values from 100 to 255 (wouldn't accomadate some of my forums for some reason). And for some reason, I had to comment out the following:
<pre id=code><font face=courier size=2 id=code> ' strSql = "UPDATE TABLE " & strTablePrefix & "ONLINE " ' strSql = strSql & "SET UserID = " & "0" ' strSql = strSql & "SET Status = " & "0"
' Response.Write "<p>" & strSql & "</p>" ' my_Conn.Execute strSql </font id=code></pre id=code> I'd get an syntax error with the last line there if I didn't comment those out.
<b>Slemieux</b>, you left out the images (plus.gif, minus.gif, vbwhos.gif, vbclose.gif and online.gif). I already had the plus and minus and I grabbed the online.gif from your site.
- <font color=red>*</font id=red><font color=blue>Interested in <b>Radio Control</b> </font id=blue><font color=red>-</font id=red> http://www.rcwebboard.com/<font color=red>*</font id=red>
Edited by - James on 08 October 2000 22:50:35 |
 |
|
RichardKinser
Snitz Forums Admin
    
USA
16655 Posts |
Posted - 08 October 2000 : 22:54:23
|
I thought I left that UPDATE part out. whoops. there is no need for it, so don't worry about it.
The Zip file has been updated. I took the UPDATE part out of it.
Edited by - Richard Kinser on 08 October 2000 22:59:10 |
 |
|
ilovemoney
Starting Member
Taiwan
27 Posts |
Posted - 21 October 2000 : 14:09:59
|
Can i add it in 3.1 final??
some body help me please..
My English is very poor...
Edited by - ilovemoney on 21 October 2000 17:17:35 |
 |
|
Topic  |
|