################################################# #Newcalendar for SP1 mod by Ironwing and GauGau.# #Based on Event Calendar by Nermware # #Support: boardmod.yabbforums.com # #Version 3.0 ubbc3 # ################################################# $Newcalendarplver = 'NewcalendarSP1 3.0 for SP1'; # CalMain is the main calendar routine, called by YaBB sub CalMain { $rev = "1.3.1"; #This is the Nermware calendar ver num, must not change require "$vardir/eventcal.txt"; #This is the settings file @sbjlist = split(" ",$sbjlist); $yytitle = $calpagetitle; $dbfile = "$vardir/eventcaldb"; #This is the database file $origcom = qq~$ecaltxt{'58'}eventcalendar.pl v$rev$ecaltxt{'59'}~;# Nermware credit must remain $adaptcom = 'Ironwing'; use Time::Local; use CGI; $webpage_obj = new CGI; $acttype = GetActType(); @seldate = GetSelDate(); GetDbData(); if($acttype =~ /display/) { CalBDay2(); DisCalendar(); DisCalForm(); } EnterData() if($acttype =~ /enterdata/); ViewData() if($acttype =~ /viewdata/); if(($acttype =~ /newdata/) || ($acttype =~ /deldata/)) { NewData(); $acttype = display; GetDbData(); CalBDay2(); DisCalendar(); DisCalForm(); } SendTrailer(); &template; exit; } # GetActType determines type of action selected by user # called by CalMain sub and IndexCal sub sub GetActType { my($type) = "display"; $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('badtype'); } # GetSelDate determines current time/date or selected time/date to display # called by CalMain sub and IndexCal sub sub GetSelDate { (my($selmonth),my($selday),my($selyear)) = (gmtime(time-$gmtminos*60))[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, # called by CalMain sub and IndexCal sub sub GetDbData { my($thismonth) = $seldate[0]; my($thisyear) = $seldate[2]; my($selmonfst) = timegm(0,0,0,1,$thismonth,$thisyear); my($nextmonth) = $thismonth+1; my($nextyear) = $thisyear; if($nextmonth > 11) { $nextmonth = 0; $nextyear = $thisyear+1; } my($nxtmonfst) = timegm(0,0,0,1,$nextmonth,$nextyear); die("ERROR .. unable to open $dbfile\n") unless fopen(DBFILE,$dbfile); while ($strline=) { chop($strline); @line = split(/\|/,$strline); my($index) = shift(@line); $dayinfo{$index} = [ @line ] if($index < $nxtmonfst); } fclose(DBFILE); return if(($acttype !~ /display/) && ($acttype !~ /viewdata/)); my($daysecs) = 24*60*60; my($weeksecs) = 168*60*60; my(@dayinfokeys) = keys(%dayinfo); foreach $index (@dayinfokeys) { my($element) = ""; my(@entry) = (); foreach $element (@{ $dayinfo{$index} }) { my(@entry) = split('{',$element); my($repeatfor) = $entry[$#entry]; if($repeatfor > 1) { my($newindex) = $index; $addsecs = $daysecs if($entry[$#entry-1] =~ /$ecaltxt{'43'}/); $addsecs = $weeksecs if($entry[$#entry-1] =~ /$ecaltxt{'44'}/); if(($entry[$#entry-1] =~ /$ecaltxt{'43'}/) || ($entry[$#entry-1] =~ /$ecaltxt{'44'}/)) { for($i=2;$i<=$repeatfor;$i++) { $newindex = $newindex + $addsecs; $entry[$#entry] = 0; ${$dayinfo{$newindex}}[++$#{$dayinfo{$newindex}}] = join('{',@entry) if(($newindex < $nxtmonfst) && ($newindex >= $selmonfst)); } next; } my($addyears) = my($addmonths) = 0; $addyears = 1 if($entry[$#entry-1] =~ /$ecaltxt{'46'}/); $addmonths = 1 if($entry[$#entry-1] =~ /$ecaltxt{'45'}/); my(@thisdate) = gmtime($index); splice(@thisdate,-1,3); for($i=2;$i<=$entry[$#entry];$i++) { $thisdate[4] = $thisdate[4] + $addmonths; $thisdate[5] = $thisdate[5] + $addyears; if($thisdate[4] > 11) { $thisdate[4]=0; $thisdate[5]++; } $newindex = timegm(@thisdate); ${$dayinfo{$newindex}}[++$#{$dayinfo{$newindex}}] = $element if(($newindex < $nxtmonfst) && ($newindex >= $selmonfst)); } } } } } #DisCalendar generates month view calendar page, called by CalMain sub sub DisCalendar { 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]; my($daysecs) = 24*60*60; my(@today) = gmtime(time-$gmtminos*60); 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; } $yymain .= qq~
~; $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 (defined($dayinfo{$thisdaysecs})) { $data = ""; foreach $info (@{ $dayinfo{$thisdaysecs} }) { @daydata = split(/\{/,$info); next if($daydata[1] =~ /DELETED/); # Run UBBC interpreter on the event name. $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; # End UBBC $data = $data . "
  • $daydata[0]
  • "; } $data = $data . "

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

  • ~; } } # End bday code if($thisdayweek == 0) { $yymain .= qq~ ~; } else { $yymain .= qq~ $thisdaymonth $data ~; } } else { if($todaysecs == $thisdaysecs) { $yymain .= qq~ $thisdaymonth $data ~; } else { $yymain .= qq~ $thisdaymonth $data ~; } } } $yymain .= qq~
    $caltitle
    $monthname         $thisyear
      $ecaltxt{'13'}       $ecaltxt{'14'}       $ecaltxt{'15'}   $ecaltxt{'16'}   $ecaltxt{'17'}       $ecaltxt{'18'}       $ecaltxt{'19'}  
    ~; } else { $yymain .= qq~ ~; } if($username ne "Guest" || $enable_guestposting != 0){ 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'}
    ~; } # 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++; } } if ($newcaldate == 1) { $newcaldatestring = "$seldate[1]".'/'."${seldate[0]+1}".'/'."$seldate[2]"; } else { $newcaldatestring = "${seldate[0]+1}/$seldate[1]/$seldate[2]"; } 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. $yymain .= qq~

    $entitle


    ~; $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' || $eventusername eq 'Invalid user name placeholder') { if($eventusername eq 'Invalid user name placeholder') {$eventusername = $username}; #Sets new events to current username $yymain .= qq~
    $ecaltxt{'41'}$entrynumstr$ecaltxt{'42'}$newcaldatestring
    $ecaltxt{'31'} $ecaltxt{'37'}
    $ecaltxt{'50'} $ecaltxt{'35'}
    $ecaltxt{'54'} $eventusername
    ~; } # The above closing 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 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++; } } if ($newcaldate == 1) { $newcaldatestring = "$seldate[1]".'/'."${seldate[0]+1}".'/'."$seldate[2]"; } else { $newcaldatestring = "${seldate[0]+1}/$seldate[1]/$seldate[2]"; } my($subject) = ""; my($commentview) = ""; $yymain .= qq~

    $vwtitle

    ~; $yymain .= qq~
    ~; $newcalmax2 = $newcalmax - 1; for ($entrynum=0;$entrynum<=$newcalmax2;$entrynum++) { next if !(defined(${$dayvars[$entrynum]}[0])); next if(${$dayvars[$entrynum]}[1] =~ /DELETED/); # Addon for user security $commentview = ${$dayvars[$entrynum]}[2] if (defined(${$dayvars[$entrynum]}[2])); $eventusername = ${$dayvars[$entrynum]}[3] if (defined(${$dayvars[$entrynum]}[3])); # Censor the subject and message. &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $commentview =~ s~\Q$tmpa\E~$tmpb~gi; ${$dayvars[$entrynum]}[0] =~ s~\Q$tmpa\E~$tmpb~gi; } # Run UBBC interpreter on the description. $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; # Run UBBC interpreter on the event name. $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; # End UBBC #End addon for user security $yymain .= qq~ ~; } $yymain .= qq~
    $ecaltxt{'49'}$newcaldatestring

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


    ~; } # NewData writes new enteries to database file, called by CalMain sub 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'); # Addon for user security $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; $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; # End addon for user security $repeatby =~ tr/!-~/ /cs; $repeatnum =~ tr/!-~/ /cs; $title =~ s/[\{\|]//g; $subject =~ s/[\{\|]//g; $comment =~ s/[\{\|]//g; $eventusername =~ s/[\{\|]//g; $repeatby =~ s/[\{\|]//g; $repeatnum =~ s/[\{\|]//g; $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 { $yymain .= qq~

    $ecaltxt{'23'}$mbname


    $origcom
    $Newcalendarplver$ecaltxt{'51'}$adaptcom
    ~; } # IndexCal and IndexCal2 show today's events in Info Center on BoardIndex # Split into two subs to allow for addon mods (like CalBDay), called by YaBB sub IndexCal { require "$vardir/eventcal.txt"; #This is the settings file @sbjlist = split(" ",$sbjlist); $yytitle = $calpagetitle; $dbfile = "$vardir/eventcaldb"; #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(); CalBDay(); IndexCal2(); } # IndexCal2 shows today's events in Info Center on BoardIndex, called by IndexCal sub sub IndexCal2 { 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]; my($daysecs) = 24*60*60; my(@today) = gmtime(time-$gmtminos*60); 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; } 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 (defined($dayinfo{$thisdaysecs})) { $data = ""; foreach $item (@sbjlist) { $itemcount=0; foreach $info (@{ $dayinfo{$thisdaysecs} }) { @daydata = split(/\{/,$info); next if($daydata[1] =~ /DELETED/); # Run UBBC interpreter on the event name. $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; # End UBBC $daydata[0] =~ s/(^.+)( $)/$1/; if($daydata[1] =~ /$item/) { if ($itemcount == 0) { $data = $data . qq~
  • $daydata[1]:\ \;$daydata[0]~; $itemcount++; } else { $data = $data . qq~,\ \;$daydata[0]~; $itemcount++; } } } } # Censor the subject. &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $data =~ s~\Q$tmpa\E~$tmpb~gi; } # End censor subject routine } # Add birthday info from CalBDay $data = $data . "$calwhobg"; if($todaysecs == $thisdaysecs) { $yymain .= qq~$data~; } } } # CalBDay adds Today's Birthdays to Info Center and SSI script, called by IndexCal and IncludeCal subs sub CalBDay { &timeformat($date); ($tocheckm, $tocheckd, $years) = split(/\//, $date); ($year, $trash) = split(/ /, $years); $calwhobd = ""; $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"; @userbd = ; fclose(FILE); chomp $userbd[16]; ($matchm, $matchd, $useryear) = split(/\//, $userbd[16]); if(($tocheckm == $matchm) && ($tocheckd == $matchd)) { $age = $year - $useryear + 2000; $calwhobg .=qq~$userbd[1] ($age) ~; $countbd++; } } }#end foreach chomp $calwhobg; if ($calwhobg ne "") {$calwhobg = qq~
  • $ecaltxt{'56'}$calwhobg
  • ~;} } # CalBDay2 adds All Birthdays to Calendar, called by CalMain sub 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]; #skip user if no birthday in file or birthday date invalid. if ($userbd[16] ne "") { ($usermonth, $userday, $dummyyear) = split(/\//, $userbd[16]); if ($usermonth > 0 && $usermonth < 13) { if ($userday > 0 && $userday < 32) { $usermonth = $usermonth - 1; $bdayindex = timegm(0,0,0,$userday,$usermonth,$thisyear); $userprofstring = qq~$userbd[1]~; $bdayshash{$userprofstring} = $bdayindex; } } } }# end file exists }#end foreach } # IncludeCal and IncludeCal2 show today's events on any HTML page through include virtual # Split into two subs to allow for addon mods (like CalBDay), called by YaBB sub IncludeCal { require "$vardir/eventcal.txt"; #This is the settings file @sbjlist = split(" ",$sbjlist); $yytitle = $calpagetitle; $dbfile = "$vardir/eventcaldb"; #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(); CalBDay(); IncludeCal2(); exit; } # IncludeCal2 shows today's events as SSI call on html pages, called by IncludeCal sub sub IncludeCal2 { 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]; my($daysecs) = 24*60*60; my(@today) = gmtime(time-$gmtminos*60); 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; } 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 (defined($dayinfo{$thisdaysecs})) { $data = ""; foreach $item (@sbjlist) { $itemcount=0; foreach $info (@{ $dayinfo{$thisdaysecs} }) { @daydata = split(/\{/,$info); next if($daydata[1] =~ /DELETED/); # Run UBBC interpreter on the event name. $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; # End UBBC $daydata[0] =~ s/(^.+)( $)/$1/; if($daydata[1] =~ /$item/) { if ($itemcount == 0) { $data = $data . qq~
  • $daydata[1]:\ \;$daydata[0]~; $itemcount++; } else { $data = $data . qq~,\ \;$daydata[0]~; $itemcount++; } } } } # Censor the subject. &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $data =~ s~\Q$tmpa\E~$tmpb~gi; } # End censor subject routine } # Add birthday info from CalBDay $data = $data . "$calwhobg"; if($todaysecs == $thisdaysecs) { print qq~Content-type: text/html\n\n~; if ($data ne "") { print qq~$data~; } else { print qq~$ecaltxt{'73'}~; } } } } #CompactCal removes duplicate calendar entries. Called by sub NewData. sub CompactCal { # 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 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); } # CalSettings generates edit settings page for Newcalendar in the Admin Center. Calls CalSettings2. sub CalSettings { &is_admin; require "$vardir/eventcal.txt"; my($newcalopenchecked); my($newcaldatechecked); if ($newcalopen) { $newcalopenchecked = ' checked'; } if ($newcaldate) { $newcaldatechecked = ' checked'; } $yymain .= qq~
    $ecaltxt{'60'}

    $ecaltxt{'61'}

    $ecaltxt{'62'}
    $ecaltxt{'63'}
    $ecaltxt{'64'}
    $ecaltxt{'65'}
    $ecaltxt{'66'}
    $ecaltxt{'67'}
    $ecaltxt{'68'}
    $ecaltxt{'69'}
    $ecaltxt{'70'}
    $ecaltxt{'75'}
    $ecaltxt{'72'}
    $ecaltxt{'71'}
    $ecaltxt{'74'}

    ~; $yytitle = $ecaltxt{'60'}; &template; exit; } # CalSettings2 saves changes to Newcalendar settings in eventcal.txt. Called by CalSettings. sub CalSettings2 { &is_admin; my @onoff = qw/ newcalopen newcaldate /; # Set as 0 or 1 if box was checked or not my $fi; map { $fi = lc $_; ${$_} = $FORM{$fi} eq 'on' ? 1 : 0; } @onoff; $newcalopen = $FORM{'newcalopen'} || 0; $newcaldate = $FORM{'newcaldate'} || 0; $calpagetitle = $FORM{'calpagetitle'} || 'My Calendar Page'; $caltitle = $FORM{'caltitle'} || 'My Calendar'; $sbjlist = $FORM{'sbjlist'} || 'Meeting Game Birthday Anniversary Other'; $sbjdefault = $FORM{'sbjdefault'} || 'Meeting'; $vwpgtitle = $FORM{'vwpgtitle'} || 'Notices for Selected Date'; $vwtitle = $FORM{'vwtitle'} || 'Notices for Selected Date'; $enpgtitle = $FORM{'enpgtitle'} || 'Edit Notices Page'; $entitle = $FORM{'entitle'} || 'Edit Notices Page'; $gmtminos = $FORM{'gmtminos'} || 300; $newcalmax = $FORM{'newcalmax'} || 5; if ($newcalmax < 1) {$newcalmax = 1}; $newcalgroup = $FORM{'newcalgroup'} || 'Newcalendar Group'; my $filler = q~ ~; my $setfile = << "EOF"; ############################################################################### # eventcal.txt - Settings for Newcalendar 3.0 # ############################################################################### \$calpagetitle = "$calpagetitle"; # Title of the calendar page (window title) \$caltitle = "$caltitle"; # Title of the calendar (not the window title) \$sbjlist = "$sbjlist"; # Selection for subject (type) menu, modify to suit event types desired \$sbjdefault = "$sbjdefault"; # Default subject list selection \$vwpgtitle = "$vwpgtitle"; # Viewer page title (window title) \$vwtitle = "$vwtitle"; # Viewer table title (not the window title) \$enpgtitle = "$enpgtitle"; # Edit page title (window title) \$entitle = "$entitle"; # Edit table title (not the window title) \$gmtminos = $gmtminos; # Local time offset from GMT in minutes. 300 = 5 hours. I.E Eastern Standard Time \$newcalmax = $newcalmax; # Maximum number of events per date (default = 5) \$newcalgroup = "$newcalgroup"; # Name of group to give exclusive calendar access if newcalopen = 0 \$newcalopen = $newcalopen; # Newcalendar open to all or just admin + group Newcalgroup \$newcaldate = $newcaldate; # Newcalendar Date Format: Check for 12/31/2002,
    uncheck for 31/12/2002 1; EOF $setfile =~ s~(.+\;)\s+(\#.+$)~$1 . substr( $filler, 0, (70-(length $1)) ) . $2 ~gem; $setfile =~ s~(.{64,}\;)\s+(\#.+$)~$1 . "\n " . $2~gem; $setfile =~ s~^\s\s\s+(\#.+$)~substr( $filler, 0, 70 ) . $1~gem; fopen(FILE, ">$vardir/eventcal.txt"); print FILE $setfile; fclose(FILE); $yySetLocation = qq~$cgi;action=admin~; &redirectexit; } # WhosCal and WhosCal2 show today's events in the modified Whoson mod # Split into two subs to allow for addon mods (like WhosBDay), called by Whoson SSI mod sub WhosCal { require "$vardir/eventcal.txt"; #This is the settings file @sbjlist = split(" ",$sbjlist); $dbfile = "$vardir/eventcaldb"; #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(); WhosBDay(); WhosCal2(); } # WhosCal2 shows today's events in the modified Whoson mod, called by WhosCal sub sub WhosCal2 { 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]; my($daysecs) = 24*60*60; my(@today) = gmtime(time-$gmtminos*60); 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; } 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 (defined($dayinfo{$thisdaysecs})) { $data = ""; foreach $item (@sbjlist) { $itemcount=0; foreach $info (@{ $dayinfo{$thisdaysecs} }) { @daydata = split(/\{/,$info); next if($daydata[1] =~ /DELETED/); # Run UBBC interpreter on the event name. $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; # End UBBC $daydata[0] =~ s/(^.+)( $)/$1/; if($daydata[1] =~ /$item/) { if ($itemcount == 0) { $data = $data . qq~
  • $daydata[1]:\ \;$daydata[0]~; $itemcount++; } else { $data = $data . qq~,\ \;$daydata[0]~; $itemcount++; } } } } # Censor the subject. &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $data =~ s~\Q$tmpa\E~$tmpb~gi; } # End censor subject routine } # Add birthday info from WhosBDay $data = $data . '
    ' . "$calwhobg"; if($todaysecs == $thisdaysecs) { print qq~$data~; } } } # WhosBDay adds Today's Birthdays to the modified Whoson mod, called by WhosCal sub sub WhosBDay { &timeformat($date); ($tocheckm, $tocheckd, $years) = split(/\//, $date); ($year, $trash) = split(/ /, $years); $calwhobd = ""; $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"; @userbd = ; fclose(FILE); chomp $userbd[16]; ($matchm, $matchd, $useryear) = split(/\//, $userbd[16]); if(($tocheckm == $matchm) && ($tocheckd == $matchd)) { $age = $year - $useryear + 2000; $calwhobg .=qq~$userbd[1]
    ~; $countbd++; } } }#end foreach chomp $calwhobg; if ($calwhobg ne "") {$calwhobg = qq~» $ecaltxt{56}
    $calwhobg~;} } 1;