3 # Display a table of days in the current month
5 $trust_unknown_referers = 1;
6 require './web-lib.pl';
7 require 'timelocal.pl';
11 @daysin = ( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
12 $daysin[1] = $in{'year'}%400 == 0 ? 29 :
13 $in{'year'}%100 == 0 ? 28 :
14 $in{'year'}%4 == 0 ? 29 : 28;
16 @tm = localtime(time());
17 if ($in{'day'} !~ /^\d+$/ || $in{'day'} < 1 || $in{'year'} !~ /^\d+$/) {
19 $in{'month'} = $tm[4];
20 $in{'year'} = $tm[5]+1900;
22 if ($in{'day'} > $daysin[$in{'month'}]) {
23 $in{'day'} = $daysin[$in{'month'}];
25 $tm = timelocal(0, 0, 12, $in{'day'}, $in{'month'}, $in{'year'});
27 &popup_header($text{'chooser_date'});
28 $uday = &urlize($in{'day'});
29 $umonth = &urlize($in{'month'});
30 $uyear = &urlize($in{'year'});
35 location = "date_chooser.cgi?day=$uday&month="+m.selectedIndex+"&year=$uyear";
39 location = "date_chooser.cgi?day=$uday&month=$umonth&year="+(y.selectedIndex+$in{'year'}-10);
43 opener.dfield.value = d;
44 opener.mfield.selectedIndex = $umonth;
45 opener.yfield.value = $uyear;
49 <form><table border width=100%>
50 <tr> <td colspan=7 align=center><select name=year onChange='newyear(this)'>
52 for($i=$in{'year'}-10; $i<=$in{'year'}+10; $i++) {
53 printf "<option %s>%s\n",
54 $i == $in{'year'} ? 'selected' : '', $i;
56 print "</select> <select name=month onChange='newmonth(this)'>\n";
57 for($i=0; $i<12; $i++) {
58 printf "<option value=%s %s>%s\n",
59 $i, $i == $in{'month'} ? 'selected' : '',
60 $text{"month_".($i+1)};
62 print "</select></td> </tr>\n";
65 for($i=0; $i<7; $i++) {
66 print "<td><b>",$text{"sday_$i"},"</b></td>\n";
70 @first = localtime($tm - ($in{'day'}-1)*24*60*60);
71 $count = -$first[6] + 1;
72 for($y=0; $y<6; $y++) {
74 for($x=0; $x<7; $x++) {
75 if ($count < 1 || $count > $daysin[$in{'month'}]) {
76 print "<td align=center></td>\n";
79 printf "<td align=center %s><a href='' onClick='newday($count)'>%s</a></td>\n", $in{'day'} == $count ? $cb : '', $count;
85 print "</table></form>\n";