This module takes care of user uLPC-scripts, which works somewhat like CGI, with the exception that they are handled internally in the server.

Variables

Extensions to parse
All files ending with those extensions, will be handled as uLPC-scripts. It's a comma separated list.

Spinner 2.0 compatible calling method.
If this is set, the scripts will be called as they were called in Spinner 2.0. Kept for compability reasons only.

The parse() function

When someone access the URL of an uLPC script, the function parse() gets called in it, with one argument - object request_id.

Example Script

This is an example of a short script that reads a file with names of images, separated by a newline. It returns a random image.
inherit "spiderlib"; // Has some nice functions, as for
		     // example, http_direct
 
array (string)files; // An array of strings, with the image filenames
 
#define FILELIST "/the/full/path/to/the/filelist"
   		     // Absolute path to the image list.

#define BASEDIR	"/"
		     // The path to be prepended to the filenames in 
		     // the list

		
/* Create is called when the script is loaded.
   Here we read the file from the disk and explode it into an array 
  */
void create()
{
  files = read_bytes(FILELIST)/"\n"; 
} 			

/* Don't reload the module from file, unless the creator want to.
   (Call the script with '/random.ulpc?reload=whatever', to reload it.)
  */
int no_reload(object id) 
{ 
  if(!id->variables->reload)
    return 1; 
  return 0;
}
 
/* This function is called every time someone goes to the URL of the
   script.
  */
mapping parse(object id)
{
  return http_redirect(BASEDIR+files[random(sizeof(files))); 
			// Return a random file
}