mnlight has asked for the wisdom of the Perl Monks concerning the following question:
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_passw +ord); 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","whe +re day=$vday and month=$vmon and year=$vyear"); until ($count == 0) { ($eventid,$subject,$description) = split(/\|/,$mysql->[$count] +); print qq~ <center> <center> <table width="$table_width" border="$table_border" cellspacing="$table +_cellspacing" cellpadding="$table_cellpadding" bordercolor="$t able_bordercolor"> <tr bgcolor=$table_title_bgcolor> <td><font size=$table_title_text_size face=$table_title_text_font colo +r="$table_title_text_color">$vday/$vmon/$vyear - $subject</fon t></td> </tr> <tr bgcolor="$table_day_bgcolor" > <td> <table width=95% border=0><tr><td>$description</td></tr> </table> </td> </tr> </table> </center> ~; $count--; } } $count = undef; @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday',' +Saturday'); @months = ('January','February','March','April','May','June','July','A +ugust','September','October','November','December'); $timeoffset = $param{jumpto} * 24 ; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = local +time(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) = sp +lit(/\//,$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 .= "<option>$tmp</option>\n"; $tmp++; } print <<endofhtml; <html> <head> <title>$title</title> </head> <body bgcolor="$bgcolor" text="$text" link="$link" vlink="$vlink" alin +k="$alink" background="$background"> <center><BR><BR><BR><BR> <h1>$months[$mon] $year</h1> <br> <table width=$table_width border=0><tr><td width=50%> <font face=arial color=white><a href="mysql_calendar.cgi?jumpto=$last" +>View Last Month</a></font> </td><td width=50%> <div align=right><font face=arial color=white><a href="mysql_calendar. +cgi?jumpto=$next">View Next Month</a></font></div> </td></tr></table> <table width="$table_width" border="$table_border" cellspacing="$table +_cellspacing" cellpadding="$table_cellpadding" bordercolor="$t able_bordercolor"> <tr bgcolor=$table_title_bgcolor> <td width=$cell_width><font size=$table_title_text_size face=$tabl +e_title_text_font color="$table_title_text_color">Sunday</font ></td> <td width=$cell_width><font size=$table_title_text_size face=$tabl +e_title_text_font color="$table_title_text_color">Monday</font ></td> <td width=$cell_width><font size=$table_title_text_size face=$tabl +e_title_text_font color="$table_title_text_color">Tuesday</fon t></td> <td width=$cell_width><font size=$table_title_text_size face=$tabl +e_title_text_font color="$table_title_text_color">Wednesday</f ont></td> <td width=$cell_width><font size=$table_title_text_size face=$tabl +e_title_text_font color="$table_title_text_color">Thursday</fo nt></td> <td width=$cell_width><font size=$table_title_text_size face=$tabl +e_title_text_font color="$table_title_text_color">Friday</font ></td> <td width=$cell_width><font size=$table_title_text_size face=$tabl +e_title_text_font color="$table_title_text_color">Saturday</fo nt></td> </tr> <tr bgcolor="$table_day_bgcolor" > endofhtml $day = ($currentday - 1) * 86400; $count; $sectime = $sectime - $day; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($sec +time); $year = $year + 1900; while ($wday != 0) { $wday--; print "<td height=$cell_height valign=top><div align=right><B> +<font size=$table_day_size color=$table_day_color face=$table_ day_face> </font></b></div></td>"; $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=\"$u +sername\" and year=\"$year\" and month=\"$tmpmon\" and day=\"$ mday\""); $tmp = $mysql->Select("events","subject,description","where year=\"$ye +ar\" 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 .= "<a href=\"mysql_calendar.cgi?$jumpto\view=$mday-$tm +pmon-$year\">$subject</a><br>"; $tmp--; } print "<td height=$cell_height valign=top $color><div align=right><B>< +font size=$table_day_size color=$table_day_color face=$table_d ay_face>$mday</font></b></div><BR><center><table width=80><tr><Td vali +gn=top><font size=-2 color=$table_day_color face=$table_day_fa ce>$desc</font></td></tr></table></center></td>"; $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 "</tr><tr bgcolor=\"$table_day_bgcolor\" >\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<BR>"; 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=\"$u +sername\" and year=\"$year\" and month=\"$tmpmon\" and day=\"$ mday\""); $tmp = $mysql->Select("events","subject,description","where year=\"$ye +ar\" 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 .= "<a href=\"mysql_calendar.cgi?$jumpto\view=$mday-$tm +pmon-$year\">$subject</a><br>"; $tmp--; } print "<td height=$cell_height valign=top $color><div align=right><B>< +font size=$table_day_size color=$table_day_color face=$table_d ay_face>$mday</font></b></div><center><table width=80><tr><Td valign=t +op><font size=-2 color=$table_day_color face=$table_day_face>$ event</font></td></tr></table></center></td>"; $count++; $desc = ''; $color = ''; $tmpmon=undef; $tmp=undef; $event = undef; $subject = undef; $description = undef; } } until ($count == 7) { print "<td height=$cell_height valign=top><div align=r +ight><B><font size=$table_day_size color=$table_day_color face =$table_day_face> </font></b></div></td>"; $count++; } print "</table>"; print <<endofhtml; <a href="addevent/calendar.cgi">ADD EVENTS</a> endofhtml
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unable to see entries from 1st day of the month.
by grep (Monsignor) on Mar 28, 2002 at 01:54 UTC | |
by mnlight (Scribe) on Mar 28, 2002 at 19:30 UTC | |
|
Re: unable to see entries from 1st day of the month.
by rinceWind (Monsignor) on Mar 28, 2002 at 01:27 UTC | |
|
Re: unable to see entries from 1st day of the month.
by Fletch (Bishop) on Mar 28, 2002 at 01:56 UTC |