use Cwd;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use mysql_manip;
use Read_Parse;
$| = 1;
$cwd = cwd();
%param = Read_Parse->new("getall");
$mysql = mysql_manip->Connect($mysql_database,$mysql_user,$mysql_password);
print "Content-Type: text/html\n\n";
%nonleapdays = (
"0" => "31",
"1" => "28",
"2" => "31",
"3" => "30",
"4" => "31",
"5" => "30",
"6" => "31",
"7" => "31",
"8" => "30",
"9" => "31",
"10" => "30",
"11" => "31",
);
%leapdays = (
"0" => "31",
"1" => "29",
"2" => "31",
"3" => "30",
"4" => "31",
"5" => "30",
"6" => "31",
"7" => "31",
"8" => "30",
"9" => "31",
"10" => "30",
"11" => "31",
);
$count = $mysql->Select("events","id");
$id = 0;
$id = $mysql->[$count] if ($count > 0);
$tmpmon = $param{month};
$tmpmon--;
if ($param{view}) {
($vday,$vmon,$vyear) = split(/\-/,$param{view});
$count = $mysql->Select("events","id,subject,description","where day=$vday and month=$vmon and year=$vyear");
until ($count == 0) {
($eventid,$subject,$description) = split(/\|/,$mysql->[$count]);
print qq~
| $vday/$vmon/$vyear - $subject |
|
|
~;
$count--;
}
}
$count = undef;
@days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July','August','September','October','November','December');
$timeoffset = $param{jumpto} * 24 ;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time + (3600*$timeoffset));
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime(time);
$savehour = $hour;
$hour = "0$hour" if ($hour < 10);
$min = "0$min" if ($min < 10);
$sec = "0$sec" if ($sec < 10);
$year = 1900 + $year;
$Tsavehour = $Thour;
$Thour = "0$Thour" if ($Thour < 10);
$Tmin = "0$Tmin" if ($Tmin < 10);
$Tsec = "0$Tsec" if ($Tsec < 10);
$Tyear = 1900 + $Tyear;
$sectime = time;
$sectime = $sectime + (3600*$timeoffset);
$date = "$days[$mday]/$mon/$mday/$year/";
$date .= $sectime;
($currentweekday,$currentmonth,$currentday,$currentyear,$sectime) = split(/\//,$date);
$last = $currentday - (($currentday * 2) + 1);
$last = $last + $param{jumpto};
$next;
if ($currentyear % 4) {
$next = $leapdays{$currentmonth} - $currentday + 1 + $param{jumpto};
} else {
$next = $nonleapdays{$currentmonth} - $currentday + 1 + $param{jumpto};
}
$tmp = $year - 25;
until ($tmp == ($year + 25)) {
$option .= "\n";
$tmp++;
}
print <
$title
$months[$mon] $year
| Sunday |
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
endofhtml
$day = ($currentday - 1) * 86400;
$count;
$sectime = $sectime - $day;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($sectime);
$year = $year + 1900;
while ($wday != 0) {
$wday--;
print "  | ";
$count++;
}
$desc;
foreach $i (@events) {
($eventYEAR,$eventMONTH,$eventDAY,$eventDESCRIPTION) = split(/\|\^\|/,$i);
if ($eventYEAR == $year && $eventMONTH == $mon && $eventDAY == $mday) {
$desc = $eventDESCRIPTION;
}
}
$color;
if ($year == $Tyear && $mon == $Tmon && $mday == $Tmday) {
$color = "bgcolor=$table_currentday_bgcolor";
}
$tmpmon = $mon;
$tmpmon++;
#$tmp = $mysql->Select("events","subject,description","where user=\"$username\" and year=\"$year\" and month=\"$tmpmon\" and day=\"$
mday\"");
$tmp = $mysql->Select("events","subject,description","where year=\"$year\" and month=\"$tmpmon\" and day=\"$mday\"");
until ($tmp == 0) {
($subject,$description) = split(/\|/,$mysql->[$tmp]) if ($tmp >= 1);
$jumpto = $timeoffset / 24;
if ($jumpto) { $jumpto = "jumpto=$jumpto&" } else { $jumpto = undef }
$event .= "$subject
";
$tmp--;
}
print "$mday
| ";
$desc = '';
$color = '';
$tmpmon=undef;
$tmp=undef;
$event = undef;
$subject = undef;
$description = undef;
$count++;
$PRIMEmon = $currentmonth + 1;
if ($PRIMEmon == 12) { $PRIMEmon = 0; }
while ($mon ne $PRIMEmon) {
if ($count == 7) {
print "
\n";
$count = 0;
}
$sectime = $sectime + 86400;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($sectime);
$year = $year + 1900;
if ($PRIMEmon ne $mon) {
# print "$months[$mon]/$mday/$year
";
foreach $i (@events) {
($eventYEAR,$eventMONTH,$eventDAY,$eventDESCRIPTION) = split(/\|\^\|/,$i);
if ($eventYEAR == $year && $eventMONTH == $mon && $eventDAY == $mday) {
$desc = $eventDESCRIPTION;
}
}
if ($year == $Tyear && $mon == $Tmon && $mday == $Tmday) {
$color = "bgcolor=$table_currentday_bgcolor";
}
$tmpmon = $mon;
$tmpmon++;
#$tmp = $mysql->Select("events","subject,description","where user=\"$username\" and year=\"$year\" and month=\"$tmpmon\" and day=\"$
mday\"");
$tmp = $mysql->Select("events","subject,description","where year=\"$year\" and month=\"$tmpmon\" and day=\"$mday\"");
until ($tmp == 0) {
($subject,$description) = split(/\|/,$mysql->[$tmp]) if ($tmp >= 1);
$jumpto = $timeoffset / 24;
if ($jumpto) { $jumpto = "jumpto=$jumpto&" } else { $jumpto = undef }
$event .= "$subject
";
$tmp--;
}
print "$mday | ";
$count++;
$desc = '';
$color = '';
$tmpmon=undef;
$tmp=undef;
$event = undef;
$subject = undef;
$description = undef;
}
}
until ($count == 7) {
print "  | ";
$count++;
}
print "
";
print <ADD EVENTS
endofhtml