#!/usr/local/bin/perl # date_chooser.cgi # Display a table of days in the current month BEGIN { push(@INC, ".."); }; use WebminCore; use Time::Local; $trust_unknown_referers = 1; &init_config(); &ReadParse(); @daysin = ( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); $daysin[1] = $in{'year'}%400 == 0 ? 29 : $in{'year'}%100 == 0 ? 28 : $in{'year'}%4 == 0 ? 29 : 28; @tm = localtime(time()); if ($in{'day'} !~ /^\d+$/ || $in{'day'} < 1 || $in{'year'} !~ /^\d+$/) { $in{'day'} = $tm[3]; $in{'month'} = $tm[4]; $in{'year'} = $tm[5]+1900; } if ($in{'day'} > $daysin[$in{'month'}]) { $in{'day'} = $daysin[$in{'month'}]; } $tm = timelocal(0, 0, 12, $in{'day'}, $in{'month'}, $in{'year'}); &popup_header($text{'chooser_date'}); $uday = &urlize($in{'day'}); $umonth = &urlize($in{'month'}); $uyear = &urlize($in{'year'}); print < function newmonth(m) { location = "date_chooser.cgi?day=$uday&month="+m.selectedIndex+"&year=$uyear"; } function newyear(y) { location = "date_chooser.cgi?day=$uday&month=$umonth&year="+(y.selectedIndex+$in{'year'}-10); } function newday(d) { opener.dfield.value = d; opener.mfield.selectedIndex = $umonth; opener.yfield.value = $uyear; close(); }
\n"; print "\n"; for($i=0; $i<7; $i++) { print "\n"; } print "\n"; @first = localtime($tm - ($in{'day'}-1)*24*60*60); $count = -$first[6] + 1; for($y=0; $y<6; $y++) { print "\n"; for($x=0; $x<7; $x++) { if ($count < 1 || $count > $daysin[$in{'month'}]) { print "\n"; } else { printf "\n", $in{'day'} == $count ? $cb : '', $count; } $count++; } print "\n"; } print "
",$text{"sday_$i"},"
%s
\n"; &popup_footer();