Author |
Topic |
|
frankdmann
Starting Member
3 Posts |
Posted - 29 November 2003 : 22:40:49
|
Hello everyone,
I logged on tonight to find out how in the world I could take the logon scripts/variables out of the code and use it as part of an entire website. Well, after I found a little (but no real) help, I went back to the drawing board and came up with a solution. Follow these instructions and it should work just fine:
1. Create a new file called "inc_users.asp" 2. Paste the following code into the file:
<!--#INCLUDE FILE="config.asp" --> <!--#INCLUDE FILE="inc_func_common.asp" --> <!--#INCLUDE FILE="inc_sha256.asp"-->
<% if strShowTimer = "1" then '### start of timer code Dim StopWatch(19)
sub StartTimer(x) StopWatch(x) = timer end sub
function StopTimer(x) EndTime = Timer
'Watch for the midnight wraparound... if EndTime < StopWatch(x) then EndTime = EndTime + (86400) end if
StopTimer = EndTime - StopWatch(x) end function
StartTimer 1
'### end of timer code end if
strArchiveTablePrefix = strTablePrefix & "A_" strScriptName = request.servervariables("script_name")
if Application(strCookieURL & "down") then if not Instr(strScriptName,"admin_") > 0 then Response.redirect("down.asp") end if end if
if strPageBGImageURL = "" then strTmpPageBGImageURL = "" elseif Instr(strPageBGImageURL,"/") > 0 or Instr(strPageBGImageURL,"\") > 0 then strTmpPageBGImageURL = " background=""" & strPageBGImageURL & """" else strTmpPageBGImageURL = " background=""" & strImageUrl & strPageBGImageURL & """" end if
If strDBType = "" then Response.Write "<table border=""0"" cellspacing=""0"" cellpadding=""5"" width=""50%"" height=""40%"" align=""center"">" & vbNewLine & _ " <tr>" & vbNewLine & _ " <td bgColor=""navyblue"" align=""center""><p><font face=""Verdana, Arial, Helvetica"" size=""2"">" & _ "<b>There has been a problem...</b><br /><br />" & _ "Your <b>strDBType</b> is not set, please edit your <b>config.asp</b><br />to reflect your database type." & _ "</font></p></td>" & vbNewLine & _ " </tr>" & vbNewLine & _ " <tr>" & vbNewLine & _ " <td align=""center""><font face=""Verdana, Arial, Helvetica"" size=""2"">" & _ "<a href=""default.asp"" target=""_top"">Click here to retry.</a></font></td>" & vbNewLine & _ " </tr>" & vbNewLine & _ "</table>" & vbNewLine & _ Response.End end if
set my_Conn = Server.CreateObject("ADODB.Connection") my_Conn.Open strConnString
if (strAuthType = "nt") then call NTauthenticate() if (ChkAccountReg() = "1") then call NTUser() end if end if
if strGroupCategories = "1" then if Request.QueryString("Group") = "" then if Request.Cookies(strCookieURL & "GROUP") = "" Then Group = 2 else Group = Request.Cookies(strCookieURL & "GROUP") end if else Group = cLng(Request.QueryString("Group")) end if 'set default Session(strCookieURL & "GROUP_ICON") = "icon_group_categories.gif" Session(strCookieURL & "GROUP_IMAGE") = strTitleImage 'Forum_SQL - Group exists ? strSql = "SELECT GROUP_ID, GROUP_NAME, GROUP_ICON, GROUP_IMAGE " strSql = strSql & " FROM " & strTablePrefix & "GROUP_NAMES " strSql = strSql & " WHERE GROUP_ID = " & Group set rs2 = my_Conn.Execute (strSql) if rs2.EOF or rs2.BOF then Group = 2 strSql = "SELECT GROUP_ID, GROUP_NAME, GROUP_ICON, GROUP_IMAGE " strSql = strSql & " FROM " & strTablePrefix & "GROUP_NAMES " strSql = strSql & " WHERE GROUP_ID = " & Group set rs2 = my_Conn.Execute (strSql) end if Session(strCookieURL & "GROUP_NAME") = rs2("GROUP_NAME") if instr(rs2("GROUP_ICON"), ".") then Session(strCookieURL & "GROUP_ICON") = rs2("GROUP_ICON") end if if instr(rs2("GROUP_IMAGE"), ".") then Session(strCookieURL & "GROUP_IMAGE") = rs2("GROUP_IMAGE") end if rs2.Close set rs2 = nothing Response.Cookies(strCookieURL & "GROUP") = Group Response.Cookies(strCookieURL & "GROUP").Expires = dateAdd("d", intCookieDuration, strForumTimeAdjust) if Session(strCookieURL & "GROUP_IMAGE") <> "" then strTitleImage = Session(strCookieURL & "GROUP_IMAGE") end if end if
strDBNTUserName = Request.Cookies(strUniqueID & "User")("Name") strDBNTFUserName = trim(chkString(Request.Form("Name"),"SQLString")) if strDBNTFUserName = "" then strDBNTFUserName = trim(chkString(Request.Form("User"),"SQLString")) if strAuthType = "nt" then strDBNTUserName = Session(strCookieURL & "userID") strDBNTFUserName = Session(strCookieURL & "userID") end if
if strRequireReg = "1" and strDBNTUserName = "" then if not Instr(strScriptName,"policy.asp") > 0 and _ not Instr(strScriptName,"register.asp") > 0 and _ not Instr(strScriptName,"password.asp") > 0 and _ not Instr(strScriptName,"faq.asp") > 0 and _ not Instr(strScriptName,"login.asp") > 0 then scriptname = split(request.servervariables("SCRIPT_NAME"),"/") if Request.QueryString <> "" then Response.Redirect("login.asp?target=" & lcase(scriptname(ubound(scriptname))) & "?" & Request.QueryString) else Response.Redirect("login.asp?target=" & lcase(scriptname(ubound(scriptname)))) end if end if end if
select case Request.Form("Method_Type") case "login" strEncodedPassword = sha256("" & Request.Form("Password")) select case chkUser(strDBNTFUserName, strEncodedPassword,-1) case 1, 2, 3, 4 Call DoCookies(Request.Form("SavePassword")) strLoginStatus = 1 case else strLoginStatus = 0 end select case "logout" Call ClearCookies() end select
if trim(strDBNTUserName) <> "" and trim(Request.Cookies(strUniqueID & "User")("Pword")) <> "" then chkCookie = 1 mLev = cLng(chkUser(strDBNTUserName, Request.Cookies(strUniqueID & "User")("Pword"),-1)) chkCookie = 0 else MemberID = -1 mLev = 0 end if
if mLev = 4 and strEmailVal = "1" and strRestrictReg = "1" and strEmail = "1" then '## Forum_SQL - Get membercount from DB strSql = "SELECT COUNT(MEMBER_ID) AS U_COUNT FROM " & strMemberTablePrefix & "MEMBERS_PENDING WHERE M_APPROVE = " & 0
set rs = Server.CreateObject("ADODB.Recordset") rs.open strSql, my_Conn
if not rs.EOF then User_Count = cLng(rs("U_COUNT")) else User_Count = 0 end if
rs.close set rs = nothing end if
if (mlev = 0) then if not(Instr(Request.ServerVariables("Path_Info"), "register.asp") > 0) and _ not(Instr(Request.ServerVariables("Path_Info"), "policy.asp") > 0) and _ not(Instr(Request.ServerVariables("Path_Info"), "pop_profile.asp") > 0) and _ not(Instr(Request.ServerVariables("Path_Info"), "search.asp") > 0) and _ not(Instr(Request.ServerVariables("Path_Info"), "login.asp") > 0) and _ not(Instr(Request.ServerVariables("Path_Info"), "password.asp") > 0) and _ not(Instr(Request.ServerVariables("Path_Info"), "faq.asp") > 0) then Response.Write " <form action=""" & Request.ServerVariables("URL") & """ method=""post"" id=""form1"" name=""form1"">" & vbNewLine & _ " <input type=""hidden"" name=""Method_Type"" value=""login"">" & vbNewLine & _ " <table><tr>" & vbNewLine & _ " <td align=""center"">" & vbNewLine & _ " <table>" & vbNewLine & _ " <tr>" & vbNewLine if (strAuthType = "db") then Response.Write " <td><center><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """><b>Username:</b></font><br />" & vbNewLine & _ " <input type=""text"" name=""Name"" size=""10"" maxLength=""25"" value=""""><br><br>" & vbNewLine & _ " <font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """><b>Password:</b></font><br />" & vbNewLine & _ " <input type=""password"" name=""Password"" size=""10"" maxLength=""25"" value="""">" & vbNewLine & _ " " & vbNewLine if strGfxButtons = "1" then Response.Write " <input src=""" & strImageUrl & "button_login.gif"" type=""image"" border=""0"" value=""Login"" id=""submit1"" name=""Login"">" & vbNewLine else Response.Write " <input type=""submit"" value=""Login"" id=""submit1"" name=""submit1"">" & vbNewLine end if Response.Write " </td>" & vbNewLine & _ " </tr>" & vbNewLine & _ " <tr>" & vbNewLine & _ " <td colspan=""3"" align=""left""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>" & vbNewLine & _ " <input type=""checkbox"" name=""SavePassWord"" value=""true"" tabindex=""-1"" CHECKED><b> Save Password</b></font></center></td>" & vbNewLine else if (strAuthType = "nt") then Response.Write " <td><font face=""" & strDefaultFontFace & """ size=""1"" color=""" & strHiLiteFontColor & """>Please <a href=""policy.asp"" tabindex=""-1"">register</a> to post in these Forums</font></td>" & vbNewLine end if end if Response.Write " </tr>" & vbNewLine if (lcase(strEmail) = "1") then Response.Write " <tr>" & vbNewLine & _ " <td colspan=""3"" align=""left""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>" & vbNewLine & _ " <a href=""password.asp""" & dWStatus("Choose a new password if you have forgotten your current one...") & " tabindex=""-1"">Forgot your " if strAuthType = "nt" then Response.Write("Admin ") Response.Write "Password?</a>" & vbNewLine if (lcase(strNoCookies) = "1") then Response.Write " |" & vbNewLine & _ " <a href=""admin_home.asp""" & dWStatus("Access the Forum Admin Functions...") & " tabindex=""-1"">Admin Options</a>" & vbNewLine end if Response.Write " <br /><br /></font></td>" & vbNewLine & _ " </tr>" & vbNewLine end if Response.Write " </table>" & vbNewLine & _ " </td>" & vbNewLine & _ " </tr></table>" & vbNewLine & _ " </form>" & vbNewLine end if else Response.Write " <form action=""" & Request.ServerVariables("URL") & """ method=""post"" id=""form2"" name=""form2"">" & vbNewLine & _ " <input type=""hidden"" name=""Method_Type"" value=""logout"">" & vbNewLine & _ " <table><tr>" & vbNewLine & _ " <td align=""center"">" & vbNewLine & _ " <table>" & vbNewLine & _ " <tr>" & vbNewLine & _ " <td align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>You are logged on as<br />" if strAuthType="nt" then Response.Write "<b>" & Session(strCookieURL & "username") & " (" & Session(strCookieURL & "userid") & ")</b></font>" & vbNewLine & _ " " else if strAuthType = "db" then Response.Write "<b>" & ChkString(strDBNTUserName, "display") & "</b></font>" & vbNewLine & _ " " if strGfxButtons = "1" then Response.Write "<br><br><input src=""" & strImageUrl & "button_logout.gif"" type=""image"" border=""0"" value=""Logout"" id=""submit1"" name=""Logout"" tabindex=""-1"">" else Response.Write "<br><br><input type=""submit"" value=""Logout"" id=""submit1"" name=""submit1"" tabindex=""-1"">" end if end if end if Response.Write "</td>" & vbNewLine & _ " </tr>" & vbNewLine & _ " </table>" & vbNewLine & _ " </td>" & vbNewLine & _ " </tr>" & vbNewLine if (mlev = 4) or (lcase(strNoCookies) = "1") then Response.Write " <tr>" & vbNewLine & _ " <td align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """><a href=""admin_home.asp""" & dWStatus("Access the Forum Admin Functions...") & " tabindex=""-1"">Admin Options</a>" if mLev = 4 and (strEmailVal = "1" and strRestrictReg = "1" and strEmail = "1" and User_Count > 0) then Response.Write(" | <a href=""admin_accounts_pending.asp""" & dWStatus("(" & User_Count & ") Member(s) awaiting approval") & " tabindex=""-1"">(" & User_Count & ") Member(s) awaiting approval</a>") Response.Write "<br /><br /></font></td>" & vbNewLine & _ " </tr></table>" & vbNewLine end if Response.Write " </form>" & vbNewLine end if Response.Write "</td>" select case Request.Form("Method_Type")
case "login" Response.Write " </tr>" & vbNewLine & _ "</table>" & vbNewLine if strLoginStatus = 0 then Response.Write "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>Your username and/or password were incorrect.</font></p>" & vbNewLine & _ "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>Please either try again or register for an account.</font></p>" & vbNewLine else Response.Write "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>You logged on successfully!</font></p>" & vbNewLine & _ "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>Thank you for your participation.</font></p>" & vbNewLine end if Response.Write "<meta http-equiv=""Refresh"" content=""0; URL=" & Request.ServerVariables("HTTP_REFERER") & """>" & vbNewLine & _ "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><a href=""" & Request.ServerVariables("HTTP_REFERER") & """>Back To Forum</font></a></p>" & vbNewLine & _ "<table align=""center"" border=""0"" cellPadding=""0"" cellSpacing=""0"" width=""95%"">" & vbNewLine & _ " <tr>" & vbNewLine & _ " <td>" & vbNewLine WriteFooter Response.End case "logout" Response.Write "</tr>" & vbNewLine & _ "</table>" & vbNewLine & _ "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>You logged out successfully!</font></p>" & vbNewLine & _ "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>Thank you for your participation.</font></p>" & vbNewLine & _ "<meta http-equiv=""Refresh"" content=""0; URL=index.asp"">" & vbNewLine & _ "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><a href=""default.asp"">Back To Forum</font></a></p>" & vbNewLine & _ "<table align=""center"" border=""0"" cellPadding=""0"" cellSpacing=""0"" width=""95%"">" & vbNewLine & _ " <tr>" & vbNewLine & _ " <td>" & vbNewLine WriteFooter Response.End end select
Response.Write "</tr>" & vbNewLine & _ "</table>" & vbNewLine & _ "<table align=""center"" border=""0"" cellPadding=""0"" cellSpacing=""0"" width=""95%"">" & vbNewLine Response.Write " <tr>" & vbNewLine & _ " <td>" & vbNewLine %>
3. Save the this new include file into THE SAME DIRECTORY AS YOUR FORUM CODE. This is the biggest key!!!!
4. Now, all you have to do is call your include file on any other .asp page using a standard include statement.
This particular version is formatted for a table 140 pixels wide (or so) and you should be able to edit the HTML commands to fit your needs. Remember that you'll have to edit it in the "logged in" case as well as the "not logged in" case. Another thing to keep in mind is that for administrators, the "Admin Options" link should be changed to fit your needs if you plan on having a site admin console different from the forum admin console.
To see this in action, check out an incomplete site that I'm currently developing for a buddy:
http://nflhistory.net/bucs/
The site login box is located in the top left corner under the site logo.
|
Edited by - ruirib on 30 November 2003 04:48:19 |
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 30 November 2003 : 02:05:03
|
quote: 3. Save the this new include file into THE SAME DIRECTORY AS YOUR FORUM CODE. This is the biggest key!!!!
To use forum logins outside the forum directory you set your cookie options to "Website" instead of "Forum" in the Admin options.
Theres probably a lot of extra code there you don't really need for a simple logon too, I think someone actually did a mod for logins outside the forum files, did you check www.Snitzbitz.com for mods first ? |
Kiwihosting.Net - The Forum Hosting Specialists
|
|
|
frankdmann
Starting Member
3 Posts |
Posted - 30 November 2003 : 03:41:58
|
Never knew about snitzbitz. I came right here and did a google search, but didn't uncover anything special. I realized that I probably had some extra code, lol....but hey, at least it worked for me!! Thanks for the info Gremlin!!!
Frank |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 30 November 2003 : 05:13:20
|
I think the MOD was called "Universal logon" or something to that effect, you'll probably find it if you search the forums here for that as well.
|
Kiwihosting.Net - The Forum Hosting Specialists
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
Classicmotorcycling
Development Team Leader
Australia
2084 Posts |
Posted - 30 November 2003 : 16:41:32
|
I have my own Uni Login happening at: Classic Motorcycling Australia
There was lots about the Uni Loging on here.. But as Gremlin said: quote: Originally posted by Gremlin
To use forum logins outside the forum directory you set your cookie options to "Website" instead of "Forum" in the Admin options.
|
Cheers, David Greening |
|
|
Astralis
Senior Member
USA
1218 Posts |
Posted - 30 November 2003 : 18:20:26
|
Thanks for all the info and sharing your work frankdmann!
About setting the cookies to Website instead of Forum, will that affect the way they work with the forum in any way? |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 02 December 2003 : 01:51:19
|
No it shouldn't effect the forum at all Astralis. It basically just changes the path that the cookie is saved into. |
Kiwihosting.Net - The Forum Hosting Specialists
|
|
|
jayceeaz
Starting Member
11 Posts |
Posted - 02 December 2003 : 20:36:38
|
Yeah, I got only one problem with Universal Login; I seem to end up with two complete collections of vars running at the same time... so when I make changes, I have to literally restart IIS before the changes can be read by the second (who knows why?) collection...
I was too lazy to go see why, when I run varChk.asp:
<% response.write "<table border=""1"">" Response.Write("<tr><th>APPLICATION VARIABLE</th><th>CONTENTS</th></tr>") For Each Item in Application.Contents() Response.Write("<tr><td><font color=""black"" size=""2"">" & Item & "</font></td>" &_ "<td><font color=""black"" size=""2"">" & Application.Contents(Item) & "</font></td></tr>") Next response.write "</table>" %>
I see two sets of forum settings. :) Guess I am including it twice or something. Shrug.
|
|
|
|
Topic |
|
|
|