Author |
Topic  |
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 21 July 2002 : 16:47:32
|
The above code doesn't work ... I just saw my server being reset, now we have 2 users on and AU count is still 0.
http://www.v8central.com/snitz/ if you're interested. If I can find a fix I'll let you know 
Edit : I don't have a C_VARIABLE of 'intAURecord' 
Edited by - laser on 21 July 2002 17:00:15 |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 21 July 2002 : 17:35:13
|
This will be my first code hack in Snitz, so I'm treading very lightly (& I can't afford to crash my forums )
Can someone clean/correct/verfiy my code ? .. I haven't implemented this yet ... red code should be replaced by green code
quote:
Ok, try replacing the function for this one to see if it helps:
function chkAURecord(intTotalActiveUsers) Dim rsRec, strRecSql, tempRec
if intTotalActiveUsers > intAURecord then 'We have a new record!!! :) 'test this against the database:
strRecSql = "SELECT C_VALUE FROM " & strTablePrefix & "CONFIG_NEW WHERE C_VARIABLE='intAURecord'"
Set rsRec = Server.CreateObject("ADODB.Recordset")
rsRec.Open strRecSql, my_conn
if rsRec.EOF or rsRec.BOF then 'Exit if you cannot read the current value rsRec.Close Set rsRec = nothing Exit Function 'Create the record for intAURecord ... do we need strAURecordDate as well ? strRecSql = "INSERT INTO " & strTablePrefix & "CONFIG_NEW (C_VARIABLE, C_VALUE) VALUES ('intAURecord', intAURecord)" Set rsRec = Server.CreateObject("ADODB.Recordset") rsRec.Open strRecSql, my_conn End if
'now test the value from the DB:
tempRec = Cint(rsRec("C_VALUE"))
if intTotalActiveUsers > tempRec Then strDummy = SetConfigValue(1, "intAURecord", cstr(intTotalActiveUsers)) strDummy = SetConfigValue(1, "strAURecordDate", DateToStr(strForumTimeAdjust)) intAURecord = intTotalActiveUsers strAURecordDate = DateToStr(strForumTimeAdjust) Application(strCookieURL & "INTAURECORD") = intTotalActiveUsers Application(strCookieURL & "STRAURECORDDATE") = DateToStr(strForumTimeAdjust) end if rsRec.Close set rsRec = nothing end if end function
Edited by - laser on 21 July 2002 17:37:31 |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 21 July 2002 : 17:43:06
|
For all those who have implemented the above, you might want to do the following to your code if you're having the same problems as me (this is currently in place on my forums so I can still get an AU count
function chkAURecord(intTotalActiveUsers) Dim rsRec, strRecSql, tempRec
if intTotalActiveUsers > intAURecord then 'We have a new record!!! :) intAURecord = intTotalActiveUsers strAURecordDate = DateToStr(strForumTimeAdjust) Application(strCookieURL & "INTAURECORD") = intTotalActiveUsers Application(strCookieURL & "STRAURECORDDATE") = DateToStr(strForumTimeAdjust) Exit Function 'test this against the database:
strRecSql = "SELECT C_VALUE FROM " & strTablePrefix & "CONFIG_NEW WHERE C_VARIABLE='intAURecord'"
Set rsRec = Server.CreateObject("ADODB.Recordset")
rsRec.Open strRecSql, my_conn
if rsRec.EOF or rsRec.BOF then 'Exit if you cannot read the current value rsRec.Close Set rsRec = nothing Exit Function End if
'now test the value from the DB:
tempRec = Cint(rsRec("C_VALUE"))
if intTotalActiveUsers > tempRec Then strDummy = SetConfigValue(1, "intAURecord", cstr(intTotalActiveUsers)) strDummy = SetConfigValue(1, "strAURecordDate", DateToStr(strForumTimeAdjust)) intAURecord = intTotalActiveUsers strAURecordDate = DateToStr(strForumTimeAdjust) Application(strCookieURL & "INTAURECORD") = intTotalActiveUsers Application(strCookieURL & "STRAURECORDDATE") = DateToStr(strForumTimeAdjust) end if rsRec.Close set rsRec = nothing end if end function
Hope it helps 
Edit : correcting the colours
Edited by - laser on 21 July 2002 17:43:42 |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 21 July 2002 : 17:56:07
|
I don't see how that code will prevent the record being reset, which was the first problem, and the reason for the code being changed. It even looks like that was what was being done in the first place, so I really fail to see your point here.
I can understand the first change, but the second will put you where you started, as far as I can see.
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 21 July 2002 : 18:19:06
|
quote:
I can understand the first change, but the second will put you where you started, as far as I can see.
Oh definitely !! .. as I said, with the code fix that was posted at the beginning of this thread then your AU count will always be 0, even when you have users on the forums. The reason for this (in my instance) is that the code never gets to set the Application variable, because the record doesn't exist in the table.
I'm a newbie to changing Snitz code though, so if my red/green alterations are ok I'll try them - do you thnk that will solve the problem ?
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 21 July 2002 : 19:04:59
|
Well, if you have a value at the table, that code should work, as far as I can tell. Your fix, writing the value to the database when EOF or BOF is found should really not be needed if you execute this code when that happens:
strDummy = SetConfigValue(1, "intAURecord", cstr(intTotalActiveUsers)) strDummy = SetConfigValue(1, "strAURecordDate", DateToStr(strForumTimeAdjust)) intAURecord = intTotalActiveUsers strAURecordDate = DateToStr(strForumTimeAdjust) Application(strCookieURL & "INTAURECORD") = intTotalActiveUsers Application(strCookieURL & "STRAURECORDDATE") = DateToStr(strForumTimeAdjust)
That function, SetConfigValue, writes the value to the database, so no need to write it directly. And when there is no value in the database, you should also change the app vars values, which this code does.
Hope this is clear.
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 21 July 2002 : 19:56:00
|
Just to make it clear, this is how it should look:
function chkAURecord(intTotalActiveUsers) Dim rsRec, strRecSql, tempRec
if intTotalActiveUsers > intAURecord then 'We have a new record!!! :) 'test this against the database:
strRecSql = "SELECT C_VALUE FROM " & strTablePrefix & "CONFIG_NEW WHERE C_VARIABLE='intAURecord'"
Set rsRec = Server.CreateObject("ADODB.Recordset")
rsRec.Open strRecSql, my_conn
if rsRec.EOF or rsRec.BOF then 'Exit if you cannot read the current value rsRec.Close Set rsRec = nothing
strDummy = SetConfigValue(1, "intAURecord", cstr(intTotalActiveUsers)) strDummy = SetConfigValue(1, "strAURecordDate", DateToStr(strForumTimeAdjust)) intAURecord = intTotalActiveUsers strAURecordDate = DateToStr(strForumTimeAdjust) Application(strCookieURL & "INTAURECORD") = intTotalActiveUsers Application(strCookieURL & "STRAURECORDDATE") = DateToStr(strForumTimeAdjust)
End if
'now test the value from the DB:
tempRec = Cint(rsRec("C_VALUE"))
if intTotalActiveUsers > tempRec Then strDummy = SetConfigValue(1, "intAURecord", cstr(intTotalActiveUsers)) strDummy = SetConfigValue(1, "strAURecordDate", DateToStr(strForumTimeAdjust)) intAURecord = intTotalActiveUsers strAURecordDate = DateToStr(strForumTimeAdjust) Application(strCookieURL & "INTAURECORD") = intTotalActiveUsers Application(strCookieURL & "STRAURECORDDATE") = DateToStr(strForumTimeAdjust) end if rsRec.Close set rsRec = nothing end if end function
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 22 July 2002 : 05:17:50
|
Does that code really work ?? ... in the EOF/BOF condition you close rsRec before writing to the db ? ... and where can I find the code for SetConfigValue ? - I did a quick search, but couldn't find it.
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 22 July 2002 : 06:50:40
|
quote:
Does that code really work ?? ... in the EOF/BOF condition you close rsRec before writing to the db ? ... and where can I find the code for SetConfigValue ? - I did a quick search, but couldn't find it.
Well it should work. rsRec is just a local var, SetConfigValue will use its own variables to do the DB writing.
As wrote elsewhere, SetConfigValue is located in inc_functions.asp.
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 22 July 2002 : 07:35:15
|
quote:
As wrote elsewhere, SetConfigValue is located in inc_functions.asp.
Fair enough, it wasn't in mine, but it is now ... .I found it in the 3.3.05 version of inc_functions. All seems well now, I just have to wait for another server reboot.
|
 |
|
Topic  |
|
|
|