####################################################### # Newcalendar for SP1 mod by Ironwing and GauGau. # # Based on Event Calendar by Nermware # # Support: boardmod.yabbforums.com # # Version 3.6special # ####################################################### $Newcalendarplver = 'NewcalendarSP1 3.6 special'; # CalMain is the main calendar routine, called by YaBB.pl sub CalMain { $rev = "1.3.1"; # This is the Nermware calendar ver num, must not change require "$vardir/newcalsettings.txt"; # This is the settings file @sbjlist = split(" ",$sbjlist); # Build event type list from settings file $yytitle = $ecaltxt{'109'}; # Set window title $dbfile = "$vardir/newcaldb.txt"; # This is the database file $origcom = qq~$ecaltxt{'58'}eventcalendar.pl v$rev$ecaltxt{'59'}~; # Nermware credit must remain $adaptcom = 'Ironwing'; # Credit text use Time::Local; # Loads perl time::local module use CGI; # Loads full perl CGI module. YaBB only loads subset so full module needs to be loaded here. $webpage_obj = new CGI; # Creates new web object for oo perl calls $acttype = GetActType(); # Find out what the user wants to do @seldate = GetSelDate(); # Get the user specified date or the current date if ($acttype ne 'disyear') { $yeardbflag = 'dummy'; # Sets database read parameters for all reads but year view GetDbData(); # Read the database except for Year View Cal } if($acttype =~ /display/) { if ($addbdays1 == 1) { CalBDay2(); # Birthday routine for month view } DisCalendar(); # Create the Month View Calendar DisCalForm(); # Create select month form at bottom of Month View } if($acttype =~ /disyear/) { YearCal(); # Create the Year View Calendar DisYearForm(); # Create select year form at bottom of Year View } EnterData() if($acttype =~ /enterdata/); # Create the Edit Events Page ViewData() if($acttype =~ /viewdata/); # Create the View Events Page NewCalSearch() if($acttype =~ /search/); # Create the Calendar Search Page NewCalSearch2() if($acttype =~ /calsrch2/); # Create the Calendar Search Page if(($acttype =~ /newdata/) || ($acttype =~ /deldata/)) { NewData(); # Write to the Calendar DataBase $acttype = display; # Set action to month view after write $yeardbflag = 'dummy'; GetDbData(); if ($addbdays1 == 1) { CalBDay2(); } DisCalendar(); DisCalForm(); } SendTrailer(); # Adds trailer to all calendar pages &template; # Sends the results back into YaBB exit; } # GetActType determines type of action selected by user as passed by YaBB.pl # This routine prevents abuse of INFO array by effectively filtering all INFO data. # Called by CalMain, IndexCal, WhosCal, IncludeCal sub GetActType { my($type) = "display"; # Sets default action to show month view $type = $webpage_obj->param('acttype') if(defined($webpage_obj->param('acttype'))); $type = newdata if(defined($webpage_obj->param('newdata'))); $type = deldata if(defined($webpage_obj->param('deldata'))); return('display') if ($type =~ /display/); return('enterdata') if ($type =~ /enterdata/); return('viewdata') if($type =~/viewdata/); return('newdata') if($type =~/newdata/); return('deldata') if($type =~/deldata/); return('search') if($type =~/search/); return('calsrch2') if($type =~/calsrch2/); return('disyear') if($type =~/disyear/); return('badtype'); } # GetSelDate determines current time/date or selected time/date to display. # Current time is based on YaBB user time settings. Current time is used unless # overridden by selected time. # Called by CalMain, IndexCal, WhosCal, IncludeCal, and Newcalsearch2 sub GetSelDate { (my($selmonth),my($selday),my($selyear)) = (localtime(time + (3600*($timeoffset + $settings[18]))))[4,3,5]; $selyear = $selyear+1900; $selmonth = $webpage_obj->param('selmonth') if (defined($webpage_obj->param('selmonth'))); $selday = $webpage_obj->param('selday') if (defined($webpage_obj->param('selday'))); $selyear = $webpage_obj->param('selyear') if (defined($webpage_obj->param('selyear'))); return($selmonth,$selday,$selyear); } # GetDbData gets event data from database and builds recurring event data. # Dates are stored using perl time indexing. Index is number of seconds # since the first of the year 1900. The keys in dayinfo hash are time index numbers. # Events are stored one date to a line with all events for that date on same line. # Called by CalMain, IndexCal, IncludeCal, WhosCal, and Newcalsearch2 sub GetDbData { %dayinfo = ''; # Initialize event hash if( $yeardbflag eq 'yearview' ) { $thismonth = $monthyear; # Set data read parameters for Year View routine $thisyear = $yeardisyear; $nextmonth = $thismonth+1; $nextyear = $thisyear; if($nextmonth > 11) { $nextmonth = 0; $nextyear = $thisyear+1; } } if( $yeardbflag eq 'dummy' ) { $thismonth = $seldate[0]; # Set data read parameters for all other routines $thisyear = $seldate[2]; $nextmonth = $thismonth+2; # Set to two months so Upcoming Events lists can cross over to next calendar month. $nextyear = $thisyear; if($nextmonth = 11) { $nextmonth = 0; $nextyear = $thisyear+1; } if($nextmonth = 12) { $nextmonth = 1; $nextyear = $thisyear+1; } } my($selmonfst) = timegm(0,0,0,1,$thismonth,$thisyear); # Time index of first of this month my($nxtmonfst) = timegm(0,0,0,1,$nextmonth,$nextyear); # Time index of first of next month die("ERROR .. unable to open $dbfile\n") unless fopen(DBFILE,$dbfile); # Read database file while ($strline=) { chomp($strline); @line = split(/\|/,$strline); # Split line into date index and event info. my($index) = shift(@line); # Peel date index off of front of list. $dayinfo{$index} = [ @line ] if($index < $nxtmonfst); # dayinfo hash now has date indices as keys and events as values. } fclose(DBFILE); return if(($acttype =~ /enterdata/) || ($acttype =~ /newdata/) || ($acttype =~ /deldata/) || ($acttype =~ /badtype/) ); # Rest of this routine is for recurring events, not needed by routines listed here. # Start building new pseudo-indices for recurring events. my($daysecs) = 24*60*60; # Seconds in a day my($weeksecs) = 168*60*60; # Seconds in a week my(@dayinfokeys) = keys(%dayinfo); # Build list of dates for which events exist. # Start loop of dates for which events exist foreach $index (@dayinfokeys) { my($element) = ""; my(@entry) = (); foreach $element (@{ $dayinfo{$index} }) { my(@entry) = split('{',$element); # For each date, separate individual events out of string holding all events for that date. my($repeatfor) = $entry[$#entry]; # Find out if event is to repeat (recur). Rest of routine is only run for recurring events. if($repeatfor > 1) { my($newindex) = $index; # Create pseudo-index for event. $addsecs = $daysecs if($entry[$#entry-1] =~ /$ecaltxt{'43'}/); # Set number of seconds to add to pseudo-index for events which repeat daily. $addsecs = $weeksecs if($entry[$#entry-1] =~ /$ecaltxt{'44'}/); # Set number of seconds to add to pseudo-index for events which repeat weekly. if(($entry[$#entry-1] =~ /$ecaltxt{'43'}/) || ($entry[$#entry-1] =~ /$ecaltxt{'44'}/)) { # Loop for number of repeats specified. for($i=2;$i<=$repeatfor;$i++) { $newindex = $newindex + $addsecs; # Add seconds to pseudo-index for events recurring daily or weekly. $entry[$#entry] = 0; # Set repeats to zero for newly created psuedo-event, prevents run away repeating of psuedo-events. ${$dayinfo{$newindex}}[++$#{$dayinfo{$newindex}}] = join('{',@entry) if(($newindex < $nxtmonfst) && ($newindex >= $selmonfst)); # Create new dayinfo hash element for pseudo-event. } next; } # End loop for daily and weekly type recurring events my($addyears) = my($addmonths) = 0; $addyears = 1 if($entry[$#entry-1] =~ /$ecaltxt{'46'}/); # Set number of years to add to events which recur annually. $addmonths = 1 if($entry[$#entry-1] =~ /$ecaltxt{'45'}/); # Set number of months to add to events which recur monthly. my(@thisdate) = gmtime($index); # Get date array for original event index $addmonths = 1 if($entry[$#entry-1] =~ /$ecaltxt{'46a'}/); # Set number of months to add to events which recur on 3rd Tuesday basis. $addyears = 1 if($entry[$#entry-1] =~ /$ecaltxt{'42'}/); # Set number of years to add to events which recur on 2nd Sunday in May basis. my ($dayofweek) = $thisdate[6]; # Get day of week for original event date. my ($weekofmonth) = int( ($thisdate[3] - 1) / 7 ); # Calculate week of month for original event date. splice(@thisdate,-1,3); # Loop for number of repeats specified. for($i=2;$i<=$entry[$#entry];$i++) { $thisdate[4] = $thisdate[4] + $addmonths; # Add months to pseudo-index. $thisdate[5] = $thisdate[5] + $addyears; # Add years to pseudo-index. if($thisdate[4] > 11) { $thisdate[4]=0; # Roll over year if needed $thisdate[5]++; # Roll over year if needed } # Find day of week of first day of new month $tstring = timegm(0,0,0,1,$thisdate[4],$thisdate[5]); # Get time index of first day of month for pseudo-date my (@newmonth1st) = gmtime($tstring); # Get date array of first day of month for pseudo-date my ($wdaynewmonth1st) = $newmonth1st[6]; # Get weekday of first day of month of pseudo-date if ( ( $entry[$#entry-1] =~ /$ecaltxt{'46a'}/ ) || ( $entry[$#entry-1] =~ /$ecaltxt{'42'}/ ) ) { if ( $wdaynewmonth1st <= $dayofweek ) { $thisdate[3] = ( $weekofmonth * 7 ) + 1 + $dayofweek - $wdaynewmonth1st; # Calculate day-of-month for pseudo-date when first of month is earlier in week then pseudo-date } else { $thisdate[3] = ( $weekofmonth * 7 ) + 8 + $dayofweek - $wdaynewmonth1st; # Calculate day-of-month for pseudo-date when first of month is later in week then pseudo-date } } $newindex = timegm(@thisdate); # Get date index for pseudo-date if ( ( $entry[$#entry-1] =~ /$ecaltxt{'46a'}/ ) || ( $entry[$#entry-1] =~ /$ecaltxt{'42'}/ ) ) { $testindexflag = 1; my (@testindex) = gmtime($newindex); # Test if new date is in same month if ( $testindex[4] != $thisdate[4] ) { $testindexflag = 0; } ${$dayinfo{$newindex}}[++$#{$dayinfo{$newindex}}] = $element if( ($newindex < $nxtmonfst) && ($newindex >= $selmonfst) && ($testindexflag == 1) ); # Add new pseudo-event to dayinfo hash if in same month for events recurring 3rdTuesday and 2ndSunMay } else { ${$dayinfo{$newindex}}[++$#{$dayinfo{$newindex}}] = $element if( ($newindex < $nxtmonfst) && ($newindex >= $selmonfst) ); # Add new pseudo-event to dayinfo hash if in same month for annual and monthly events } } # End loop for annual, monthly, 3ndTues, and 2ndSunMay type recurring events } # End loop for all recurring events } # End loop for events for date } # End loop through dayinfo hash } #DisCalendar generates month view calendar page, called by CalMain sub sub DisCalendar { require "$sourcedir/MoonPhase.pl"; #This is the moon phase calculator my($thismonth) = $seldate[0]; my($thisyear) = $seldate[2]; $monthname = ($ecaltxt{'01'},$ecaltxt{'02'},$ecaltxt{'03'},$ecaltxt{'04'},$ecaltxt{'05'},$ecaltxt{'06'},$ecaltxt{'07'},$ecaltxt{'08'},$ecaltxt{'09'},$ecaltxt{'10'},$ecaltxt{'11'},$ecaltxt{'12'})[$thismonth]; my($thisdaysecs) = timegm(0,0,0,1,$thismonth,$thisyear); my($thisdayweek) = (gmtime($thisdaysecs))[6]; if ($mondayfirst == 1) { if ($thisdayweek == 0) { $thisdayweek = 6; } else { $thisdayweek = $thisdayweek - 1; } } my($daysecs) = 24*60*60; my(@today) = localtime(time + (3600*($timeoffset + $settings[18]))); my($todaysecs) = timegm(0,0,0,$today[3],$today[4],$today[5]); my($nextmonth) = $thismonth+1; my($nextyear) = $thisyear; if($nextmonth > 11) { $nextmonth = 0; $nextyear = $thisyear+1; } my($prevmonth) = $thismonth-1; my($prevyear) = $thisyear; if($prevmonth < 0) { $prevmonth = 11; $prevyear = $thisyear-1; } chomp $newcaladmingroup; @newcaladmingrouplist = split(",",$newcaladmingroup); # List of Calendar Moderators $newcaladmingroupflag = 0; foreach $newcaladmingroupitem (@newcaladmingrouplist) { if ($settings[7] eq $newcaladmingroupitem) { $newcaladmingroupflag = 1; } } $yymain .= qq~
~; if ($mondayfirst == 1) { $yymain .= qq~ ~; } else { $yymain .= qq~ ~; } $yymain .= qq~~ if($thisdayweek > 0); my($thisdaymonth) = 1; for($thisdaysecs;$thisdaysecs <= $thisdaysecs+$daysecs*31;$thisdaysecs=$thisdaysecs+$daysecs) { $thismoonsecs = $thisdaysecs + $daysecs; last if ((gmtime($thisdaysecs))[4] != $thismonth); $data=""; ($thisdaymonth,$thisdayweek) = (gmtime($thisdaysecs))[3,6]; if ($mondayfirst == 1) { if ($thisdayweek == 0) { $thisdayweek = 6; } else { $thisdayweek = $thisdayweek - 1; } } if (defined($dayinfo{$thisdaysecs})) { $data = ""; foreach $info (@{ $dayinfo{$thisdaysecs} }) { @daydata = split(/\{/,$info); next if($daydata[1] =~ /DELETED/); $message = $daydata[0]; # put the message back into the proper variable to do ubbc on it &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $daydata[0] = $message; $data = $data . qq~
  • $daydata[0]
  • ~; } $data = $data . "

    "; &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $data =~ s~\Q$tmpa\E~$tmpb~gi; } } # Add bday code if ($addbdays1 == 1) { while (($bdaykey, $bdayindex) = each %bdayshash) { if ($bdayindex == $thisdaysecs) { $data .= qq~
  • $ecaltxt{'57'}$bdaykey

  • ~; } } } # End bday code # Add moon phase info if ($newcalmoon == 1) { ( $MoonPhase, $MoonIllum, $MoonAge, $MoonDist, $MoonAng, $SunDist, $SunAng ) = phase($thismoonsecs); if ( ($MoonPhase >= 0.48305) && ( $MoonPhase <= 0.51695) ){ $data = $data . '
    ' . qq~ $ecaltxt{'78'}~; } if ( ($MoonPhase <= 0.01695) || ( $MoonPhase >= 0.98305) ){ $data = $data . '
    ' . qq~ $ecaltxt{'77'}~; } } # end moon phase info if($thisdayweek == 0) { $yymain .= qq~~; } else { $yymain .= qq~$thisdaymonth$data~; } } else { if($todaysecs == $thisdaysecs) { $yymain .= qq~$thisdaymonth$data~; } else { $yymain .= qq~$thisdaymonth$data~; } } } else { if($todaysecs == $thisdaysecs) { $yymain .= qq~$thisdaymonth$data~; } else { $yymain .= qq~$thisdaymonth$data~; } } } $yymain .= qq~
    $ecaltxt{'109'}
    $monthname         $thisyear
    $ecaltxt{'14'}
    $ecaltxt{'15'}
    $ecaltxt{'16'}
    $ecaltxt{'17'}
    $ecaltxt{'18'}
    $ecaltxt{'19'}
    $ecaltxt{'13'}
    $ecaltxt{'13'}
    $ecaltxt{'14'}
    $ecaltxt{'15'}
    $ecaltxt{'16'}
    $ecaltxt{'17'}
    $ecaltxt{'18'}
    $ecaltxt{'19'}
    ~; } else { $yymain .= qq~ ~; } if( $username ne "Guest" || $newcalguest == 1 ){ if ($newcaladmin != 1 || $newcaladmingroupflag == 1 || $settings[7] eq 'Administrator' ) { if($todaysecs == $thisdaysecs) { $yymain .= qq~$thisdaymonth$data

    ~; $yymain .= qq~$ecaltxt{'24'}
    $ecaltxt{'25'}
    ~; } # DisCalForm displays select month-year form at bottom of month view page, called by CalMain sub DisCalForm { $yymain .= qq~
    $ecaltxt{'26'}
    $ecaltxt{'27'}
    $ecaltxt{'28'}
    ~; } # CalBDay2 adds birthdays to Month Calendar, called by CalMain sub CalBDay2 { %bdayshash; #keys are userprofstrings, values are birthdays in timegm format my $thisyear = $seldate[2]; $userprofstring = ""; open(FILE, "$memberdir/memberlist.txt") || die "cannot open list file"; @members = ; close(FILE); foreach $usernames (@members) { chomp $usernames; if ( -e "$memberdir/$usernames.dat") { fopen(FILE, "$memberdir/$usernames.dat") || die "cannot open user file"; @userbd = ; fclose(FILE); chomp $userbd[16]; if ($userbd[16] ne "") { ($usermonth, $userday, $useryear) = split(/\//, $userbd[16]); if ($usermonth > 0 && $usermonth < 13) { if ($userday > 0 && $userday < 32) { $usermonth = $usermonth - 1; $bdayindex = timegm(0,0,0,$userday,$usermonth,$thisyear); ### Add Ages $newcalagestring = ''; if( $newcalshowage1 == 1 ) { $newcalage = $thisyear - $useryear; $newcalagestring = qq~($newcalage)~; } ###End Add Ages $userprofstring = qq~$userbd[1] $newcalagestring~; $bdayshash{$userprofstring} = $bdayindex; } } } }# end file exists }#end foreach } # EnterData generates Edit Events page, called by CalMain sub EnterData { my($daynum) = timegm(0,0,0,$seldate[1],$seldate[0],$seldate[2]); if (defined($dayinfo{$daynum})) { my($entrynum) = 0; foreach $entry (@{ $dayinfo{$daynum} }) { my(@daydata) = split(/\{/,$entry); $dayvars[$entrynum] = [ @daydata ]; $entrynum++; } } ($thisdaymonth,$thismonth,$thisyear,$thisdayweek) = (gmtime($daynum))[3,4,5,6]; $thisweekdayname = ($ecaltxt{'13'},$ecaltxt{'14'},$ecaltxt{'15'},$ecaltxt{'16'},$ecaltxt{'17'},$ecaltxt{'18'},$ecaltxt{'19'})[$thisdayweek]; $monthname = ($ecaltxt{'01'},$ecaltxt{'02'},$ecaltxt{'03'},$ecaltxt{'04'},$ecaltxt{'05'},$ecaltxt{'06'},$ecaltxt{'07'},$ecaltxt{'08'},$ecaltxt{'09'},$ecaltxt{'10'},$ecaltxt{'11'},$ecaltxt{'12'})[$thismonth]; $thisyear += 1900; if ($newcaldate == 1) { $newcaldatestring = qq~$thisweekdayname $thisdaymonth. $monthname $thisyear~; } else { $newcaldatestring = qq~$thisweekdayname, $monthname $thisdaymonth, $thisyear~; } my($entrynumstr)=1; my($title) = ""; my($subject) = "$sbjdefault"; my($repeatnum) = 1; my($repeatby) = "Daily"; my($comment) = ""; my($eventusername) = 'Invalid user name placeholder'; #Sets variable to string no legitimate user name could possibly be. chomp $newcaladmingroup; @newcaladmingrouplist = split(",",$newcaladmingroup); $newcaladmingroupflag = 0; foreach $newcaladmingroupitem (@newcaladmingrouplist) { if ($settings[7] eq $newcaladmingroupitem) { $newcaladmingroupflag = 1; } } $yymain .= qq~
    $ecaltxt{'108'}$newcaldatestring

    ~; $newcalmax2 = $newcalmax - 1; for ($entrynum=0;$entrynum<=$newcalmax2;$entrynum++) { if (${$dayvars[$entrynum]}[1] !~ /DELETED/) { $title = ${$dayvars[$entrynum]}[0] if (defined(${$dayvars[$entrynum]}[0])); $subject = ${$dayvars[$entrynum]}[1] if (defined(${$dayvars[$entrynum]}[1])); $comment = ${$dayvars[$entrynum]}[2] if (defined(${$dayvars[$entrynum]}[2])); $comment =~ s~
    ~\n~g; $eventusername = ${$dayvars[$entrynum]}[3] if (defined(${$dayvars[$entrynum]}[3])); $repeatby = ${$dayvars[$entrynum]}[4] if (defined(${$dayvars[$entrynum]}[4])); $repeatnum = ${$dayvars[$entrynum]}[5] if (defined(${$dayvars[$entrynum]}[5])); } if($username eq $eventusername || $settings[7] eq 'Administrator' || $newcaladmingroupflag == 1 || $eventusername eq 'Invalid user name placeholder') { if($eventusername eq 'Invalid user name placeholder') {$eventusername = $username}; #Sets new events to current username ##### Get Display name # Load the current nickname of the account name of the event poster. if( $eventusername ne 'Guest' && -e "$memberdir/$eventusername.dat" ) { &LoadUser($eventusername); $mname2 = $userprofile{$eventusername}->[1] || $mname2 || $txt{'28'}; } else { $mname2 ||= $txt{'28'}; } ##### Get Display name end $yymain .= qq~
    $ecaltxt{'41'}$entrynumstr
    $ecaltxt{'31'} $ecaltxt{'37'}
    $ecaltxt{'50'} $ecaltxt{'35'}
    $ecaltxt{'54'} $mname2
    ~; } # This bracket is the end of the username controlled exclusion $entrynumstr++; $title = ""; $subject = "$sbjdefault"; $repeatnum = 1; $repeatby = "Daily"; $comment = ""; $eventusername = 'Invalid user name placeholder'; #reset the variable for the next iteration } $yymain .=qq~ $ecaltxt{'53'}
    $ecaltxt{'31'} $ecaltxt{'32'}
    $ecaltxt{'33'} $ecaltxt{'34'}
    $ecaltxt{'35'} $ecaltxt{'36'}
    $ecaltxt{'37'} $ecaltxt{'38'}
    $ecaltxt{'39'} $ecaltxt{'40'}

    ~; } # ViewData shows Events Details (View Events) page, called by CalMain sub ViewData { my($daynum) = timegm(0,0,0,$seldate[1],$seldate[0],$seldate[2]); if (defined($dayinfo{$daynum})) { my($entrynum) = 0; foreach $entry (@{ $dayinfo{$daynum} }) { my(@daydata) = split(/\{/,$entry); $dayvars[$entrynum] = [ @daydata ]; $entrynum++; } } chomp $newcaladmingroup; @newcaladmingrouplist = split(",",$newcaladmingroup); $newcaladmingroupflag = 0; foreach $newcaladmingroupitem (@newcaladmingrouplist) { if ($settings[7] eq $newcaladmingroupitem) { $newcaladmingroupflag = 1; } } ($thisdaymonth,$thismonth,$thisyear,$thisdayweek) = (gmtime($daynum))[3,4,5,6]; $thisweekdayname = ($ecaltxt{'13'},$ecaltxt{'14'},$ecaltxt{'15'},$ecaltxt{'16'},$ecaltxt{'17'},$ecaltxt{'18'},$ecaltxt{'19'})[$thisdayweek]; $monthname = ($ecaltxt{'01'},$ecaltxt{'02'},$ecaltxt{'03'},$ecaltxt{'04'},$ecaltxt{'05'},$ecaltxt{'06'},$ecaltxt{'07'},$ecaltxt{'08'},$ecaltxt{'09'},$ecaltxt{'10'},$ecaltxt{'11'},$ecaltxt{'12'})[$thismonth]; $thisyear += 1900; if ($newcaldate == 1) { $newcaldatestring = qq~$thisweekdayname $thisdaymonth. $monthname $thisyear~; $newcaldatestring2 = qq~$thisweekdayname $thisdaymonth. $monthname $thisyear~; } else { $newcaldatestring = qq~$thisweekdayname, $monthname $thisdaymonth, $thisyear~; $newcaldatestring2 = qq~$thisweekdayname, $monthname $thisdaymonth, $thisyear~; } my($subject) = ""; my($commentview) = ""; $yymain .= qq~
    $ecaltxt{'49'}$newcaldatestring2

    ~; $newcalmax2 = $newcalmax - 1; for ($entrynum=0;$entrynum<=$newcalmax2;$entrynum++) { next if !(defined(${$dayvars[$entrynum]}[0])); next if(${$dayvars[$entrynum]}[1] =~ /DELETED/); $commentview = ${$dayvars[$entrynum]}[2] if (defined(${$dayvars[$entrynum]}[2])); $eventusername = ${$dayvars[$entrynum]}[3] if (defined(${$dayvars[$entrynum]}[3])); &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $commentview =~ s~\Q$tmpa\E~$tmpb~gi; ${$dayvars[$entrynum]}[0] =~ s~\Q$tmpa\E~$tmpb~gi; } if( $eventusername ne 'Guest' && -e "$memberdir/$eventusername.dat" ) { &LoadUser($eventusername); $mname = $userprofile{$eventusername}->[1] || $mname || $txt{'28'}; $mname2 = $mname; $mname = qq~$mname~; } else { $mname = $txt{'28'}; $mname2 = $mname; } ####### Media Player mod $mediausername = $mname2; ####### Media Player mod end $message = $commentview; # put the message back into the proper variable to do ubbc on it &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $commentview = $message; $eventnamesend = ${dayvars[$entrynum]}[0]; #bypass UBBC for SendEvent $message = ${dayvars[$entrynum]}[0]; # put the message back into the proper variable to do ubbc on it &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; ${dayvars[$entrynum]}[0] = $message; $yymain .= qq~ ~; #### send event form if ($newcalsend == 1) { my($eventday) = $seldate[1]; my($eventmonth) = $seldate[0]; my($eventyear) = $seldate[2]; $yymain .= qq~ ~; } #### end send event form } if( $username ne "Guest" || $newcalguest == 1 ){ if ($newcaladmin != 1 || $newcaladmingroupflag == 1 || $settings[7] eq 'Administrator' ) { $yymain .= qq~ ~; } } $yymain .= qq~

    $ecaltxt{'31'} ${$dayvars[$entrynum]}[0]
    $ecaltxt{'50'} ${$dayvars[$entrynum]}[1]
    $ecaltxt{'35'} $commentview
    $ecaltxt{'54'} $mname

    $ecaltxt{'107'}


    ~; } # NewData writes new enteries to database file, called by CalMain sub # Calls CompactCal sub NewData { my($daynum) = timegm(0,0,0,$seldate[1],$seldate[0],$seldate[2]); my($arrayloc) = $webpage_obj->param('formnum'); my($title) = $webpage_obj->param('title'); my($subject) = $webpage_obj->param('subject'); my($comment) = $webpage_obj->param('comment'); my($eventusername) = $webpage_obj->param('eventusername'); my($repeatby) = $webpage_obj->param('repeatby'); my($repeatnum) = $webpage_obj->param('repeatnum'); $title =~ s/\cM//g; $title =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; $title =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; $title =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g; $title =~ s~www\.~www \.~; $eventusername =~ tr/!-~/ /cs; if (length($comment)>$MaxMessLen) { &fatal_error($txt{'499'}); } &spam_protection; $comment =~ s/\cM//g; $comment =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; $comment =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; $comment =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g; &ToHTML($comment); $comment =~ s~\t~ \  \  \ ~g; $comment =~ s~\n~
    ~g; $repeatnum =~ tr/!-~/ /cs; $title =~ s/[\{\|]//g; $subject =~ s/[\{\|]//g; $comment =~ s/[\{\|]//g; $eventusername =~ s/[\{\|]//g; $repeatby =~ s/[\{\|]//g; $repeatnum =~ s/[\{\|]//g; ##### @sbjlist = split(" ",$sbjlist); my($subjectcheck) = 0; foreach $item (@sbjlist) { chomp $item; if( $subject eq $item ) { $subjectcheck = 1; } } if( $subjectcheck == 0 ) { &fatal_error($ecaltxt{'115'}); } ##### $subject = "DELETED" if($acttype=~/deldata/); my($dbentry) = join( '{',$title,$subject,$comment,$eventusername,$repeatby,$repeatnum); ${$dayinfo{$daynum}}[$arrayloc]="$dbentry"; my($dbrow) = "$daynum"; foreach $one (@{$dayinfo{$daynum}}) { $dbrow = join('|',$dbrow,$one); } die("ERROR .. unable to open $dbfile\n") unless fopen(DBFILE,">>$dbfile"); print(DBFILE "$dbrow\n"); fclose(DBFILE); CompactCal(); } # SendTrailer puts footer at bottom of all calendar pages. # Nermware credit must be shown on all calendar pages. sub SendTrailer { my $helpfile2 = $helpfile; $helpfile2 =~ m/(.+)(\/.+$)/; my $newcalhelpfile = $1 . qq~/NewcalendarHelp.html~; $yymain .= qq~
    $ecaltxt{'89'}~; if ($newcalhelp == 1) { $yymain .= qq~                  $ecaltxt{'96'}~; } $yymain .= qq~
    $ecaltxt{'23'}$mbname

    $origcom
    $Newcalendarplver$ecaltxt{'51'}$adaptcom
    ~; } #CompactCal removes duplicate calendar entries. Called by sub NewData. # Only last record for a date is kept in hash since index is reused. # Since this sub is run each time NewData is called, the database # should never contain duplicate date info. In campactdayinfo # hash: keys are index dates and values are complete date-event strings. sub CompactCal { my %compactdayinfo; die("ERROR .. unable to open $dbfile\n") unless fopen(DBFILE,$dbfile); $dummy=; # read first line which is always empty while ($strline=) { chop($strline); @line = split(/\|/,$strline); my($index) = shift(@line); $compactdayinfo{$index} = $strline; } fclose(DBFILE); # now write events back to dbfile without duplicates. fopen(DBFILE, ">$dbfile"); print DBFILE qq~\n~; while (($dateindex, $dayevents) = each %compactdayinfo) { print DBFILE qq~$dayevents\n~; } fclose(DBFILE); } # IndexCal shows today's events in Info Center on BoardIndex # Split into two subs to allow for addon mods, called by BoardIndex.pl, calls IncludeCal2 sub IndexCal { $moonincludeflag = 0; $yeardbflag = 'dummy'; IncludeCal2(); if ($data ne "") { $yymain .= qq~$data~; } else { $yymain .= qq~$ecaltxt{'73'}~; } } # IncludeCal shows today's events on any HTML page through SSI # Split into two subs to allow for addon mods, called by YaBB.pl, calls IncludeCal2 sub IncludeCal { $moonincludeflag = 1; $yeardbflag = 'dummy'; IncludeCal2(); print qq~Content-type: text/html\n\n~; if ($data ne "") { print qq~$data~; } else { print qq~$ecaltxt{'73'}~; } exit; } # WhosCal shows today's events in the modified Whoson mod (YaBB FrontEnd mod). # Split into two subs to allow for addon mods, called by Whoson SSI mod, calls IncludeCal2. sub WhosCal { $moonincludeflag = 1; $yeardbflag = 'dummy'; IncludeCal2(); print qq~$data~; } # IncludeCal2 shows today's events on BoardIndex, WhosOn, and SSI call on html pages. # Called by IndexCal, IncludeCal, and WhosCal subs sub IncludeCal2 { require "$vardir/newcalsettings.txt"; #This is the settings file @sbjlist = split(" ",$sbjlist); $dbfile = "$vardir/newcaldb.txt"; #This is the database file use Time::Local; #keep? Try without and see use CGI; #Already called in YaBB but may need more functions $webpage_obj = new CGI; #keep or lose? $acttype = GetActType(); @seldate = GetSelDate(); GetDbData(); my($thismonth) = $seldate[0]; my($thisyear) = $seldate[2]; my($newcalspread2) = 24*60*60*($newcalspread-1); my($daysecs) = 24*60*60; my(@today) = localtime(time + (3600*($timeoffset + $settings[18]))); my($todaysecs) = timegm(0,0,0,$today[3],$today[4],$today[5]); my($thisdaysecs) = $todaysecs; my($thisdaymonth) = 1; my ($addbdaytext) = 0; $data = ""; for ($thisdaysecs = $todaysecs; $thisdaysecs <= $todaysecs+$newcalspread2; $thisdaysecs += $daysecs) { $data2 = ""; ($thisdaymonth,$thismonth,$thisdayweek) = (gmtime($thisdaysecs))[3,4,6]; if (defined($dayinfo{$thisdaysecs})) { foreach $item (@sbjlist) { $itemcount=0; foreach $info (@{ $dayinfo{$thisdaysecs} }) { @daydata = split(/\{/,$info); next if($daydata[1] =~ /DELETED/); $message = $daydata[0]; # put the message back into the proper variable to do ubbc on it &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $daydata[0] = $message; $daydata[0] =~ s/(^.+)( $)/$1/; chomp $item; if($daydata[1] eq $item) { if ($itemcount == 0) { $data2 = $data2 . qq~
  • $daydata[1]: $daydata[0]~; $itemcount++; } else { $data2 = $data2 . qq~, $daydata[0]~; $itemcount++; } } } } &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $data =~ s~\Q$tmpa\E~$tmpb~gi; } } #### new b-day stuff if ($addbdays2 == 1) { my($bdaymonth,$bmonth,$byear,$bdayweek) = (gmtime($thisdaysecs))[3,4,5,6]; $bmonth += 1; $byear += 1900; $calwhobg = ""; $countbd = 0; fopen(FILE, "$memberdir/memberlist.txt") || die "cannot open list file"; @members = ; fclose(FILE); foreach $usernames (@members) { chomp $usernames; if ( -e "$memberdir/$usernames.dat") { fopen(FILE, "$memberdir/$usernames.dat") || die "cannot open user file $usernames.dat"; @userbd = ; fclose(FILE); chomp $userbd[1]; chomp $userbd[16]; ($matchm, $matchd, $useryear) = split(/\//, $userbd[16]); if(($bmonth == $matchm) && ($bdaymonth == $matchd)) { ### Add Age $newcalagestring = ''; if( $newcalshowage2 == 1 ) { $newcalage = $byear - $useryear; $newcalagestring = qq~($newcalage)~; } ### End Age if( $countbd == 0 ){ $calwhobg .=qq~$userbd[1] $newcalagestring~; } if( $countbd > 0 ){ $calwhobg .=qq~, $userbd[1] $newcalagestring~; } $countbd++; } } } chomp $calwhobg; if ($calwhobg ne "") { $calwhobg = qq~
  • $ecaltxt{'56'}$calwhobg
  • ~; } } ### end new b-day stuff if ( $calwhobg ne "" || $data2 ne "" ) { if ( $todaysecs == $thisdaysecs) { $data .= qq~$txt{'769'}:~ . $data2 . $calwhobg; } else { $thisweekdayname = ($ecaltxt{'13'},$ecaltxt{'14'},$ecaltxt{'15'},$ecaltxt{'16'},$ecaltxt{'17'},$ecaltxt{'18'},$ecaltxt{'19'})[$thisdayweek]; $monthname = ($ecaltxt{'01'},$ecaltxt{'02'},$ecaltxt{'03'},$ecaltxt{'04'},$ecaltxt{'05'},$ecaltxt{'06'},$ecaltxt{'07'},$ecaltxt{'08'},$ecaltxt{'09'},$ecaltxt{'10'},$ecaltxt{'11'},$ecaltxt{'12'})[$thismonth]; if ($newcaldate == 1) { $data .= qq~
    $thisweekdayname $thisdaymonth. $monthname:~ . $data2 . $calwhobg; } else { $data .= qq~
    $thisweekdayname, $monthname $thisdaymonth:~ . $data2 . $calwhobg; } } } } # end of loop for each date # Add moon phase info if ( ( $newcalmoon2 == 1 ) && ( $moonincludeflag == 1 ) ) { require "$sourcedir/MoonPhase.pl"; #This is the moon phase calculator ( $MoonPhase, $MoonIllum, $MoonAge, $MoonDist, $MoonAng, $SunDist, $SunAng ) = phase(); my ($newphaselow) = 0.016666667; my ($newphasehigh) = 0.983333333; my ($phaseincrement) = 0.033333333; if ( ($MoonPhase < $newphaselow) || ($MoonPhase > $newphasehigh) ){ $data = $data . '
    ' . qq~~; } else { $gifnumber = 1; for ($phasescan = $newphaselow; $phasescan < $newphasehigh; $phasescan += $phaseincrement) { if ( ($MoonPhase > $phasescan) && ( $MoonPhase <= ($phasescan + $phaseincrement)) ){ if ($gifnumber < 10) { $data = $data . '
    ' . qq~~; } else { $data = $data . '
    ' . qq~~; } } $gifnumber++; } } } # end moon phase info } # NewCalSearch creates the calendar search page. # Called by CalMain. sub NewCalSearch { $yytitle = "$ecaltxt{'89'}"; $yymain .= qq~
    $txt{'183'}
    $txt{'582'}:  
    $txt{'573'}:
    $ecaltxt{'90'} $ecaltxt{'91'}



    ~; } # NewCalSearch2 is a stripped down version of the YaBB search engine. # Called by CalMain. sub NewCalSearch2 { my($eventsfound) = 0; my $searchtype = $FORM{'searchtype'}; my $search = $FORM{'search'}; if( $searchtype eq 'anywords' ) { $searchtype = 2; } elsif( $searchtype eq 'asphrase' ) { $searchtype = 3; } else { $searchtype = 1; } if ($search eq ""){ &fatal_error($txt{'754'}); } if ($search =~ m~/~){ &fatal_error($txt{'397'}); } if ($search =~ m~\\~){ &fatal_error($txt{'397'}); } my $searchsubject = $FORM{'subfield'} eq 'on'; my $searchmessage = $FORM{'msgfield'} eq 'on'; $search =~ s/\A\s+//; $search =~ s/\s+\Z//; &ToHTML($search); $search =~ s/\t/ \  \  \ /g; $search =~ s/\cM//g; $search =~ s/\n/
    /g; if( $searchtype != 3 ) { @search = split( /\s+/, $search ); } else { @search = ( $search ); } $yeardbflag = 'dummy'; # at this point each key in $dayinfo{$index} holds the # date index of an event and the value is string holding # each event field, separated by {. $yymain .= qq~
    ~; # start searching the database my(@searchdayinfokeys) = keys(%dayinfo); foreach $searchindex (@searchdayinfokeys) { my($searchmonth, $searchday, $searchyear) = (gmtime($searchindex))[4,3,5]; $searchyear += 1900; $searchmonth += 1; my($searchelement) = ""; my(@searchentry) = (); my($entrynum) = 0; foreach $searchelement (@{ $dayinfo{$searchindex} }) { my(@searchentry) = split('{',$searchelement); $dayvars[$entrynum] = [ @searchentry ]; $entrynum++; } eventcheck: for ($entrynum=0;$entrynum<=$newcalmax2;$entrynum++) { next if !(defined(${$dayvars[$entrynum]}[0])); next if(${$dayvars[$entrynum]}[1] =~ /DELETED/); $eventname = ${$dayvars[$entrynum]}[0] if (defined(${$dayvars[$entrynum]}[0])); $eventmessage = ${$dayvars[$entrynum]}[2] if (defined(${$dayvars[$entrynum]}[2])); if( $searchsubject ) { if( $searchtype == 2 ) { $subfound = 0; foreach( @search ) { if( $eventname =~ m~\Q$_\E~i ) { $subfound = 1; last; } } } else { $subfound = 1; foreach( @search ) { if( $eventname !~ m~\Q$_\E~i ) { $subfound = 0; last; } } } } if( $searchmessage && ! $subfound ) { if( $searchtype == 2 ) { $msgfound = 0; foreach( @search ) { if( $eventmessage =~ m~\Q$_\E~i ) { $msgfound = 1; last; } } } else { $msgfound = 1; foreach( @search ) { if( $eventmessage !~ m~\Q$_\E~i ) { $msgfound = 0; last; } } } } unless( $msgfound || $subfound ) { next eventcheck; } if( $subfound || $msgfound ) { $eventsfound = 1; # this is what to do with matching events: # Censor the subject and message. &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $eventmessage =~ s~\Q$tmpa\E~$tmpb~gi; $eventname =~ s~\Q$tmpa\E~$tmpb~gi; } # Run UBBC interpreter on the description. $message = $eventmessage; # put the message back into the proper variable to do ubbc on it &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $eventmessage = $message; # Run UBBC interpreter on the event name. $eventnamesend = ${dayvars[$entrynum]}[0]; #bypass UBBC for SendEvent $message = $eventname; # put the message back into the proper variable to do ubbc on it &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $eventname = $message; # End UBBC foreach( @search ) { $eventmessage =~ s~(\Q$_\E)~$_~ig; $eventname =~ s~(\Q$_\E)~$_~ig; } ##### Get author display name $eventusername = ${$dayvars[$entrynum]}[3]; # Load the current nickname of the account name of the event poster. if( $eventusername ne 'Guest' && -e "$memberdir/$eventusername.dat" ) { &LoadUser($eventusername); $mname = $userprofile{$eventusername}->[1] || $mname || $txt{'28'}; $mname2 = $mname; $mname = qq~$mname~; } else { $mname = $txt{'28'}; $mname2 = $mname; } ##### Get Display name end ####### Media Player mod $mediausername = $mname2; ####### Media Player mod end $yymain .= qq~ ~; } } } if ($eventsfound == 0) { $yymain .= qq~ ~; } $yymain .= qq~
    $txt{'166'}
    $ecaltxt{'85'} $searchmonth/$searchday/$searchyear
    $ecaltxt{'31'} $eventname
    $ecaltxt{'50'} ${$dayvars[$entrynum]}[1]
    $ecaltxt{'35'} $eventmessage
    $ecaltxt{'54'} $mname

    $ecaltxt{'92'}

    ~; $yytitle = "$txt{'166'}"; } #YearCal generates year view calendar page, called by CalMain, calls GetDbData sub YearCal { chomp $newcaladmingroup; @newcaladmingrouplist = split(",",$newcaladmingroup); $newcaladmingroupflag = 0; foreach $newcaladmingroupitem (@newcaladmingrouplist) { if ($settings[7] eq $newcaladmingroupitem) { $newcaladmingroupflag = 1; } } $monthyear = 0; $yeardisyear = $seldate[2]; $yymain .= qq~
    ~; # This starts year table my($butprevyear) = $yeardisyear-1; my($butnextyear) = $yeardisyear+1; $yymain .= qq~ ~; for($monthyear;$monthyear <= 11;$monthyear=$monthyear+1) { $yeardbflag = 'yearview'; &GetDbData; if( ( $monthyear == 4 ) || ( $monthyear == 8 ) ) { $yymain .= qq~~; } my($thismonth) = $monthyear; my($thisyear) = $seldate[2]; $monthname = ($ecaltxt{'01'},$ecaltxt{'02'},$ecaltxt{'03'},$ecaltxt{'04'},$ecaltxt{'05'},$ecaltxt{'06'},$ecaltxt{'07'},$ecaltxt{'08'},$ecaltxt{'09'},$ecaltxt{'10'},$ecaltxt{'11'},$ecaltxt{'12'})[$thismonth]; my($thisdaysecs) = timegm(0,0,0,1,$thismonth,$thisyear); my($thisdayweek) = (gmtime($thisdaysecs))[6]; if ($mondayfirst == 1) { if ($thisdayweek == 0) { $thisdayweek = 6; } else { $thisdayweek = $thisdayweek - 1; } } my($daysecs) = 24*60*60; my(@today) = localtime(time + (3600*($timeoffset + $settings[18]))); my($todaysecs) = timegm(0,0,0,$today[3],$today[4],$today[5]); my($nextmonth) = $thismonth+1; my($nextyear) = $thisyear; if($nextmonth > 11) { $nextmonth = 0; $nextyear = $thisyear+1; } $yymain .= qq~ ~; # This end table for each month } #this bracket ends year loop $yymain .= qq~
    $yeardisyear
    ~; $yymain .= qq~~ if($thisdayweek > 0); my($thisdaymonth) = 1; for($thisdaysecs;$thisdaysecs <= $thisdaysecs+$daysecs*31;$thisdaysecs=$thisdaysecs+$daysecs) { last if ((gmtime($thisdaysecs))[4] != $thismonth); $data=""; ($thisdaymonth,$thisdayweek) = (gmtime($thisdaysecs))[3,6]; if ($mondayfirst == 1) { if ($thisdayweek == 0) { $thisdayweek = 6; } else { $thisdayweek = $thisdayweek - 1; } } if (defined($dayinfo{$thisdaysecs})) { foreach $info (@{ $dayinfo{$thisdaysecs} }) { @daydata = split(/\{/,$info); next if($daydata[1] =~ /DELETED/); if($todaysecs == $thisdaysecs) { $data = $data . qq~$thisdaymonth~; } else { $data = $data . qq~$thisdaymonth~; } last if ( $data ne "" ); } } if($thisdayweek == 0) { $yymain .= qq~~; } else { if( $username ne "Guest" || $newcalguest == 1 ){ if ($newcaladmin != 1 || $newcaladmingroupflag == 1 || $settings[7] eq 'Administrator' ) { if($todaysecs == $thisdaysecs) { $yymain .= qq~$thisdaymonth~; } else { $yymain .= qq~$thisdaymonth~; } } else { if($todaysecs == $thisdaysecs) { $yymain .= qq~$thisdaymonth~; } else { $yymain .= qq~$thisdaymonth~; } } } else { if($todaysecs == $thisdaysecs) { $yymain .= qq~$thisdaymonth~; } else { $yymain .= qq~$thisdaymonth~; } } } } $yymain .= qq~
    $monthname
    ~; } else { $yymain .= qq~ ~; } if ( $data ne '') { $yymain .= qq~$data

    ~; # This ends over all year table } #this bracket ends subroutine # DisYearForm displays select year form at bottom of year view page, called by CalMain sub DisYearForm { $yymain .= qq~
    $ecaltxt{'27'}
    $ecaltxt{'28'}
    ~; } 1;