The scripts below just demonstrate how a minimal script can be written to serve Across puzzles in various languages. If you are going to be serving several Across puzzles, use them as a reference to construct a more elaborate and more efficient script. If you cannot get a script to work, contact us at help@litsoft.com and we will try to help you out.
We have assumed that the link you provide for the puzzle is of the form
If you use links of the form
replace PATH_INFO below with QUERY_STRING.
The main thing to note is that we never use the information obtained from the link URL directly in constructing the path name where the puzzle file is found. This is one way to ensure that your script (and your site) is safe from hackers. If you really know what you are doing, you may be able to write scripts that are secure without resorting to that guideline.
Script using Unix sh
#!/bin/sh
echo Content-type: application/x-crossword
echo
puzzle=$PATH_INFO
if (test $puzzle = puzzle1) then
echo cat /put puzzle directory path here/puzzle1.puz
Script using C
main(int argc, char*argv[]) {
char* puzzle;
printf("Content-type: application/x-crossword\n\n");
puzzle = getenv("PATH_INFO");
if (strcmp(puzzle,"puzzle1") == 0)
system("cat /put puzzle directory path here/puzzle1.puz");
}
Script using PERL
#!/usr/local/bin/perl
#change the above line to wherever the perl interpreter resides at your site.
print "Content-type: application/x-crossword\n\n";
$_ = $ENV{'PATH_INFO'};
if (/^puzzle1$/) {
open(P, "< /put puzzle directory path here/puzzle1.puz");
while (<P>) {print;}
close(P);
}