1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
|
<?php
/**
* cal.php (LX' Calendar module)
*
* # shows a calendar of the current month
* # highlights the current day
* # can be styled by referring to CSS-ID 'cal'
*
*****************************************************
*
* Changelog:
* 2005-05-16: fixed bug when months start on a sunday
* 2005-04-12: first version
*
*****************************************************
*/
// get current date
$datum = getdate();
// sunday should be the seventh day of the week, not the zeroth
if ( $datum [ 'wday' ] == 0 ) $datum [ 'wday' ] = 7;
// table head
$kalender = <<<Ausgabe
<table cellspacing="0" cellpadding="0" class="cal">
<tr>
<th colspan="7">${datum['month']} ${datum['year']}</th>
</tr>
<tr>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
</tr>
<tr>
Ausgabe;
$tag = 1;
// get first of month
$first = getdate ( mktime ( 0, 0, 0, $datum [ 'mon' ], 1, $datum [ 'year' ] ) );
// empty table cells until first day of month
if ( $first [ 'wday' ] == 0 ) $first [ 'wday' ] = 7;
for ( $wday = 1; $wday < $first [ 'wday' ]; $wday++ )
{
$kalender .= " <td></td>\n";
}
// fill rest of the cells of the first week
for ( ; $wday <= 7; $wday++)
{
// current date
if ( $datum [ 'mday' ] == $tag )
$kalender .= " <td><em><b>$tag</b></em></td>\n";
// weekend
else if ( $wday == 6 || $wday == 7 )
$kalender .= " <td><b>$tag</b></td>\n";
// every other day
else
$kalender .= " <td>$tag</td>\n";
$tag++;
}
$kalender .= "</tr>\n";
// fill in days for the rest of the month
while ( $tag < 32 )
{
$kalender .= "<tr>\n";
for ( $wday = 0; $wday < 7; $wday++ )
{
// empty cells filling the final week
if ( $tag >= 32 )
$kalender .= " <td></td>\n";
// current day
else if ( $datum [ 'mday' ] == $tag )
$kalender .= " <td><em><b>$tag</b></em></td>\n";
// weekend
else if ( $wday == 5 || $wday == 6 )
$kalender .= " <td><b>$tag</b></td>\n";
// every other day
else
$kalender .= " <td>$tag</td>\n";
$tag++;
}
$kalender .= "</tr>\n";
}
$kalender .= "</table>";
// if month has less than 31 days, empty the superfluous cells
for ( $i = 35; $i > 28; $i-- )
{
if ( !checkdate ( $datum [ 'mon' ], $i, $datum [ 'year' ] ) )
$kalender = str_replace($i, " ", $kalender);
}
// print out calendar
echo $kalender;
?> |