Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 AL's "Cookies Instead of DB for LastHereDate" Mod
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Jeepaholic
Average Member

USA
697 Posts

Posted - 26 February 2004 :  13:56:56  Show Profile  Visit Jeepaholic's Homepage
Haha, sorry, the title makes me laugh.

The dilemma I had, which created this mod, was that I had just converted a number of websites to a single user database. While beneficial in many regards, one of the downfalls to this system is that the LastHereDate (the last time a user visited a forum) is stored within this single user database.

What's the big deal? Well, when you visit one site...it will affect the LastHereDate for ALL of the sites attached to this single user account, thus, making "Active Topics" and the Purple Folder icons useless.

So, my solution was to use Cookies instead of the database to store the LastHereDate. As you know, cookies are site dependant. Thus, LastHereDate is now dependant on whatever site you visit - and the other sites are not affected.

When a user logs in, it will modify the cookie to hold the LastHereDate information. As well, it continues to modify the database as it used to. When the LastHereDate is requested, it will look to the cookie FIRST. If it doesn't find what it's looking for, it will then resort to the database.

Essentially, the existing functionality is NOT changed regarding the database. The cookie system is simply overlayed on top of it, and used when appropriate.

The modifications required to your forum are excessively simple. I've attached the ENTIRE modified functions below. Please make sure that any changes you've made to your original functions are incorporated into these new ones!



inc_func_common.asp

function ReadLastHereDate(UserName)
	dim rs_date
	dim strSql
	if trim(UserName) = "" then 
		ReadLastHereDate = DateToStr(DateAdd("d", -10, strForumTimeAdjust))
		exit function
	end if

	if Request.Cookies(strUniqueID & "LHD")("LastHereDate") <> "" then
		ReadLastHereDate = DateToStr(Request.Cookies(strUniqueID & "LHD")("LastHereDate")) 
	else

		'## Forum_SQL
		strSql = "SELECT M_LASTHEREDATE "
		strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
		strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(UserName, "SQLString") & "' "
		Set rs_date = Server.CreateObject("ADODB.Recordset")
		rs_date.open strSql, my_Conn
		if (rs_date.BOF and rs_date.EOF) then
			ReadLastHereDate = DateToStr(DateAdd("d",-10,strForumTimeAdjust))
		else
			if rs_date("M_LASTHEREDATE") = "" or IsNull(rs_date("M_LASTHEREDATE")) then
				ReadLastHereDate = DateToStr(DateAdd("d",-10,strForumTimeAdjust))
			else
				ReadLastHereDate = rs_date("M_LASTHEREDATE")
			end if
		end if
		rs_date.close
		set rs_date = nothing
	end if

	UpdateLastHereDate DateToStr(strForumTimeAdjust),UserName
end function


function UpdateLastHereDate(fTime,UserName)
	'## Forum_SQL - Do DB Update
	strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS "
	strSql = strSql & " SET M_LASTHEREDATE = '" & fTime & "'"
	strSql = strSql & ",    M_LAST_IP = '" & Request.ServerVariables("REMOTE_ADDR") & "'"
	strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(UserName, "SQLString") & "' "
	my_conn.Execute (strSql),,adCmdText + adExecuteNoRecords       
	Response.Cookies(strUniqueID & "LHD").Expires = dateAdd("d", intCookieDuration, strForumTimeAdjust)
	Response.Cookies(strUniqueID & "LHD")("LastHereDate") = fTime

end function



'##############################################
'##        Cookie functions and Subs         ##
'##############################################

sub doCookies(fSavePassWord)
	if strSetCookieToForum = 1 then
		Response.Cookies(strUniqueID & "User").Path = strCookieURL
		Response.Cookies(strUniqueID & "LHD").Path = strCookieURL
	else
		Response.Cookies(strUniqueID & "User").Path = "/"        
		Response.Cookies(strUniqueID & "LHD").Path = "/"		
	end if
	Response.Cookies(strUniqueID & "User")("Name") = strDBNTFUserName
	Response.Cookies(strUniqueID & "User")("Pword") = strEncodedPassword
	'Response.Cookies(strUniqueID & "User")("Cookies") = Request.Form("Cookies")
	if fSavePassWord = "true" then
		Response.Cookies(strUniqueID & "User").Expires = dateAdd("d", intCookieDuration, strForumTimeAdjust)
		Response.Cookies(strUniqueID & "LHD").Expires = dateAdd("d", intCookieDuration, strForumTimeAdjust)		
	end if
	Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTFUserName)
	Response.Cookies(strUniqueID & "LHD")("LastHereDate") = Session(strCookieURL & "last_here_date")
end sub


sub ClearCookies()
	if strSetCookieToForum = 1 then
		Response.Cookies(strUniqueID & "User").Path = strCookieURL 
		Response.Cookies(strUniqueID & "LHD").Path = strCookieURL
	else
		Response.Cookies(strUniqueID & "User").Path = "/"        
		Response.Cookies(strUniqueID & "LHD").Path = "/"
	end if
	Response.Cookies(strUniqueID & "User") = ""
	Response.Cookies(strUniqueID & "LHD") = ""	
	Session(strCookieURL & "Approval") = ""
	Session.Abandon
	'Response.Cookies(strUniqueID & "User").Expires = dateadd("d", -2, strForumTimeAdjust)
end sub



The initial thread that spawned me to start working on this is here:
http://forum.snitz.com/forum/topic.asp?TOPIC_ID=51489

Al Bsharah
Aholics.com

Jeepaholics Anonymous
Broncoholics Anonymous
Network Insight

Edited by - Jeepaholic on 26 February 2004 15:53:18

Etymon
Advanced Member

United States
2385 Posts

Posted - 28 February 2004 :  00:25:30  Show Profile  Visit Etymon's Homepage

Thank ya muchly, Jeepers!
Go to Top of Page

Jeepaholic
Average Member

USA
697 Posts

Posted - 29 February 2004 :  11:57:23  Show Profile  Visit Jeepaholic's Homepage
NP. Let me know if ya find any quirks. I've had it running for about 3 days now and haven't seen any problems or complaints from anyone.

Al Bsharah
Aholics.com

Jeepaholics Anonymous
Broncoholics Anonymous
Network Insight
Go to Top of Page

Etymon
Advanced Member

United States
2385 Posts

Posted - 29 February 2004 :  12:39:58  Show Profile  Visit Etymon's Homepage

Hey Jeep,

Are you using SQL databases with this? Does it <b>not</b> work with any databases that you know of?

Etymon
Go to Top of Page

Jeepaholic
Average Member

USA
697 Posts

Posted - 01 March 2004 :  12:49:54  Show Profile  Visit Jeepaholic's Homepage
Etymon,

No changes were made to HOW the system accesses the database, so it should work among all Snitz-supported DB's. The only additions were for cookies, the only modifications were for timing on when things actually happened. HOW they happen didn't change.

Al Bsharah
Aholics.com

Jeepaholics Anonymous
Broncoholics Anonymous
Network Insight
Go to Top of Page

Etymon
Advanced Member

United States
2385 Posts

Posted - 01 March 2004 :  22:09:27  Show Profile  Visit Etymon's Homepage
quote:
Originally posted by Jeepaholic

Etymon,

No changes were made to HOW the system accesses the database, so it should work among all Snitz-supported DB's. The only additions were for cookies, the only modifications were for timing on when things actually happened. HOW they happen didn't change.



Thank you for the update on this Jeepaholic.

I went to one of your sites. My condolances go out to Rave and all who knew him.

I lost a nephew to the same disease some time ago.

Sincerely,

Etymon
Go to Top of Page

Jeepaholic
Average Member

USA
697 Posts

Posted - 02 March 2004 :  17:41:56  Show Profile  Visit Jeepaholic's Homepage
Yeah, it's pretty sad. Lots of folks on JA knew him...personally, I only knew him through the forums but he seemed like a great guy.

Al Bsharah
Aholics.com

Jeepaholics Anonymous
Broncoholics Anonymous
Network Insight
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07