Calendar - Version 1.1.2

Version Description

Download this release

Release Info

Developer KieranOShea
Plugin Icon 128x128 Calendar
Version 1.1.2
Comparing to
See all releases

Version 1.1.2

readme.txt ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Calendar ===
2
+ Contributors: KieranOShea
3
+ Donate link: http://www.kieranoshea.com
4
+ Tags: calendar, dates, times, events
5
+ Requires at least: 2.0
6
+ Tested up to: 2.1
7
+ Stable tag: 1.1.2
8
+
9
+ A simple but effective Calendar plugin for WordPress that allows you to
10
+ manage your events and appointments and display them to the world.
11
+
12
+ == Description ==
13
+
14
+ A simple but effective Calendar plugin for WordPress that allows you to
15
+ manage your events and appointments and display them to the world on your
16
+ website.
17
+
18
+ Features:
19
+
20
+ * Monthly view of events
21
+ * Mouse-over details for each event
22
+ * Events can have a timestamp (optional)
23
+ * Events can span more than one day
24
+ * Multiple events per day possible
25
+ * Events can repeat on a weekly, monthly or yearly basis
26
+ * Repeats can occur indefinitely or a limited number of times
27
+ * User and search friendly URL scheme
28
+ * Easy to use events manager in admin dashboard
29
+
30
+
31
+ == Installation ==
32
+
33
+ The installation process is simple and only takes a few minutes. Please read
34
+ these steps carefully though to ensure a trouble free install.
35
+
36
+ Installing:
37
+
38
+ 1. Ensure you have a permalink structure defined in your WordPress settings.
39
+ You can do this by selecting the appropriate option in the WP admin panel
40
+
41
+ Options -> Permalinks
42
+
43
+ If you already have a permalink structure enabled, there is no need to
44
+ enable it again
45
+
46
+ 2. Once you have enabled permalinks, you should have a file called .htaccess
47
+ in the root directory of your blog. Check it is there - this may be
48
+ difficult on Windows due to the way files are displayed.
49
+
50
+ 3. Add the following lines to your .htaccess file to enable the nice URLs
51
+ the calendar uses. The calendar WILL NOT WORK properly without these lines!
52
+
53
+ After the line containing:
54
+ RewriteBase
55
+
56
+ Add:
57
+ RewriteRule ^calendar/([^/\.]+)/([^/\.]+)/?$ wp-calendar.php?year=$1&month=$2 [QSA,L]
58
+ RewriteRule ^calendar/?$ wp-calendar.php [QSA,L]
59
+
60
+ Save and upload the .htaccess file to your install.
61
+
62
+ 4. Upload the other included files into the same directories as they are in
63
+ the package
64
+
65
+ 5. Visit the plugins page of your dashboard and activate Calendar 1.1.2 by
66
+ Kieran O'Shea
67
+
68
+ 6. Visit Manage -> Calendar in the dashboard to initialise the database and
69
+ start adding calendar events into your system
70
+
71
+ 7. Visit your blog URL /calendar to see your calendar in action
72
+
73
+
74
+ Uninstalling:
75
+
76
+ 1. Deactivate the plugin on the plugins page of your blog dashboard
77
+
78
+ 2. Delete the uploaded files for the plugin
79
+
80
+ 3. Remove the added lines from the .htaccess file
81
+
82
+ 4. Drop the wp_calendar table from your database
83
+
84
+ == Frequently Asked Questions ==
85
+
86
+ = How do I modify the style and layout of the calendar page? =
87
+
88
+ You can modify the look and layout of the public calendar page by editing
89
+ wp-calendar.php Note the style block it contains and line of php calling
90
+ the display of the actual calendar.
91
+
92
+ = Can I removing the link to you? =
93
+
94
+ If you want to remove the text and link to my site from underneath the
95
+ calendar you can do so in the calendar.php file. Please only do this if
96
+ you have to though as it will stop other people from finding out how to
97
+ get their own copy. You could always link to me in your blogroll or in
98
+ your site footer as an alternative if you prefer. Ultimately it's your
99
+ site however and if you don't want to link to me you are under no
100
+ obligation to do so.
101
+
102
+ == Screenshots ==
103
+
104
+ There are no screenshots available for the Calednar at this time, however you
105
+ can get an idea of how it looks from the [Calendar on my site](http://www.kieranoshea.com/calendar "Personal Website of Kieran O'Shea")
wp-admin/edit-calendar.php ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Author: Kieran O'Shea
4
+ Author URI: http://www.kieranoshea.com
5
+ Description: Admin panel for the calendar plugin
6
+ Version: 1.1.2
7
+ */
8
+
9
+ require_once('admin.php');
10
+ $title = __('Calendar');
11
+ $parent_file = 'edit.php';
12
+
13
+ // Global variable cleanup.
14
+ $edit = $create = $save = $delete = false;
15
+
16
+ // How to control the app
17
+ $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
18
+ $event_id = !empty($_REQUEST['event_id']) ? $_REQUEST['event_id'] : '';
19
+
20
+ // Messages for the user
21
+ $debugText = '';
22
+ $messages = '';
23
+
24
+
25
+ require_once('admin-header.php');
26
+ //get_currentuserinfo();
27
+ ?>
28
+
29
+ <style type="text/css">
30
+ <!--
31
+ .error
32
+ {
33
+ background: lightcoral;
34
+ border: 1px solid #e64f69;
35
+ margin: 1em 5% 10px;
36
+ padding: 0 1em 0 1em;
37
+ }
38
+
39
+ .center { text-align: center; }
40
+ .right { text-align: right; }
41
+ .left { text-align: left; }
42
+ .top { vertical-align: top; }
43
+ .bold { font-weight: bold; }
44
+ .private { color: #e64f69; }
45
+ //-->
46
+ </style>
47
+
48
+ <?php
49
+
50
+ //
51
+ // Lets see if this is first run and create us a table if it is!
52
+ //
53
+ $tableExists = false;
54
+ $tables = $wpdb->get_results("show tables;");
55
+
56
+ foreach ( $tables as $table )
57
+ {
58
+ foreach ( $table as $value )
59
+ {
60
+ if ( $value == WP_CALENDAR_TABLE )
61
+ {
62
+ $tableExists=true;
63
+ break;
64
+ }
65
+ }
66
+ }
67
+
68
+ if ( !$tableExists )
69
+ {
70
+ $sql = "CREATE TABLE `" . WP_CALENDAR_TABLE . "` (
71
+ `event_id` INT(11) NOT NULL AUTO_INCREMENT ,
72
+ `event_begin` DATE NOT NULL ,
73
+ `event_end` DATE NOT NULL ,
74
+ `event_title` VARCHAR(30) NOT NULL ,
75
+ `event_desc` VARCHAR(255) NOT NULL ,
76
+ `event_time` TIME ,
77
+ `event_recur` CHAR(1) ,
78
+ `event_repeats` INT(3) ,
79
+ PRIMARY KEY ( `event_id` )
80
+ )";
81
+ $wpdb->get_results($sql);
82
+
83
+ echo "<div class=\"updated\"><p><strong>Greetings</strong><br /><br />
84
+ This is the first time you have visited the admin page for calendar. The plugin has created a database table
85
+ for you (" . WP_CALENDAR_TABLE . ") and all your events will be stored there. If you want
86
+ to remove the data, make sure to delete that table after deactivating the plugin.
87
+ This plugin's website is at <a href=\"http://www.kieranoshea.com/programming\">http://www.kieranoshea.com/programming</a></p></div>";
88
+ }
89
+ //
90
+ // First run stage finished
91
+ //
92
+
93
+
94
+ //
95
+ // Lets deal with the various functions
96
+ //
97
+ if ( $action == 'add' )
98
+ {
99
+ $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
100
+ $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
101
+ $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
102
+ $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
103
+ $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
104
+ $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
105
+ $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
106
+
107
+ // Deal with the fools who have left magic quotes turned on
108
+ if ( ini_get('magic_quotes_gpc') )
109
+ {
110
+ $title = stripslashes($title);
111
+ $desc = stripslashes($desc);
112
+ $begin = stripslashes($begin);
113
+ $end = stripslashes($end);
114
+ $time = stripslashes($time);
115
+ $recur = stripslashes($recur);
116
+ $repeats = stripslashes($repeats);
117
+ }
118
+
119
+ $sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
120
+ . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
121
+ . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "'";
122
+
123
+ $wpdb->get_results($sql);
124
+
125
+ $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
126
+ . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' AND event_recur='" . mysql_escape_string($recur) . "' AND event_repeats='" . mysql_escape_string($repeats) . "' LIMIT 1";
127
+ $result = $wpdb->get_results($sql);
128
+
129
+ if ( empty($result) || empty($result[0]->event_id) )
130
+ {
131
+ ?>
132
+ <div class="error"><p><strong>Error:</strong> For some bizare reason your event was not added. Why not try again </p></div>
133
+ <?php
134
+ }
135
+ else
136
+ {
137
+ ?>
138
+ <div class="updated"><p>Event added. It will now show in your calendar.</p></div>
139
+ <?php
140
+ }
141
+ }
142
+ elseif ( $action == 'edit_save' )
143
+ {
144
+ $title = !empty($_REQUEST['event_title']) ? $_REQUEST['event_title'] : '';
145
+ $desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
146
+ $begin = !empty($_REQUEST['event_begin']) ? $_REQUEST['event_begin'] : '';
147
+ $end = !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : '';
148
+ $time = !empty($_REQUEST['event_time']) ? $_REQUEST['event_time'] : '';
149
+ $recur = !empty($_REQUEST['event_recur']) ? $_REQUEST['event_recur'] : '';
150
+ $repeats = !empty($_REQUEST['event_repeats']) ? $_REQUEST['event_repeats'] : '';
151
+
152
+ // Deal with the fools who have left magic quotes turned on
153
+ if ( ini_get('magic_quotes_gpc') )
154
+ {
155
+ $title = stripslashes($title);
156
+ $desc = stripslashes($desc);
157
+ $begin = stripslashes($begin);
158
+ $end = stripslashes($end);
159
+ $time = stripslashes($time);
160
+ $recur = stripslashes($recur);
161
+ $repeats = stripslashes($repeats);
162
+ }
163
+
164
+ if ( empty($event_id) )
165
+ {
166
+ ?>
167
+ <div class="error"><p><strong>Failure:</strong> You can't update an event if you haven't submitted an event id</p></div>
168
+ <?php
169
+ }
170
+ else
171
+ {
172
+ $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
173
+ . "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
174
+ . "', event_end='" . mysql_escape_string($end) . "', event_time='" . mysql_escape_string($time) . "', event_recur='" . mysql_escape_string($recur) . "', event_repeats='" . mysql_escape_string($repeats) . "'" . " WHERE event_id='" . mysql_escape_string($event_id) . "'";
175
+
176
+ $wpdb->get_results($sql);
177
+
178
+ $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_title='" . mysql_escape_string($title) . "'"
179
+ . " AND event_desc='" . mysql_escape_string($desc) . "' AND event_begin='" . mysql_escape_string($begin) . "' AND event_end='" . mysql_escape_string($end) . "' AND event_recur='" . mysql_escape_string($recur) . "' AND event_repeats='" . mysql_escape_string($repeats) . "' LIMIT 1";
180
+ $result = $wpdb->get_results($sql);
181
+
182
+ if ( empty($result) || empty($result[0]->event_id) )
183
+ {
184
+ ?>
185
+ <div class="error"><p><strong>Failure:</strong> For some reason the event didn't update. Why not try again. </p></div>
186
+ <?php
187
+ }
188
+ else
189
+ {
190
+ ?>
191
+ <div class="updated"><p>Event updated successfully</p></div>
192
+ <?php
193
+ }
194
+ }
195
+ }
196
+ elseif ( $action == 'delete' )
197
+ {
198
+ if ( empty($event_id) )
199
+ {
200
+ ?>
201
+ <div class="error"><p><strong>Error:</strong> Good Lord you gave me nothing to delete, nothing I tell you!</p></div>
202
+ <?php
203
+ }
204
+ else
205
+ {
206
+ $sql = "DELETE FROM " . WP_CALENDAR_TABLE . " WHERE event_id='" . mysql_escape_string($event_id) . "'";
207
+ $wpdb->get_results($sql);
208
+
209
+ $sql = "SELECT event_id FROM " . WP_CALENDAR_TABLE . " WHERE event_id='" . mysql_escape_string($event_id) . "'";
210
+ $result = $wpdb->get_results($sql);
211
+
212
+ if ( empty($result) || empty($result[0]->event_id) )
213
+ {
214
+ ?>
215
+ <div class="updated"><p>Event deleted successfully</p></div>
216
+ <?php
217
+ }
218
+ else
219
+ {
220
+ ?>
221
+ <div class="error"><p><strong>Error:</strong> For some bizare reason the event could not be deleted. Why not try again.</p></div>
222
+ <?php
223
+
224
+ }
225
+ }
226
+ }
227
+ //
228
+ // End of the functionality definitions
229
+ //
230
+
231
+ ?>
232
+
233
+ <div class="wrap">
234
+ <?php
235
+ if ( $action == 'edit' )
236
+ {
237
+ ?>
238
+ <h2><?php _e('Edit Event'); ?></h2>
239
+ <?php
240
+ if ( empty($event_id) )
241
+ {
242
+ echo "<div class=\"error\"><p>Good lord you didn't provide an event id to edit, what were you thinking?</p></div>";
243
+ }
244
+ else
245
+ {
246
+ wp_events_edit_form('edit_save', $event_id);
247
+ }
248
+ }
249
+ else
250
+ {
251
+ ?>
252
+ <h2><?php _e('Add Event'); ?></h2>
253
+ <?php wp_events_edit_form(); ?>
254
+
255
+ <h2><?php _e('Manage Events'); ?></h2>
256
+ <?php
257
+ wp_events_display_list();
258
+ }
259
+ ?>
260
+ </div>
261
+
262
+ <?php
263
+ include('admin-footer.php');
264
+
265
+
266
+ /**
267
+ * Display code for the listing
268
+ */
269
+ function wp_events_display_list()
270
+ {
271
+ global $wpdb;
272
+
273
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " ORDER BY event_begin DESC");
274
+
275
+ if ( !empty($events) )
276
+ {
277
+ ?>
278
+ <table width="100%" cellpadding="3" cellspacing="3">
279
+ <tr>
280
+ <th scope="col"><?php _e('ID') ?></th>
281
+ <th scope="col"><?php _e('Title') ?></th>
282
+ <th scope="col"><?php _e('Description') ?></th>
283
+ <th scope="col"><?php _e('Start Date') ?></th>
284
+ <th scope="col"><?php _e('End Date') ?></th>
285
+ <th scope="col"><?php _e('Recurs') ?></th>
286
+ <th scope="col"><?php _e('Repeats') ?></th>
287
+ <th scope="col"><?php _e('Edit') ?></th>
288
+ <th scope="col"><?php _e('Delete') ?></th>
289
+ </tr>
290
+ <?php
291
+ $class = '';
292
+ foreach ( $events as $event )
293
+ {
294
+ $class = ($class == 'alternate') ? '' : 'alternate';
295
+ ?>
296
+ <tr class="<?php echo $class; ?>">
297
+ <th scope="row"><?php echo $event->event_id; ?></th>
298
+ <td><?php echo $event->event_title; ?></td>
299
+ <td><?php echo $event->event_desc; ?></td>
300
+ <td><?php echo $event->event_begin; ?></td>
301
+ <td><?php echo $event->event_end; ?></td>
302
+ <td>
303
+ <?php
304
+ if ($event->event_recur == 'S') { echo 'Never'; }
305
+ else if ($event->event_recur == 'W') { echo 'Weekly'; }
306
+ else if ($event->event_recur == 'M') { echo 'Monthly'; }
307
+ else if ($event->event_recur == 'Y') { echo 'Yearly'; }
308
+ ?>
309
+ </td>
310
+ <td>
311
+ <?php
312
+ if ($event->event_recur == 'S') { echo 'N/A'; }
313
+ else if ($event->event_repeats == 0) { echo 'Forever'; }
314
+ else if ($event->event_repeats > 0) { echo $event->event_repeats.' Times'; }
315
+ ?>
316
+ </td>
317
+ <td><a href="edit-calendar.php?action=edit&amp;event_id=<?php echo $event->event_id;?>" class='edit'><?php echo __('Edit'); ?></a></td>
318
+ <td><a href="edit-calendar.php?action=delete&amp;event_id=<?php echo $event->event_id;?>" class="delete" onclick="return confirm('Are you sure you want to delete this event?')"><?php echo __('Delete'); ?></a></td>
319
+ </tr>
320
+ <?php
321
+ }
322
+ ?>
323
+ </table>
324
+ <?php
325
+ }
326
+ else
327
+ {
328
+ ?>
329
+ <p><?php _e("There are no events in the database!") ?></p>
330
+ <?php
331
+ }
332
+ }
333
+
334
+
335
+ /**
336
+ * Display code for the add/edit form
337
+ */
338
+ function wp_events_edit_form($mode='add', $event_id=false)
339
+ {
340
+ global $wpdb;
341
+ $data = false;
342
+
343
+ if ( $event_id !== false )
344
+ {
345
+ if ( intval($event_id) != $event_id )
346
+ {
347
+ echo "<div class=\"error\"><p>Bad Monkey! No banana!</p></div>";
348
+ return;
349
+ }
350
+ else
351
+ {
352
+ $data = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_id='" . mysql_escape_string($event_id) . "' LIMIT 1");
353
+ if ( empty($data) )
354
+ {
355
+ echo "<div class=\"error\"><p>An event with that ID couldn't be found</p></div>";
356
+ return;
357
+ }
358
+ $data = $data[0];
359
+ }
360
+ }
361
+
362
+ ?>
363
+ <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
364
+ <input type="hidden" name="action" value="<?php echo $mode?>">
365
+ <input type="hidden" name="event_id" value="<?php echo $event_id?>">
366
+
367
+ <div id="item_manager">
368
+ <div style="float: left; width: 98%; clear: both;" class="top">
369
+ <!-- List URL -->
370
+ <fieldset class="small"><legend><?php _e('Event Title'); ?></legend>
371
+ <input type="text" name="event_title" class="input" size=30
372
+ value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_title); ?>" />
373
+ </fieldset>
374
+
375
+ <fieldset class="small"><legend><?php _e('Event Description'); ?></legend>
376
+ <input type="text" name="event_desc" class="input" size=50
377
+ value="<?php if ( !empty($data) ) echo htmlspecialchars($data->event_desc); ?>" />
378
+ </fieldset>
379
+
380
+ <fieldset class="small"><legend><?php _e('Start Date'); ?></legend>
381
+ <input type="text" name="event_begin" class="input" size=12
382
+ value="
383
+ <?php
384
+ if ( !empty($data) )
385
+ {
386
+ echo htmlspecialchars($data->event_begin);
387
+ }
388
+ else
389
+ {
390
+ echo date("Y-m-d");
391
+ }
392
+ ?>
393
+ " />
394
+ </fieldset>
395
+
396
+ <fieldset class="small"><legend><?php _e('End Date'); ?></legend>
397
+ <input type="text" name="event_end" class="input" size=12
398
+ value="
399
+ <?php
400
+ if ( !empty($data) )
401
+ {
402
+ echo htmlspecialchars($data->event_end);
403
+ }
404
+ else
405
+ {
406
+ echo date("Y-m-d");
407
+ }
408
+ ?>" />
409
+ </fieldset>
410
+
411
+ <fieldset class="small"><legend><?php _e('Time (optional, set blank if not required)'); ?></legend>
412
+ <input type="text" name="event_time" class="input" size=12
413
+ value="
414
+ <?php
415
+ if ( !empty($data) )
416
+ {
417
+ if ($data->event_time == "00:00:00")
418
+ {
419
+ echo '';
420
+ }
421
+ else
422
+ {
423
+ echo date("H:i",strtotime(htmlspecialchars($data->event_time)));
424
+ }
425
+ }
426
+ else
427
+ {
428
+ echo date("H:i");
429
+ }
430
+ ?>" />
431
+ </fieldset>
432
+
433
+ <fieldset class="small"><legend><?php _e('Recurring Events: '); ?></legend>
434
+ <?php
435
+ if ($data->event_repeats != NULL)
436
+ {
437
+ $repeats = $data->event_repeats;
438
+ }
439
+ else
440
+ {
441
+ $repeats = 0;
442
+ }
443
+
444
+ if ($data->event_recur == "S")
445
+ {
446
+ $selected_s = 'selected="selected"';
447
+ }
448
+ else if ($data->event_recur == "W")
449
+ {
450
+ $selected_w = 'selected="selected"';
451
+ }
452
+ else if ($data->event_recur == "M")
453
+ {
454
+ $selected_m = 'selected="selected"';
455
+ }
456
+ else if ($data->event_recur == "Y")
457
+ {
458
+ $selected_y = 'selected="selected"';
459
+ }
460
+ ?>
461
+ Repeats for
462
+ <input type="text" name="event_repeats" class="input" size=1 value="
463
+ <?php echo $repeats; ?>
464
+ " />
465
+ <select name="event_recur" class="input">
466
+ <option class="input" <?php echo $selected_s; ?> value="S">None</option>
467
+ <option class="input" <?php echo $selected_w; ?> value="W">Weeks</option>
468
+ <option class="input" <?php echo $selected_m; ?> value="M">Months</option>
469
+ <option class="input" <?php echo $selected_y; ?> value="Y">Years</option>
470
+ </select><br />
471
+ Entering 0 means forever. Where the recurrance interval <br />
472
+ is left at none, the event will not reoccur.
473
+ </fieldset>
474
+ <br />
475
+ <input type="submit" name="save" class="button bold" value="Save &raquo;" />
476
+ </div>
477
+ <div style="clear:both; height:1px;">&nbsp;</div>
478
+ </div>
479
+ </form>
480
+ <?php
481
+ }
482
+
483
+ ?>
wp-calendar.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Calendar
4
+ Plugin URI: http://www.kieranoshea.com/programming
5
+ Description: This plugin allows you to display a calendar of all your events an\d appointments as a page on your site.
6
+ Author: Kieran O'Shea
7
+ Version: 1.1.2
8
+ Author URI: http://www.kieranoshea.com
9
+ */
10
+
11
+ // Require the standard WordPress header
12
+ require(dirname(__FILE__).'/wp-blog-header.php');
13
+
14
+ // Begin content of page
15
+
16
+ get_header();
17
+ ?>
18
+
19
+ <style type="text/css">
20
+ span.calnk a {
21
+ text-decoration:none;
22
+ color:#000000;
23
+ border-bottom:1px dotted #000000;
24
+ }
25
+ span.calnk a:hover {
26
+ text-decoration:none;
27
+ color:#000000;
28
+ border-bottom:1px dotted #000000;
29
+ }
30
+ span.calnk {
31
+ position:relative;
32
+ }
33
+ span.calnk a span {
34
+ display:none;
35
+ }
36
+ span.calnk a:hover span {
37
+ color:#333333;
38
+ background:#F6F79B;
39
+ display:block;
40
+ position:absolute;
41
+ margin-top:1px;
42
+ padding:5px;
43
+ width:150px;
44
+ z-index:100;
45
+ }
46
+ </style>
47
+
48
+ <h2>Calendar</h2>
49
+
50
+ <?php echo calendar(); ?>
51
+
52
+ <?php get_sidebar(); ?>
53
+ <?php get_footer(); ?>
wp-content/plugins/calendar.php ADDED
@@ -0,0 +1,508 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Calendar
4
+ Plugin URI: http://www.kieranoshea.com/
5
+ Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
6
+ Author: Kieran O'Shea
7
+ Author URI: http://www.kieranoshea.com
8
+ Version: 1.1.2
9
+ */
10
+
11
+ // Define the table for the plugin.
12
+ define('WP_CALENDAR_TABLE', $table_prefix . 'calendar');
13
+
14
+ // Puts the events management link under manage
15
+ function wp_events_admin_menu($content)
16
+ {
17
+ global $submenu;
18
+ $submenu['edit.php'][50] = array(__('Calendar'), 9, 'edit-calendar.php');
19
+ }
20
+ add_action('admin_menu', 'wp_events_admin_menu');
21
+
22
+
23
+ // Now we define the tonne of functions the calendar needs to run
24
+
25
+ function next_link($cur_year,$cur_month)
26
+ {
27
+ $mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec');
28
+
29
+ $next_year = $cur_year + 1;
30
+
31
+ if ($cur_month == 12)
32
+ {
33
+ return '<a href="' . get_bloginfo('wpurl') . '/calendar/' . $next_year . '/jan">Next &raquo;</a>';
34
+ }
35
+ else
36
+ {
37
+ $next_month = $cur_month + 1;
38
+ $month = $mod_rewrite_months[$next_month];
39
+ return '<a href="' . get_bloginfo('wpurl') . '/calendar/' . $cur_year . '/' . $month . '">Next &raquo;</a>';
40
+ }
41
+ }
42
+
43
+ function prev_link($cur_year,$cur_month)
44
+ {
45
+ $mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec');
46
+
47
+ $last_year = $cur_year - 1;
48
+
49
+ if ($cur_month == 1)
50
+ {
51
+ return '<a href="' . get_bloginfo('wpurl') . '/calendar/'. $last_year .'/dec">&laquo; Prev</a>';
52
+ }
53
+ else
54
+ {
55
+ $next_month = $cur_month - 1;
56
+ $month = $mod_rewrite_months[$next_month];
57
+ return '<a href="' . get_bloginfo('wpurl') . '/calendar/' . $cur_year . '/' . $month . '">&laquo; Prev</a>';
58
+ }
59
+ }
60
+
61
+ function grab_events($y,$m,$d)
62
+ {
63
+ global $wpdb;
64
+ $date = $y . '-' . $m . '-' . $d;
65
+ $output = '';
66
+
67
+ // Firstly we check for conventional events. These will form the first instance of a recurring event
68
+ // or the only instance of a one-off event
69
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_begin <= '$date' AND event_end >= '$date' AND event_recur = 'S' ORDER BY event_id");
70
+ if (!empty($events))
71
+ {
72
+ foreach($events as $event)
73
+ {
74
+ if ($event->event_time == "00:00:00")
75
+ {
76
+ $event_time = '';
77
+ }
78
+ else
79
+ {
80
+ $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
81
+ }
82
+ //$output .= '<br />* <a style="color:#333333; border-bottom: 1px dotted #333333;" title="' . $event_time . $event->event_desc . '">' . $event->event_title . '</a>';
83
+ $output .= '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
84
+ }
85
+ }
86
+
87
+ // Even if there were results for that query, we may still have events recurring
88
+ // from the past on this day. We now methodically check the for these events
89
+
90
+ /*
91
+ The yearly code - easy because the day and month will be the same, so we return all yearly
92
+ events that match the date part. Out of these we show those with a repeat of 0, and fast-foward
93
+ a number of years for those with a value more than 0. Those that land in the future are displayed.
94
+ */
95
+
96
+
97
+ // Deal with forever recurring year events
98
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0 ORDER BY event_id");
99
+
100
+ if (!empty($events))
101
+ {
102
+ foreach($events as $event)
103
+ {
104
+ // This is going to get complex so lets setup what we would place in for
105
+ // an event so we can drop it in with ease
106
+ if ($event->event_time == "00:00:00")
107
+ {
108
+ $event_time = '';
109
+ }
110
+ else
111
+ {
112
+ $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
113
+ }
114
+ $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
115
+
116
+ // Technically we don't care about the years, but we need to find out if the
117
+ // event spans the turn of a year so we can deal with it appropriately.
118
+ $year_begin = date('Y',strtotime($event->event_begin));
119
+ $year_end = date('Y',strtotime($event->event_end));
120
+
121
+ if ($year_begin == $year_end)
122
+ {
123
+ if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) &&
124
+ date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
125
+ {
126
+ $output .= $event_out;
127
+ }
128
+ }
129
+ else if ($year_begin < $year_end)
130
+ {
131
+ if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) ||
132
+ date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
133
+ {
134
+ $output .= $event_out;
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ // Now the ones that happen a finite number of times
141
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (EXTRACT(YEAR FROM '$date')-EXTRACT(YEAR FROM event_begin)) <= event_repeats ORDER BY event_id");
142
+ if (!empty($events))
143
+ {
144
+ foreach($events as $event)
145
+ {
146
+ // This is going to get complex so lets setup what we would place in for
147
+ // an event so we can drop it in with ease
148
+ if ($event->event_time == "00:00:00")
149
+ {
150
+ $event_time = '';
151
+ }
152
+ else
153
+ {
154
+ $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
155
+ }
156
+ $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
157
+
158
+ // Technically we don't care about the years, but we need to find out if the
159
+ // event spans the turn of a year so we can deal with it appropriately.
160
+ $year_begin = date('Y',strtotime($event->event_begin));
161
+ $year_end = date('Y',strtotime($event->event_end));
162
+
163
+ if ($year_begin == $year_end)
164
+ {
165
+ if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) &&
166
+ date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
167
+ {
168
+ $output .= $event_out;
169
+ }
170
+ }
171
+ else if ($year_begin < $year_end)
172
+ {
173
+ if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) ||
174
+ date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
175
+ {
176
+ $output .= $event_out;
177
+ }
178
+ }
179
+ }
180
+ }
181
+
182
+ /*
183
+ The monthly code - just as easy because as long as the day of the month is correct, then we
184
+ show the event
185
+ */
186
+
187
+ // The monthly events that never stop recurring
188
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0 ORDER BY event_id");
189
+ if (!empty($events))
190
+ {
191
+ foreach($events as $event)
192
+ {
193
+ // This is going to get complex so lets setup what we would place in for
194
+ // an event so we can drop it in with ease
195
+ if ($event->event_time == "00:00:00")
196
+ {
197
+ $event_time = '';
198
+ }
199
+ else
200
+ {
201
+ $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
202
+ }
203
+ $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
204
+
205
+ // Technically we don't care about the years or months, but we need to find out if the
206
+ // event spans the turn of a year or month so we can deal with it appropriately.
207
+ $month_begin = date('m',strtotime($event->event_begin));
208
+ $month_end = date('m',strtotime($event->event_end));
209
+
210
+ if ($month_begin == $month_end)
211
+ {
212
+ if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
213
+ date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
214
+ {
215
+ $output .= $event_out;
216
+ }
217
+ }
218
+ else if ($month_begin < $month_end)
219
+ {
220
+ if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
221
+ date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
222
+ {
223
+ $output .= $event_out;
224
+ }
225
+ }
226
+ }
227
+ }
228
+
229
+
230
+ // Now the ones that happen a finite number of times
231
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM event_begin))) <= event_repeats ORDER BY event_id");
232
+ if (!empty($events))
233
+ {
234
+ foreach($events as $event)
235
+ {
236
+ // This is going to get complex so lets setup what we would place in for
237
+ // an event so we can drop it in with ease
238
+ if ($event->event_time == "00:00:00")
239
+ {
240
+ $event_time = '';
241
+ }
242
+ else
243
+ {
244
+ $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
245
+ }
246
+ $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
247
+
248
+ // Technically we don't care about the years or months, but we need to find out if the
249
+ // event spans the turn of a year or month so we can deal with it appropriately.
250
+ $month_begin = date('m',strtotime($event->event_begin));
251
+ $month_end = date('m',strtotime($event->event_end));
252
+
253
+ if ($month_begin == $month_end)
254
+ {
255
+ if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
256
+ date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
257
+ {
258
+ $output .= $event_out;
259
+ }
260
+ }
261
+ else if ($month_begin < $month_end)
262
+ {
263
+ if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
264
+ date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
265
+ {
266
+ $output .= $event_out;
267
+ }
268
+ }
269
+ }
270
+ }
271
+
272
+
273
+ /*
274
+ Weekly - well isn't this fun! We need to scan all weekly events, find what day they fell on
275
+ and see if that matches the current day. If it does, we check to see if the repeats are 0.
276
+ If they are, display the event, if not, we fast forward from the original day in week blocks
277
+ until the number is exhausted. If the date we arrive at is in the future, display the event.
278
+ */
279
+
280
+ // The weekly events that never stop recurring
281
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats = 0 ORDER BY event_id");
282
+ if (!empty($events))
283
+ {
284
+ foreach($events as $event)
285
+ {
286
+ // This is going to get complex so lets setup what we would place in for
287
+ // an event so we can drop it in with ease
288
+ if ($event->event_time == "00:00:00")
289
+ {
290
+ $event_time = '';
291
+ }
292
+ else
293
+ {
294
+ $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
295
+ }
296
+ $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
297
+
298
+ // Now we are going to check to see what day the original event
299
+ // fell on and see if the current date is both after it and on
300
+ // the correct day. If it is, display the event!
301
+ $day_start_event = date('D',strtotime($event->event_begin));
302
+ $day_end_event = date('D',strtotime($event->event_end));
303
+ $current_day = date('D',strtotime($date));
304
+
305
+ $plan = array();
306
+ $plan['Mon'] = 1;
307
+ $plan['Tue'] = 2;
308
+ $plan['Wed'] = 3;
309
+ $plan['Thu'] = 4;
310
+ $plan['Fri'] = 5;
311
+ $plan['Sat'] = 6;
312
+ $plan['Sun'] = 7;
313
+
314
+ if ($plan[$day_start_event] > $plan[$day_end_event])
315
+ {
316
+ if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
317
+ {
318
+ $output .= $event_out;
319
+ }
320
+ }
321
+ else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event]))
322
+ {
323
+ if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event]))
324
+ {
325
+ $output .= $event_out;
326
+ }
327
+ }
328
+
329
+ }
330
+ }
331
+
332
+ // The weekly events that have a limit on how many times they occur
333
+ $events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats != 0 AND (event_repeats*7) >= (TO_DAYS('$date') - TO_DAYS(event_end)) ORDER BY event_id");
334
+ if (!empty($events))
335
+ {
336
+ foreach($events as $event)
337
+ {
338
+ // This is going to get complex so lets setup what we would place in for
339
+ // an event so we can drop it in with ease
340
+ if ($event->event_time == "00:00:00")
341
+ {
342
+ $event_time = '';
343
+ }
344
+ else
345
+ {
346
+ $event_time = 'Time: ' . date("H:i", strtotime($event->event_time)) . '<br /><br />';
347
+ }
348
+ $event_out = '<br />* <span class="calnk" nowrap="nowrap"><a>' . $event->event_title . '<span>' . $event_time . '' . $event->event_desc . '</span></a></span>';
349
+
350
+ // Now we are going to check to see what day the original event
351
+ // fell on and see if the current date is both after it and on
352
+ // the correct day. If it is, display the event!
353
+ $day_start_event = date('D',strtotime($event->event_begin));
354
+ $day_end_event = date('D',strtotime($event->event_end));
355
+ $current_day = date('D',strtotime($date));
356
+
357
+ $plan = array();
358
+ $plan['Mon'] = 1;
359
+ $plan['Tue'] = 2;
360
+ $plan['Wed'] = 3;
361
+ $plan['Thu'] = 4;
362
+ $plan['Fri'] = 5;
363
+ $plan['Sat'] = 6;
364
+ $plan['Sun'] = 7;
365
+
366
+ if ($plan[$day_start_event] > $plan[$day_end_event])
367
+ {
368
+ if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
369
+ {
370
+ $output .= $event_out;
371
+ }
372
+ }
373
+ else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event]))
374
+ {
375
+ if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event]))
376
+ {
377
+ $output .= $event_out;
378
+ }
379
+ }
380
+
381
+ }
382
+ }
383
+
384
+ return $output;
385
+ }
386
+
387
+ function calendar()
388
+ {
389
+
390
+ $name_days = array(1=>'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
391
+ $name_months = array(1=>'January','February','March','April','May','June','July','August','September','October','November','December');
392
+
393
+ if (empty($_GET['month']) || empty($_GET['year']))
394
+ {
395
+ $c_year = date("Y");
396
+ $c_month = date("m");
397
+ $c_day = date("d");
398
+ }
399
+ if ($_GET['year'] <= 3000 && $_GET['year'] >= 0)
400
+ {
401
+ if ($_GET['month'] == 'jan' || $_GET['month'] == 'feb' || $_GET['month'] == 'mar' || $_GET['month'] == 'apr' || $_GET['month'] == 'may' || $_GET['month'] == 'jun' || $_GET['month'] == 'jul' || $_GET['month'] == 'aug' || $_GET['month'] == 'sept' || $_GET['month'] == 'oct' || $_GET['month'] == 'nov' || $_GET['month'] == 'dec')
402
+ {
403
+ $c_year = $_GET['year'];
404
+ if ($_GET['month'] == 'jan')
405
+ {
406
+ $t_month = 1;
407
+ }
408
+ else if ($_GET['month'] == 'feb')
409
+ {
410
+ $t_month = 2;
411
+ }
412
+ else if ($_GET['month'] == 'mar')
413
+ {
414
+ $t_month = 3;
415
+ }
416
+ else if ($_GET['month'] == 'apr')
417
+ {
418
+ $t_month = 4;
419
+ }
420
+ else if ($_GET['month'] == 'may')
421
+ {
422
+ $t_month = 5;
423
+ }
424
+ else if ($_GET['month'] == 'jun')
425
+ {
426
+ $t_month = 6;
427
+ }
428
+ else if ($_GET['month'] == 'jul')
429
+ {
430
+ $t_month = 7;
431
+ }
432
+ else if ($_GET['month'] == 'aug')
433
+ {
434
+ $t_month = 8;
435
+ }
436
+ else if ($_GET['month'] == 'sept')
437
+ {
438
+ $t_month = 9;
439
+ }
440
+ else if ($_GET['month'] == 'oct')
441
+ {
442
+ $t_month = 10;
443
+ }
444
+ else if ($_GET['month'] == 'nov')
445
+ {
446
+ $t_month = 11;
447
+ }
448
+ else if ($_GET['month'] == 'dec')
449
+ {
450
+ $t_month = 12;
451
+ }
452
+ $c_month = $t_month;
453
+ $c_day = date("d");
454
+ }
455
+ else
456
+ {
457
+ $c_year = date("Y");
458
+ $c_month = date("m");
459
+ $c_day = date("d");
460
+ }
461
+ }
462
+ else
463
+ {
464
+ $c_year = date("Y");
465
+ $c_month = date("m");
466
+ $c_day = date("d");
467
+ }
468
+
469
+ $first_weekday = date("w",mktime(0,0,0,$c_month,1,$c_year));
470
+ $first_weekday = ($first_weekday==0?7:$first_weekday);
471
+
472
+ $days_in_month = date("t", mktime (0,0,0,$c_month,1,$c_year));
473
+
474
+ $calendar_body = '<table border="0" cellspacing="1" cellpadding="0" width="100%">';
475
+ $calendar_body .= '<tr>
476
+ <td height="25" style="border: 1px solid #D6DED5;background-color:#E4EBE3;" colspan="7" align="center" valign="middle">
477
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
478
+ <tr>
479
+ <td align="center" valign="middle" width="15%">' . prev_link($c_year,$c_month) . '</td>
480
+ <td align="center" valign="middle" width="70%">'.$name_months[(int)$c_month].' '.$c_year.'</td>
481
+ <td align="center" valign="middle" width="15%">' . next_link($c_year,$c_month) . '</td>
482
+ </tr>
483
+ </table>
484
+ </td>
485
+ </tr>';
486
+
487
+ $calendar_body .= '<tr>';
488
+ for($i=1;$i<=7;$i++) $calendar_body .= '<td style="font-size:0.8em; border: 1px solid #DFE6DE; background-color:#EBF2EA;'.($i<6?'':'color:red;').'" align="center" valign="middle" width="25" height="25">'.$name_days[$i].'</td>';
489
+ $calendar_body .= '</tr>';
490
+
491
+ for($i=1;$i<=$days_in_month;){
492
+ $calendar_body .= '<tr>';
493
+ for($ii=1;$ii<=7;$ii++){
494
+ if($ii==$first_weekday AND $i==1) $go = TRUE;
495
+ elseif($i > $days_in_month ) $go = FALSE;
496
+
497
+ if($go) $calendar_body .= '<td align="left" valign="top" width="60" height="60" style="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd")?'border: 1px solid #BFBFBF;background-color:#E4EBE3;':'border: 1px solid #DFE6DE;').'"><span style="'.($ii<6?'':'color:red;').'">'.$i++.'</span><span style="font-size:0.7em;">' . grab_events($c_year,$c_month,($i-1)) . '</span></td>';
498
+ else $calendar_body .= '<td width="60" height="60" style="border: 1px solid #E9F0E8;">&nbsp;</td>';
499
+ }
500
+ $calendar_body .= '</tr>';
501
+ }
502
+ $calendar_body .= '</table>';
503
+ $calendar_body .= '<div style="font-size:0.7em; text-align:center; padding:2px;">Want your own calendar like this one? Download it from <a href="http://www.kieranoshea.com/programming">Kieran O\'Shea</a></div>';
504
+
505
+ return $calendar_body;
506
+ }
507
+
508
+ ?>