Christian Heilmann

A free christmas / advent calendar in PHP

Wednesday, November 16th, 2005 at 11:31 am

A friend of mine wanted a christmas / advent calendar with 50ies pin-ups, and I couldn’t find one, so I scanned some and made an online calendar for her. As those are copyrighted, I will not reveal the pinups here, but instead offer you the script oft the calendar to use with your own pictures.

What does it do?

The script shows all the links of the different days pointing to a “not yet” image on days that are in the future, and points to the real image on days that are in the past or the current one. Clicking the image gets you back to the calendar.

How to alter the display?

Simply replace the images 1.jpg to 24.jpg in the “ups” folder with your images. 25.jpg is the “not yet available” image.
The page whole look+feel is defined in styles.css. The calendar is an unordered list with the ID “calendar”, the image is a DIV with the ID “pic” containing a link around an image.
The different day links are positioned via the ID l1 to l24 settings in the CSS.
You can change all these settings in the variables section of the xmascalendar.php file:


$pictureFolder='ups';
$month=12;
$clickableClass='done';
$calendarID='calendar';
$pictureID='pic';

Why in PHP and not in JavaScript?

This functionality could of course also be done in JavaScript, but that would make it easy to cheat by changing the computer’s date. You can of course cheat now by looking in the folder for the images themselves, but there are ways to prevent that server-side.

Yes, you could do that in AJAX with the PHP just doing the date checking, but frankly, I am too lazy right now :-)

Enjoy.

Share on Mastodon (needs instance)

Share on Twitter

My other work: