PDA

Click to See Complete Forum and Search --> : Is It Friday? (Day of Week Script)


dclamp
Mar 30th, 2008, 02:34 AM
I made this script in ten minutes for fun. It uses GDLib to create an image telling you if it is the day you asked for.

Usage:
http://yoursite.com/dayofweek.php?day=monday
This will tell you if it is monday or not. Works for EVERY single day of the week!

Examples:

Sunday:
http://www.subsoft.net/projects/dayofweek.php?day=sunday

Monday:
http://www.subsoft.net/projects/dayofweek.php?day=monday

Tuesday:
http://www.subsoft.net/projects/dayofweek.php?day=tuesday

Wednesday:
http://www.subsoft.net/projects/dayofweek.php?day=wednesday

Thursday:
http://www.subsoft.net/projects/dayofweek.php?day=thursday

Friday:
http://www.subsoft.net/projects/dayofweek.php?day=friday

Saturday:
http://www.subsoft.net/projects/dayofweek.php?day=saturday

On Error (no date set):
http://www.subsoft.net/projects/dayofweek.php?day=

C0d:

<?php
Header( "Content-type: image/png");
$day = strtolower($_GET['day']);
switch ($day) {
case "sunday":
$printday = "Sunday";
break;
case "monday":
$printday = "Monday";
break;
case "tuesday":
$printday = "Tuesday";
break;
case "wednesday":
$printday = "Wenesday";
break;
case "thursday":
$printday = "Thursday";
break;
case "friday":
$printday = "Friday";
break;
case "saturday":
$printday = "Saturday";
break;
default:
$printday = "FAIL!";
break;
}
$image = imagecreate(100,18);
if ($printday!='FAIL!') {
if (date('l')==$printday) {
$color = ImageColorAllocate($image,0,255,0);
} else {
$color = ImageColorAllocate($image,255,0,0);
}
$black = ImageColorAllocate($image,0,0,0);
ImageFilledRectangle($image,0,0,320,130,$color);
ImageString($image, 12, 2, 0, "$printday", $black);
ImagePNG($image);
ImageDestroy($image);
} else {
$color = ImageColorAllocate($image,0,0,255);
$black = ImageColorAllocate($image,0,0,0);
ImageFilledRectangle($image,0,0,320,130,$color);
ImageString($image, 12, 2, 0, "You suck!", $black);
ImagePNG($image);
ImageDestroy($image);
}
?>