#!/usr/bin/perl $page_template = "daily-jigsaw-template.htm"; @months = qw( January February March April May June July August September October November December ); @days = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); ############################################################## push (@INC, '/cgi-bin'); use CGI $co = new CGI; ($mday,$mon,$year) = (localtime())[3,4,5]; $mon++; $year = $year + 1900; if ($mday < 10) { $day = "0$mday"; } else { $day = "$mday"; } if ($mon < 10) { $month = "0$mon"; } else { $month = "$mon"; } $theCookie = $co->cookie('jsaw'); if ("$theCookie") { ($color, $pieces, $guide, $turnable) = split(/-/, $theCookie); } else { $pieces = "20"; $color = "1"; $guide = "n"; $turnable = "n"; } $puzz = $co->param('puzz'); if ($puzz eq "") { $puzz = "dj-${year}-${month}-${day}"; } else { $temp = $co->param('color'); if ("$temp") { $color = ${temp}; } $temp = $co->param('pieces'); if ("$temp") { $pieces = ${temp}; } $temp = $co->param('guide'); if ("$temp") { $guide = "y"; } else { $guide = "n"; } $temp = $co->param('turnable'); if ("$temp") { $turnable = "y"; } else { $turnable = "n"; } } $cookie = "${color}-${pieces}-${guide}-${turnable}"; $theCookie = $co->cookie (-name => 'jsaw', -value => $cookie, -expires => '+1M', -domain => 'thinks.com'); print $co->header (-cookie => $theCookie); if ($color eq "1") { $bgcolor = "ffffff"; $boardcolor = "ffffee"; } if ($color eq "2") { $bgcolor = "99cc66"; $boardcolor = "84d685"; } if ($color eq "3") { $bgcolor = "ccffff"; $boardcolor = "cce5ff"; } if ($color eq "4") { $bgcolor = "f5deb3"; $boardcolor = "f2d49b"; } if ($color eq "5") { $bgcolor = "ffc0cb"; $boardcolor = "f4bfff"; } $puzzyear = substr($puzz,3,4); $puzzmo = substr($puzz,8,2); $puzzmonth = $months[0 + substr($puzz,8,2) - 1]; $puzzday = substr($puzz,11,2); if ($puzzday lt "10") { $puzzday = substr($puzz,12,1); } $puzzdate = "${puzzmonth} ${puzzday}, ${puzzyear}"; $puzzfile = "puzzles/${puzzyear}-${puzzmo}/${puzz}\.txt"; $puzzpic = "/daily-jigsaw/puzzles/${puzzyear}-${puzzmo}/${puzz}\.jpg"; $puzzthumb = "/daily-jigsaw/puzzles/${puzzyear}-${puzzmo}/${puzz}\_t.jpg"; open(HTML, $page_template); @buffer = ; close HTML; $buffer = join('',@buffer); # Adds in the includes while($buffer =~ m//g) { open(HTML, "/home/vhosts/thinks.com/docs${1}"); @data = ; close HTML; $data = join('',@data); $buffer =~ s/$&/$data/g; } ($part1,$part2) = split ('', $buffer); open (PUZZ, $puzzfile); $title = readline(*PUZZ); $width = readline(*PUZZ); $height = readline(*PUZZ); close PUZZ; chomp $title; chomp $height; chomp $width; if ($pieces eq "12") { if ($height > $width) { $rows=4; $cols=3; } else { $rows=3; $cols=4; } } if ($pieces eq "20") { if ($height > $width) { $rows=5; $cols=4; } else { $rows=4; $cols=5; } } if ($pieces eq "30") { if ($height > $width) { $rows=6; $cols=5; } else { $rows=5; $cols=6; } } if ($pieces eq "42") { if ($height > $width) { $rows=7; $cols=6; } else { $rows=6; $cols=7; } } if ($pieces eq "56") { if ($height > $width) { $rows=8; $cols=7; } else { $rows=7; $cols=8; } } if ($pieces eq "72") { if ($height > $width) { $rows=9; $cols=8; } else { $rows=8; $cols=9; } } if ($pieces eq "90") { if ($height > $width) { $rows=10; $cols=9; } else { $rows=9; $cols=10; } } print $part1, "

Daily Jigsaw Puzzle

", "

${title}

", ""; print "
", "Daily Jigsaw Puzzle for ${puzzdate}   (${pieces} pieces)

", "\')\">(View picture)", "

A new free online jigsaw puzzle will appear every day.

To Play\: drag-and-drop the pieces onto the rectangular \'board\'.

", "If required, you can drag the timer to a new position (not over the puzzle!).

", "
", "", "
", "

Timer
", "", "

", "Start
", "Stop
", "Reset", "
"; print "", "", "", "", "", ""; if ($guide eq "y") { print ""; } if ($turnable eq "y") { print ""; } print "", "", "", "", "", "", "", "", "Sorry, you need a Java-enabled browser for the Daily Jigsaw Puzzle.", "\n
\n"; print "
", "
", "Change Options: Select your options then click the Go button.

", "", "", "
", "Number of pieces:", "", "12  ", "20  ", "30  ", "42  ", "56  ", "72  ", "90  ", "", "
Background color:", " White    ", " Green  ", " Blue    ", " Tan  ", " Pink  
Turnable pieces:", "      ", "Picture guide:  ", "", "
"; print "
"; print $part2; exit;