|
Translate |
Print |
A |
A |
A |
to
Convert
<cfsetting enablecfoutputonly="Yes">
<!-------------------------------------------------------------------------
Template Name: MySpace/user.session
Orig Author: TheBoz(Keith Boster)
Orig Date: 12/23/03
Description: DESCRIPTION
Inputs: MyUserInfo - COOKIE - Users Info Cookie
encKey - GLOBALS - Enc Key
Output: MyUserID - INT
userType - INT
permissions - STRING
userEmail - STRING
userFirstName - STRING
lastClick - TIMESTAMP
isUser - TRUE / FALSE
isGroup - TRUE / FALSE
isModerator - TRUE / FALSE
isPowerUser - TRUE / FALSE
isPaidUser - TRUE / FALSE
-------------------------------------------------------------------------->
<!--- Try to Decrypt the cookie --->
<cftry>
<cfif IsDefined("cookie.MyUserInfo")>
<cfif UseDotNetEncryption>
<cftry>
<cf_Encrypt action="decrypt" input="#trim(cookie.MyUserInfo)#" passphrase="#encKey#" output="decrypted">
<cfset cookieData = decrypted>
<cfcatch type="Any">
<cftry>
<cfmail from="site@myspace.com" to="kfreund@myspace.com" subject="encryption error" type="HTML">#cookie.MyUserInfo#<br>#cfcatch.message#</cfmail>
<cfcatch></cfcatch>
</cftry>
<cfrethrow>
</cfcatch>
</cftry>
<cfelseif UseCustomEncryption>
<cf_cryp type="de" string="#trim(cookie.MyUserInfo)#" key="#encKey#">
<cfif not cryp.error>
<cfset cookieData = cryp.value>
<cfelse>
<cfset cookieData = "">
</cfif>
<!--- Added by KDF for debugging --->
<!---
<cftry>
<cf_COMEncrypt action="encrypt" input="#cookieData#" passphrase="#encKey#" output="kevintestencrypted">
<cf_COMEncrypt action="decrypt" input="#kevintestencrypted#" passphrase="#encKey#" output="kevintestdecrypted">
<cfcatch type="Any">
<cfmail from="kfreund@myspace.com" to="kfreund@myspace.com" subject="encryption error" type="HTML">#ServerName#<br>#cookieData#<br>#cfcatch.message#</cfmail>
</cfcatch>
</cftry>
--->
<!--- Added by KDF for debugging --->
<cfelse>
<cfset cookieData = decrypt(cookie.MyUserInfo, encKey)>
</cfif>
<cfelse>
<cfset cookieData = "">
</cfif>
<cfcatch>
<cfset cookieData = "">
</cfcatch>
</cftry>
<!--- USER INFO BASED ON COOKIE --->
<cfscript>
MyUserID = -1;
userType = -1;
permissions = "-1";
userEmail = "";
userFirstName = "";
lastClick = NOW();
hideonlinestatus = 0;
isUser = FALSE; // UserStatusID = 2
isGroup = FALSE; // UserStatusID = 5
isModerator = FALSE; // UserStatusID = 4
isPowerUser = FALSE; // UserStatusID = 7
isBand = FALSE; // UserStatusID = 6
isPaidUser = FALSE; // UserStautsID = xx
isProtectedUser = FALSE; // High Security user
buildUserCookie = TRUE;
updateOnlineStatus = FALSE;
processCookie = TRUE;
// Check to see if the Cookie Exists that contains User Info
if( IsDefined("cookie.MyUserInfo") )
{
if( LEN(trim(cookie.MyUserInfo)) GT 0 )
{
if( LEN( cookieData ) GT 0 )
{
if( ListLen(cookieData, "|") GT 5 )
{
// If the site is in read only mode let a default user login
if( trim(ListGetAt(cookieData, 1, "|")) EQ readOnlyDefaultUserID AND siteMode NEQ "READONLY" )
{
processCookie = FALSE;
}
if( processCookie )
{
// Load up the Variables with the Cookie Data
MyUserID = trim(ListGetAt(cookieData, 1, "|"));
userType = trim(ListGetAt(cookieData, 2, "|"));
permissions = trim(ListGetAt(cookieData, 3, "|"));
userEmail = trim(ListGetAt(cookieData, 4, "|"));
userFirstName = (ListGetAt(cookieData, 5, "|"));
lastClick = trim(ListGetAt(cookieData, 6, "|"));
if (listlen(cookiedata,"|") eq 7 )
{
hideonlinestatus = trim(ListGetAt(cookieData, 7, "|"));
}
// Check to see if we need to Update Online Status
if( MyUserID GT 0 AND IsDate(lastClick) )
{
if( MyUserID GT -1 )
{
if( siteMode NEQ "READONLY" )
{
if( DateDiff("n", lastClick, NOW()) GTE 10 )
{
updateOnlineStatus = TRUE;
}
}
}
}
// Define the user Type
if( userType EQ 2 )
{
isUser = TRUE; // UserStatusID = 2
}
else if( userType EQ 5 )
{
isGroup = TRUE; // UserStatusID = 5
}
else if( userType EQ 4 )
{
isModerator = TRUE; // UserStatusID = 4
isPaidUser = TRUE;
}
else if( userType EQ 6 )
{
isPowerUser = TRUE; // UserStatusID = 6
}
else if( userType EQ 7 )
{
isBand = TRUE; // UserStatusID = 7
}
}
}
}
}
}
</cfscript>
<!--- Update the users online Status --->
<cfif updateOnlineStatus>
<!--- Construct the Cookie --->
<cfif UseDotNetEncryption>
<cf_Encrypt action="encrypt" input="#MyUserID#|#userType#|-1|#userEmail#|#userFirstName#|#NOW()#|#hideonlinestatus#" passphrase="#encKey#" output="encrypted">
<cfset cookieData = encrypted>
<cfelseif UseCustomEncryption>
<cf_cryp type="en" string="#MyUserID#|#userType#|-1|#userEmail#|#userFirstName#|#NOW()#|#hideonlinestatus#" key="#encKey#">
<cfif not cryp.error>
<cfset cookieData = cryp.value>
<cfelse>
<cfset cookieData = "">
</cfif>
<cfelse>
<cfset cookieData = encrypt("#MyUserID#|#userType#|-1|#userEmail#|#userFirstName#|#NOW()#|#hideonlinestatus#", encKey)>
</cfif>
<cfcookie name="MyUserInfo" value="#cookieData#" domain="#domaincookies#">
<cfstoredproc procedure="dbo.UpdateOnlineStatus" datasource="#dsn#" returncode="Yes">
<cfprocparam type="In" cfsqltype="CF_SQL_INTEGER" dbvarname="@userID" value="#myuserid#" null="No">
<cfprocparam type="In" cfsqltype="CF_SQL_INTEGER" dbvarname="@OnlineNow" value="1" null="No">
</cfstoredproc>
<CFSET UpdateOnlineStatusReturnCode = cfstoredproc.statusCode>
<!--- UPDATE the shared DB --->
<cfstoredproc procedure="dbo.Shared_updateLastOn" datasource="#sharedDSN#">
<cfprocparam type="In" cfsqltype="CF_SQL_INTEGER" dbvarname="@userID" value="#MyUserID#" null="No">
</cfstoredproc>
<cfif SendOLNUDP>
<cfset setonlinenow=1> <!--- <CFX_UDPClient server="10.20.0.153" port="1890" message="#myuserid#,1,#hideonlinestatus#">--->
</cfif>
<!---<cfif SendOLNUDP>
<CFX_UDPClient server="10.20.0.153" port="1890" message="#userLogin.UserID#,1,#displayonlinestatus#">
<CFOBJECT ACTION=CREATE NAME=obj CLASS=Intrafoundation.UDPClient.2>
<cfset obj.ClearLog()>
<cfset ip="10.20.0.153">
<cfset port="1890">
<cfset c=obj.Open(ip,port)>
<!--- <cfset s=chr(255) & chr(255) & chr(255) & chr(255) & "status" & chr(10)> --->
<cfset s="#userLogin.UserID#,1,#displayonlinestatus#">
<cfset c=obj.Send(s)>
<cfset obj.Close()>
<cfset c=obj.Close()>
</cfif>--->
<CFIF UpdateOnlineStatusReturnCode EQ 1>
<!--- <cfexecute
name="#ROOT_FILE_PATH#\wget\wget.exe"
arguments="--spider --tries=1 --post-data=""userid=#MyUserID#"" --timeout=5 ""#logInNotifyURL#"""
timeout="0"
>
</cfexecute> --->
<!---
<CFHTTP URL="#logInNotifyURL#" METHOD="POST">
<CFHTTPPARAM NAME="userid" VALUE="#MyUserID#" TYPE="FORMFIELD">
</CFHTTP>
--->
</CFIF>
</cfif>
<!--- Set affiliate tracking code if in url and not already set --->
<cfif IsDefined("URL.msaf")>
<cfif not isdefined("cookie.msaf")>
<cfcookie domain="#domaincookies#" name="msaf" value="#url.msaf#">
</cfif>
</cfif>
<!--- This is just some Debug Output. --->
<!---
<cfoutput>
<table cellspacing="1" cellpadding="0" border="0">
<tr>
<td>MyUserID</td>
<td> = </td>
<td>#MyUserID#</td>
</tr>
<tr>
<td>userType</td>
<td> = </td>
<td>#userType#</td>
</tr>
<tr>
<td>permissions</td>
<td> = </td>
<td>#permissions#</td>
</tr>
<tr>
<td>userEmail</td>
<td> = </td>
<td>#userEmail#</td>
</tr>
<tr>
<td>userFirstName</td>
<td> = </td>
<td>#userFirstName#</td>
</tr>
<tr>
<td>lastClick</td>
<td> = </td>
<td>#lastClick#</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td>isUser</td>
<td> = </td>
<td>#isUser#</td>
</tr>
<tr>
<td>isGroup</td>
<td> = </td>
<td>#isGroup#</td>
</tr>
<tr>
<td>isModerator</td>
<td> = </td>
<td>#isModerator#</td>
</tr>
<tr>
<td>isPowerUser</td>
<td> = </td>
<td>#isPowerUser#</td>
</tr>
<tr>
<td>isBand</td>
<td> = </td>
<td>#isBand#</td>
</tr>
<tr>
<td>isPaidUser</td>
<td> = </td>
<td>#isPaidUser#</td>
</tr>
<tr>
<td>isProtectedUser</td>
<td> = </td>
<td>#isProtectedUser#</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td>buildUserCookie</td>
<td> = </td>
<td>#buildUserCookie#</td>
</tr>
<tr>
<td>updateOnlineStatus</td>
<td> = </td>
<td>#updateOnlineStatus#</td>
</tr>
</table>
</cfoutput>
--->
<cfsetting enablecfoutputonly="No">
|