kalender

Gesponsorde koppelingen

PHP script bestanden

  1. kalender

« Lees de omschrijving en reacties

kalender.php:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
##########################
# Calendar-script in PHP #
#  Copyright Sytze Loor  #
#  [email protected]  #
#  Last update 07-02-24  #
##########################

// Names for the days of the week (currently Dutch):

$weekday['all'] = array(1=>"ma","di","wo","do","vr","za","zo");
// Names for the months of the year (currently Dutch):
$month['all'] = array(1=>"januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december");

// Check the user-input, is it numeric and accepted by date():
if (($_GET['month'] > 0) && ($_GET['month'] <= 12) && ($_GET['year'] > 1902) && ($_GET['year'] < 2036)) {
    if (is_numeric($_GET['month'])) {
        $month['input'] = $_GET['month'];
    }

    if (is_numeric($_GET['year'])) {
        $year['input'] = $_GET['year'];
    }
}
else {
// If no input of false input, take the current date:
    $month['input'] = date(n);
    $year['input'] = date(Y);
}


// The current year and month:
$month['current'] = date(n);
$year['current'] = date(Y);

// The timestamp from the first day of the current month:
$timestamp['start_month'] = mktime(0,0,0,$month['input'],1,$year['input']);
// Number of days in current month:
$i_days['month'] = date(t,$timestamp['start_month']);
// Sets the first day:
$day['start_day'] = date(j,$timestamp['start_month']);
// Which day of the week is the first day:
$weekday['start_day'] = date(N,$timestamp['start_month']);
// Sets the timestamp for the last day:
$timestamp['last_month'] = mktime(0,0,0,$month['input'],$i_days['month'],$year['input']);
// Sets the last day:
$day['last_day'] = date(j,$timestamp['last_month']);
// Which day of the week is the last day:
$weekday['last_day'] = date(N,$timestamp['last_month']);

// Collect all data (current month only!), from first to last day:
$i = 1;
while ($i <= $i_days['month']) {
    $timestamp['now'] = mktime(0,0,0,$month['input'],$i,$year['input']);
    $weekday['now'] = date(N,$timestamp['now']);    
    $day['all'][$i] = array($i,$month['input'],$year['input'],$weekday['all'][$weekday['now']]);
    $i++;
}


// Collect data from previous month:
$i = $weekday['start_day']-1;
while ($i >= 1) {
    $i_int = 1 - $i;
    $timestamp['now'] = mktime(0,0,0,$month['input'],$i_int,$year['input']);
    $weekday['now'] = date(N,$timestamp['now']);
    $day['now'] = date(j,$timestamp['now']);
    $month['now'] = date(n,$timestamp['now']);
    $year['now'] = date(Y,$timestamp['now']);
    $day['prev']['all'][$i] = array($day['now'],$month['now'],$year['now'],$weekday['all'][$weekday['now']]);
    $i--;
}

// Sort the previous month:
@sort($day['prev']['all']);

// Collect data from next month:
if ($weekday['last_day'] < 7) {
    $i = 1;
    while ($i + $weekday['last_day'] <= 7) {
        $i_int = $day['last_day'] + $i;
        $timestamp['now'] = mktime(0,0,0,$month['input'],$i_int,$year['input']);
        $weekday['now'] = date(N,$timestamp['now']);
        $day['now'] = date(j,$timestamp['now']);
        $month['now'] = date(n,$timestamp['now']);
        $year['now'] = date(Y,$timestamp['now']);
        $day['next']['all'][$i] = array($day['now'],$month['now'],$year['now'],$weekday['all'][$weekday['now']]);
        $i++;
    }
}
else {
    $day['next']['all'] == "";
}


// Set the links to the previous en next month:
$month['prev'] = $month['input'] - 1;
$year['prev'] = $year['input'];
if ($month['input'] == 1) {
    $month['prev'] = 12;
    $year['prev'] = $year['input'] - 1;
}

$month['next'] = $month['input'] + 1;
$year['next'] = $year['input'];
if ($month['input'] == 12) {
    $month['next'] = 1;
    $year['next'] = $year['input'] + 1;
}


// Create a default header:
$header = "";
$header .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$header .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
$header .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n";
$header .= "<title>Kalender</title>\n";
$header .= "<link href=\"default.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
$header .= "</head>\n";

// Create the body:
$body = "";
$body .= "<body>\n";

// Create the table:
$table = "";
$table .= "<table cellspacing=\"0\" border=\"0\">\n";
// The tableheader:
$table .= "<tr>\n";
$table .= "<td class=\"maand_header\" height=\"30\" width=\"25\"><a href=\"kalender.php?month=".$month['prev']."&amp;year=".$year['prev']."\">&lt;</a></td>\n";
$table .= "<td class=\"maand_header\" height=\"30\" colspan=\"6\">".ucfirst($month['all'][$month['input']])." ".$year['input']."</td>\n";
$table .= "<td class=\"maand_header\" height=\"30\" width=\"25\"><a href=\"kalender.php?month=".$month['next']."&amp;year=".$year['next']."\">&gt;</a></td>\n";
$table .= "</tr>\n";
// The days of the week:
$table .= "<tr>\n";
$table .= "<td class=\"dag_header\" height=\"30\" width=\"25\">Wk:</td>\n";
$i = 1;
while ($i <= count($weekday['all'])) {
    $table .= "<td class=\"dag_header\" height=\"30\" width=\"25\">".ucfirst($weekday['all'][$i])."</td>\n";
    $i++;
}

// Total days to display this month:
$day['total_prev'] = count($day['prev']['all']);
$day['total_all'] = count($day['all']);
$day['total_next'] = count($day['next']['all']);
$day['total'] = $day['total_prev'] + $day['total_all'] + $day['total_next'];
// Create a array with the days in the correct order:
$i = 0;
$i_int = 0;
while ($i_int <= $day['total_prev']) {
    $day['display'][$i] = $day['prev']['all'][$i_int];
    $i_int++;
    $i++;
}

$i_int = 0;
while ($i_int <= $day['total_all']) {
    $day['display'][$i] = $day['all'][$i_int];
    $i_int++;
    $i++;
}

if ($weekday['last_day'] < 7) {
    $i_int = 0;
    while ($i_int <= $day['total_next']) {
        $day['display'][$i] = $day['next']['all'][$i_int];
        $i_int++;
        $i++;
    }
}


// Display the days:
$i = 0;
while ($i < count($day['display'])) {
    $i_int = 0;
    if (($day['display'][$i][0] == "") && ($day['display'][$i][3] == "")) {
        $timestamp['now'] = mktime(0,0,0,$day['display'][6][1],1,$day['display'][6][2]);
    }
else {
        $timestamp['now'] = mktime(0,0,0,$day['display'][$i][1],$day['display'][$i][0],$day['display'][$i][2]);
    }

    $week['now'] = date(W,$timestamp['now']);
    $table .= "<tr>\n";
    $table .= "<td class=\"weken_tekst\" height=\"30\" width=\"25\">".$week['now']."</td>\n";
    while ($i_int < 7) {
        if (is_array($day['display'][$i])) {
            if ($day['display'][$i][1] == $month['input']) {
                $style = "dagen_dezemaand";
            }
else {
                $style = "dagen_anderemaand";
            }

            if (($day['display'][$i][0] == date(j)) && ($day['display'][$i][1] == date(m)) && ($year['input'] == $year['current'])) {
                $style = "dagen_vandaag";
            }

            $table .= "<td class=\"".$style."\" height=\"30\" width=\"25\">".$day['display'][$i][0]."</td>\n";
            $i_int++;
        }

        $i++;
    }

    $table .= "</tr>\n";
}


// The tablefooter:
$table .= "<tr>\n";
$table .= "<td class=\"maand_header\" height=\"30\" width=\"25\">&nbsp;</td>\n";
$table .= "<td class=\"maand_header\" height=\"30\" colspan=\"6\"><a href=\"kalender.php?month=".$month['current']."&amp;year=".$year['current']."\">naar huidige maand</a></td>\n";
$table .= "<td class=\"maand_header\" height=\"30\" width=\"25\">&nbsp;</td>\n";
$table .= "</tr>\n";
$table .= "</table>\n";


$body .= $table;
$body .= "</body>\n";

// Create a default footer:
$footer = "";
$footer .= "</html>\n";

// Display the header, body and footer:
echo $header;
echo $body;
echo $footer;
?>


default.css:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
/* Standaard CSS */
body,td,th {
    font-family: Tahoma, Arial, Helvetica, sans-serif;
    font-size: 11px;
    color: #333333;
    padding: 4px;
}
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
a:link {
    color: #006699;
}
a:visited {
    color: #006699;
}
a:hover {
    color: #FF9900;
}
a:active {
    color: #FF9900;
}
.maand_header {
    font-weight: bold;
    text-align: center;
}
.dag_header {
    font-style: italic;
    text-align: center;
    background-color: #EEE;
}
.dagen_dezemaand {
    text-align: center;
}
.weken_tekst {
    text-align: center;
    background-color: #EEE;
}
.dagen_anderemaand {
    text-align: center;
    color: #666666;
    background-color: #999999;
}
.dagen_vandaag {
    text-align: center;
    background-color: #FF0000;
}

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.