<% ' ############################################################# ' ## Change the database_location field to be the local path ## ' ## to the database file. For instance, if you move the ## ' ## database file inside of a folder named "data123" the ## ' ## field would be changed to: ## ' ## ## ' ## database_location = "data123/o12calgold.mdb" ## ' ## ## ' ############################################################# database_location = "../access_db/o12calgold.mdb" ' ########################################### ' ## Do NOT edit any of the following code ## ' ########################################### dsn="DBQ=" & Server.Mappath(database_location) & ";Driver={Microsoft Access Driver (*.mdb)};" Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open dsn Set RSBODY = Server.CreateObject("ADODB.Recordset") SQLBODY = "SELECT * FROM o12calgold_Settings WHERE SettingID=1" RSBODY.Open SQLBODY, Conn, 1, 3 %> <% Dim mailComponent(5) Dim mailComponentName(5) mailComponent(0) = "SMTPsvg.Mailer" mailComponent(1) = "Persits.MailSender" mailComponent(2) = "CDONTS.NewMail" mailComponent(3) = "CDO.Message" mailComponent(4) = "Dundas.Mailer" mailComponent(5) = "Jmail.smtpmail" mailComponentName(0) = "ASPMail" mailComponentName(1) = "ASPEMail" mailComponentName(2) = "CDONTS" mailComponentName(3) = "CDOSYS" mailComponentName(4) = "Dundas Mailer" mailComponentName(5) = "JMail" Function findMonth(varDate) 'Finds month given YYYYMMDD findMonth = CInt(Right(Left(varDate,6),2)) End Function Function findDay(varDate) 'Finds day given YYYYMMDD findDay = CInt(Right(Left(varDate,8),2)) End Function Function findYear(varDate) 'Finds year given YYYYMMDD findYear = CInt(Left(varDate,4)) End Function Function findHour(varDate) 'Finds hour given YYYYMMDD If CInt(Right(Left(varDate,10),2)) > 12 Then findHour = CInt(Right(Left(varDate,10),2)) - 12 ElseIf CInt(Right(Left(varDate,10),2)) = 0 Then findHour = 12 ElseIf CInt(Right(Left(varDate,10),2) < 10) Then findHour = CInt(Right(Left(varDate,10),1)) Else findHour = CInt(Right(Left(varDate,10),2)) End If End Function Function findHourLong(varDate) 'Finds 0-23 hour given YYYYMMDD findHourLong = CInt(Right(Left(varDate,10),2)) End Function Function findMinute(varDate) 'Finds minute given YYYYMMDD findMinute = Right(Left(varDate,12),2) End Function Function findSecond(varDate) 'Finds second given YYYYMMDD findSecond = Right(varDate,2) End Function Function findAMPM(varDate) 'Finds AM/PM given YYYYMMDD If Right(Left(varDate,10),2) >= 12 Then findAMPM = "PM" Else findAMPM = "AM" End If End Function Function findYearRev(varDate) 'Finds year given MM/YY/DDDD findYearRev = Right(varDate, 4) End Function Function findMonthRev(varDate) 'Finds month given MM/YY/DDDD If RSBODY("DateFormat") = "MM/DD/YYYY" Then findMonthRev = Left(varDate, InStr(varDate, "/") - 1) Else findMonthRev = Mid(varDate, InStr(varDate, "/") + 1, InStrRev(varDate, "/") - InStr(varDate, "/") - 1) End If End Function Function findDayRev(varDate) 'Finds month given MM/YY/DDDD If RSBODY("DateFormat") = "MM/DD/YYYY" Then findDayRev = Mid(varDate, InStr(varDate, "/") + 1, InStrRev(varDate, "/") - InStr(varDate, "/") - 1) Else findDayRev = Left(varDate, InStr(varDate, "/") - 1) End If End Function Function findDate(varDate) 'Finds MM/DD/YYYY given YYYYMMDD If RSBODY("DateFormat") = "MM/DD/YYYY" Then findDate = findMonth(varDate) & "/" & findDay(varDate) & "/" & findYear(varDate) Else findDate = findDay(varDate) & "/" & findMonth(varDate) & "/" & findYear(varDate) End If End Function Function findShortDate(varDate) 'Finds YYYYMMDD given YYYYMMDDHHMMSS findShortDate = prepareDate(findMonth(varDate), findDay(varDate), findYear(varDate)) End Function Function findTime(varDate) 'Finds HH:MMAMPM given YYYYMMDD findTime = CInt(findHour(varDate)) & ":" & findMinute(varDate) & lcase(findAMPM(varDate)) End Function Function findTimeName(varDate) 'Finds HH:MMAMPM given YYYYMMDD If CInt(findHour(varDate)) = 12 AND CInt(findMinute(varDate)) = 0 AND findAMPM(varDate) = "AM" Then findTimeName = "Midnight" ElseIf CInt(findHour(varDate)) = 12 AND CInt(findMinute(varDate)) = 0 AND findAMPM(varDate) = "PM" Then findTimeName = "Noon" ElseIf CInt(findHour(varDate)) = 11 AND CInt(findMinute(varDate)) = 59 AND findAMPM(varDate) = "PM" Then findTimeName = "Midnight" Else findTimeName = CInt(findHour(varDate)) & ":" & findMinute(varDate) & lcase(findAMPM(varDate)) End If End Function Function findDateName(varDate) 'Finds Name DD, YYYY given YYYYMMDD If RSBODY("DateFormat") = "MM/DD/YYYY" Then findDateName = MonthName(findMonth(varDate)) & " " & findDay(varDate) & ", " & findYear(varDate) Else findDateName = findDay(varDate) & " " & MonthName(findMonth(varDate)) & " " & findYear(varDate) End If End Function Function findDateTime(varDate) 'Finds MM/DD/YYYY HH:MM:SS AMPM given YYYYMMDD If RSBODY("DateFormat") = "MM/DD/YYYY" Then findDateTime = findMonth(varDate) & "/" & findDay(varDate) & "/" & findYear(varDate) & " " & findHour(varDate) & ":" & findMinute(varDate) & ":" & findSecond(varDate) & " " & findAMPM(varDate) Else findDateTime = findDay(varDate) & "/" & findMonth(varDate) & "/" & findYear(varDate) & " " & findHour(varDate) & ":" & findMinute(varDate) & ":" & findSecond(varDate) & " " & findAMPM(varDate) End If End Function Function findDateTimeShort(varDate) 'Finds MM/DD/YYYY HH:MM AMPM given YYYYMMDD If RSBODY("DateFormat") = "MM/DD/YYYY" Then findDateTime = findMonth(varDate) & "/" & findDay(varDate) & "/" & findYear(varDate) & " " & findHour(varDate) & ":" & findMinute(varDate) & " " & findAMPM(varDate) Else findDateTime = findDay(varDate) & "/" & findMonth(varDate) & "/" & findYear(varDate) & " " & findHour(varDate) & ":" & findMinute(varDate) & " " & findAMPM(varDate) End If End Function Function prepareDate(x, y, z) varMonth = x varDay = y varYear = z ' Finds YYYYMMDD given Month, Day, Year If varMonth < 10 Then varMonth = "0" & varMonth End If If varDay < 10 Then varDay = "0" & varDay End If prepareDate = varYear & varMonth & varDay End Function Function prepareDateTime(varMonth, varDay, varYear, varHour, varMinute, varSecond) ' Finds YYYYMMDD given Month, Day, Year varMonth1 = varMonth If varMonth1 < 10 Then varMonth1 = "0" & varMonth1 End If varDay1 = varDay If varDay1 < 10 Then varDay1 = "0" & varDay1 End If varHour1 = varHour If varHour1 < 10 Then varHour1 = "0" & varHour1 End If varMinute1 = varMinute If varMinute1 < 10 Then varMinute1 = "0" & varMinute1 End If varSecond1 = varSecond If varSecond1 < 10 Then varSecond1 = "0" & varSecond1 End If prepareDateTime = varYear & varMonth1 & varDay1 & varHour1 & varMinute1 & varSecond1 End Function Function dateToday() varMonth = Month(Now) varDay = Day(Now) varYear = Year(Now) dateToday = prepareDate(varMonth, varDay, varYear) End Function Function prepareDateTimeNow() If Month(Now) < 10 Then varMonth = "0" & Month(Now) Else varMonth = Month(Now) End If If Day(Now) < 10 Then varDay = "0" & Day(Now) Else varDay = Day(Now) End If If Hour(Now) < 10 Then varHour = "0" & Hour(Now) Else varHour = Hour(Now) End If If Minute(Now) < 10 Then varMinute = "0" & Minute(Now) Else varMinute = Minute(Now) End If If Second(Now) < 10 Then varSecond = "0" & Second(Now) Else varSecond = Second(Now) End If prepareDateTimeNow = Year(Now) & varMonth & varDay & varHour & varMinute & varSecond End Function Function addDate(strBy, strDate, intNum) iYear = CInt(findYear(strDate)) iMonth = CInt(findMonth(strDate)) iDay = CInt(findDay(strDate)) iHour = CInt(findHourLong(strDate)) iMinute = CInt(findMinute(strDate)) iSecond = CInt(findSecond(strDate)) iDays = daysOfMonth(iMonth, iYear) If strBy = "d" Then ' Add Days iDay = iDay + intNum Do While iDay > daysOfMonth(iMonth, iYear) iDay = iDay - daysOfMonth(iMonth, iYear) iMonth = iMonth + 1 If iMonth = 13 Then iMonth = 1 iYear = iYear + 1 End If Loop ElseIf strBy = "w" Then ' Add Weeks iDay = iDay + (intNum * 7) Do While iDay > daysOfMonth(iMonth, iYear) iDay = iDay - daysOfMonth(iMonth, iYear) iMonth = iMonth + 1 If iMonth = 13 Then iMonth = 1 iYear = iYear + 1 End If Loop ElseIf strBy = "m" Then ' Add Weeks iMonth = iMonth + intNum Do While iMonth > 12 iMonth = iMonth - 12 iYear = iYear + 1 Loop ElseIf strBy = "y" Then ' Add Weeks iYear = iYear + intNum End If addDate = prepareDateTime(iMonth, iDay, iYear, iHour, iMinute, iSecond) End Function Function subDate(strBy, strDate, intNum) iYear = CInt(findYear(strDate)) iMonth = CInt(findMonth(strDate)) iDay = CInt(findDay(strDate)) iHour = CInt(findHourLong(strDate)) iMinute = CInt(findMinute(strDate)) iSecond = CInt(findSecond(strDate)) iDays = daysOfMonth(iMonth, iYear) If strBy = "d" Then ' Add Days iDay = iDay - intNum Do While iDay < 0 iMonth = iMonth - 1 iDay = iDay + daysOfMonth(iMonth, iYear) If iMonth = 0 Then iMonth = 12 iYear = iYear - 1 End If Loop ElseIf strBy = "w" Then ' Add Weeks iDay = iDay - (intNum * 7) Do While iDay < 0 iMonth = iMonth - 1 iDay = iDay + daysOfMonth(iMonth, iYear) If iMonth = 0 Then iMonth = 12 iYear = iYear - 1 End If Loop ElseIf strBy = "m" Then ' Add Weeks iMonth = iMonth - intNum Do While iMonth < 1 iMonth = iMonth + 12 iYear = iYear - 1 Loop ElseIf strBy = "y" Then ' Add Weeks iYear = iYear - intNum End If subDate = prepareDateTime(iMonth, iDay, iYear, iHour, iMinute, iSecond) End Function Function findFirstDayOfWeek(varDate) iMonth = findMonth(varDate) iDay = findDay(varDate) iYear = findYear(varDate) thisDayOfWeek = findDayOfWeek(iMonth, iDay, iYear) findFirstDayOfWeek = subDate("d", varDate, thisDayOfWeek) End Function Function findDayOfMonth(varYear, varMonth, varWhich, varWhichDay) iNumDays = daysOfMonth(varMonth, varYear) Dim Days(7) For i = 1 to iNumDays tmp = i curWeekDay = findDayOfWeek(varMonth, tmp, varYear) + 1 Days(curWeekDay) = Days(curWeekDay) + 1 If curWeekDay = varWhichDay AND Days(curWeekDay) = varWhich Then findDayOfMonth = i Exit For End If Next ' Check for last If Len(findDayOfMonth) = 0 AND varWhich = 5 Then For i = iNumDays to 1 step -1 tmp = i If findDayOfWeek(varMonth, tmp, varYear) + 1 = varWhichDay Then findDayOfMonth = i Exit For End If Next End If End Function Function findFirstDayOfMonth(varMonth, varYear) findFirstDayOfMonth = prepareDateTime(varMonth, 1, varYear, 0, 0, 0) End Function Function findGraphWidth(varTotal, varThis) findGraphWidth = Round(((varThis / varTotal * 100) * 2),0) End Function Function findGraphPercent(varTotal, varThis) findGraphPercent = FormatNumber((varThis / varTotal * 100),2) End Function Function findResponseRate(varResponses,varViews) If varViews = 0 Then findResponseRate = 0 Else findResponseRate = FormatNumber((varResponses / varViews * 100),2) End If End Function Function sendMail(varTo, varFrom, varEmailComp, varSMTPServer, varBody, varSubject) If varEmailComp = "CDONTS" Then Set mailObj = Server.CreateObject("CDONTS.NewMail") mailObj.BodyFormat = 1 mailObj.MailFormat = 1 mailObj.To = varTo mailObj.From = varFrom mailObj.Subject = varSubject mailObj.Body = varBody mailObj.Send Set mailObj = Nothing ElseIf varEmailComp = "CDOSYS" Then Set mailObj = Server.CreateObject("CDO.Message") mailObj.To = varTo mailObj.From = varFrom mailObj.Subject = varSubject mailObj.TextBody = varBody mailObj.Send Set mailObj = Nothing ElseIf varEmailComp = "ASPEmail" Then Set mailObj = Server.CreateObject("Persits.MailSender") mailObj.Host = varSMTPServer mailObj.IsHTML = False mailObj.AddAddress varTo mailObj.From = varFrom mailObj.Subject = varSubject mailObj.Body = varBody mailObj.Send Set mailObj = Nothing ElseIf varEmailComp = "ASPMail" Then Set mailObj = Server.CreateObject("SMTPsvg.Mailer") mailObj.RemoteHost = varSMTPServer mailObj.CharSet = 2 mailObj.FromName = varFrom mailObj.FromAddress= varFrom mailObj.AddRecipient varTo,varTo mailObj.Subject = varSubject mailObj.BodyText = varBody mailObj.SendMail ElseIf varEmailComp = "JMail" Then set mailObj = Server.CreateOBject("JMail.Message") mailObj.Logging = true mailObj.silent = true mailObj.From = varFrom mailObj.AddRecipient varTo mailObj.Subject = varSubject mailObj.body = varBody mailObj.Send(varSMTPServer) ElseIf varEmailComp = "Dundas" Then Set mailObj = Server.CreateOBject("Dundas.Mailer") mailObj.FromAddress = varFrom mailObj.TOs.Add varTo mailObj.Subject = varSubject mailObj.body = varBody mailObj.SendMail End If sendMail = 1 End Function Function true_mod(x, y) tmp = x Mod y If tmp < 0 Then true_mod = tmp + y Else true_mod = tmp End If End Function Function isLeapYear(yr) If isDivisibleBy(yr, 4) Then If isDivisibleBy(yr, 100) Then If isDivisibleBy(yr, 400) Then isLeapYear = True Else isLeapYear = False End If Else isLeapYear = True End If Else isLeapYear = False End If End Function Function isDivisibleBy(x, y) If x Mod y = 0 Then isDivisibleBy = True Else isDivisibleBy = False End If End Function Function daysOfMonth(m, y) Select Case m Case 1, 3, 5, 7, 8, 10, 12 daysOfMonth = 31 Case 4, 6, 9, 11 daysOfMonth = 30 Case Else If isLeapYear(y) Then daysOfMonth = 29 Else daysOfMonth = 28 End If End Select End Function Function findDayOfWeek(x, y, z) m = x d = y yr = z If m < 3 Then m = m + 10 yr = yr - 1 Else m = m - 2 End If y = true_mod(yr, 100) c = yr \ 100 a = (13 * m - 1) \ 5 b = y \ 4 e = c \ 4 f = a + b + e + d + y - 2 * c findDayOfWeek = true_mod(f, 7) End Function Function prepareSQL(varString) If Len(varString) > 0 Then prepareSQL = Replace(varString,"'","''") Else prepareSQL = varString End If End Function Function prepareHTML(varString) If Len(varString) > 0 Then varString = Replace(varString,"<","<") varString = Replace(varString,">",">") varString = Replace(varString,"''","'") prepareHTML = Replace(varString,"""",""") Else prepareHTML = varString End If End Function Function prepareRenderHTML(varString) If Len(varString) > 0 Then prepareRenderHTML = Replace(varString,"''","'") Else prepareRenderHTML = varString End If End Function Function IsObjInstalled(strClassString) On Error Resume Next IsObjInstalled = False Err = 0 Dim xTestObj Set xTestObj = Server.CreateObject(strClassString) If 0 = Err Then IsObjInstalled = True End If Set xTestObj = Nothing Err = 0 End Function %> <% Set RS = Server.CreateObject("ADODB.Recordset") Set RS2 = Server.CreateObject("ADODB.Recordset") Set RSCalendar = Server.CreateObject("ADODB.Recordset") ' Get Calendar ID CalendarID = request("CalendarID") If Len(Trim(CalendarID)) = 0 Then CalendarID = RSBODY("DefaultCalendar") End If If Len(Trim(CalendarID)) = 0 OR isNull(CalendarID) Then SQL = "SELECT CalendarID FROM o12calgold_Calendars ORDER BY CalendarID" RS.Open SQL, Conn, 1, 3 If Not RS.EOF Then CalendarID = RS("CalendarID") Else Response.redirect "admin.asp?Error=NoCalendar" End If RS.Close End If SQLCalendar = "SELECT * FROM o12calgold_Calendars WHERE CalendarID= " & CalendarID RSCalendar.Open SQLCalendar, Conn, 1, 3 calendarName = RSCalendar("Title") isPrivate = RSCalendar("Private") StyleID = RSCalendar("StyleID") AllowRegister = RSCalendar("AllowRegister") ' Get this Month & Year thisMonth = request("thisMonth") thisYear = request("thisYear") If Len(thisMonth) = 0 Then thisMonth = Month(Now) Else thisMonth = CInt(thisMonth) End If If Len(thisYear) = 0 Then thisYear = Year(Now) Else thisYear = CInt(thisYear) End If ' Get last Month & Year lastMonth = thisMonth - 1 If lastMonth = 0 Then lastMonth = 12 lastYear = thisYear - 1 Else lastYear = thisYear End If ' Get next Month & Year nextMonth = thisMonth + 1 If nextMonth = 13 Then nextMonth = 1 nextYear = thisYear + 1 Else nextYear = thisYear End If numDays = daysOfMonth(thisMonth, thisYear) firstDay = findDayOfWeek(thisMonth, 1, thisYear) startDayLastMonth = daysOfMonth(lastMonth, lastYear) - (firstDay - 1) calMonth = thisMonth If calMonth < 10 Then calMonth = "0" & calMonth End If calNextMonth = thisMonth + 1 If calNextMonth < 10 Then calNextMonth = "0" & calNextMonth End If ' Get last day of current month firstDayOfMonth = thisYear & calMonth & "01000000" lastDayOfMonth = thisYear & calMonth & numDays & "000000" firstDayOfNextMonth = thisYear & calNextMonth & "01000000" ' Get Events dim Events(31) SQL = "SELECT * FROM o12calgold_Events WHERE CalendarID=" & CalendarID & " AND StartDate < '" & firstDayOfNextMonth & "'" RS.Open SQL, Conn, 1, 3 Do While Not RS.EOF If RS("StartDate") >= firstDayOfMonth Then ' Event starts in or before this Month startDay = findDay(RS("StartDate")) startMonth = findMonth(RS("StartDate")) endDay = findDay(RS("EndDate")) endMonth = findMonth(RS("EndDate")) endYear = findYear(RS("EndDate")) If thisMonth <> endMonth OR thisYear < endYear Then endDay = numDays End If For i = startDay To endDay If Len(Events(i)) = 0 Then Events(i) = RS("EventID") Else Events(i) = Events(i) & ", " & RS("EventID") End If Next ElseIf RS("EndDate") >= firstDayOfMonth Then ' Event starts before this month, but ends in this month endDay = findDay(RS("EndDate")) endMonth = findMonth(RS("EndDate")) If thisMonth <> endMonth Then endDay = numDays End If For i = 1 To endDay If Len(Events(i)) = 0 Then Events(i) = RS("EventID") Else Events(i) = Events(i) & ", " & RS("EventID") End If Next End If RS.movenext Loop RS.Close ' Get Recurring Events SQL = "SELECT * FROM o12calgold_Events WHERE CalendarID=" & CalendarID & " AND StartDate <= '" & lastDayOfMonth & "' AND Recur > 0" RS.Open SQL, Conn, 1, 3 Do While Not RS.EOF thisfirstDay = findDay(firstDayOfMonth) thislastDay = findDay(lastDayOfMonth) RecurNum = 1 If RS("Recur") = 1 Then ' Event recurs Daily If RS("RecurDailyType") = 0 Then ' Recur every d Days eventDay = addDate("d", RS("StartDate"), RS("RecurDailyEveryNumDays")) Do While eventDay < firstDayOfNextMonth If eventDay >= firstDayOfMonth Then ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If eventDay >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(findDay(eventDay))) = 0 Then Events(findDay(eventDay)) = RS("EventID") Else Events(findDay(eventDay)) = Events(findDay(eventDay)) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 Else RecurNum = RecurNum + 1 End If eventDay = addDate("d", eventDay, RS("RecurDailyEveryNumDays")) ' Check End Recur If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit Do End If End If Loop Else ' Recur every weekday eventDay = addDate("d", RS("StartDate"), 1) Do While eventDay < firstDayOfNextMonth dayofweek = findDayOfWeek(findMonth(eventDay), findDay(eventDay), findYear(eventDay)) If eventDay >= firstDayOfMonth Then If eventDay >= firstDayOfMonth AND (dayofweek = 1 OR dayofweek = 2 OR dayofweek = 3 OR dayofweek = 4 OR dayofweek = 5) Then ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If eventDay >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(findDay(eventDay))) = 0 Then Events(findDay(eventDay)) = RS("EventID") Else Events(findDay(eventDay)) = Events(findDay(eventDay)) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 End If Else If dayofweek = 1 OR dayofweek = 2 OR dayofweek = 3 OR dayofweek = 4 OR dayofweek = 5 Then RecurNum = RecurNum + 1 End If End If eventDay = addDate("d", eventDay, 1) ' Check End Recur If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit Do End If End If Loop End If ElseIf RS("Recur") = 2 Then ' Event recurs Weekly ' Recur every w weeks eventDay = addDate("d", RS("StartDate"), 1) startWeek = findFirstDayOfWeek(eventDay) eventDayOfWeek = findDayOfWeek(findMonth(eventDay), findDay(eventDay), findYear(eventDay)) ' Check remainder of first week For i = eventDayOfWeek to 6 thisRecurDate = addDate("d", startWeek, i) If thisRecurDate < firstDayOfNextMonth Then If RS("RecurWeeklyDay" & i + 1) = 1 Then If thisRecurDate > firstDayOfMonth Then ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then Exit For End If End If If Len(Events(findDay(thisRecurDate))) = 0 Then Events(findDay(thisRecurDate)) = RS("EventID") Else Events(findDay(thisRecurDate)) = Events(findDay(thisRecurDate)) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 Else ' Event happened in previous month. RecurNum = RecurNum + 1 End If End If If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit For End If End If End If Next ' Check other weeks Do While addDate("w", startWeek, RS("RecurWeeklyNumWeeks")) < firstDayOfNextMonth startWeek = addDate("w", startWeek, RS("RecurWeeklyNumWeeks")) For i = 0 to 6 thisRecurDate = addDate("d", startWeek, i) If thisRecurDate < firstDayOfNextMonth Then If RS("RecurWeeklyDay" & i + 1) = 1 Then If thisRecurDate > firstDayOfMonth Then ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(findDay(thisRecurDate))) = 0 Then Events(findDay(thisRecurDate)) = RS("EventID") Else Events(findDay(thisRecurDate)) = Events(findDay(thisRecurDate)) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 Else ' Event happened in previous month. RecurNum = RecurNum + 1 End If End If If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit For End If End If End If Next Loop ElseIf RS("Recur") = 3 Then ' Event recurs Monthly If RS("RecurMonthlyType") = 0 Then ' Recur every d Day of m Months eventDay = RS("StartDate") ' check this month If findDay(eventDay) < RS("RecurMonthlyDay") AND findMonth(eventDay) = thisMonth AND findYear(eventDay) = thisYear Then thisRecurDate = prepareDateTime(thisMonth, RS("RecurMonthlyDay"), thisYear, 0, 0, 0) ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(RS("RecurMonthlyDay"))) = 0 Then Events(RS("RecurMonthlyDay")) = RS("EventID") Else Events(RS("RecurMonthlyDay")) = Events(RS("RecurMonthlyDay")) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 End If ' check other months eventDay = addDate("m", findFirstDayOfMonth(findMonth(eventDay), findYear(eventDay)), RS("RecurMonthlyDayMonths")) Do While eventDay < firstDayOfNextMonth If findMonth(eventDay) = thisMonth AND findYear(eventDay) = thisYear Then thisRecurDate = prepareDateTime(thisMonth, RS("RecurMonthlyDay"), thisYear, 0, 0, 0) ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(RS("RecurMonthlyDay"))) = 0 Then Events(RS("RecurMonthlyDay")) = RS("EventID") Else Events(RS("RecurMonthlyDay")) = Events(RS("RecurMonthlyDay")) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 Else RecurNum = RecurNum + 1 End If eventDay = addDate("m", eventDay, RS("RecurMonthlyDayMonths")) If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit Do End If End If Loop Else ' Recur w week, d weekday of every m months eventDay = RS("StartDate") ' check this month recurDay = findDayOfMonth(thisYear, thisMonth, RS("RecurMonthlyWhich"), RS("RecurMonthlyWhichDay")) If findDay(eventDay) < recurDay AND findMonth(eventDay) = thisMonth AND findYear(eventDay) = thisYear Then thisRecurDate = prepareDateTime(thisMonth, recurDay, thisYear, 0, 0, 0) ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(recurDay)) = 0 Then Events(recurDay) = RS("EventID") Else Events(recurDay) = Events(recurDay) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 End If ' check other months eventDay = addDate("m", findFirstDayOfMonth(findMonth(eventDay), findYear(eventDay)), RS("RecurMonthlyWhichMonth")) Do While eventDay < firstDayOfNextMonth recurDay = findDayOfMonth(thisYear, thisMonth, RS("RecurMonthlyWhich"), RS("RecurMonthlyWhichDay")) If findMonth(eventDay) = thisMonth AND findYear(eventDay) = thisYear Then thisRecurDate = prepareDateTime(thisMonth, recurDay, thisYear, 0, 0, 0) ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(recurDay)) = 0 Then Events(recurDay) = RS("EventID") Else Events(recurDay) = Events(recurDay) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 Else RecurNum = RecurNum + 1 End If eventDay = addDate("m", eventDay, RS("RecurMonthlyWhichMonth")) If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit Do End If End If Loop End If ElseIf RS("Recur") = 4 Then ' Event recurs Yearly If RS("RecurYearlyType") = 0 Then ' Recur every d day of m month recurMonth = RS("RecurYearlyMonth") recurDay = RS("RecurYearlyDay") eventDay = prepareDate(recurMonth, recurDay, findYear(RS("startDate"))) Do While eventDay < firstDayOfNextMonth If eventDay > findShortDate(RS("startDate")) Then If eventDay >= firstDayOfMonth Then ' Check if past end recur date thisRecurDate = prepareDateTime(findMonth(eventDay), findDay(eventDay), findYear(eventDay), 0, 0, 0) If Len(RS("RecurEndDate")) > 0 Then If eventDay >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(findDay(eventDay))) = 0 Then Events(findDay(eventDay)) = RS("EventID") Else Events(findDay(eventDay)) = Events(findDay(eventDay)) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 Else RecurNum = RecurNum + 1 End If End If eventDay = addDate("y", eventDay, 1) ' Check End Recur If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit Do End If End If Loop Else ' Recur w week, d weekday of every m Month eventDay = RS("StartDate") ' check this month recurDay = findDayOfMonth(findYear(eventDay), RS("RecurYearlyWhichMonth"), RS("RecurYearlyWhich"), RS("RecurYearlyWhichDay")) recurDate = prepareDate(RS("RecurYearlyWhichMonth"), recurDay, findYear(eventDay)) If findShortDate(eventDay) < recurDate AND findMonth(recurDate) = thisMonth AND findYear(recurDate) = thisYear Then thisRecurDate = prepareDateTime(thisMonth, recurDay, thisYear, 0, 0, 0) ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then ' Don't display Else If Len(Events(recurDay)) = 0 Then Events(recurDay) = RS("EventID") Else Events(recurDay) = Events(recurDay) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 End If Else If Len(Events(recurDay)) = 0 Then Events(recurDay) = RS("EventID") Else Events(recurDay) = Events(recurDay) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 End If End If ' check other months eventDay = addDate("y", findFirstDayOfMonth(RS("RecurYearlyWhichMonth"), findYear(eventDay)), 1) Do While eventDay < firstDayOfNextMonth recurDay = findDayOfMonth(findYear(eventDay), RS("RecurYearlyWhichMonth"), RS("RecurYearlyWhich"), RS("RecurYearlyWhichDay")) recurDate = prepareDate(RS("RecurYearlyWhichMonth"), recurDay, findYear(eventDay)) If findShortDate(eventDay) < recurDate AND findMonth(recurDate) = thisMonth AND findYear(recurDate) = thisYear Then thisRecurDate = prepareDateTime(thisMonth, recurDay, thisYear, 0, 0, 0) ' Check if past end recur date If Len(RS("RecurEndDate")) > 0 Then If thisRecurDate >= addDate("d", RS("RecurEndDate"), 1) Then Exit Do End If End If If Len(Events(recurDay)) = 0 Then Events(recurDay) = RS("EventID") Else Events(recurDay) = Events(recurDay) & ", " & RS("EventID") End If RecurNum = RecurNum + 1 Else RecurNum = RecurNum + 1 End If eventDay = addDate("y", eventDay, 1) If Len(RS("RecurEnd")) > 0 Then If RS("RecurEnd") = RecurNum Then Exit Do End If End If Loop End If End If RS.movenext Loop RS.Close %> <%=calendarName%> <% ' Get CSS SQL = "SELECT * FROM o12calgold_Styles WHERE StyleID = " & StyleID RS.Open SQL, Conn, 1, 3 %> <% Header = RS("Header") Footer = RS("Footer") DisplayWidth = RS("DisplayWidth") Color_Border = RS("Color_Border") EventDisplayType = RS("EventDisplayType") If Len(EventDisplayType) = 0 Then EventDisplayType = 0 End If RS.Close %> <%=prepareRenderHTML(Header)%> <% SQL = "SELECT o12calgold_Users.* FROM o12calgold_Users, o12calgold_CalendarUser WHERE o12calgold_Users.UserID = o12calgold_CalendarUser.UserID AND o12calgold_Users.Username = '" & Session("o12calgold_Username") & "' AND o12calgold_CalendarUser.CalendarID = " & CalendarID RS.Open SQL, Conn, 1, 3 If RS.BOF AND RS.EOF Then userLoggedIn = False Else userLoggedIn = True End If RS.Close SQL = "SELECT o12calgold_Users.* FROM o12calgold_Users, o12calgold_CalendarAdmin WHERE o12calgold_Users.UserID = o12calgold_CalendarAdmin.UserID AND o12calgold_Users.Username = '" & Session("o12calgold_Username") & "' AND o12calgold_CalendarAdmin.CalendarID = " & CalendarID RS.Open SQL, Conn, 1, 3 If RS.BOF AND RS.EOF Then adminLoggedIn = False Else adminLoggedIn = True End If RS.Close If (isPrivate = 1 AND NOT userLoggedIn AND NOT adminLoggedIn AND NOT Session("o12calgold_isAdmin")) OR request("Page") = "Login" OR Len(request("Error")) > 0 Then %>
<%If Len(Trim(request("Error"))) = 0 Then%><%If request("Page") <> "Login" Then%>This calendar is set to private.<%End If%><%Else%>Login Failed.<%End If%>

   Login
Request Password
<%If AllowRegister = 1 Then%>Register<%End If%>
<%Else%>
<    << <%=RSBODY("MonthName" & thisMonth)%> <%=thisYear%> >>    >
<% dayOfWeek = 0 For i = startDayLastMonth to startDayLastMonth + (firstDay - 1) Response.write "" dayOfWeek = dayOfWeek + 1 Next For i = 1 to numDays If thisMonth = Month(Now) AND thisYear = Year(Now) AND i = Day(Now) Then thisStyle = "c_today" ElseIf dayOfWeek = 0 OR dayOfWeek = 6 Then thisStyle = "c_weekend" Else thisStyle = "c_weekday" End If ' Get Events If Len(Events(i)) > 0 Then SQL = "SELECT * FROM o12calgold_Events WHERE EventID IN (" & Events(i) & ") ORDER BY AllDay Desc, mid(StartDate, 9, 6), mid(EndDate, 9, 6), StartDate" RS.Open SQL, Conn, 1, 3 iEvents = "" Do While Not RS.EOF startDate = prepareDate(findMonth(RS("StartDate")), findDay(RS("StartDate")), findYear(RS("StartDate"))) endDate = prepareDate(findMonth(RS("EndDate")), findDay(RS("EndDate")), findYear(RS("EndDate"))) thisDate = prepareDate(thisMonth, i, thisYear) SQL2 = "SELECT * FROM o12calgold_EventsNoRecur WHERE EventID =" & RS("EventID") & " AND Date = '" & thisDate & "'" RS2.Open SQL2, Conn, 1, 3 If RS2.EOF Then If RS("AllDay") = 1 OR (startDate < thisDate AND endDate > thisDate) Then thisTime = "All Day" ElseIf startDate = thisDate AND startDate < endDate Then thisTime = findTimeName(RS("StartDate")) & "-Midnight" ElseIf endDate = thisDate AND startDate < endDate Then thisTime = "Midnight-" & findTimeName(RS("EndDate")) Else thisTime = findTimeName(RS("StartDate")) & "-" & findTimeName(RS("EndDate")) End If iEvents = iEvents & "
" & thisTime & " " & prepareHTML(RS("Name")) & "" & prepareHTML(RS("Location")) & "
" End If RS2.Close RS.movenext Loop RS.Close Else iEvents = "" End If Response.write "" If dayOfWeek = 6 Then If i = numDays Then Response.write "" Else Response.write "" End If dayOfWeek = -1 End If dayofWeek = dayOfWeek + 1 Next If dayOfWeek > 0 Then For i = 1 to 7 - dayofWeek Response.write "" dayOfWeek = dayOfWeek + 1 Next End If %>
<%=prepareHTML(RSBODY("DayName1"))%> <%=prepareHTML(RSBODY("DayName2"))%> <%=prepareHTML(RSBODY("DayName3"))%> <%=prepareHTML(RSBODY("DayName4"))%> <%=prepareHTML(RSBODY("DayName5"))%> <%=prepareHTML(RSBODY("DayName6"))%> <%=prepareHTML(RSBODY("DayName7"))%>
" & i & "
" & i & "
" & iEvents & "
" & i & "
<%If Len(Trim(Session("o12calgold_Username"))) = 0 Then%>Login
<%End If%><%If AllowRegister = 1 Then%>Register<%End If%>
main.asp<%Else%>admin.asp<%End If%>">Administrator Login
<%End If%> <%=prepareRenderHTML(Footer)%>