Total time online ? - Posted (1839 Views)
New Member
pitstraight
Posts: 82
82
Is there a mod that will add the total users's online time onto their profile ?
I have Active Users installed, could I take the time from that ?<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
New Member
pitstraight
Posts: 82
82
I don't see the problem with everyone seeing it, but if someone can write the code Im sure I can make it show the way I want.
also VERY glad to see some life in this thread bigsmile<
Posted
Junior Member
PPSSWeb
Posts: 312
312
I am not sure how this will work as I havn't had time to really test it, but maybe this will give you a start.

As stated you will need to add a field to the Members table. With a numeric value started at 0. Make sure you chose a data type that will have enough room so you will not be likely to over run the value if you forum stays up for a number of years.
To get the total time value from the database and current active time then add the two and update the total time, you will need something like this.
Code:
'##Total online time##
if MemberID="-1" then 'If this is a Guest, do nothing
else 'If this is a Member, get Login Time
strSql = "SELECT AU_LOGINTIME FROM " & strTablePrefix & "ACTIVE_USERS WHERE MEMBER_ID = " & MemberID
set rsAM = my_conn.execute (strSql)
if rs.EOF or rs.BOF then 'do nothing
else 'get Total Time online
strSQL = "SELECT M_TIMEONLINE FROM " & strTablePrefix & "MEMBERS WHERE (MEMBER_ID = " & MemberID & " AND MEMBER_ID <> -1)"
set rs = my_conn.execute (strSql)
if rs.EOF or rs.BOF then 'do nothing
Else 'update total time online
onlineTime = rs("M_TIMEONLINE") + abs(DateDiff("n",StrToDate(rsAM("AU_LOGINTIME")),strForumTimeAdjust))
strSql = "UPDATE " & strTablePrefix & "MEMBERS SET M_TIMEONLINE='" & onlineTime & "'" & _
"WHERE MEMBER_ID = " & MemberID
my_conn.execute (strSql)
End IF
end if
rsAM.close
set rsAM = Nothing
rs.close
set rs = Nothing
end if
'######

It has been mentioned that this should go in inc_func_common. I am just not sure where it is best to put it at the moment. I added it to the ActiveUserTracker() function and it has not run when I expected it to. Or maybe I was just too impatient. smile
Where you want to display this information, you will need to put something like this:
Code:
      		strSQL = "SELECT M_TIMEONLINE FROM " & strTablePrefix & "MEMBERS WHERE (MEMBER_ID = " & MemberID & " AND MEMBER_ID <> -1)"
set rs = my_conn.execute (strSql)
if rs.EOF or rs.BOF then 'do nothing
Else 'output total time online
Response.Write " Total Time Online: " & rs("M_TIMEONLINE")
End if

I am pretty sure this code will need some tweaking and cleanup. But perhaps it will give you a start.


<
You Must enter a message