require("common.php"); $WeekDays = array( "0" => "Sun", "1" => "Mon", "2" => "Tue", "3" => "Wed", "4" => "Thu", "5" => "Fri", "6" => "Sat"); //set the LocationID if it's not defined if (!$LocationID) { $LocationID = "0"; } // We've got some data processing to do! // first check all of the common elements // check for mising title if ($Returned == 1 AND !$Title) { commonHeader($glbl_SiteTitle); echo "
\n\n"; // the common data checks out, lets check our other data } elseif ($Returned == 1) { // set the Active state based on the config option if ($glbl_ApprovePublicSubmission != 1) { $Active = 1; } else { $Active = 0; } // START CHECKS FOR DAILY EVENTS if ($EventType == "Daily") { // check the start date if (!checkdate($DailyStartMonth, $DailyStartDay, $DailyStartYear)) { commonHeader("Add an item"); echo "
\n\n"; $Stop = 1; // check the end date } elseif ($DailyStopMonth AND (!checkdate($DailyStopMonth, $DailyStopDay, $DailyStopYear))) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; } // Compile the dates $StartDate = $DailyStartYear."-".$DailyStartMonth."-".$DailyStartDay; $StopDate = $DailyStopYear."-".$DailyStopMonth."-".$DailyStopDay; // make sure the start comes before the stop if ($DailyStopYear) { $result = mysql("$DBName","SELECT (TO_DAYS('$StopDate') - TO_DAYS('$StartDate'))") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $dateDiff = $row[0]; } } else { $dateDiff = 0; } // somebody was trying to trick by making a stop date // before it was started if ($dateDiff < 0) { commonHeader($glbl_SiteTitle); echo "
\n\n"; // all of our checks on the surface data was good } elseif ($Stop != 1) { // check to see if the CalendarLocation already exists if (!$EventLocationID) { $result = mysql("$DBName","SELECT EventLocationID FROM phpCalendar_EventLocations WHERE LocationID = '$LocationID' AND Title = '$CLTitle' AND Address1 = '$Address1' AND Address2 = '$Address2' AND City = '$City' AND State = '$State'") or die(mysql_error()); $CountLocations = mysql_num_rows($result); } else { $CountLocations = 99; } if ($CountLocations > 0 AND $CountLocations < 99) { while($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } elseif ($CountLocations != 99 AND $CLTitle) { mysql("$DBName","INSERT INTO phpCalendar_EventLocations VALUES ( '$CLTitle','$Address1','$Address2','$City','$State','$Zip','$LocationID','')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_EventLocations") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } // if the web address doesn't begin with http:// if ($ContactWeb AND !eregi("http://",$ContactWeb)) { $ContactWeb = "http://".$ContactWeb; } // format the times if ($StartPeriod == PM AND $StartHour != 12) { $StartHour += 12; } elseif ($StartPeriod == AM AND $StartHour == 12) { $StartHour = 0; } if ($EndPeriod == PM AND $EndHour != 12) { $EndHour += 12; } elseif ($EndPeriod == AM AND $EndHour == 12) { $EndHour = 0; } $StartTime = $StartHour.":".$StartMinute; $EndTime = $EndHour.":".$EndMinute; // we can insert now mysql("$DBName","INSERT INTO phpCalendar_Details VALUES ( '$Title','$Details','$ContactName','$ContactPhone','$ContactEmail','$ContactWeb', '$EventLocationID','$StartTime','$EndTime','$ShowStart','$ShowEnd', '$LocationID','$CalendarDetailsID')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_Details") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $CalendarDetailsID = $row[0]; } mysql("$DBName","INSERT INTO phpCalendar_Daily VALUES( '$StartDate','$StopDate','$Active','$LocationID','$CalendarDetailsID')") or die(mysql_error()); // do we send a notification and to whom? if ($glbl_ApprovePublicSubmission == 1 AND ($glbl_ApprovalBySiteAdmin == 1 OR !$LocationID)) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } elseif ($glbl_ApprovePublicSubmission == 1) { $result = mysql("$DBName","SELECT Email FROM phpCalendar_AdminUsers WHERE LocationID = '$LocationID'") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $MailTo = $row[0]; } $AddrVar = $glbl_WebAdminRoot; } // what if we still don't have an address? if (!$MailTo) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } $Message = " A request has been generated from your web site for a calendar submission to be approved. Visit the address: ".$glbl_WebAddress.$AddrVar." Once logged in, select the \"Pending event administration\" link. Thank you. "; mail($MailTo, $glbl_EmailSubject, $Message, "From: $glbl_MailFrom", "-f$MailTo"); Header("Location: ./thankyou.php?LocationID=$LocationID"); exit; } // END CHECKS FOR DAILY EVENTS // START CHECKS FOR WEEKLY EVENTS } elseif ($EventType == "Weekly") { // check for missing days for ($i = 0; $WeekDays[$i]; $i++) { if ($WeeklyDays[$i] == 1) { $GotDays = 1; } } if ($GotDays != 1) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the start date } elseif (!checkdate($WeeklyStartMonth, $WeeklyStartDay, $WeeklyStartYear)) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the end date } elseif ($WeeklyStopMonth AND (!checkdate($WeeklyStopMonth, $WeeklyStopDay, $WeeklyStopYear))) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; } // Compile the dates $DisplayStart = $WeeklyStartYear."-".$WeeklyStartMonth."-".$WeeklyStartDay; $DisplayStop = $WeeklyStopYear."-".$WeeklyStopMonth."-".$WeeklyStopDay; // make sure the start comes before the stop if ($WeeklyStopYear) { $result = mysql("$DBName","SELECT (TO_DAYS('$DisplayStop') - TO_DAYS('$DisplayStart'))") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $dateDiff = $row[0]; } } else { $dateDiff = 0; } // somebody was trying to trick by making a stop date // before it was started if ($dateDiff < 0) { commonHeader($glbl_SiteTitle); echo "
\n\n"; // all of our checks on the surface data was good } elseif ($Stop != 1) { // check to see if the CalendarLocation already exists if (!$EventLocationID) { $result = mysql("$DBName","SELECT EventLocationID FROM phpCalendar_EventLocations WHERE LocationID = '$LocationID' AND Title = '$CLTitle' AND Address1 = '$Address1' AND Address2 = '$Address2' AND City = '$City' AND State = '$State'") or die(mysql_error()); $CountLocations = mysql_num_rows($result); } else { $CountLocations = 99; } if ($CountLocations > 0 AND $CountLocations < 99) { while($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } elseif ($CountLocations != 99 AND $CLTitle) { mysql("$DBName","INSERT INTO phpCalendar_EventLocations VALUES ( '$CLTitle','$Address1','$Address2','$City','$State','$Zip','$LocationID','')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_EventLocations") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } // if the web address doesn't begin with http:// if ($ContactWeb AND !eregi("http://",$ContactWeb)) { $ContactWeb = "http://".$ContactWeb; } // make a string with the days of the week for ($i = 0; $WeekDays[$i]; $i++) { if ($WeeklyDays[$i] == 1) { $DaysOfWeek .= "|$i"; } } $DaysOfWeek = ereg_replace("^\|","",$DaysOfWeek); // format the times if ($StartPeriod == PM AND $StartHour != 12) { $StartHour += 12; } elseif ($StartPeriod == AM AND $StartHour == 12) { $StartHour = 0; } if ($EndPeriod == PM AND $EndHour != 12) { $EndHour += 12; } elseif ($EndPeriod == AM AND $EndHour == 12) { $EndHour = 0; } $StartTime = $StartHour.":".$StartMinute; $EndTime = $EndHour.":".$EndMinute; // we can insert now mysql("$DBName","INSERT INTO phpCalendar_Details VALUES ( '$Title','$Details','$ContactName','$ContactPhone','$ContactEmail','$ContactWeb', '$EventLocationID','$StartTime','$EndTime','$ShowStart','$ShowEnd', '$LocationID','$CalendarDetailsID')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_Details") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $CalendarDetailsID = $row[0]; } mysql("$DBName","INSERT INTO phpCalendar_Weekly VALUES( '$DaysOfWeek','$DisplayStart','$DisplayStop','$Active','$LocationID','$CalendarDetailsID')") or die(mysql_error()); // do we send a notification and to whom? if ($glbl_ApprovePublicSubmission == 1 AND ($glbl_ApprovalBySiteAdmin == 1 OR !$LocationID)) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } elseif ($glbl_ApprovePublicSubmission == 1) { $result = mysql("$DBName","SELECT Email FROM phpCalendar_AdminEmail WHERE LocationID = '$LocationID'") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $MailTo = $row[0]; } $AddrVar = $glbl_WebAdminRoot; } // what if we still don't have an address? if (!$MailTo) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } $Message = " A request has been generated from your web site for a calendar submission to be approved. Visit the address: ".$glbl_WebAddress.$AddrVar." Once logged in, select the \"Pending event administration\" link. Thank you. "; if ($glbl_ApprovePublicSubmission == 1) { mail($MailTo, $glbl_EmailSubject, $Message, "From: $glbl_MailFrom", "-f$MailTo"); } Header("Location: ./thankyou.php?LocationID=$LocationID"); exit; } // END CHECKS FOR WEEKLY EVENTS // START CHECKS FOR MONTHLY EVENTS } elseif ($EventType == "Monthly") { // check for valid DayOfMonth if (!$MonthlyDayOfMonth OR $MonthlyDayOfMonth > 31 OR $MonthlyDayOfMonth < 1) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the start date } elseif (!checkdate($MonthlyStartMonth, $MonthlyStartDay, $MonthlyStartYear)) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the end date } elseif ($MonthlyStopMonth AND (!checkdate($MonthlyStopMonth, $MonthlyStopDay, $MonthlyStopYear))) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; } // Compile the dates $DisplayStart = $MonthlyStartYear."-".$MonthlyStartMonth."-".$MonthlyStartDay; $DisplayStop = $MonthlyStopYear."-".$MonthlyStopMonth."-".$MonthlyStopDay; // make sure the start comes before the stop if ($MonthlyStopYear) { $result = mysql("$DBName","SELECT (TO_DAYS('$DisplayStop') - TO_DAYS('$DisplayStart'))") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $dateDiff = $row[0]; } } else { $dateDiff = 0; } // somebody was trying to trick by making a stop date // before it was started if ($dateDiff < 0) { commonHeader($glbl_SiteTitle); echo "
\n\n"; // all of our checks on the surface data was good } elseif ($Stop != 1) { // check to see if the CalendarLocation already exists if (!$EventLocationID) { $result = mysql("$DBName","SELECT EventLocationID FROM phpCalendar_EventLocations WHERE LocationID = '$LocationID' AND Title = '$CLTitle' AND Address1 = '$Address1' AND Address2 = '$Address2' AND City = '$City' AND State = '$State'") or die(mysql_error()); $CountLocations = mysql_num_rows($result); } else { $CountLocations = 99; } if ($CountLocations > 0 AND $CountLocations < 99) { while($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } elseif ($CountLocations != 99 AND $CLTitle) { mysql("$DBName","INSERT INTO phpCalendar_EventLocations VALUES ( '$CLTitle','$Address1','$Address2','$City','$State','$Zip','$LocationID','')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_EventLocations") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } // if the web address doesn't begin with http:// if ($ContactWeb AND !eregi("http://",$ContactWeb)) { $ContactWeb = "http://".$ContactWeb; } // format the times if ($StartPeriod == PM AND $StartHour != 12) { $StartHour += 12; } elseif ($StartPeriod == AM AND $StartHour == 12) { $StartHour = 0; } if ($EndPeriod == PM AND $EndHour != 12) { $EndHour += 12; } elseif ($EndPeriod == AM AND $EndHour == 12) { $EndHour = 0; } $StartTime = $StartHour.":".$StartMinute; $EndTime = $EndHour.":".$EndMinute; // we can insert now mysql("$DBName","INSERT INTO phpCalendar_Details VALUES ( '$Title','$Details','$ContactName','$ContactPhone','$ContactEmail','$ContactWeb', '$EventLocationID','$StartTime','$EndTime','$ShowStart','$ShowEnd', '$LocationID','$CalendarDetailsID')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_Details") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $CalendarDetailsID = $row[0]; } mysql("$DBName","INSERT INTO phpCalendar_Monthly VALUES( '$MonthlyDayOfMonth','$DisplayStart','$DisplayStop','$Active','$LocationID','$CalendarDetailsID')") or die(mysql_error()); // do we send a notification and to whom? if ($glbl_ApprovePublicSubmission == 1 AND ($glbl_ApprovalBySiteAdmin == 1 OR !$LocationID)) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } elseif ($glbl_ApprovePublicSubmission == 1) { $result = mysql("$DBName","SELECT Email FROM phpCalendar_AdminEmail WHERE LocationID = '$LocationID'") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $MailTo = $row[0]; } $AddrVar = $glbl_WebAdminRoot; } // what if we still don't have an address? if (!$MailTo) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } $Message = " A request has been generated from your web site for a calendar submission to be approved. Visit the address: ".$glbl_WebAddress.$AddrVar." Once logged in, select the \"Pending event administration\" link. Thank you. "; if ($glbl_ApprovePublicSubmission == 1) { mail($MailTo, $glbl_EmailSubject, $Message, "From: $glbl_MailFrom", "-f$MailTo"); } Header("Location: ./thankyou.php?LocationID=$LocationID"); exit; } // END CHECKS FOR MONTHLY EVENTS // START CHECKS FOR YEARLY EVENTS } elseif ($EventType == "Yearly") { // check for valid Day if (!$YearlyDayOfMonth OR $YearlyDayOfMonth > 31 OR $YearlyDayOfMonth < 1) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the start date } elseif (!checkdate($YearlyStartMonth, $YearlyStartDay, $YearlyStartYear)) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the end date } elseif ($YearlyStopMonth AND (!checkdate($YearlyStopMonth, $YearlyStopDay, $YearlyStopYear))) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; } // Compile the dates $DisplayStart = $YearlyStartYear."-".$YearlyStartMonth."-".$YearlyStartDay; $DisplayStop = $YearlyStopYear."-".$YearlyStopMonth."-".$YearlyStopDay; // make sure the start comes before the stop if ($YearlyStopYear) { $result = mysql("$DBName","SELECT (TO_DAYS('$DisplayStop') - TO_DAYS('$DisplayStart'))") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $dateDiff = $row[0]; } } else { $dateDiff = 0; } // somebody was trying to trick by making a stop date // before it was started if ($dateDiff < 0) { commonHeader($glbl_SiteTitle); echo "
\n\n"; // all of our checks on the surface data was good } elseif ($Stop != 1) { // check to see if the CalendarLocation already exists if (!$EventLocationID) { $result = mysql("$DBName","SELECT EventLocationID FROM phpCalendar_EventLocations WHERE LocationID = '$LocationID' AND Title = '$CLTitle' AND Address1 = '$Address1' AND Address2 = '$Address2' AND City = '$City' AND State = '$State'") or die(mysql_error()); $CountLocations = mysql_num_rows($result); } else { $CountLocations = 99; } if ($CountLocations > 0 AND $CountLocations < 99) { while($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } elseif ($CountLocations != 99 AND $CLTitle) { mysql("$DBName","INSERT INTO EVENTLocations VALUES ( '$CLTitle','$Address1','$Address2','$City','$State','$Zip','$LocationID','')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_EventLocations") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } // if the web address doesn't begin with http:// if ($ContactWeb AND !eregi("http://",$ContactWeb)) { $ContactWeb = "http://".$ContactWeb; } // format the times if ($StartPeriod == PM AND $StartHour != 12) { $StartHour += 12; } elseif ($StartPeriod == AM AND $StartHour == 12) { $StartHour = 0; } if ($EndPeriod == PM AND $EndHour != 12) { $EndHour += 12; } elseif ($EndPeriod == AM AND $EndHour == 12) { $EndHour = 0; } $StartTime = $StartHour.":".$StartMinute; $EndTime = $EndHour.":".$EndMinute; // we can insert now mysql("$DBName","INSERT INTO phpCalendar_Details VALUES ( '$Title','$Details','$ContactName','$ContactPhone','$ContactEmail','$ContactWeb', '$EventLocationID','$StartTime','$EndTime','$ShowStart','$ShowEnd', '$LocationID','$CalendarDetailsID')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_Details") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $CalendarDetailsID = $row[0]; } mysql("$DBName","INSERT INTO phpCalendar_Yearly VALUES( '$YearlyMonth','$YearlyDayOfMonth','$DisplayStart','$DisplayStop','$Active','$LocationID','$CalendarDetailsID')") or die(mysql_error()); // do we send a notification and to whom? if ($glbl_ApprovePublicSubmission == 1 AND ($glbl_ApprovalBySiteAdmin == 1 OR !$LocationID)) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } elseif ($glbl_ApprovePublicSubmission == 1) { $result = mysql("$DBName","SELECT Email FROM phpCalendar_AdminEmail WHERE LocationID = '$LocationID'") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $MailTo = $row[0]; } $AddrVar = $glbl_WebAdminRoot; } // what if we still don't have an address? if (!$MailTo) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } $Message = " A request has been generated from your web site for a calendar submission to be approved. Visit the address: ".$glbl_WebAddress.$AddrVar." Once logged in, select the \"Pending event administration\" link. Thank you. "; if ($glbl_ApprovePublicSubmission == 1) { mail($MailTo, $glbl_EmailSubject, $Message, "From: $glbl_MailFrom", "-f$MailTo"); } Header("Location: ./thankyou.php?LocationID=$LocationID"); exit; } // END CHECKS FOR YEARLY EVENTS // START CHECKS FOR MONTHLY PERIODICAL EVENTS } elseif ($EventType == "MonthlyP") { // check for missing days for ($i = 0; $WeekDays[$i]; $i++) { if ($MonthlyPWeekDays[$i] == 1) { $GotDays = 1; } } if ($GotDays != 1) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the start date } elseif (!checkdate($MonthlyPStartMonth, $MonthlyPStartDay, $MonthlyPStartYear)) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the end date } elseif ($MonthlyPStopMonth AND (!checkdate($MonthlyPStopMonth, $MonthlyPStopDay, $MonthlyPStopYear))) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; } // Compile the dates $DisplayStart = $MonthlyPStartYear."-".$MonthlyPStartMonth."-".$MonthlyPStartDay; $DisplayStop = $MonthlyPStopYear."-".$MonthlyPStopMonth."-".$MonthlyPStopDay; // make sure the start comes before the stop if ($MonthlyPStopYear) { $result = mysql("$DBName","SELECT (TO_DAYS('$DisplayStop') - TO_DAYS('$DisplayStart'))") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $dateDiff = $row[0]; } } else { $dateDiff = 0; } // somebody was trying to trick by making a stop date // before it was started if ($dateDiff < 0) { commonHeader($glbl_SiteTitle); echo "
\n\n"; // all of our checks on the surface data was good } elseif ($Stop != 1) { // check to see if the CalendarLocation already exists if (!$EventLocationID) { $result = mysql("$DBName","SELECT EventLocationID FROM phpCalendar_EventLocations WHERE LocationID = '$LocationID' AND Title = '$CLTitle' AND Address1 = '$Address1' AND Address2 = '$Address2' AND City = '$City' AND State = '$State'") or die(mysql_error()); $CountLocations = mysql_num_rows($result); } else { $CountLocations = 99; } if ($CountLocations > 0 AND $CountLocations < 99) { while($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } elseif ($CountLocations != 99 AND $CLTitle) { mysql("$DBName","INSERT INTO phpCalendar_EventLocations VALUES ( '$CLTitle','$Address1','$Address2','$City','$State','$Zip','$LocationID','')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_EventLocations") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } // if the web address doesn't begin with http:// if ($ContactWeb AND !eregi("http://",$ContactWeb)) { $ContactWeb = "http://".$ContactWeb; } // make a string with the days of the week for ($i = 0; $WeekDays[$i]; $i++) { if ($MonthlyPWeekDays[$i] == 1) { $ShowWeekDays .= "|$i"; } } $ShowWeekDays = ereg_replace("^\|","",$ShowWeekDays); // format the times if ($StartPeriod == PM AND $StartHour != 12) { $StartHour += 12; } elseif ($StartPeriod == AM AND $StartHour == 12) { $StartHour = 0; } if ($EndPeriod == PM AND $EndHour != 12) { $EndHour += 12; } elseif ($EndPeriod == AM AND $EndHour == 12) { $EndHour = 0; } $StartTime = $StartHour.":".$StartMinute; $EndTime = $EndHour.":".$EndMinute; // we can insert now mysql("$DBName","INSERT INTO phpCalendar_Details VALUES ( '$Title','$Details','$ContactName','$ContactPhone','$ContactEmail','$ContactWeb', '$EventLocationID','$StartTime','$EndTime','$ShowStart','$ShowEnd', '$LocationID','$CalendarDetailsID')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_Details") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $CalendarDetailsID = $row[0]; } mysql("$DBName","INSERT INTO phpCalendar_PeriodicalMonthly VALUES( '$MonthlyPWeekNumber','$ShowWeekDays','$DisplayStart','$DisplayStop','$Active','$LocationID','$CalendarDetailsID')") or die(mysql_error()); // do we send a notification and to whom? if ($glbl_ApprovePublicSubmission == 1 AND ($glbl_ApprovalBySiteAdmin == 1 OR !$LocationID)) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } elseif ($glbl_ApprovePublicSubmission == 1) { $result = mysql("$DBName","SELECT Email FROM phpCalendar_AdminEmail WHERE LocationID = '$LocationID'") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $MailTo = $row[0]; } $AddrVar = $glbl_WebAdminRoot; } // what if we still don't have an address? if (!$MailTo) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } $Message = " A request has been generated from your web site for a calendar submission to be approved. Visit the address: ".$glbl_WebAddress.$AddrVar." Once logged in, select the \"Pending event administration\" link. Thank you. "; if ($glbl_ApprovePublicSubmission == 1) { mail($MailTo, $glbl_EmailSubject, $Message, "From: $glbl_MailFrom", "-f$MailTo"); } Header("Location: ./thankyou.php?LocationID=$LocationID"); exit; } // END CHECKS FOR MONTHLY PERIODICAL EVENTS // START CHECKS FOR YEARLY PERIODICAL EVENTS } elseif ($EventType == "YearlyP") { // check for missing days for ($i = 0; $WeekDays[$i]; $i++) { if ($YearlyPWeekDays[$i] == 1) { $GotDays = 1; } } if ($GotDays != 1) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the start date } elseif (!checkdate($YearlyPStartMonth, $YearlyPStartDay, $YearlyPStartYear)) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; // check the end date } elseif ($YearlyPStopMonth AND (!checkdate($YearlyPStopMonth, $YearlyPStopDay, $YearlyPStopYear))) { commonHeader($glbl_SiteTitle); echo "
\n\n"; $Stop = 1; } // Compile the dates $DisplayStart = $YearlyPStartYear."-".$YearlyPStartMonth."-".$YearlyPStartDay; $DisplayStop = $YearlyPStopYear."-".$YearlyPStopMonth."-".$YearlyPStopDay; // make sure the start comes before the stop if ($YearlyPStopYear) { $result = mysql("$DBName","SELECT (TO_DAYS('$DisplayStop') - TO_DAYS('$DisplayStart'))") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $dateDiff = $row[0]; } } else { $dateDiff = 0; } // somebody was trying to trick by making a stop date // before it was started if ($dateDiff < 0) { commonHeader($glbl_SiteTitle); echo "
\n\n"; // all of our checks on the surface data was good } elseif ($Stop != 1) { // check to see if the CalendarLocation already exists if (!$EventLocationID) { $result = mysql("$DBName","SELECT EventLocationID FROM phpCalendar_EventLocations WHERE LocationID = '$LocationID' AND Title = '$CLTitle' AND Address1 = '$Address1' AND Address2 = '$Address2' AND City = '$City' AND State = '$State'") or die(mysql_error()); $CountLocations = mysql_num_rows($result); } else { $CountLocations = 99; } if ($CountLocations > 0 AND $CountLocations < 99) { while($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } elseif ($CountLocations != 99 AND $CLTitle) { mysql("$DBName","INSERT INTO EventLocations VALUES ( '$CLTitle','$Address1','$Address2','$City','$State','$Zip','$LocationID','')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_EventLocations") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $EventLocationID = $row[0]; } } // if the web address doesn't begin with http:// if ($ContactWeb AND !eregi("http://",$ContactWeb)) { $ContactWeb = "http://".$ContactWeb; } // make a string with the days of the week for ($i = 0; $WeekDays[$i]; $i++) { if ($YearlyPWeekDays[$i] == 1) { $ShowWeekDays .= "|$i"; } } $ShowWeekDays = ereg_replace("^\|","",$ShowWeekDays); // format the times if ($StartPeriod == PM AND $StartHour != 12) { $StartHour += 12; } elseif ($StartPeriod == AM AND $StartHour == 12) { $StartHour = 0; } if ($EndPeriod == PM AND $EndHour != 12) { $EndHour += 12; } elseif ($EndPeriod == AM AND $EndHour == 12) { $EndHour = 0; } $StartTime = $StartHour.":".$StartMinute; $EndTime = $EndHour.":".$EndMinute; // we can insert now mysql("$DBName","INSERT INTO phpCalendar_Details VALUES ( '$Title','$Details','$ContactName','$ContactPhone','$ContactEmail','$ContactWeb', '$EventLocationID','$StartTime','$EndTime','$ShowStart','$ShowEnd', '$LocationID','$CalendarDetailsID')") or die(mysql_error()); $result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM phpCalendar_Details") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $CalendarDetailsID = $row[0]; } mysql("$DBName","INSERT INTO phpCalendar_PeriodicalYearly VALUES( '$YearlyPMonth','$ShowWeekDays','$YearlyPWeekNumber','$DisplayStart','$DisplayStop','$Active','$LocationID','$CalendarDetailsID')") or die(mysql_error()); // do we send a notification and to whom? if ($glbl_ApprovePublicSubmission == 1 AND ($glbl_ApprovalBySiteAdmin == 1 OR !$LocationID)) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } elseif ($glbl_ApprovePublicSubmission == 1) { $result = mysql("$DBName","SELECT Email FROM phpCalendar_AdminEmail WHERE LocationID = '$LocationID'") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $MailTo = $row[0]; } $AddrVar = $glbl_WebAdminRoot; } // what if we still don't have an address? if (!$MailTo) { $MailTo = $glbl_AdminEmail; $AddrVar = $glbl_AdminRoot; } $Message = " A request has been generated from your web site for a calendar submission to be approved. Visit the address: ".$glbl_WebAddress.$AddrVar." Once logged in, select the \"Pending event administration\" link. Thank you. "; if ($glbl_ApprovePublicSubmission == 1) { mail($MailTo, $glbl_EmailSubject, $Message, "From: $glbl_MailFrom", "-f$MailTo"); } Header("Location: ./thankyou.php?LocationID=$LocationID"); exit; } // END CHECKS FOR YEARLY PERIODICAL EVENTS } // we haven't returned, so do everything else } else { commonHeader($glbl_SiteTitle); } if (!$EventType) { $EventType = "Daily"; } popUp(300,200); ?> Adding a calendar item...
Select the appropriate items from ONE of the colored boxes and complete the information at the bottom.
|