#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); package main; #use strict; #use vars qw( $calendar_type $session_file $session_name $session_email # $session_group $session_username $currentmonth $currentyear # $current_month_name $greatest_year $category $base_file # $database_file $temp_file $lock_file $db_exist $ltyear # $ltmon $ltday $lib $framecal_dir %form_data ); my( $action ) = (); # First, tell Perl to bypass the buffer. Set up binary mode for input/output # if using dos derivatives. $| = 1; if( $^O =~ /(dos|win|os2|vms)/io ) { binmode(STDIN); binmode(STDOUT); binmode(STDERR); } # LOCATE LIBRARIES # # $lib is the path to the directory containing the library files that # are used by this, and many other, scripts. Note that the line below # sets it using a relative path. On some server setups, you will have to # change this to an absolute path. $framecal_dir is the directory # that the framecal.pl, fc_admin.pl, and fc_recur.pl files are located # in. Set this to an absolute path if need be. $lib = "../libs"; $framecal_dir = "."; # GET FORM DATA # # Now we use the subroutine parse_data to get our form data # into the hash %form_data. After this, we will be able # to get all incoming form data by referencing $form_data{'variablename'}. %form_data = (); %form_data = &parse_data(); # DETERMINE CALENDAR # # Since this script allows us to keep many different calendars using one # script, we need to get the calendar to use from the form data. This # information will be stored in the key 'calendar'. We read this information # in and untaint it. Note that only alphanumeric are allowed. # In order to access this, the original link must have had ?calendar=some/dir # in the URL. If this value is omitted, we assume we are using calendar files # stored in the script directory. # After getting the calendar, we finish by requiring the calendar specific # files. if( $form_data{'calendar'} ne '' ) { $form_data{'calendar'} =~ /^(\w+\/?\w*)/o; $calendar_type = "./$1"; } else { # $calendar_type = "."; $calendar_type = "./sfbay"; } &CgiRequire( "$calendar_type/calendar.setup", "$calendar_type/auth.setup", "global.setup" ); &CgiRequire( "$auths::auth_lib/auth-lib.pl" ); $home = $form_data{'home'}; # IN MAINTENANCE # # We can place the calendar in maintenance mode by placing a text file called # 'fc_maint.txt' in the calendar's directory. This allows us to do admin tasks # such as working manually with the database files, uploading new copies of the # program, etc., while keeping the calendar locked out. if( -e "$calendar_type/fc_maint.txt" ) { &header( "Calendar Unavailable" ); print qq!

Calendar Unavailable

I'm sorry, but the calendar is currently unavailable due to system maintenance. Please try back in 15 minutes.
!; &footer; } else { # SESSION FILE # # The session file is used on every pass through the script, to determine # who is using it on the given pass. So, we define a variable and set it # to the value of session_file passed through the form data. On the first # pass, this will be blank, and will start us into the authorization process # in a little while. if( $form_data{'session_file'} ne '' ) { $form_data{'session_file'} =~ /^(\w+)/o; $session_file = $1; } else { $session_file = ''; } # DATE INFORMATION # # Okay, this is a calendar script, so there should be a lot of date # variables, right? This is where we start defining them all. We # get the current day, month, and year from the system time. Note that # the system returns the month as a number from 0-11, and year returns # the number of years since 1900, so we need to modify them a little. # We then set the currentyear for the script by either reading in the # year passed to us by the form data, or, in the absence of that, we # set it to the localtime year. We do the same with the currentmonth. # We also go ahead and get the name of the currentmonth at this time. ( $ltday, $ltmon, $ltyear ) = ( localtime(time) )[3,4,5]; $ltmon += 1; $ltyear += 1900; if( $form_data{'year'} ne '' ) { $form_data{'year'} =~ /^(\d{4})/o; $currentyear = "$1"; } else { $currentyear = "$ltyear"; } if( $form_data{'month'} ne '' ) { $form_data{'month'} =~ /^(\d{1,2})/o; $currentmonth = "$1"; } else { $currentmonth = "$ltmon"; } $current_month_name = $fcs::month_hash{ $currentmonth }; $greatest_year = $ltyear + $fcs::num_years - 1; if( $form_data{'category'} ne '' ) { $category = join( ",", ( split("\0", $form_data{'category'} ) ) ); } else { $category = ''; } if( $form_data{'category'} ne '' ) { $cat3 = join( ", ", ( split("\0", $form_data{'category'} ) ) ); } else { $cat3 = ''; } # DEFINE DATABASE FILES # # This implementation of the script uses a database file for # each month and year. Thus, for January 1999, we will be working # with a base file called 199901. We set up the base file # from the month and year variables we just defined, set the # database file to this plus ".events", and then define a lock # file and temp file. Since we're here, we also check to see if the # database file currently exists. $base_file = "$currentyear".sprintf( "%.2d", $currentmonth ); $database_file = "$calendar_type/$base_file".".events"; $temp_file = "$fcs::temp_lock_dir/framecal_temp.file"; $lock_file = "$fcs::temp_lock_dir/framecal_lock.file"; $db_exist = ( -e $database_file ); $places_file = "$calendar_type/places.db"; # USER AUTHENTICATION # # Okay, at this point, we want to find out if the user should actually be # here. We use the GetSessionInfo subroutine found in auth-lib.pl, which # we have already required, to get the user to login, and authenticate them. # We also chomp the session email, which removes a new line character if one # exists on it. ($session_file, $session_username, $session_group, $session_name, $session_email) = &al::GetSessionInfo($session_file, "$fcs::this_script_url", \%form_data); chomp $session_email; # WHAT DO YOU WANT ME TO DO? # # Each button on the forms that are presented, and most links, provide a tag # called 'action'. This form data variable tells the script what button # or type of link you selected, and thus, what you want to do. So, we grab # this data, and do it with a 'perl-esque' Case statement. Note that if # no action is defined, we must want to see the month table, and we also have # the option to clean up old datafiles if the URL we call the script with # has the 'first_pass=on' value in it. Note that no portion of the script # will ever include that item, so if you want automatic clean up of files, # you will have to set it in your URL that you call the script with, and # set a number of months to save in your calendar.setup file. This is the # end of the MAIN section of the script. From here on out, we are just # calling subroutines. unless( $session_file eq '' ) { $action = $form_data{'action'} if( exists($form_data{'action'}) ); CASE: { if( $action =~ /^view_month/io ) { do { view_week_month_sub(); last CASE; } } if( $action =~ /^view_week/io ) { do { view_week_month_sub(); last CASE; } } if( $action =~ /^spam_week/io ) { do { spam_week_sub(); last CASE; } } if( $action =~ /^Send Spam/io ) { do { notification2(); last CASE; } } if( $action =~ /^view_day/io ) { do { view_day_sub(); last CASE; } } if( $action =~ /^view_search/io ) { do { view_search_sub(); last CASE; } } if( $action =~ /^w/io ) { do { short2(); last CASE; } } if( $action =~ /^short/io ) { do { view_search_2(); last CASE; } } if( $action =~ /^lists_users/io ) { do { lists_users(); last CASE; } } if( $action =~ /^e_f/io ) { do { mail_friend(); last CASE; } } if( $action =~ /^Add Event/io ) { do { add_item_form_sub(); last CASE; } } if( $action =~ /^Add Item/io ) { do { add_event_sub(); last CASE; } } if( $action =~ /^Modify Item/io ) { do { modify_item_form_sub(); last CASE; } } if( $action =~ /^Modify Event/io ) { do { modify_event_sub(); last CASE; } } if( $action =~ /^Delete Item/io ) { do { delete_item_form_sub(); last CASE; } } if( $action =~ /^Delete Event/io ) { do { delete_event_sub(); last CASE; } } if( $action =~ /^Search/io ) { do { search_form(); last CASE; } } if( $action =~ /^Find Events/io ) { do { search_events(); last CASE; } } if( exists($form_data{'first_pass'}) ) { &trim_events(); } &view_cal_sub(); } } } # SUB VIEW_CAL_SUB # # Okay, if we have called this subroutine, that means we want to print out the # table formatted month. sub view_cal_sub { # We need to make an array that is formatted for the current month, i.e., has # the day numbers in the correct indices in the array, so we call the # make_month_array subroutine with the julian day for the first day of the month # and year that we are in. my (@mymonth) = &make_month_array(); my ($size_of_mymonth); my ($variable_list,$next_month,$next_year,$prev_month,$prev_year); my ($next_link,$prev_link,$month_link,$day,%event_days,$temp_cat); my ($count_till_last_day,$weekday,$day_number,$td_color); my ($num_weeks,$start,$end,$count,$i,$city_hash); $size_of_mymonth = scalar(@mymonth); # We start to print out our HTML page here, with the header sub being called. &header2 ("Calendar: $current_month_name - $currentyear"); # We now create our Next Month, Prev. Month, and View Month links. We do this # by just increasing the month by one for Next, decreasing it by one for Prev., # and checking to see if we thus move into another year, and correct for that. # We then concatenate together three strings to be used to hold the link information # for these values, providing all the information that would be required by the script. $variable_list = ''; $variable_list .= "calendar=$form_data{'calendar'}"; $variable_list .= "&session_file=$session_file&category=$category&home=$form_data{'home'}"; $next_month = $currentmonth + 1; $next_year = $currentyear; $prev_month = $currentmonth - 1; $prev_year = $currentyear; if ($next_month > 12) { $next_month = 1; $next_year++; } if ($prev_month < 1) { $prev_month = 12; $prev_year--; } $next_link = $variable_list."&month=$next_month&year=$next_year"; $prev_link = $variable_list."&month=$prev_month&year=$prev_year"; $month_link = "$variable_list"; $month_link .= "&action=view_month&month=$currentmonth&year=$currentyear"; # Now that we have the links together, we put them in a small one row table at the # top of the month table, and then start the month table, setting its title. #begin dave mod # sping mod = bgcolor=$fcs::apptcol print qq!

!; #end dave mod # Print out the days of the week in table format. For every day (foreach $day) in # our list of days (@day_names) we create a cell, and then end the row. foreach $day (@fcs::day_names) { print "\n"; } print "\n\n"; # If our database file that we defined above exists, we need to open it and index # the days that have events associated with them. So, if it exists, we open # up the file and read through it. For each entry, we extract the day, then see # if that day number exists in the hash %event_days. If it does, we add to the # value associated with the $day key, if not, its the first one, so we set the value # to 1 for that key. Thus, this provides us with a list of days that have events # for the month, and how many events that day has. if ($db_exist) { open (DATABASE, "$database_file") || &open_error($database_file); while () { ($day,$user,$temp_cat) = (split (/\|/, $_))[0,2,3]; if ($temp_cat =~ /\b$category\b/ || $category eq '') { if ($session_username ne $user && $temp_cat =~ /\bPrivate\b/) { } else { if ($event_days{$day}) { $event_days{$day}++; } else { $event_days{$day} = 1; } } } } close (DATABASE); } # We initialize the variable $count_till_last_day, which we will use to be sure # we don't add too many s at the end of the calendar. We also initialize # $weekday, which we will use to be sure that we end one row and start another # every seven days, to maintain a two-diminsional table. $count_till_last_day = 0; $weekday = 0; # We now need to create a cell in the table for each day in the month, using # the mymonth array we created when we first entered our subroutine. foreach $day_number (@mymonth) { # We increment our two variables for each pass through the loop. When we get # to 7 in weekday, we have reached the end of a week, so we reset it. $count_till_last_day++; $weekday++; $weekday = 0 if ($weekday > 6); # For each day, we need to find out what type it is, so we can set the # background color for the cell. There are three options: the current # day of the year, a day with an event, and a day that is neither. This # conditional statement sets the cell color variable that will be used to # format the day cell. # Dave mod - Spring change unless ($day_number == $ltday && $currentyear == $ltyear && $currentmonth == $ltmon) { if ($event_days{$day_number}) { $td_color = ""; # bgcolor=$fcs::evntcol } else { $td_color = ""; # bgcolor=$fcs::noevntcol } } else { $td_color = " bgcolor=$fcs::tdycol"; } #end dave mod # We now print out the cell information for the day. If the day contains an # event as defined in the index that we made, we create the link to allow us # to view that day's events. Otherwise, we will just print out the day number. # Note that if a day has events, we will also include the number of events on # that day, which is also determined from our index of events for the month. print qq!\n"; # If we have have reached the end of the week, we print out the row ending tag. # We also start the next row, unless we are at the end of the month. if ($weekday == 0) { print "\n"; unless ($count_till_last_day == $size_of_mymonth) { print ""; } } } # Print the end of the table, and run through the code that will create our # links to view the events in each week. Basically, we calculate the number # of weeks in the month from the size of our mymonth array. Then, we create # in $variable_list, the portion of the query string link that will remain # the same for each link, and create the first link which we know will start # with 1 and end on index 6 of the array, and print out the link. Then, # we go through a loop to create the all the links except the last. Finally, # we create the last link by getting the start day from the mymonth array, and # the end day from the number of days in the month. print qq!
Go to previous month $current_month_name - $currentyear Go to next month
", "$day
!; if ($event_days{$day_number}) { $variable_list = ''; $variable_list = "day=$day_number&year=$currentyear"; $variable_list .= "&month=$currentmonth"; $variable_list .= "&session_file=$session_file&category=$category"; $variable_list .= "&calendar=$form_data{'calendar'}&home=$form_data{'home'}"; $variable_list .= "&action=view_day"; print qq!
$day_number!; } else { print qq!
$day_number!; } print "
!; $num_weeks = $size_of_mymonth / 7; $variable_list = "$fcs::this_script_url?calendar=$form_data{'calendar'}"; $variable_list .= "&session_file=$session_file&category=$category"; $variable_list .= "&action=view_week&month=$currentmonth&year=$currentyear"; $start = 1; $count = 6; $end = $mymonth[ $count ]; # print "
 Show Full Week: 1"; for( $i = 2; $i < $num_weeks; $i++ ) { $start = $mymonth[ $count + 1 ]; $count += 7; $end = $mymonth[ $count ]; # print "  $i"; } $start = $mymonth[ $count + 1 ]; $end = &days_in_month( $currentyear, $currentmonth ); # print "  $num_weeks

"; # We now use two subroutines to provide the user # with selection items to jump to another month and year directly. # If we have a categories array in our setup file, we also provide a # category selector, that can be used as a filter for the events. # We also generate the end of our form, with all the tags containing the # information we will need to pass on for the next pass. These items are # for all users. Note that we have to start a new form so we can target # frames for output. #begin dave mod print ""; # Dave mod #&select_a_month(); #&select_a_year(); # print ""; print qq! !; if (scalar(@fcs::categories)) { print "Refine by Category\:
"; &select_a_category (3); # print ""; # print "
But not\: "; #end dave mod } print qq!
!; # If the session group is user or admin, we have found someone who is allowed # to post events to the calendar, so we provide an Add Item button. if (($session_group eq "user" && $form_data{'home'} eq $form_data{'calendar'}) || $session_group eq "admin") { print qq! !; # If the session group is admin, we provide another form to access the # adminstration script to provide an online way to administer users, # and pending users if the $auth_alt_user_file is being used as well. #Begin Dave Mod # this was the old user admin stuff. if ($session_group eq "admin" && $form_data{'calendar'} ne "sfbay" && $session_username ne "David") { print qq!

!; if ($auths::auth_alt_user_file) { print qq! !; } } if ($session_username eq "David") { #begin Dave mod pt 2 $num_weeks = $size_of_mymonth / 7; $variable_list = "$fcs::this_script_url?calendar=$form_data{'calendar'}&home=$form_data{'home'}"; $variable_list .= "&session_file=$session_file"; $variable_list .= "&action=spam_week&month=$currentmonth&year=$currentyear"; #$count = $count + 5; $start = 1; $count = 7; $end = $mymonth[ $count ]; print "
1"; for( $i = 2; $i < $num_weeks; $i++ ) { $start = $mymonth[ $count+5 ]; $count += 7; $end = $mymonth[ $count+5 ]; print "  $i"; } $url_year = $currentyear - 2000; if ($currentmonth < 10) { $url_lead = "0"; } $long_url = "$url_lead$currentmonth"; $long_url .= "0"; $long_url .= "$url_year"; $variable_list2 = "$fcs::this_script_url?calendar=$form_data{'calendar'}&home=$form_data{'home'}"; $variable_list2 .= "&session_file=$session_file"; $variable_list2 .= "&action=lists_users"; $start = $mymonth[ $count + 3 ]; $end = &days_in_month( $currentyear, $currentmonth ); print "  $num_weeks"; print "  M
mail | Stats | URLs | Users"; } # End Dave Mod # If we are using online help, we now provide the links to the # help script with the correct help topic number. if ($fcs::use_help) { if ($session_group eq "user") { &help_link ("2"); } else { &help_link ("3"); } } } # print "
"; $list2 = "&month=$currentmonth&year=$currentyear&session_file=$session_file"; # print qq!$global::city_hash{$form_data{'calendar'}}!; # # foreach $i (sort (keys %global::city_hash)) { # if ($i ne $form_data{'calendar'}) { # print qq! | $global::city_hash{$i}!; # } # } # # if ($form_data{'calendar'} ne "sfbay") { # print qq!San Francisco | !; # } # # if ($form_data{'calendar'} ne "london") { # print qq!London | !; # } # # if ($form_data{'calendar'} ne "ny") { # print qq!New York | !; # } # # if ($form_data{'calendar'} ne "seattle") { # print qq!Seattle!; # } # # if ($form_data{'calendar'} ne "seattle" && $form_data{'calendar'} ne "la") { # print qq! | !; # } # # if ($form_data{'calendar'} ne "la") { # print qq!Los Angeles!; # } if ($session_group eq "public" && $form_data{'home'} eq $form_data{'calendar'}) { #begin Dave mod print qq!

Want to Add Stuff\?
!; if ($fcs::use_help) { &help_link ("1"); # &help_link ("1"); #end dave mod } } # Finally, we give the user some information that lets them know that we know # who they are, and what access level they are at. We then close the page with # the standard footer. # if ($session_group eq "admin") { # print qq! # Admin Access.
!; # } if ($session_username eq "David") { $session_group = "Supreme Being"; } if ($session_name eq "Simone") { $session_group = "Purple (BB grins)"; } $squid = $fcs::color_tag; $squid .= '_ls.jpg'; if ($session_name eq "") { $session_name = "Guest"; } #
#   Access: $session_group
#
#   User: $session_name print qq!


  Columnists:
  Adventures in the Underground
  Horoscope By Mamad Shreak
  Letters from a Monkey
  Goo\!
  Guest Artist
  The Truth Hurts
  The Anna Chronicles

  The 1040 Form
<\!--   a href="javascript:openstation(10037883,1);">Radio Thought Police
  Burning Man Pix
  BayBoyz Party Photos

  FAQ
  Read the Fuckin’ Book
  Feedback
  Need a Programmer?
Powered by Laughing Squid !; &footer; #

  Need a Programmer? #

  Other Listings: #
# # #
  # Maps
# E-Guide
# SF Station
# SF Weekly
# MetroActive
#
  # SF Girl
# Craig’s List
# Bay Insider
# CitySearch
# BayGuardian #

} # SUB VIEW_DAY_SUB # # If we have called this subroutine, it means we want to see the events for # a certain day, normally linked from the Month Table. sub view_day_sub { my ($day,$username,$time,$temp_cat,$id,$item_found,$dayname); # We start off by printing up the header information for display, along with # the date of the event. We then check to see if the database file exists for # this days month and year. Normally, we would only access this from a link # that tells us that the file exists, but there are some tricks that can be # used in the HTML document that calls the script that require this check. $day = $form_data{'day'}; $dayname = &day_of_week($currentyear, $currentmonth, $day); &header ("$dayname, $current_month_name $day, $currentyear"); print qq! $dayname, $current_month_name $day, $currentyear!; if ($category) { $temp_cat = " ($category)"; $temp_cat =~ tr/_/ /; print $temp_cat; print qq! !; } else { print qq!   Events are listed chronologically by start-time (earliest to latest.)
 If too many events are listed, try selecting a single category in the navigation column and refreshing the calendar. !; } print qq!


!; if ($db_exist) { # If the file exists, we want to start printing out the information for the # day. We start by printing out a ") unless ($last_day eq ''); $last_day = $day; $dayname = &day_of_week($currentyear, $currentmonth, $day); print qq! $dayname, $current_month_name $day, $currentyear$cat_tag
") unless ($item_found ne "yes"); # If we didn't find events, we need to tell the user that there are no # events scheduled for the month/week. if ($item_found ne "yes") { print "

No Events For $word

"; $word = lcfirst( $word ); print qq!
I'm sorry, but there are not any events scheduled for the current $word and selected category. Please check back again later for future additions.
!; } # If we are using help with the calendar, we print out the link to # the help topic, and then we close the HTML page with the standard # footer. if ($fcs::use_help) { print "

"; &help_link ("$help"); print "

"; } &footer; } # SUB VIEW_SEARCH_SUB # # If this subroutine has been selected, it means that someone is trying to # get the details on an event that was returned as a hit from a previous search. sub view_search_sub { my ($day,$id,$dayname); # The extra info passed by this type of link is the actual id number of the event # that we want to look at, as we will only be looking at one at a time. We need # to untaint this value in order to open it. We also get the day of the event # from the link. $form_data{'id'} =~ /^(\d+)(_\d)?(\d*)$/o; $id = "$1$2$3"; $day = $form_data{'day'}; $dayname = &day_of_week($currentyear, $currentmonth, $day); # We now print out the standard HTML header, and close out the form since there # is not interaction options for this subroutine's output, especially since it # will be opened in its own "mini-window". &header ("$dayname, $current_month_name $day, $currentyear"); print ""; # Now we just print out the information for the event as we have in the previous # event displaying subroutines. Nothing new here. We of course close with the # standard footer. if ($session_username ne $user && $temp_cat =~ /\bPrivate\b/) { print qq! You do not have permission to view this event. !; } print qq! $dayname, $current_month_name $day, $currentyear


"); &footer; } # SUB ADD_ITEM_FORM_SUB # # If this subroutine has been called, it means we want to print out the # form to allow the user to add an event to the database. # This subroutine is very simple. We start the HTML, provide a subject, # then call the submission_form subroutine to print out the main form. # We then provide the appropriate form buttons, and finish with the footer. sub add_item_form_sub { &header ("Add an Item to $fcs::cal_name Calendar"); print "

Add Event to the Database

"; &submission_form; print qq!

!; &footer; } # SUB ADD_EVENT_SUB # # If we are calling this subroutine, it means someone has entered information # for a new event, and we need to add it into our database. sub add_event_sub { my ($n_days,$var_name,$id,$value,$subject,$time,$time_zone,$error); my ($location,$dur_hrs,$day,$cost,$phone,$cat2,$end_date,$body,$new_row); my (@notify_users,$missing_info,$dur_mins,$linkurl,$linktitle); my ($notified,$new_event,$to_notify,$name,$email,$event_cat,$i); my (@dates,$date,$datea,$dateb,$recur,$rec_a,$rec_b,$temp_base,$event_id); # We initialize our variable to check for missing form data, then # print out our standard header. We also get the number of days # in the current month and year. $missing_info = 0; $error = 0; &header ("Adding an Item to the $fcs::cal_name Calendar Database"); $n_days = &days_in_month($currentyear,$currentmonth); # We do some error checking now. First, we see if the user tried to # add an event on a day that doesn't exist. If so, we call the # invalid_date subroutine. If the date is valid, we look to see if # all of the fields in @req_fields have been filled in. We also # check that if the session name is blank, the user has entered a # name and email address to go with the event. if ($form_data{'day'} > $n_days) { &invalid_date ($n_days,$form_data{'day'}); $error = 1; } # Now we continue our error checking on the data supplied to us by the user. # We first strip out any image tags the user may have entered. Next we strip # out any server side include tags the user may have entered. If we are not # allowing HTML, we strip out any remaining HTML tags. We then remove any # Windows hard returns, change any double occurrences of new line into a # paragraph tag, any single new lines with a break line tag, and any pipe symbols # with a colon. # begin Dave mod # Find and replace foreach $value (@fcs::field_values) { $form_data{$value} =~ s///gio; $form_data{$value} =~ s///go; if ($fcs::strip_html) { $form_data{$value} =~ s/<(.|\n)*?>//go; } if ($session_username ne "David") { $form_data{$value} =~ s/Big Brother sez check it out//g; $form_data{$value} =~ s/Big brother sez check it out//g; $form_data{$value} =~ s/Big Brother says check it out//g; $form_data{$value} =~ s/Big Brother sez\: check it out//g; $form_data{$value} =~ s/Big brother sez\: check it out//g; $form_data{$value} =~ s/Big Brother says\: check it out//g; $form_data{$value} =~ s/Big Brother sez\: Check it out//g; $form_data{$value} =~ s/Big brother sez\: Check it out//g; $form_data{$value} =~ s/Big Brother says\: Check it out//g; } $form_data{$value} =~ s/\r//go; $form_data{$value} =~ s/\|/:/go; $form_data{$value} =~ s/ / /go; $form_data{$value} =~ s/\ Sf/ SF/g; $form_data{$value} =~ s/from the website:\n\n//g; $form_data{$value} =~ s/from the website: \n\n//g; $form_data{$value} =~ s/href\=\"www/href\=\"http\:\/\/www/g; $form_data{$value} =~ s/\n /\n/g; $form_data{$value} =~ s/\n\n\*/\n
  • /g; $form_data{$value} =~ s/\n\*/\n
  • /g; $form_data{$value} =~ s/\n\n-/\n
  • /g; $form_data{$value} =~ s/\n-/\n
  • /g; $form_data{$value} =~ s/\n\n/ \ \;

    /g; $form_data{$value} =~ s//\"/g; $form_data{$value} =~ s/\^/\'/g; $form_data{$value} =~ s//-/g; $form_data{$value} =~ s//-/g; $form_data{$value} =~ s/\ '/ \‘\;/g; $form_data{$value} =~ s/\/\’\;/g; $form_data{$value} =~ s/\'/\’\;/g; $form_data{$value} =~ s//\’\;/g; $form_data{$value} =~ s//\’\;/g; $form_data{$value} =~ s//\“\;/g; $form_data{$value} =~ s//\”\;/g; $form_data{$value} =~ s//\“\;/g; $form_data{$value} =~ s//\”\;/g; $form_data{$value} =~ s//\–\;/g; $form_data{$value} =~ s//\.\.\.\;/g; $form_data{$value} =~ s/’/\’\;/g; $form_data{$value} =~ s/“/\“\; /g; $form_data{$value} =~ s/”/\”\; /g; $form_data{$value} =~ s/\n\"/\n\“\;/g; $form_data{$value} =~ s/ \"/ \“\;/g; $form_data{$value} =~ s/\" /\”\; /g; $form_data{$value} =~ s/\"\./\”\;\./g; $form_data{$value} =~ s/\.\"/\.\”\;/g; $form_data{$value} =~ s/\"\n/\”\;\n/g; $form_data{$value} =~ s/\"-/\”\;-/g; $form_data{$value} =~ s/\"\,/\”\;\,/g; $form_data{$value} =~ s/\"\)/\”\;\)/g; $form_data{$value} =~ s/\,\"/\,\”\;/g; $form_data{$value} =~ s/\"/\“\;/g; $form_data{$value} =~ s/\“\;http/\"http/g; $form_data{$value} =~ s/\“\;mailto/\"mailto/g; $form_data{$value} =~ s/\“\;>/\">/g; $form_data{$value} =~ s/\n>/\n/g; $form_data{$value} =~ s/\n> \n/

    /g; $form_data{$value} =~ s/\n>\n/

    /g; $form_data{$value} =~ s/\n/ /g; #was
    $form_data{$value} =~ s/
    / \ \;
    /g; $form_data{$value} =~ s/

    \ \;/ \ \;/g; $form_data{$value} =~ s/href/target\=\"new\" href/g; } # end Dave mod # We are going to fill in our session names from the hidden values entered # via the submission form subroutine. We have still checked for a valid # session file, we just do this for flexibility later on. $session_name = "$form_data{'real_name'}"; $session_email = "$form_data{'email'}"; $session_username = "$form_data{'username'}"; # We now check for missing information for our required fields. foreach $var_name (@fcs::req_fields) { if ($form_data{$var_name} eq '') { $missing_info = 1; } } if ($session_name eq '' && (($form_data{'real_name'} eq '') || ($form_data{'email'} eq ''))) { $missing_info = 1; } # If we have missing information, we print out an error message, and # set our error flag. if ($missing_info) { print qq!

    Error in Add Event Form

    You didn't complete all the required fields. Please hit the back button and try again.
    !; $error = 1; } # We now check for the error flag being set, and if it isn't we start in. # If we are allowing use of the notify users option, we process the multiple # select list by splitting the email addresses into an array, then join # the array with commas. unless( $error ) { if ($form_data{'notify'} eq "on") { @notify_users = split ("\0", $form_data{'mail_choices'}); $notified = join (",", @notify_users); } # We assign the rest of our form data information to variables. Note that # if no duration time was entered, we set the event up to be displayed as a # general information event, applicable to the whole day. #assign URL and Title $day = "$form_data{'day'}"; $time_zone = "$form_data{'time_zone'}"; $event_cat = $category; $dur_hrs = "$form_data{'dur_hrs'}"; $dur_mins = "$form_data{'dur_mins'}"; if ($dur_hrs || $dur_mins) { $time = "$form_data{'time'}"; } else { $time = ' '; } $name = "$session_name"; $email = "$session_email"; if (($form_data{'linktitle'} ne '') && ($form_data{'linkurl'} ne '')) { $linktitle = "$form_data{'linktitle'}"; $form_data{'linkurl'} =~ s/\\/\//go; if ($form_data{'linkurl'} =~ /(^(http:|https:|ftp:|news:)\/\/)|(^mailto:)/o) { $linkurl = "$form_data{'linkurl'}"; } else { $linkurl = "http://$form_data{'linkurl'}"; } } # start Dave's mod elsif (($form_data{'linkurl'} ne '')) { $linktitle = "$form_data{'linkurl'}"; $form_data{'linkurl'} =~ s/\\/\//go; if ($form_data{'linkurl'} =~ /(^(http:|https:|ftp:|news:)\/\/)|(^mailto:)/o) { $linkurl = "$form_data{'linkurl'}"; } else { $linkurl = "http://$form_data{'linkurl'}"; } } # end Dave's mod else { $linkurl = ''; $linktitle = ''; } #Start Dave's mapping mod # $location = "$form_data{'location'}"; $city_map = $global::city_hash{$form_data{'calendar'}}; $city_map =~ s/ /\+/go; $state_map = $global::state_hash{$form_data{'calendar'}}; if (($form_data{'street_add'} ne '') && ($form_data{'city_add'} ne '')) { foreach $value (@fcs::field_values) { $form_data{'street_add'} =~ s/ /\+/g; $form_data{'city_add'} =~ s/ /\+/g; } if ($session_username eq "David") { $location = "$form_data{'location'} (map)"; } elsif ($form_data{'calendar'} eq "london"){ $location = "$form_data{'location'} - $form_data{'street_add'}, $form_data{'city_add'}"; } else { $location = "$form_data{'location'} (map)"; } } elsif ($form_data{'street_add'} ne '') { foreach $value (@fcs::field_values) { $form_data{'street_add'} =~ s/ /\+/g; } if ($session_username eq "David") { $location = "$form_data{'location'} (map)"; } elsif ($form_data{'calendar'} eq "london"){ $location = "$form_data{'location'} - $form_data{'street_add'}, London"; } else { $location = "$form_data{'location'} (map)"; } } else { $location = "$form_data{'location'}"; } #end dave's mapping location. $cost = "$form_data{'cost'}"; $phone = "$form_data{'phone'}"; $subject = "$form_data{'subject'}"; $body = "$form_data{'body'}"; $cat2 = "$cat3"; $end_month = $fcs::month_hash{$form_data{'rec_mon'}}; $end_date = "$end_month $form_data{'rec_day'}"; # We now fill in the new_event variable with a string that will be used to # create the event file for this particular event. If you are going to modify # information stored for each event, this is another place you will have to make # modifications. $new_event = "time->$time\ntimezone->$time_zone\ndurationhrs->$dur_hrs\n"; $new_event .= "durationmins->$dur_mins\nname->$name\nemail->$email\n"; $new_event .= "notified->$notified\nlinkurl->$linkurl\nlinktitle->$linktitle\n"; $new_event .= "location->$location\nsubject->$subject\nbody->$body\ncost->$cost\nphone->$phone\n"; $new_event .= "cat2->$cat2\nend_date->$end_date\n"; # Now we need to check for recurring events, and get the dates that the event # will apply to. If the user has specified a recurring event, we do our error # checking here to be sure the values are valid before attempting to get the # dates from fc_recur.pl. if( $form_data{'rep_opt'} == 0 ) { $datea = "$base_file".sprintf("%.2d", $day); $dateb = ''; push( @dates, $datea ); } else { &CgiRequire( "$framecal_dir/fc_recur.pl" ); $datea = "$base_file".sprintf("%.2d", $day); $dateb = &fcr::date_join( $form_data{'rec_year'},$form_data{'rec_mon'}, $form_data{'rec_day'} ); unless( ($dateb ge $datea) && (&fcr::is_val_date( $dateb )) ) { $error = 1; } if( ($form_data{'rep_opt'} == 1) && (! $error) ) { my( @temp ); $rec_a = int($form_data{'rec_a'}); $rec_b = $form_data{'rec_b'}; $rec_b =~ s/rec/$rec_a/i; $recur = $rec_b; } elsif( ($form_data{'rep_opt'} == 2) && (! $error) ) { $rec_a = int($form_data{'rec_c'}); $rec_b = join( ",", split("\0", $form_data{'rec_d'}) ); $recur = "0:0:$rec_a*$rec_b"; } elsif( ($form_data{'rep_opt'} == 3) && (! $error) ) { my( $rec_c ); $rec_a = join( ",", split("\0", $form_data{'rec_e'}) ); $rec_b = join( ",", split("\0", $form_data{'rec_f'}) ); $rec_c = $form_data{'rec_g'}; $recur = "$rec_c*$rec_a:$rec_b"; } else { $error = 1; } @dates = &fcr::get_dates( $recur, $datea, $dateb ) unless( $error ); if( $#dates < 0 ) { $error = 1; } } if( $error ) { print qq!

    Error in Add Event

    I'm very sorry, but there was a problem with the information you specified for your recurring event. Please hit your back button, and try again, being sure to specify a valid end date, that the end date is after the begin date, and that you only used the values in the form to specify the recurrence.
    !; } else { if( scalar(@dates) > $fcs::max_posts ) { if ($session_group ne "admin") { @dates = @dates[ 0..($fcs::max_posts - 1) ]; } } $id = &counter; # We are now ready to start writing to files. First we get our filelock. If our # database exists, we open it in append mode. If it does not, we create it and # open it at the same time. We then print our new row to the database, close # the database, release our file lock, and sort the events in the database file. # Note that in the case of a recurring event, we may have to switch databases, # so that is kept track of as we move through our array of dates. &GetFileLock ("$lock_file"); open (DATABASE, ">>$database_file") || &open_error($database_file); for( $i = 0; $i <= $#dates; $i++ ) { $dates[ $i ] =~ /^(\d{6})(\d{2})/o; ( $temp_base, $day ) = ( $1, $2 ); $day = int($day); if( $temp_base != $base_file ) { close( DATABASE ); &sort_events(); $database_file = "$calendar_type/$temp_base".".events"; $db_exist = (-e $database_file); open (DATABASE, ">>$database_file") || &open_error($database_file); } if( $#dates == 0 ) { $event_id = $id; } else { $event_id = "$id"."_"."$i"; } $new_row = "$day\|$time\|$session_username\|$event_cat\|$event_id"; print DATABASE "$new_row\n"; $event_id =~ /^(\d+)(_\d)?(\d*)$/o; $event_id = "$1$2$3"; open (EVENTFILE, ">$fcs::path_to_events/$event_id") || &open_error("event file $event_id"); print EVENTFILE "$new_event"; close (EVENTFILE); } close (DATABASE); &sort_events(); &ReleaseFileLock ("$lock_file"); # We now print out some information to the user regarding the addition of the # event to the calendar database, and close it out with the required form data # tags and the standard footer. print qq!

    Your Event "$subject" has been Added.

    !; # If we are allowing notification of users about events, we put together # our mailing list from the information passed to us via the form. We add # the administrator onto the list if she has been set up to receive notifications, # and we then call the notification subroutine with the information to # create the message with. if (($form_data{'notify'} eq "on") && $notified) { $to_notify = "$notified"; } if ($fcs::notify_event) { $to_notify = "$auths::auth_admin_email_address,$to_notify"; } if ($to_notify) { for( $i = 0; $i <= $#dates; $i++ ) { $date = $dates[ $i ]; $date =~ /^(\d{4})(\d{2})(\d{2})/o; $date = "$2/$3/$1"; $dates[ $i ] = $date; } $date = join( ", ", @dates ); ¬ification ($date,$time,$time_zone,$dur_hrs,$dur_mins, $to_notify,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$linkurl, $linktitle,"1"); } } } &footer; } # SUB MODIFY_ITEM_FORM_SUB # # If we have called this subroutine, it means we need to generate the form # to allow the user to modify an item in the database. # This subroutine is very simple. We start our HTML, place some hidden variables # that will tell the modify subroutine who modified the item, then print out a # table of events that we are allowed to modify. We pass a parameter to the # subroutine to let it know we want the modify table form. We then call the # submission form subroutine to get the modify variety of the form, and then # print out some helpful notes to the user to let them know how to use the # form. Then supply buttons, and close the HTML using the standard footer. sub modify_item_form_sub { my( $error ); &header ("Modify an Item"); $error = &event_table (1); unless( $error ) { print ""; &submission_form("modify"); print "
    "; if ($fcs::allow_notify) { print qq!

    Note: In the "Notify" selection box above, be aware that those already notified when the event was added will be notified of the modification. Select only additional people to notify of the event if you need to.!; } print qq!

    Note: Make sure to select an item to modify using the radio buttons on the top table. Then change any of the form inputs you want changed, leaving the others as they are. Feel free to cut and paste from the top table to the bottom table if you only need to change a small amount of text.

    !; } &footer; } # SUB DELETE_ITEM_FORM_SUB # # If we have called this subroutine, it means we want to create the form # to allow the user to delete items from the events database. # This subroutine is very simple. We start the HTML, provide a list of events # for the user using the event_table subroutine, with a parameter to tell the # subroutine that we want the delete form of the table, then provide buttons # to the user, and close with the standard footer. sub delete_item_form_sub { my( $error ); &header ("Delete an Item"); $error = &event_table (0); unless( $error ) { print qq! !; } &footer; } # SUB DELETE_EVENT_SUB # # If we have called this subroutine, the user has requested to delete an # event from the calendar database, using the form generate above. sub delete_event_sub { my (@grepfields,$id); my (@del_events,%del_events,$i,$to_notify,$day); my ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified); my ($linkurl,$linktitle,$location,$subject,$body,$cost,$date,$no_email); # We need to create an index of all the events the user has requested to # delete. We first split the information from the checkboxes on the form # into an array, then fill our %del_events hash with this information so # we don't have to loop through the array later. @del_events = split("\0", $form_data{'item_to_mod_del'}); foreach $i (@del_events) { $del_events{"$i"} = 1; } # We check to see if the @del_events array is empty. If it is, the user # didn't actually select any events to delete, so we print out an error message. # If it is not empty, we start processing the deletion. unless (@del_events) { &header ("Woopsy"); print qq!

    Delete an Item in the Database Error

    I'm sorry, I was not able to modify the database because none of the checkboxes on the table were selected, so I was not sure which item to delete. Would you please make sure that you select an item. Just hit your back button. Thanks.
    !; } else { # We are now processing the deletion. First, we get our lock file in place # to prevent someone else from modifying the file while we are trying to. # We then open up the temp file and database file specific to the events # database we will be deleting from. We also set a variable to let us know # that we are in a public calendar, for email purposes (no $session_email # if not using authentication). $no_email = 0; $no_email = 1 if( $session_email eq '' ); &GetFileLock ("$lock_file"); open (TEMP, ">$temp_file") || &open_error($temp_file); open (DATA, "$database_file") || &open_error($database_file); # We now read through our database file one line at a time. For each line, # we get the event id from the line, as well as the day, remove the new line # character from the id number, and check to see if the id number is in our # index of events to delete. If it is not, we print the item to the temp # file. while () { @grepfields=split(/\|/,$_); $id = pop (@grepfields); $category = pop (@grepfields); $day = shift (@grepfields); chomp $id; unless ($del_events{$id}) { print TEMP "$_"; } else { # If the id number is in our index of items to delete, we do not print the line # to the temp file. Instead, we check to see if we want to notify people of the # change. If we do, we get the information about the event from its file, and # prepare to notify people. ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified, $linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date) = &get_event_info("$id"); $to_notify = ''; $session_email = $email if( $no_email ); if ($fcs::allow_notify) { $to_notify = "$notified"; } # If the administrator wants notification of event changes, we add their address # onto the list of people to notify. if ($fcs::notify_event) { $to_notify = "$auths::auth_admin_email_address,$to_notify"; } # If the people to notify is not empty, we send out the message to everyone # using the notification subroutine, with the final value set to tell that # subroutine that it is a deletion. if ($to_notify) { $date = "$currentmonth/$day/$currentyear"; $category =~ tr/_/ /; ¬ification ($date,$time,$time_zone,$dur_hrs,$dur_mins, $to_notify,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$linkurl, $linktitle,"0"); } # We now untaint the id number, and use it to delete the event file associated # with the event. $id =~ /^(\d+)(_\d)?(\d*)$/o; $id = "$1$2$3"; unlink ("$fcs::path_to_events/$id"); } } # We are now done reading through the DATA file, so we close it and the TEMP file # as well. We remove the DATA file, and replace it with the TEMP file, which # now contains all the information of the original file, minus the events that # we wanted to delete, then release the file lock. close (DATA); close (TEMP); unlink ("$database_file"); rename ($temp_file, $database_file); &ReleaseFileLock ("$lock_file"); # We are now done with all of our processing, so we let the user know that # we are done, and provide a button to refresh the Month Table view in the # month frame. We close the HTML with the standard footer. &header ("Deleted an Item from the $fcs::cal_name Calendar"); print qq!

    Your Event(s) have been Deleted.

    !; } &footer; } # SUB MODIFY_EVENT_SUB # # If we have called this subroutine, it means a user has requeted to modify # an event in the database file. sub modify_event_sub { my ($n_days,$id,$new_line,$value,@notify_users,$notified); my (@fields,$temp_db,$temp_base,$error); my ($subject,$time,$time_zone,$orig_year,$orig_month,$mod_item); my ($location,$dur_hrs,$day,$body,$cost,$phone,$cat2,$end_date,$name,$email,$event_cat); my ($dur_mins,$linkurl,$linktitle,$to_notify,$username,$date); # Okay, let's go ahead and print out the standard header to get started here. # We also grab the item to modify from the form data, untaint it, and place # it into the mod_item variable. $error = 0; &header("Modify an Item in the Database"); $form_data{'item_to_mod_del'} =~ /^(\d+)(_\d)?(\d*)$/o; $mod_item= "$1$2$3"; # We now need to do some error checking. First we check to see if the user # has tried to modify an event by placing it into a day that does not exist. # If they have, we call the invalid date subroutine. $n_days = &days_in_month($currentyear,$currentmonth); if ($form_data{'day'} > $n_days) { &invalid_date ($n_days,$form_data{'day'}); $error = 1; } # If mod_item doesn't have a value in it, that means the user forgot to # select an event from the table presented. We print out an error message # to let them know that. if ( ($mod_item eq '') && (! $error) ) { print qq!

    Modifying an Item in the Database Error

    I'm sorry, I was not able to modify the database because none of the radio buttons on the table were selected, so I was not sure which item to modify. Would you please make sure that you select an item \"and\" fill in the new information. Just hit your back button. Thanks.
    !; $error = 1; } unless( $error ) { # If we have made it to here, we are ready to modify our selected event. # We read in the original year and original month form data variables, because # we want to be sure that if the user is modifying an event in a way that # would move it into a different month, we can handle it. $form_data{'orig_year'} =~ /^(\d{4})/o; $orig_year = $1; $form_data{'orig_month'} =~ /^(\d{1,2})/o; $orig_month = sprintf("%.2d", $1); $temp_base = "$orig_year$orig_month"; $temp_db = "$calendar_type/$temp_base".".events"; # We are now ready to open up the original database file, so we first lock it, # open up a temp file, and go through the database, looking for the id number # we are going to modify. If the id is not the item we are going to modify, # we print it to the temp file. Otherwise, set the fields we have into our # old fields variables. We then close the temp file and original database, # unlink the original database, and rename the temp file to the original database. &GetFileLock ("$lock_file"); open (TEMPFILE, ">$temp_file") || &open_error($temp_file); open (DATABASE, "$temp_db") || &open_error($temp_db); while () { @fields = split (/\|/, $_); $id = pop(@fields); chomp $id; push (@fields, $id); if ($id ne "$mod_item") { print TEMPFILE "$_"; } else { ($day,$time,$username,$event_cat,$mod_item) = @fields; $mod_item =~ /^(\d+)(_\d)?(\d*)$/o; $mod_item = "$1$2$3"; } } close (TEMPFILE); close (DATABASE); unlink ("$temp_db"); rename ($temp_file, $temp_db); &ReleaseFileLock("$lock_file"); # We get the information on our event to modify from the get_event_info subroutine. ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified, $linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date) = &get_event_info("$mod_item"); # We now go through all of our form data values. If the form data value # is not blank, we do the same sort of formatting we did when we added an item # to the database. #find and replace 2 #begin Dave mod foreach $value (@fcs::field_values) { if ($form_data{$value} ne '') { $form_data{$value} =~ s///gio; $form_data{$value} =~ s///go; if ($fcs::strip_html) { $form_data{$value} =~ s/<(.|\n)*?>//go; } if ($session_username ne "David") { $form_data{$value} =~ s/Big Brother sez check it out//g; $form_data{$value} =~ s/Big brother sez check it out//g; $form_data{$value} =~ s/Big Brother says check it out//g; $form_data{$value} =~ s/Big Brother sez\: check it out//g; $form_data{$value} =~ s/Big brother sez\: check it out//g; $form_data{$value} =~ s/Big Brother says\: check it out//g; } $form_data{$value} =~ s/\r//go; $form_data{$value} =~ s/\|/:/go; $form_data{$value} =~ s/\ '/\ ‘\;/g; $form_data{$value} =~ s/\'/\’\;/g; $form_data{$value} =~ s/\n\"/\n\“\;/g; $form_data{$value} =~ s/ \"/ \“\;/g; $form_data{$value} =~ s/from the website\:\n//g; $form_data{$value} =~ s/from the website\: \n//g; $form_data{$value} =~ s/\" /\”\; /g; $form_data{$value} =~ s/\"\./\”\;\./g; $form_data{$value} =~ s/\.\"/\.\”\;/g; $form_data{$value} =~ s/\"\n/\”\;\n/g; $form_data{$value} =~ s/\"-/\”\;-/g; $form_data{$value} =~ s/\"\,/\”\;\,/g; $form_data{$value} =~ s/\,\"/\,\”\;/g; $form_data{$value} =~ s/\"/\“\;/g; $form_data{$value} =~ s/\“\;http/\"http/g; $form_data{$value} =~ s/\“\;>/\">/g; $form_data{$value} =~ s/\n>/\n/g; $form_data{$value} =~ s/\n> \n/

    /g; $form_data{$value} =~ s/\n\*/\n

  • /g; $form_data{$value} =~ s/\n\n/

    /g; $form_data{$value} =~ s/\n/ /g; #was
    } } #end Dave mod # We now go through all of our form data, and update our event if the corresponding # form data value is present. $day = $form_data{'day'} if ($form_data{'day'} ne ''); $username = $form_data{'username'} if ($form_data{'username'} ne ''); $event_cat = $form_data{'category'} if ($form_data{'category'} ne ''); $time_zone = $form_data{'time_zone'} if ($form_data{'time_zone'} ne ''); $name = $form_data{'real_name'} if ($form_data{'real_name'} ne ''); $email = $form_data{'email'} if ($form_data{'email'} ne ''); $location = $form_data{'location'} if ($form_data{'location'} ne ''); $subject = $form_data{'subject'} if ($form_data{'subject'} ne ''); $body = $form_data{'body'} if ($form_data{'body'} ne ''); $cost = $form_data{'cost'} if ($form_data{'cost'} ne ''); $phone = $form_data{'phone'} if ($form_data{'phone'} ne ''); $dur_hrs = $form_data{'dur_hrs'} if ($form_data{'dur_hrs'} ne ''); $dur_mins = $form_data{'dur_mins'} if ($form_data{'dur_mins'} ne ''); if ($dur_hrs || $dur_mins) { $time = $form_data{'time'} if ($form_data{'time'} ne ''); $time = "09:00" if ($time eq ' '); } else { $time = ' '; } # With the notification service turned on, however, we need to do some extra # formatting. The user can add new people to be notified after the event # has been added. We bring in the data from the form, split it, and # add the email addresses to the notify_users array. If we did indeed have # people selected to be notified (@notify_users > 0), we need to merge them # into our original list of attendees. We do this by using the %seen hash. # We split out the original list and put it into @old_users. We then # go through each array, and add them to the hash. With the %seen hash, if there # is a repeat, it overwrites itself, and we don't get any copies. We then # get our final result by joining the keys of the seen hash, which are the # email addresses, using commas, and put this onto the new_event array. If # form data did not have any users selected, we just push the old list onto # the new array. if ($form_data{'notify'} eq "on") { @notify_users = split ("\0", $form_data{'mail_choices'}); } if (scalar(@notify_users > 0)) { my (@old_users) = split (/,/, $notified); my (%seen, $item, $result); foreach $item (@notify_users) { $seen{$item} = 1; } foreach $item (@old_users) { $seen{$item} = 1; } $notified = join(",", (keys(%seen))); } $linktitle = $form_data{'linktitle'} if ($form_data{'linktitle'} ne ''); $linkurl = $form_data{'linkurl'} if ($form_data{'linkurl'} ne ''); if ($linkurl ne '' && $linktitle ne '') { $linkurl =~ s/\\/\//go; unless ($linkurl =~ /(^(http:|https:|ftp:|news:)\/\/)|(^mailto:)/o) { $linkurl = "http://$linkurl"; } } else { $linkurl = ''; $linktitle = ''; } # Okay, we are done updating our event, so we need to write out the information to # files. We create our new line by joining the values with "|". We then get a # lock file, and open up the new database file, creating it if it doesn't exist, # appending to it if it does. We print our new line to the database, close it up, # release the file lock, and sort the file. $new_line = "$day\|$time\|$username\|$event_cat\|$mod_item"; &GetFileLock("$lock_file"); open (DATABASE, ">>$database_file") || &open_error($database_file); print DATABASE "$new_line\n"; close (DATABASE); &sort_events (); &ReleaseFileLock ("$lock_file"); # We now create the event file for the modified event. Since the information is # all at hand, we will just clobber the original file in the process of updating # it, to make this a little easier. We format our file just as we did in the # original add event subroutine. $new_line = ''; $new_line = "time->$time\ntimezone->$time_zone\ndurationhrs->$dur_hrs\n"; $new_line .= "durationmins->$dur_mins\nname->$name\nemail->$email\n"; $new_line .= "notified->$notified\nlinkurl->$linkurl\nlinktitle->$linktitle\n"; $new_line .= "location->$location\nsubject->$subject\nbody->$body\ncost->$cost\nphone->$phone\n"; open (EVENTFILE, ">$fcs::path_to_events/$mod_item") || &open_error ("event file $mod_item"); print EVENTFILE "$new_line"; close (EVENTFILE); # If we are set up to notify people of these changes, we make our list of people # to notify, adding the administrator if they have so chosen. We use the # original poster's email address if this is a public calendar and a new email # address was not supplied. $session_email = $email if( $session_email eq '' ); if ($fcs::allow_notify) { $to_notify = "$notified"; } if ($fcs::notify_event) { $to_notify = "$auths::auth_admin_email_address,$to_notify"; } # We now send out the notification to all the email addresses in the string. if ($to_notify) { $date = "$currentmonth/$day/$currentyear"; $event_cat =~ tr/_/ /; $category = $event_cat; ¬ification ($date,$time,$time_zone,$dur_hrs,$dur_mins, $to_notify,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$linkurl, $linktitle,"2"); } # Finally, we are done, so we print out a confirmation message to the user, # and provide a button for them to refresh the calendar. We of course # close with the standard footer. print qq!

    Your Event "$subject" has been Modified

    !; } &footer; } # SUB SEARCH_FORM # # If we have called this subroutine, it means the user has requested to # perform a search, and needs to supply information on it. sub search_form { my ($i,$startyear,$endyear,$month); # We print out our standard header, and start creating HTML for the # entire form. We need to supply a start date for the search, and # we do that by using our select_a_month and select_a_year subroutines, # as well as providing a day selector. We automatically select the current # day (localtime) for the day value. &header("Search for Events"); print qq!

    Search for Events

    \n"; # Now we need an input item for the keywords to search on, radio buttons # to decide whether we want to do an AND or and OR logical search, and # checkboxes to select which fields we want to search. The choices are # Subject, Body, and Location. We then finish up our form with the # proper buttons. if (scalar(@fcs::categories)) { print qq! \n"; } print qq!
    Start Search:!; &select_a_month(); print "\ \;"; &select_a_day( "startday" ); print ",\ \;\ \;"; &select_a_year(); # Now we need our end date. We can't use select_a_month and select_a_year # again, because then the selectors would have the same name as the start # date selectors, and we wouldn't get anywhere. So we need to create # them manually. We basically copy the code out of the two subroutines, # and simply supply a different name for the selectors. See the comments # in these subroutines if you want to know what is happening here. print qq!
    End Search:!; &select_a_month( "endmonth" ); print "\ \;"; &select_an_end_day( "endday" ); print ",\ \;\ \;"; &select_a_year( "endyear" ); print "
    Category:!; &select_a_category (1); print "
    Keywords:
    Enter keywords separated by spaces.
    Match: All of the words above Any of the words above
    Search In: Body Subject Location Posted by

    !; # We are done with this form, so we print out our online help link if we are # using online help, and close with the standard footer. if ($fcs::use_help) { print "

    "; &help_link ("10"); } print "

    "; &footer; } # SUB SEARCH_EVENTS # # If we have called this subroutine, it means the user has entered their # search criteria, and is ready to see some results. sub search_events { my (@fields, $logic, $match_found, $search_month, $search_year, $end_file); my ($start_num, $end_num, $srch_str, $db_file, $day_num, $i); my (@keywords, $keywords, @results, $day, $time, $user, $id, $and_res, $link); my ($time_zone, $dur_hrs, $dur_mins, $name, $email, $notified); my ($linkurl, $linktitle, $location, $subject, $body, $cost, $phone); # We initialize some of our variables with the data entered in the form. # We get which fields the user wants to search in, the logic they wish # to use, the keywords to search for, and the date range to use for the # search. We concatenate the year, month, and day for both the start and # end dates, and we also save some information on our ending file. @fields = split(/\0/, $form_data{'fields'}); $logic = $form_data{'logic'}; @keywords = split(/ /, $form_data{'keywords'}); $keywords = join("\|", @keywords); $start_num = "$form_data{'year'}".sprintf("%.2d", $form_data{'month'}); $start_num .= sprintf("%.2d", $form_data{'startday'}); $end_num = "$form_data{'endyear'}".sprintf("%.2d", $form_data{'endmonth'}); $end_file = $end_num; $end_num .= sprintf("%.2d", $form_data{'endday'}); # Of course, we have to do some error checking. The first if statement # is checking to see if the user entered an end date that is before the # start date. The next check is to see if the user did not select any # fields to search. The next check is to see if the user did not enter # any keywords to search for. If any of the logic statements evaluate # to true, we have an error condition, and won't go into the search routine. if ( $end_num lt $start_num ) { &header ("Invalid Search Date Range"); print qq!

    Search Date Range Error

    I'm sorry, but you entered an End Date that is earlier than the Start Date for your search. Please hit your back button and try again.
    !; &footer; } elsif (scalar(@fields) < 1) { &header ("No Search Fields Selected"); print qq!

    No Search Fields Error

    I'm sorry, but you did not select any fields to be searched. Please hit your back button and try again.
    !; &footer; } elsif (scalar(@keywords) < 1) { &header ("No Keywords Entered"); print qq!

    No Keywords Error

    I'm sorry, but you did not enter any keywords for which to search. Please hit your back button and try again.
    !; &footer; } else { # If we have made it through all of our error checks, we are ready to start our # search. We initialize our search_year and search_month variables with the # currentyear and currentmonth, as they hold the values for the start year and # month for the search. We make a new base file out of these, and then a # new db_file that we will search for. This is all so we have a more efficient # loop through the start and end search dates. $search_year = $currentyear; $search_month = $currentmonth; $base_file = "$currentyear".sprintf("%.2d", $currentmonth); $base_file =~ /^(\d{6})/o; $base_file = $1; $db_file = "$calendar_type/$base_file.events"; # We now make sure that our bse_file is less than or equal to our end_file. This # is to handle the conditions where the user wants to search in only one month, or # wants to search through many months. This one statement will handle both conditions. # We will continue going through our event files until this is false. while ( $base_file <= $end_file ) { if ( -e $db_file ) { # If the db_file exists, we open up the file, then start reading through it # one line at a time. We remove the new line character from our id number for # each event, then, on each pass, we initialize our search variables, $srch_str, # $match_found, and $and_res. This is handled on one line. We then get the # day number set to our base file plus the day number for the event. open (DATA, "$db_file") || &open_error ( $db_file ); while () { ($day,$time,$user,$tmp_cat,$id) = split(/\|/, $_); # chomp ($tmp_cat,$id); $srch_str = ''; $match_found = 0; $and_res = 0; $day_num = "$base_file".sprintf("%.2d", $day); # If our day number is greater than or equal to our start number and it is also # less than or equal to our end number, we have an event that we want to search # through, so we get the event information using get_event_info, and then # use the information found therein to make our search string ($srch_str) by # concatenating each item the user has asked to search through onto this string. if ( ($day_num ge $start_num) && ($day_num le $end_num) && ($tmp_cat =~ /\b$category\b/ || $category eq '') ) { ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified, $linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date) = &get_event_info("$id"); foreach $i (@fields) { if ($i eq "subject") { $srch_str .= " $subject"; } elsif ($i eq "location") { $srch_str .= " $location"; } elsif ($i eq "body") { $srch_str .= " $body"; } elsif ($i eq "name") { $srch_str .= " $name"; } } # If the user has selected any as the logic type, we do a search on our keywords, # using a regular expression with each word separated by the or symbol in regular # expressions (|). That is why above we joined our keywords with the "|" symbol. # If we get a match, we set our $match_found flag to true. # Else, if the user has selected all as the logic type, we loop through each keyword # in our keyword array. For each keyword that we find in the search string, using # regular expressions, we add one to the $and_res variable. At the end of the # loop, we determine if $and_res equals the number of keywords we entered. If it # does, we found each of the keywords in our search string, and so we set our # $match_found flag to true. if ( $logic eq "any" ) { if ( $srch_str =~ /\b($keywords)\b/i ) {$match_found = 1;} } elsif ( $logic eq "all" ) { foreach $i (@keywords) {$and_res++ if ($srch_str =~ /\b($i)\b/i);} if ( scalar(@keywords) == $and_res ) {$match_found = 1;} } # If we made a match on the current event, as determined by our $match_found flag being # set to 1, we create a link to this event, formatted to use our javascript function # in the header of each HTML page, and including all the information that will be # required by the view_search_sub above. We then push it onto our results array for # later printing. if ( $match_found ) { if ($session_username ne $user && $tmp_cat =~ /\bPrivate\b/) { $link = ""; } else { $link = ""; $link .= "$subject"; $link .= "\ \;\ \;--\ \;\ \;$fcs::month_hash{$search_month} "; $link .= "$day, $search_year"; if ($time =~ /\d+/o) { $link .= " at $fcs::TIME{$time}"; } else { $link .= " (All Day)"; } $link .= "

    "; push (@results, $link); } } } # end if. } # end while # Once we are done with the current db_file, we close it. close (DATA); } # We now increment our search_month variable, correcting the search_year and # search_month if we go over 12. Then we concatenate it into a new base_file # and a new db_file for our next pass through the while loop above. Thus, we # will efficiently cover all of our months to search through. $search_month++; if ($search_month > 12) { $search_month = 1; $search_year++; } $base_file = "$search_year".sprintf("%.2d", $search_month); $base_file =~ /^(\d{6})/o; $base_file = $1; $db_file = "$calendar_type/$base_file.events"; } # Once the while loop quits, we are done searching through files, so we print out # the results to the user. We provide some basic HTML to let them know what we # are showing them. Then, if our results array contains one or more items, we # print each of them out. Else, we let the user know that we didn't find any # events matching their criteria. &header("Search Results"); print qq!

    Search Results

    Below are the results from your search. Click on a link to get detailed information regarding the event.
      \n!; if ( scalar(@results) > 0 ) { foreach $i (@results) { print "$i\n"; } } else { print "No Events Matched Your Search Criteria.

      "; } print "

    "; # Of course, we end by printing out a help link if we are using online help, # and then print out the standard footer, and we are done. if ($fcs::use_help) { print "

    "; &help_link ("12"); print "
    "; } &footer; } } # SUB MAKE_MONTH_ARRAY # # This subroutine is used to create an array formatted to conform to # a month display. sub make_month_array { my(@myarray, $numdays, $remain, $x); # Get the firstweekday of the month. my($firstweekday) = &day_of_week_num( $currentyear, $currentmonth, 1 ); # If you are formatting this for European calendars, where the first day of the # week is Monday, uncomment the next 5 lines. # if ($firstweekday != 0) { # $firstweekday--; # } else { # $firstweekday = 6; # } # Get the number of days in the month from the days_in_month subroutine, and # find out how many days we are short of an even multiple of 7. $numdays = &days_in_month($currentyear,$currentmonth); $remain = ( $firstweekday + $numdays ) % 7; # Pad the beginning of the array with blanks until we get to the first # week day for the month. for ($x = 0; $x < $firstweekday; $x++) { $myarray[$x] = " "; } # Now that we are into the month, assign the day number into each cell of the # array until we get above the number of days in the month. for ($x = 1; $x <= $numdays; $x++) { $myarray[$x + $firstweekday - 1] = $x; } # If we are not an even multiple of 7, pad the end of the array # with blanks. unless ($remain == 0) { for ($remain; $remain < 7; $remain++) { push (@myarray, " "); } } # We are done, so return the formatted array. return (@myarray); } # SUB CGIREQUIRE # # This subroutine takes a list of files with path information that are needed # by this script, and attempts to require them. sub CgiRequire { my (@require_files) = @_; my ($file); # Check to see if each file exists and is readable. # If it is, require it. If it is not, provide an error # message for the file we could not require, and die. # old message # I'm sorry, I was not able to open $file. Would you foreach $file (@require_files) { if (-e "$file" && -r "$file") { require "$file"; } else { print "Location: http://www.thoughtpolice.com/notallowed.html\n\n"; } } } # SUB SELECT_A_MONTH # This subroutine generates a drop selector on the form to allow # the user to pick a specific month. sub select_a_month { my ($name) = @_; my ($month); $name = "month" if( $name eq '' ); print "\n"; } # SUB SELECT_A_YEAR # # This subroutine generates a drop selector on the form to allow # the user to pick a specific year. sub select_a_year { my ($name) = @_; my ($startyear,$endyear,$i); $name = "year" if( $name eq '' ); print "\n"; } # SUB SELECT_A_DAY # # This subroutine generates a drop selector on the form to allow the user # to pick a day number. sub select_a_day { my( $name ) = @_; my( $temp_day, $i ); $name = "day" if( $name eq '' ); if( $form_data{'day'} ) { $temp_day = $form_data{'day'}; } else { $temp_day = $ltday; } print "\n"; } # SUB SELECT_AN_END_DAY # # This subroutine generates a drop selector on the form to allow the user # to pick a day number. sub select_an_end_day { my( $name ) = @_; my( $temp_day, $i ); $name = "day" if( $name eq '' ); if( $form_data{'day'} ) { $temp_day = $form_data{'day'}; } else { $temp_day = $ltday; } print "\n"; } # SUB SELECT_A_DOW # # This subroutine generates a multiple selector on the form to allow the user # to select multiple day of the week, if desired. sub select_a_dow { my( $name ) = @_; my( $i ); # print "$fcs::full_day_names[ $i ]\n"; } print "\n"; # } # SUB SELECT_A_CATEGORY # This subroutine generates a drop selector on the form to allow the user # to pick a category # 0=new # 1=nav # 2=modify #dave mod sub select_a_category { my ($type) = $_[0]; my ($i,$x); if ($type == 2 || $type == 0) { $select_input_type = 'type=checkbox'; $select_select_type = 'input'; } else { $select_input_type = ''; $select_select_type = 'option'; } # After we have started our select tag, we fill it with options by giving a # default value of All/Any, and then loop through our categories array and # provide each as an option. if ($type == 1) { print qq! Don't Change Category\n"; } elsif ($type == 3) { print qq! \n"; } } #end dave mod # SUB EVENT_TABLE # # This subroutine is used to create a nicely formatted table of events # for use in the modify and delete event form subroutines. # We pass it one paramter which defines whether it should be a modify # table or a delete table. sub event_table { my ($modify) = $_[0]; my ($value,$day,$username,$name,$email,$subject); my ($time,$time_zone,$location,$body,$cost,$phone,$cat2,$end_date,$dur_hrs,$dur_mins,$id); my ($item_found,$table,$linkurl,$linktitle,$notified,$temp_cat,$error); # Print out some HTML to let the user know which type of form this is. print "
    \n"; if ($modify) { print "

    Modify - $current_month_name $form_data{'day'}, $currentyear

    \n"; } else { print "

    Delete Events - $current_month_name, $currentyear

    \n"; } # If online help has been enabled, print out the proper help topic link. if ($fcs::use_help) { print "

    "; if ($modify) { &help_link("5"); } else { &help_link("6"); } } # Start the table. We fill the top row with the headings for the columns, and add in # the item column as the first. We fill in the other columns using a foreach loop # and the @field_names array. $table = ''; $table .= ""; $table .= "\n\n"; $table .= "\n"; foreach $value (@fcs::field_names) { $table .= "\n"; } $table .= "\n"; # We now open up the database file. open (DAYFILE, "$database_file") || &open_error($database_file); while () { # We read through the file one line at a time, stripping off the newline # character. We then split up the row into variables which we will use # in just a minute. chomp $_; ($day, $time, $username, $temp_cat, $id) = split (/\|/,$_); # If the day is equal to the form data day, or if this is not a modify # table, AND if the username of the event matches the session username # or the administrator is looking at it, we have found an event. if ((($day eq "$form_data{'day'}" && ($temp_cat =~ /\b$category\b/ || $category eq '')) || !$modify) && ( $session_username eq "$username" || $session_group eq "admin" )) { if ($session_username ne $username && $temp_cat =~ /\bPrivate\b/) { } else{ $item_found = "yes"; } # We have found an event, so we need to get the information about it by # using the get_event_info subroutine. We then format our time_zone # variable, and start adding to the table. We add a cell that spans two # rows to hold a radion button if it is a modify table, or a checkbox if # it is a delete table. These are keyed to the event id number. ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified, $linkurl,$linktitle,$location,$subject,$body,$cost) = &get_event_info("$id"); $time_zone = ($fcs::use_time_zones ? " $time_zone" : ''); $table .= "\n"; $table .= "\n"; # We now print out information about the event in a compact format for reference. $table .= "\n"; $table .= ""; $table .= "\n\n"; $table .= "\n"; $table .= "\n"; $table .= "\n"; } } $table .= "
    Item$value
    "; $table .= ""; $table .= "$currentmonth/$day/$currentyear"; if ($dur_hrs || $dur_mins) { $table .= " - $fcs::TIME{$time}$time_zone"; } $table .= "$dur_hrs hrs, $dur_mins mins$subject$location$cost
    $body"; if ($fcs::allow_links && $linktitle && $linkurl) { $table .= "

    $linktitle - $linkurl"; } $table .= "

    \n"; close (DAYFILE); # Once we have finished going through the table, we check our item_found flag. # If we haven't found any items, we let the user know that, otherwise, we print # out the table. if ($item_found ne "yes") { print qq!

    I'm sorry, no items were found that were posted by you, so there is nothing for you to modify.
    !; $error = 1; } else { print $table; $error = 0; } return( $error ); } # SUB SUBMISSION_FORM # # This subroutine is used to generate the form used to add or modify an event, # and thus takes a parameter to determine which type of form it is generating. sub submission_form { my ($type_of_form) = $_[0]; my ($i,$name,$email); # If we are using online help, we print out the help topic link. if ($fcs::use_help) { unless ($type_of_form eq "modify") { print "
    "; &help_link ("4"); print "
    "; } } # We now start to print out the table that will line up our form. print ""; # If our session name is not blank, that is, we are using some form or verification, # either cgi or server based, then we automatically fill in the information for # the poster's name and email address. Otherwise, we provide text fields for the # user to type in their name and email address. if ($session_name ne '') { print qq! !; } else { print qq! !; } # Now we provide an input field to type in the subject of the event, and # start the event date information. print qq! !; if( scalar(@fcs::categories) ) { print qq! "; } print qq! \n"; # We now provide an input item for entering the location of the event, and a # textarea box to enter the body information of the event. if ($session_group eq "booger") { print qq! \n!; } print qq! !; #begin Dave mod print qq! !; if ($session_username ne "David") { print qq! !; } #onBlur="this.form.body.value = ConvertBR(this.form.body.value);" print qq!
    !; #end Dave mod # If we are allowing web links in the calendar, we provide input items to # enter the link title and link url to be used. if ($fcs::allow_links) { print qq! !; } #begin Dave mod print qq! !; #end Dave mod # If we are allowing notifications, we provide a checkbox to select that we # do want to notify people, and then a multiple selector that is created by # opening the authorized users file and reading all the lines in there. For # each entry, we use the name of the user as the item to show up in the # selector, and their email address for the value to be returned if they are # selected. We then close the file, and print out information on how to # select multiple people to notify. # || $session_username eq "David" if ($fcs::allow_notify) { print qq! !; } if ($session_username eq "David") { print qq! !; } # if ($session_username eq "David") { # print qq! # # !; # } # If we are not in modify mode, we now need to present the user with a list of # options to make the event recurring, as an option. The following code sets # up the form to allow all kinds of different selections for this. unless ($type_of_form eq "modify") { print qq! !; } # We now provide some notes to the user regarding the properties of the Body textarea, # since many people want to hit the return key at the right margin of the # textarea rather than letting it wrap automatically. print qq!
    Your Name   Email
    Personal Event Check this box if this event is a personal/private event for your eyes only (doctor's appt, hot date, mom's birthday, etc.)
    Subject
    Category!; if ($type_of_form eq "modify") { &select_a_category (2); } else { &select_a_category (0); } print "
    Enter as many categories as you think are applicable. e.g., AnonSalon could be considered a club, concert, event, meeting, party, or miscellaneous - so check all of them.
    Date!; # To get all of the date information, we use the select_a_month subroutine to # get a month selector, then we create a selector for the day, numbering 1 # through 31, with the current day selected, and then use the select_a_year # subroutine to provide a year selector. &select_a_month(); &select_a_day(); print ",\ \;\ \;"; &select_a_year(); # We now prompt for the start time of the event. We provide a selector # keyed to our %TIME hash, but if we are using a modify item form, we # also provide a blank option to not change the time of the event. print qq!
    Start Time \n"; # If we are using time zone information, we provide a selector for the # user to pick a time zone. If we are using a modify form, we also provide # a blank to avoid changing the time zone. if ($fcs::use_time_zones) { print "\ \;\&\#45\;\ \;"; } # We now provide selectors for the user to enter the duration of the event # in hours and minutes. We provide blanks for each in the case of a modify # form, to avoid changing the duration. #
    # print qq! Duration   \ \ hours, \  \ \ mins
    Location Name
    Location Name
    Street Address
    List exact address only\! If using cross-streets,
    don\’t use Columbus and Broadway - Use
    Columbus Ave. \@ Broadway St. - w/St. or Ave.
    City: e.g. San Francisco (default city)
    Do not list county or state\! It will screw up the mapping software\!
    Cost
     
      Phone No
    Please use dollar sign if applicable. Contact number if available.
    Body !; if ($session_username ne "David") { print qq!
    STOP. You have characters left. If you are posting redundant information in the above body box (the address, your URL, a phone number, the date, etc.) which was including in the other tags, your event will be deleted. Big Brother is tired of editing out repetitious info. So edit it\! If you're just pasting in a press release without editing it, odds are it will be deleted.
    !; } print qq!
    Link Information (Optional)
    URL
     
     
    Link: e.g. http://www.babydoe.net
    Do not enter more than one URL\!
    Title: e.g. The Devil-Ettes (optional)
    Contact Name     Contact E-mail  

    Notifications (optional)
      Check box to notify, via email, selected people below.

    Hold down Ctrl key to select multiple.

    Notifications (optional)
      Check box to notify, via email, selected people below.

    Hold down Ctrl key to select multiple.
    NotificationsCheck box to notify all users/admins.!; # open (AUTHFILE, "$auths::auth_user_file") || &open_error($auths::auth_user_file); # while () { # chomp $_; # ($group, $name, $email) = (split (/\|/,$_))[2,3,4]; # if ($group eq "user") { # print "\n"; # } #close group if # elsif ($group eq "admin") { # print "\n"; # } #close group if # } # close (AUTHFILE); # print qq! #     Check box to notify contact. #

    Recurring Events (optional)
    Do Not Repeat This Event.
    Repeat    
    Repeat    !; &select_a_dow( "rec_d"); #Begin Dave mod print qq!
    Repeat on the
    FirstSecondThird FourthLast
    !; &select_a_dow( "rec_f" ); print qq!
    of the month, every  !; #End Dave mod print qq!
     
            Through  !; &select_a_month( "rec_mon" ); print "\ \ "; &select_a_day( "rec_day" ); print "\ ,\ \ "; &select_a_year( "rec_year" ); print qq!
    !; } # SUB HEADER # # This subroutine takes a title as an argument. It then generates the # content type information so the browser knows what it is receiving, and # then opens up the HTML page. It provides a javascript function that will # be used by the help files and the search routine to display information. # It also starts the standard form that will be used on most every page. sub header { my ($title) = $_[0]; if ($title eq '') { $title = "$fcs::cal_name Calendar"; } print "Content-type: text/html\n\n"; print qq! $title\n $fcs::basefont_tag
    !; } # SUB HEADER2 # # This subroutine takes a title as an argument. It then generates the # content type information so the browser knows what it is receiving, and # then opens up the HTML page. It provides a javascript function that will # be used by the help files and the search routine to display information. # It also starts the standard form that will be used on most every page. sub header2 { my ($title) = $_[0]; if ($title eq '') { $title = "$fcs::cal_name Calendar"; } print "Content-type: text/html\n\n"; print qq! $title \n $fcs::basefont_tag!; } # SUB FOOTER # # This subroutine is used to generate a standard footer for each HTML # page, and properly close the HTML. Calendar Administrator sub footer { print qq! !; } # SUB PRINT_EVENT # # This subroutine prints out the information for an event in the specified # format. It is called from three other subroutines. sub print_event { my ($event) = $_[0]; my ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified); my ($linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$end_time,$username); my ($mmn,$mh,$md,$mm,$myr,$mtime,$mtstr,$mycats,$ampm,$recur_tag,$day); # We first gather all of the information on the event that was passed to us, # and then format the time_zone variable and the end_time variable for display. ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified, $linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$day) = &get_event_info("$event"); $time_zone = (($fcs::use_time_zones && $time_zone) ? " \( $time_zone \)" : ''); if ($dur_hrs || $dur_mins) { $end_time = &get_end_time($time,$dur_hrs,$dur_mins); } # This section of code gets the time that the event file was last modified, so # we can display this with the event for informational purposes. After we get # the time, which is provided in epoch seconds by stat, we format it for printing. $mtime = (stat("$fcs::path_to_events/$event"))[9]; ($mmn,$mh,$md,$mm,$myr) = (localtime($mtime + ($fcs::time_offset * 3600)))[1..5]; $myr += 1900; $mm = $fcs::month_hash{$mm + 1}; $ampm = "am"; if ($mh >= 12 ) { $mh -= 12; $ampm = "pm"; } if ($mh == 0) { $mh = 12; } $mtstr = "$mm $md, $myr at $mh\:".sprintf("%.2d", $mmn)." $ampm"; # begin Dave Mod # XXX category listing # This section gets the category listing $event_cat =~ tr/_/ /; $mycats = $event_cat; #end Dave mod # Finally, we need to set up our recurrence tag. If the event is a recurring # event, and we have defined a value in calendar.setup for $recur_image, we # will format it here. if ($end_date) { $enddate2 = " Recurring through $end_date" } else { $enddate2 = "" } if( ($event =~ /_/o) && $fcs::recur_image ) { $recur_tag = " \"[ $enddate2 "; } # Now that we have all the information on the event, we need to print it out. # The following lines of code do just that, printing out the HTML that formats # the event information. print qq! $subject$recur_tag!; print qq!<\/font>
    !; print qq! !; } else { print qq!$fcs::TIME{$time}!; } #print qq!All Day!; #Begin Dave Mod print qq! !; if ($cost) { print qq!\n
    Time:\ \; !; if ($end_time) { print qq!$fcs::TIME{$time} - $fcs::TIME{$end_time}$time_zone
    Location:\ \; $location
    Cost:\ \; $cost
    !; } else { print qq!\n
    Cost:\ \; Ask at door.
    !; } print qq! \ \;\ \;\ \; !; if ($fcs::allow_links && $linkurl) { if ($linktitle && $linkurl) { print qq! !; } else { print qq! !; } } # if ($phone) { print qq! !; } else { } if ($cat2) { $cat2 =~ s/_/ /go; print qq! !; } else { } if ($name ne "Big Brother") { if ($name ne "Simone") { print qq! !; } } print qq!
    Event\ \;URL:\ \; $linktitle
    Event\ \;URL:\ \; $linkurl
    Posted\ \;on:\ \; $mtstr
    Phone\ \;No:\ \; $phone
    Categories:\ \; $cat2
    Contact:\ \; $name
    !; if ($session_group eq "admin") { print qq! Posted on:\ \;$mtstr by $username - db id\#\: $event
    !; } print qq!E-mail this event to a friend\!!; print qq!

    $body \ \;

    !; # end Dave mod } # SUB GET_EVENT_INFO # # This subroutine returns the information from an event file associated with an # id number. Note that we apply special formatting to the file when we create it, # and place it in the same order, so that when we call this subroutine it is # returned in the same order every time. Thus, if you make modifications to what # data is stored in this file, be sure to get the insertion/extraction order # correct! sub get_event_info { my ($filename) = $_[0]; my (@event_array); # We open up the file, then read through it one line at a time. If the line starts # with one of the tags that we have defined, we push what it "points to" onto the # array that we will return. open (EVENTFILE, "$fcs::path_to_events/$filename") || &open_error("event file $filename"); while () { if (/^time->(.*)/io) { push (@event_array, $1); } elsif (/^timezone->(.*)/io) { push (@event_array, $1); } elsif (/^durationhrs->(.*)/io) { push (@event_array, $1); } elsif (/^durationmins->(.*)/io) { push (@event_array, $1); } elsif (/^name->(.*)/io) { push (@event_array, $1); } elsif (/^email->(.*)/io) { push (@event_array, $1); } elsif (/^notified->(.*)/io) { push (@event_array, $1); } elsif (/^linkurl->(.*)/io) { push (@event_array, $1); } elsif (/^linktitle->(.*)/io) { push (@event_array, $1); } elsif (/^location->(.*)/io) { push (@event_array, $1); } elsif (/^subject->(.*)/io) { push (@event_array, $1); } elsif (/^body->(.*)/io) { push (@event_array, $1); } elsif (/^cost->(.*)/io) { push (@event_array, $1); } elsif (/^phone->(.*)/io) { push (@event_array, $1); } elsif (/^cat2->(.*)/io) { push (@event_array, $1); } elsif (/^end_date->(.*)/io) { push (@event_array, $1); } } close (EVENTFILE); # At the end of the file, we close it, then chomp the entire array, since # each item has a trailing new line character. We are then done, so we # return the array. chomp (@event_array); return (@event_array); } # SUB GET_END_TIME # # This subroutine takes a beginning time and duration and returns a # properly formatted end time. sub get_end_time { my ($time,$dur_hrs,$dur_mins) = @_; my ($end_hrs,$end_mins,$end_time); # Initialize the end_hrs and end_mins by splitting the start time # at the :. We then increase the minutes by the duration minutes. # If they are greater than 60, we add one to end_hrs, and subtract # 60 off of end_mins. Then we add the duration hours to end_hrs, # and correct for being greater than 24 if necessary. We then # format the time correctly, and return it. ($end_hrs,$end_mins) = split(/:/, $time); $end_mins += $dur_mins; if ($end_mins >= 60) { $end_hrs++; $end_mins -= 60; } $end_hrs += $dur_hrs; if ($end_hrs >= 24) { $end_hrs -= 24; } $end_time = sprintf("%.2d", $end_hrs).":".sprintf("%.2d", $end_mins); return ($end_time); } # SUB DAY_OF_WEEK # # This subroutine calculates the day of the week a particular date falls on, # and returns that name. Note that it uses English names for the days of the # week, so you will need to change these if you are converting to another language. sub day_of_week { my ($year, $month, $day) = @_; my ($d); $d = &day_of_week_num( $year, $month, $day ); return( $fcs::full_day_names[$d] ); } # SUB DAY_OF_WEEK_NUM # # This subroutine calculates the day of the week a particular date falls on, # and returns the number. sub day_of_week_num { my ($year, $month, $day) = @_; my ($a, $y, $m, $d); $a = int((14 - $month)/12); $y = $year - $a; $m = $month + (12 * $a) - 2; $d = ($day + $y + int($y/4) - int($y/100) + int($y/400) + int(31*$m/12)) % 7; return( $d ); } # SUB NOTIFICATION # # This subroutine handles all of the notification services for this script, # formatting the messages properly before sending them to sendmail. sub notification { my($date,$time,$time_zone,$dur_hrs,$dur_mins,$notified, $location,$subject,$body,$cost,$phone,$cat2,$end_date,$url,$title,$type) = @_; my($notify_user,@notified,$msg_subject,$message,$type_word); my($end_time,$temp_cat); # We start off by splitting our comma separated list of email addresses into # an array. We then use the type variable that was passed to decide whether # we are sending out a new event notice, a deleted event notice, or a modified # event notice. @notified = split (/,/, $notified); if ($type == 1) { $type_word = "Added"; } elsif ($type == 0) { $type_word = "Deleted"; } elsif ($type == 2) { $type_word = "Modified"; } # We format the time_zone and end_time variables. $time_zone = ($fcs::use_time_zones ? " - $time_zone" : ''); if ($dur_hrs || $dur_mins) { $end_time = &get_end_time($time,$dur_hrs,$dur_mins); } # We format the category... $temp_cat = $category; $temp_cat =~ tr/_/ /; # We now require our mail library for using sendmail. &CgiRequire("$lib/mail-lib.pl"); # The following lines format the message to be sent out. Since this isn't # an HTML message, we have to modify some variables to compensate for HTML # tags. $body =~ s/

    /\n\n/gio; $body =~ s/
    /\n/gio; $msg_subject = "Event $type_word - $fcs::cal_name Calendar"; $message = "The following event was ".lcfirst("$type_word")." on the $fcs::cal_name ($fcs::html_url).\nAnd Big Brother thought it was important enough to spam you.\n\n"; $message .= " Subject: $subject\n"; $message .= sprintf ("%8s", $type_word)." By: $session_name ($session_email)\n"; $message .= "Event Time: $date"; if ($end_time) { $message .= " from $fcs::TIME{$time} to $fcs::TIME{$end_time}$time_zone\n"; } else { $message .= " All Day\n"; } $message .= " Location: $location\n"; $message .= " Cost: $cost\n"; $message .= " Phone No: $phone\n"; $message .= " Category: $temp_cat\n" if( $temp_cat ne ''); $message .= " Web Page: $title ($url)\n" if( ($title ne '') && ($url ne '') ); $message .= "\n$body\n"; # Finally, after getting our message together, we send the notification out to # each person in the notified array. foreach $notify_user (@notified) { &mail::send_mail ($session_email, $notify_user, $msg_subject, $message); } } # SUB NOTIFICATION2 # # This subroutine handles all of the notification services for this script, # formatting the messages properly before sending them to sendmail. sub notification2 { my($date,$time,$time_zone,$dur_hrs,$dur_mins,$notified, $location,$subject,$body,$cost,$phone,$cat2,$end_date,$url,$title,$type); my($notify_user,@notified,$msg_subject,$message,$type_word); my($end_time,$temp_cat); print qq!

    Your Event "$subject" has been Added.

    !; # We start off by splitting our comma separated list of email addresses into # an array. @notified = split (/,/, $notified); # We format the time_zone and end_time variables. $time_zone = ($fcs::use_time_zones ? " - $time_zone" : ''); if ($dur_hrs || $dur_mins) { $end_time = &get_end_time($time,$dur_hrs,$dur_mins); } # We now require our mail library for using sendmail. &CgiRequire("$lib/mail-lib.pl"); # The following lines format the message to be sent out. Since this isn't # an HTML message, we have to modify some variables to compensate for HTML # tags. $msg_subject = "Event $type_word - $fcs::cal_name Calendar"; $message = "The following event was on the calendar. \nAnd Big Brother thought it was important enough to spam you.\n\n"; $message .= " Subject: $subject\n"; $message .= "\n$body\n"; # Finally, after getting our message together, we send the notification out to # each person in the notified array. foreach $notify_user (@notified) { &mail::send_mail ($session_email, $notify_user, $msg_subject, $message); } } # SUB DAYS_IN_MONTH # # Quite often we need to know what the last day of a month is, for error checking # purposes. sub days_in_month { my($ldyear, $ldmonth) = @_; my(@month_days) = (0,31,28,31,30,31,30,31,31,30,31,30,31); # If we are not in February, we know from the above array what the number of days # in the month is. However, if we are in February, we first have to check for a # leap year. If it is a leap year, we set the number of days for February in the # array to 29, else, we leave it at 28. if( ($ldmonth == 2) && (&is_leap_year( $ldyear )) ) { $month_days[ 2 ] = 29; } # We are done, so return the number of days in the month. return ($month_days[ $ldmonth ]); } # SUB IS_LEAP_YEAR # # This subroutine takes a year number as an argument and returns a # 1 if it is a leap year, a 0 otherwise. sub is_leap_year { my( $year ) = @_; my( $bool ) = 0; if( (($year % 4 == 0) && ($year % 100 != 0)) || ($year % 400 == 0) ) { $bool = 1; } return( $bool ); } # SUB INVALID_DATE # # If someone has tried to add or modify an event, placing it on a day # that does not occur for the given month and year, we do not add # the event. Instead, we send an error message telling them that # the date is invalid. sub invalid_date { my ($last_day,$chosen_day) = @_; print qq!

    Invalid Day for Event

    I'm sorry, but $current_month_name only has $last_day days. You tried to add an event to day number $chosen_day. Please hit your browser's back button, and choose a valid day.
    !; } # SUB HELP_LINK # # This subroutine provides a nicely formatted help link, tying it into the javascript # function we have defined in our header, given a help topic that will be accessed # by the link. # #H E L P sub help_link { my ($help_id) = $_[0]; print qq! !; } # SUB SORT_EVENTS # # This routine is used to sort the events database files when they have been # modified. sub sort_events { my (@database_rows, @sorted_temp_database, $row); # We open the file and read it into an array that we will use # to sort the items with. Then we close the file. open (DATABASE, "$database_file") || &open_error($database_file); while () { push (@database_rows, $_); } close (DATABASE); # We now sort the array, modifying the normal Perl sort routine to # with a custom sort definition found in sub date_sort. @sorted_temp_database = sort date_sort (@database_rows); # We now open up the temp file for the database file we are working # with, and write the sorted database file to it. open (TEMPFILE, ">$temp_file") || &open_error($temp_file); foreach $row (@sorted_temp_database) { print TEMPFILE "$row"; } close (TEMPFILE); # We now remove the original database file, and replace it with the # renamed temp file which contains sorted contents. unlink ("$database_file"); rename ($temp_file, $database_file); } # SUB DATE_SORT # # This subroutine is used to alter the sorting of the events database # files so that we sort by day, then time. sub date_sort { my ($aday, $atime) = (split(/\|/, $a))[0,1]; my ($bday, $btime) = (split(/\|/, $b))[0,1]; $aday <=> $bday || $atime cmp $btime; } # SUB TRIM_EVENTS # # This subroutine will only be called once when the calendar is called for # the very first time, if so configured. It will delete all events that # are older than a set number of months. sub trim_events { my ($i, $te_month, $te_year, @event_files, $x, $y); my ($id); # We set the te month and year to the current (localtime) month and year, # and then subtract out the number of old months we want to keep, and format # the whole into one number. This provides us with a number that will be used # to see if a .events file is to be deleted. $te_month = $ltmon; $te_year = $ltyear; $te_month -= $fcs::old_events; if ($te_month < 1) { $te_month += 12; $te_year--; } $y = "$te_year".sprintf("%.2d", $te_month); # We now open up the directory that holds our .events files, and # read through it, extracting all of the .events files and putting # them into an array. opendir (DIR, $calendar_type); @event_files = grep { /\.events$/i } readdir (DIR); closedir (DIR); # We now go through the array, extracting the year/month value of the # file. We then compare that value to our cut off year/month. If the # files number is less than our cutoff number, we open the file, read # through it line by line, extracting all of the id numbers for any events # in the month. We then delete each of these event files, close the # database file, and then delete the database file. Note that we have # to untaint the id numbers before we can use them to delete. &GetFileLock ("$lock_file"); foreach $i (@event_files) { $i =~ /(\d{6}\.events)$/io; $x = $1; if ($x < $y) { open (DATAFILE, "$calendar_type/$x") || &open_error("$x"); while () { chomp $_; $id = (split(/\|/,$_))[-1]; $id =~ /^(\d+)(_\d)?(\d*)$/o; $id = "$1$2$3"; if (-e "$fcs::path_to_events/$id") { unlink("$fcs::path_to_events/$id"); } } close (DATAFILE); unlink("$calendar_type/$x"); } } &ReleaseFileLock ("$lock_file"); } # SUB GETFILELOCK # # This subroutine gets a lock file so that a file can only be modified # by one user at a time. This is to prevent data mixing. If you want # to use flock, uncomment that line. We only wait for 60 seconds if # there is a lock file already in place, at which point we take over, # assuming the old lock file is from a previous hang. sub GetFileLock { my ($lock_file) = $_[0]; my ($endtime) = 60; $endtime = time + $endtime; while (-e $lock_file && time < $endtime) { sleep( 2 ); } open(LOCK_FILE, ">$lock_file"); # flock(LOCK_FILE, 2); } # SUB RELEASEFILELOCK # # This subroutine removes the passed lock file to free up a file # for further editing. If you want to use flock, uncomment that line. sub ReleaseFileLock { my ($lock_file) = $_[0]; # flock(LOCK_FILE, 8); close(LOCK_FILE); unlink($lock_file); } # SUB COUNTER # # This subroutine provides us with a unique id nubmer for # every event that is added to the calendar database. sub counter { my($item_number, $temp_item_number); # We get a file lock on the counter file, so we don't mess the numbering # up, then we open the file and get the current number out of it. &GetFileLock("$fcs::counter_lock"); open (COUNTER_FILE, "$fcs::counter_file") || &open_error($fcs::counter_file); while () { $item_number = "$_"; } close (COUNTER_FILE); # We remove the new line character, then hold the number in a temporary # id number. We increment the original number by one, then open up # the counter file, clobbering what was there before, and print the # new item number to it with a new line, close the file, and remove # the lock file. We then return the original number. chomp ($item_number); $temp_item_number = $item_number; $item_number += 1; open (NOTE, ">$fcs::counter_file") || &open_error($fcs::counter_file); print NOTE "$item_number\n"; close (NOTE); &ReleaseFileLock("$fcs::counter_lock"); return ($temp_item_number); } # SUB OPEN_ERROR # # If we have called this subroutine, it means that we have tried # to open some file in the script, and failed. We thus don't want # to proceed, but we do want to provide the user with information # on why we are not proceeding. sub open_error { my ($filename) = $_[0]; &header( "Not found" ); print qq!
    I am sorry, but for some reason I was unable to open $filename. Would you please make sure that the filename is correctly defined in the setup file, actually exists, and has the right permissions relative to the web browser. Thanks\!
    !; &footer; die; } # SUB PARSE_DATA # # This subroutine was created by reviewing the parsing routines in cgi-lib.pl # and CGI.pm, to provide a routine that would parse the form data passed to # the script without using an external module and that was also compatible with # mod_perl. sub parse_data { my( %data, @data, $data, $method, $len, $recvd, $max_data, $use_cli, $x ); my( $key, $val ); $use_cli = 0; $max_data = 52768; $method = $ENV{'REQUEST_METHOD'}; $len = $ENV{'CONTENT_LENGTH'}; # if( $len > $max_data ) { # &header( "Max Data Exceeded" ); # print qq! #
    I am sorry, but you have submitted more data via the #form than is allowed for this script. Please hit your back button, and #reduce the amount of data you are attempting to post.
    !; # &footer(); # die "$0: Too much data ($len bytes) posted by $ENV{'REMOTE_ADDR'}. $!\n"; # } if( (! defined($method)) || ($method eq '') ) { $data = $ENV{'QUERY_STRING'}; $use_cli = 1; } elsif( $method eq 'GET' || $method eq 'HEAD' ) { $data = $ENV{'QUERY_STRING'}; } elsif( $method eq 'POST' ) { $recvd = read( STDIN, $data, $len ); if( $recvd != $len ) { &header( "Incomplete Read" ); print qq!
    I am sorry, but there was an incomplete read of the data you attempted to post to this script. Please hit your back button, and try again, being sure to select a button to submit your data.
    !; &footer(); die "$0: Incomplete read from $ENV{'REMOTE_ADDR'}. $!\n"; } } else { &header( "Unsupported Method" ); print qq!
    I am sorry, but you attempted to access this script using an unsupported method ($method).
    !; &footer(); die "$0: Unsupported method ($method) from $ENV{'REMOTE_ADDR'}. $!\n"; } @data = split( '&', $data ); push( @data, @ARGV ) if( $use_cli ); foreach $x ( @data ) { ( $key, $val ) = split( '=', $x, 2 ); $key =~ tr/+/ /; $key =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack( "c", hex($1) )/ego; $val =~ tr/+/ /; $val =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack( "c", hex($1) )/ego; if(! defined($data{$key}) ) { $data{$key} = $val; } else { $data{$key} .= "\0"; $data{$key} .= $val; } } return( %data ); } # Begin Dave mods for spam # SUB SPAM_WEEK_SUB # # If we have called this subroutine, it means we want to see all of the # events for the selected month or week. sub spam_week_sub { my ($day,$username,$time,$temp_cat,$id,$item_found,$cat_tag,$dayname); my (@events,$event,$end,$start,$word,$help,$title); my ($last_day) = ''; # We start by initializing some of our variables that will tell us whether # we want to view a month or a specified week. Depending on that information, # we initialize $word and $help. $start = $form_data{'start'}; $end = $form_data{'end'}; if( $start && $end ) { $help = 13; $word = "Week"; $title = "Week of $current_month_name $start - $end, $currentyear"; } else { $start = 0; $end = 32; $help = 8; $word = "Month"; $title = "Month of $current_month_name, $currentyear"; } # We print out the header for the page, and we go ahead and # close the form tag immediately, since we don't have any interaction on # the page that is generated. We then check to see if the database file # for the selected month/week exists, and if it does, we open it. ######### mailform getter # unless( $error ) { # if ($form_data{'notify'} eq "on") { # @notify_users = split ("\0", $form_data{'mail_choices'}); # $notified = join (",", @notify_users); # } # &header ("$current_month_name, $currentyear"); print qq!
    subject:

    !; # # open (AUTHFILE, "$auths::auth_user_file") || &open_error($auths::auth_user_file); # while () { # chomp $_; # ($group, $name, $email, $city, $spam) = (split (/\|/,$_))[2,3,4,7,8]; # if (($city eq $form_data{'calendar'}) && ($spam eq "yes") && ($email ne "N\/A" && $email ne "n\/a")) { # print "$email\n"; # } #close group if # } # close (AUTHFILE); print qq!

    !; # &footer; for( $i = 0; $i <= $#dates; $i++ ) { $date = $dates[ $i ]; $date =~ /^(\d{4})(\d{2})(\d{2})/o; $date = "$2/$3/$1"; $dates[ $i ] = $date; } $date = join( ", ", @dates ); ¬ification ($date,$time,$time_zone,$dur_hrs,$dur_mins, $to_notify,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$linkurl, $linktitle,"1"); } # SUB PRINT_EVENT_SHORT # # This subroutine prints out the shortened information for an event in the specified # format. sub print_event_short { my ($event) = $_[0]; my ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified); my ($linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$end_time); my ($mmn,$mh,$md,$mm,$myr,$mtime,$mtstr,$mycats,$ampm,$recur_tag,$day,$address); # We first gather all of the information on the event that was passed to us, # and then format the time_zone variable and the end_time variable for display. ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified, $linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$day) = &get_event_info("$event"); $time_zone = (($fcs::use_time_zones && $time_zone) ? " \( $time_zone \)" : ''); $end_time = &get_end_time($time,$dur_hrs,$dur_mins); $address = $location; $subject =~ s/’/'/go; $subject =~ s/‘/'/go; $subject =~ s/“/"/go; $subject =~ s/”/"/go; $location =~ s/<(.|\n)*?>//go; $location =~ s/ \(map\)//; $location =~ s/ / /go; $address =~ s/&state=CA&mag=9">(.|\n)*?> \(map\)//go; $address =~ s///go; $address =~ s/ \(map\)//go; $address =~ s/&city\=/, /go; $address =~ s/&csz\=/, /go; $address =~ s/\+/ /go; $address =~ s/ ,/,/go; $address =~ s/ / /go; $address =~ s/%2C(.|\n)*?> \(map\)//go; $address =~ s/, San Francisco//go; $body =~ s/<(.|\n)*?>//go; $body =~ s/ / /go; $body =~ s/ / /go; $body =~ s/’/'/go; $body =~ s/‘/'/go; $body =~ s/“/"/go; $body =~ s/”/"/go; $body =~ s/(.{0,70}).*$/$1/g; print qq!Event: $subject\nTime: $fcs::TIME{$time} - $fcs::TIME{$end_time}$time_zone Location: $location ($address) !; if ($cost) { print qq!Cost: $cost !; } else { print qq!Cost: Ask at door. !; } print qq!Details: $body... Listing: http://thoughtpolice.com/bayboyz/calendar.cgi?p_o=1&action=w&i=$event&d=!; } # End SUB PRINT_EVENT_SHORT # # SUB VIEW_SEARCH_2 # sub view_search_2 { my ($day,$id,$dayname); # The extra info passed by this type of link is the actual id number of the event # that we want to look at, as we will only be looking at one at a time. We need # to untaint this value in order to open it. We also get the day of the event # from the link. $form_data{'id'} =~ /^(\d+)(_\d)?(\d*)$/o; $id = "$1$2$3"; $day = $form_data{'day'}; $dayname = &day_of_week($currentyear, $currentmonth, $day); # We now print out the standard HTML header, and close out the form since there # is not interaction options for this subroutine's output, especially since it # will be opened in its own "mini-window". &header ("$dayname, $current_month_name $day, $currentyear"); print ""; # Now we just print out the information for the event as we have in the previous # event displaying subroutines. Nothing new here. We of course close with the # standard footer. print qq! $dayname, $current_month_name $day, $currentyear
      !; &print_event("$id"); print ("
    "); print qq! For all of the day’s events,
    click here. !; &footer; } sub mail_friend { my ($day,$id,$dayname,$email); # The extra info passed by this type of link is the actual id number of the event # that we want to look at, as we will only be looking at one at a time. We need # to untaint this value in order to open it. We also get the day of the event # from the link. $form_data{'id'} =~ /^(\d+)(_\d)?(\d*)$/o; $id = "$1$2$3"; $day2 = $form_data{'day2'}; $month = $form_data{'month'}; $dayname = &day_of_week($currentyear, $month, $day2); $email = $form_data{'email'}; # We now print out the standard HTML header, and close out the form since there # is not interaction options for this subroutine's output, especially since it # will be opened in its own "mini-window". &header ("$dayname, $current_month_name $day, $currentyear"); print qq!
    !; # Now we just print out the information for the event as we have in the previous # event displaying subroutines. Nothing new here. We of course close with the # standard footer. print qq!
    E-Mail Event To A Friend (Addresses won’t be recorded or used for promotional purposes nor disclosed to a third party.)

    !; # # print qq!
    To:  (Separate multiple recipients with commas.)
    From:  (You must include your e-mail address...)
    Your Name:  (Not required, but helpful.) #
    Message: 

    !; &footer; } # SUB PRINT_EVENT_MAIL # sub print_event_mail { my ($event) = $_[0]; my ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified); my ($linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$end_time); my ($mmn,$mh,$md,$mm,$myr,$mtime,$mtstr,$mycats,$ampm,$recur_tag,$day,$address); $dayname2 = &day_of_week($form_data{'year'}, $form_data{'month'}, $form_data{'day'}); ($time,$time_zone,$dur_hrs,$dur_mins,$name,$email,$notified, $linkurl,$linktitle,$location,$subject,$body,$cost,$phone,$cat2,$end_date,$day,$address) = &get_event_info("$event"); $time_zone = (($fcs::use_time_zones && $time_zone) ? " \( $time_zone \)" : ''); $end_time = &get_end_time($time,$dur_hrs,$dur_mins); $address = $location; $subject =~ s/’/'/go; $subject =~ s/‘/'/go; $subject =~ s/“/"/go; $subject =~ s/”/"/go; $location =~ s/<(.|\n)*?>//go; $location =~ s/\(map\)//; $location =~ s/ / /; $address =~ s/&state=CA&mag=9">(.|\n)*?>//go; $address =~ s///go; $address =~ s/ \(map\)//go; $address =~ s/<\/a>//go; $address =~ s/&city\=/, /go; $address =~ s/&csz\=/, /go; $address =~ s/\+/ /go; $address =~ s/ / /go; $address =~ s/ ,/,/go; $address =~ s/%2C(.|\n)*?> \(map\)//go; $body =~ s/
    /\n/go; $body =~ s/

    /\n /go; $body =~ s/

  • /\n \*/go; $body =~ s/<(.|\n)*?>//go; $body =~ s/ / /go; $body =~ s/ / /g; $body =~ s/’/'/go; $body =~ s/‘/'/go; $body =~ s/“/"/go; $body =~ s/”/"/go; print qq!Hey - I thought you might like this event I found on the Thought Police calendar. EVENT: $subject DATE: $dayname2, $current_month_name $form_data{'day'}, $form_data{'year'} TIME: $fcs::TIME{$time} - $fcs::TIME{$end_time}$time_zone LOCATION: $location ($address)\n!; if ($cost) { print qq!COST: $cost\n!; } else { print qq!COST: Ask at door.\n!; } if ($phone) { print qq!PHONE NO: $phone\n!; } if ($linkurl) { print qq!EVENT URL: $linkurl\n!; } print qq!DETAILS: $body\n!; } # sub lists_users { &header ("$current_month_name, $currentyear"); open (AUTHFILE, "$auths::auth_user_file") || &open_error($auths::auth_user_file); while () { chomp $_; ($group, $name, $email, $city, $spam) = (split (/\|/,$_))[2,3,4,7,8]; if (($city eq $form_data{'calendar'}) && ($spam eq "yes") && ($email ne "N\/A" && $email ne "n\/a")) { print "$email
    "; } #close group if } close (AUTHFILE); } sub short2 { $day = $form_data{'d'}; $month = $form_data{'m'}; $event = $form_data{'i'}; print "Content-type: text/html\n\n"; print qq! BayBoyz Calendar !; }