<% session.Timeout=120 sn = Request.ServerVariables("script_name") Set conn = Server.CreateObject("ADODB.Connection") conn.Open Application("DbConnect") Function fnPermit(MenuID) if not instr(session("PageRole"), "|" & MenuID & "|")>0 then Response.Redirect "permission_error.asp" end if End Function function fnEmail(emailFrom, emailTo, emailSubject, emailBody) emailFrom = "SleepBetterInfo@sleepbetter.org" emailTo = Application("contactEmail") on error resume next Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing" Const cdoSendUsingPort = 2 Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver" Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport" Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" Const cdoBasic = 1 Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername" Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword" Dim objConfig ' As CDO.Configuration Dim objMessage ' As CDO.Message Dim Fields ' As ADODB.Fields ' Get a handle on the config object and it's fields Set objConfig = Server.CreateObject("CDO.Configuration") Set Fields = objConfig.Fields ' Set config fields we care about With Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = "mail.sleepbetter.org" .Item(cdoSMTPServerPort) = 25 .Item(cdoSMTPConnectionTimeout) = 10 .Item(cdoSMTPAuthenticate) = cdoBasic .Item(cdoSendUserName) = "SleepbetterInfo@sleepbetter.org" .Item(cdoSendPassword) = "!sleepEguy" .Update End With Set objMessage = Server.CreateObject("CDO.Message") Set objMessage.Configuration = objConfig With objMessage .To = emailTo .From = emailFrom .Subject = emailSubject .HTMLBody = emailBody .Send End With Set Fields = Nothing Set objMessage = Nothing Set objConfig = Nothing if err.number<>0 then response.write err.description & "(" & emailTo & ")" response.end end if end function Function fnOnClick(Link) mLink = "onmouseover=""this.bgColor='#c0c0c0'; this.style.cursor='pointer'""" mLink = mLink & " onmouseout=""this.bgColor='#ffffff'""" mLink = mLink & " OnClick=""document.location.href='" & Link & "'""" fnOnClick = "" End Function Function fnInsertLog(LogType, LogAction) sqlLog = "sp_user_log @action='insert', @LogType='" & LogType & "', @LogAction='" & replace(LogAction,"'","''") & "', @UserID='" & session("UserID") & "', @IPAddress='" & Request.ServerVariables("REMOTE_ADDR") & "'" set rsLog = conn.execute(sqlLog) End Function Function fnGenerateCode(CodeLength) Randomize Timer myArray = array("A","B","C","D","E","F","G","H","I","J","K","L","M","M","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9") for i = 0 to CodeLength - 1 x = Int(RND * 36) rn = rn & myArray(x) next GenerateCode = rn End Function Function fnCheckPromoCode(PromoCode) sql = "sp_check_promocode @Promocode='" & PromoCode & "'" set rsp = conn.Execute(sql) if rsp.eof then 'Code cannot be found fnCheckPromoCode = "1" else if rsp("PromoCode") = rsp("isUsed") then 'Code has been used fnCheckPromoCode = "2" else 'Code is good and not been used fnCheckPromoCode = "3" end if end if rsp.close set rsp=nothing End Function Function fnUpdteSiteLog(Switch, SiteID) sqlLog = "sp_sites @action='update', @Switch='" & Switch & "', @SiteID=" & SiteID set rsLog = conn.execute(sqlLog) End Function '''Purpose: Gets Prefix Dropdown Function fnGetPrefix(Prefix) if isNull(Prefix) = True then Prefix="" sql = "sp_Prefix" set rsPrefix = conn.Execute(sql) Response.Write "" rsPrefix.close set rsPrefix=nothing End Function '''Purpose: Gets Suffix Dropdown Function fnGetSuffix(Suffix) if isNull(Suffix) = True then Suffix="" sql = "sp_Suffix" set rsSuffix = conn.Execute(sql) Response.Write "" rsSuffix.close set rsSuffix=nothing End Function Function fnGetStates(StateCode) sql = "sp_state" set rsState = conn.Execute(sql) Response.Write "" End Function Function fnFormatDate(EventDate) dayValue = day(EventDate) SELECT CASE dayValue CASE 1,21,31 dayValue = dayValue & "st" CASE 2,22 dayValue = dayValue & "nd" CASE 3,23 dayValue = dayValue & "rd" CASE ELSE dayValue = dayValue & "th" END SELECT fnFormatDate = WeekDayName(WeekDay(EventDate)) & " " & monthname(month(datevalue(EventDate))) & " " & dayValue & ", " & year(datevalue(EventDate)) End Function '-------------------------- Database Excutions -------------------------- Function fnCheckCapacity(SessionID, Spots) sql = "sp_sessions @action='check_capacity', @SessionID='" & SessionID & "'" set rs = conn.Execute(sql) if rs("Capacity") - rs("RegCount") >= Spots then fnCheckCapacity=true else fnCheckCapacity=false end if End Function Function fnDbProfile(sql) set rsProfile = conn.execute(sql) If Not rsProfile.BOF and Not rsProfile.EOF then iCols = rsProfile.Fields.Count For I = 0 To iCols - 1 myfields = rsProfile.Fields.Item(I).Name Execute(Myfields & " = """"") Execute(Myfields & " = trim(rsProfile(myfields))") 'Response.Write Myfields & " | " Next End If rsProfile.close() set rsProfile=nothing End Function Function fnDBProfile2(dbname, dblogin, dbpass, dbip, sql) DBConnectx = "uid=" & dbLogin & ";pwd=" & dbPass & ";driver={SQL Server};server=" & dbip & ";database=" & dbname Set connx = Server.CreateObject("ADODB.Connection") connx.Open DBConnectx set rsProfile = connx.execute(sql) If Not rsProfile.BOF and Not rsProfile.EOF then iCols = rsProfile.Fields.Count For I = 0 To iCols - 1 myfields = rsProfile.Fields.Item(I).Name Execute(Myfields & " = """"") Execute(Myfields & " = trim(rsProfile(myfields))") 'Response.Write Myfields & " | " Next End If rsProfile.close() set rsProfile=nothing connx.Close() set connx=nothing End Function Function fnDBUpdate2(dbname, dblogin, dbpass, dbip, sql) DBConnect2 = "uid=" & dbLogin & ";pwd=" & dbPass & ";driver={SQL Server};server=" & dbip & ";database=" & dbname Set conn2 = Server.CreateObject("ADODB.Connection") conn2.Open DBConnect2 set rsProfile2 = conn2.execute(sql) End Function Function fnDbClose() conn2.close() set conn2=nothing End Function %>
<% //session("result")="" answer = request.form("answer") if answer<>"" and isnumeric(answer) and session("result")="" then sql = "update tbl_content set info3 = info3 + 1 where contentId='" & answer & "'" conn.execute(sql) session("result")=true end if sql = "select top 1 * from tbl_content where contentType='poll_questions' and convert(datetime,info2)<'" & now() & "' and convert(datetime,info3)>'" & now() & "' and status=1" set rsq=conn.execute(sql) if not rsq.eof then sql = "select sum(convert(int,info3)) as totalVote from tbl_content where info2='" & rsq("contentId") & "'" set rsv = conn.execute(sql) if not rsv.eof then totalVote = rsv("totalVote") end if rsv.close set rsv=nothing response.Write "" & rsq("info1") & "" sql = "select * from tbl_content where info2='" & rsq("contentId") & "' order by rank" set rs=conn.execute(sql) x = 0 do while not rs.eof x = x + 1 response.Write "
" if session("result")="" then response.Write " " //if x = 1 then response.Write "A. " //if x = 2 then response.Write "B. " //if x = 3 then response.Write "C. " //if x = 4 then response.Write "D. " //if x = 5 then response.Write "E. " response.Write rs("info1") if session("result") = true then if isnumeric(rs("info3")) and totalVote>0 then votePercent = cdbl(rs("info3"))/totalVote barWidth = 280 * votePercent else votePercent = 0 end if response.Write "
" & formatnumber(votePercent*100,0) & "%
" end if response.Write "
" rs.movenext loop rs.close set rs=nothing else response.Write "No Active Poll" end if rsq.close set rsq=nothing if session("result")="" then response.Write "
" %>