<?
/**
 * Configfile
 *
 * This file is used for configuration of the form-handler package. Extra
 * modules that you want to use with this package need to be added to the
 * modules array.
 * @package                            FormHandler
 * @author                            Herman Suijs
 * @see                                                    Form-handler
 * @project                            FormHandler PHP Mailscript
 */

// This is just a notification of this version of the FormHandler package.
$version="FormHandler-2.1.1";

//********* Configure these options:

/**
 * Turn use of key-file on/off. You have to call getkey.php between the
 * <form>-tags of your form-page. This means it should be a php-file. You
 * can read more information in the documentation on spamming: Anti-spam
 * This is still beta-code.
 */
define("USE_KEYFILE",false);

/**
 * Define file which contains keys for form and handler communication
 */
define("KEY_FILE","keyfile.txt");

/**
 * Define the number of keys that should be generated to work within the
 * refresh-period. When this value is too high, the file gets too big which
 * slows things down.
 */
define("KEY_FILE_SIZE",10);

/**
 * Define the refresh time in seconds for the key_file. If you set this to
 * small it will slow done the script. Especially for sites with lots of
 * hits this is not advisable. When you set it too high the same key may be
 * used for too long.
 */
define("KEY_REFRESH","600"); // 10 minutes

/**
 * Define file which contains hostnames and IP-addresses of sites that
 * are allowed to have a form that refers to this formhandler.
 * This is to prevent spamming.
 */
define("ALLOW_FILE_SPAM","allowfile.txt");

/**
 * Set auto-configuration, e.g. dynamically loading of modules
 *
 * This option includes a routine to check all options to match with
 * defined options in a specific module. If it does it is automatically
 * loaded. This decreases performance, because it uses an XML-routine for
 * the XML-configuration files of the modules
 */
define("AUTO_CONFIG",true);

/**
 * The directory where the templates reside
 */
define("TEMPLATE_DIR","./templates/");

/* Options in config.mod.php */
/**
 * Configfile options override form-options
 *
 * Make options in configfile override options in form
 */
define("CONFIGFILE_OVERRIDE",false);

/**
 * Seperator for configoptions array
 */
define("CONFIG_SEP",":");

/**
 * Directory with configfile(s)
 */
define("CONFIG_DIR","config");

/**
 * Directories for modules
 */
define("MODULES_DIR","modules");
/**
 * Directories for include-files
 */
define("INCLUDE_DIR","include");

// Options for Content
/**
 * Default string for showing options
 */
define("DEFAULT_VAR_CONTENT","%s: %s\n");
/**
 * Default string for showing options in HTML
 */
define("DEFAULT_VAR_HTMLCONTENT","<li>%s: %s\n");

/**
 * Default Title information for content-modules (also via optons)
 */
define("TITLE","Form output");
/**
 * Definition of a line
 */
define("LINE""------------------------------------------------------------\n");
/**
 * Definition of an HTML line
 */
define("HTML_LINE""<hr>\n");

/**
 * Default header
 */
define("CONTENT_HEADER"TITLE "\n" LINE);
/**
 * Default footer
 */
define("CONTENT_FOOTER"LINE "EndForm");
/**
 * Default header in HTML
 */
define("CONTENT_HEADER_HTML""<HTML>\n<HEAD>\n<TITLE>".TITLE."</TITLE>\n</HEAD>\n<BODY><H1>".TITLE."</H1>\n".HTML_LINE);
/**
 * Default footer in HTML
 */
define("CONTENT_FOOTER_HTML"HTML_LINE "<p>EndForm<p></BODY></HTML>");

/**
 * Set the translation function
 */
define("TRANS_BY_DEFAULT",true);

/**
 * Color of substituted variables in messages
 */
define("VARIABLE_COLOR","red");

/**
 * Color of index of messages
 */
define("INDEX_COLOR","blue");

// Environment options
/**
 * Seperator for Environment variables array
 */
define("ENV_SEPERATOR",",");
/**
 * Default environment variables report
 */
define("DEFAULT_ENV","HTTP_HOST:HTTP_REFERER:HTTP_USER_AGENT");

// Fieldcheck options
/**
 * Seperator for Fieldcheck array
 */
define("FIELDCHECK_SEP",":");

// Referer options
/**
 * Seperator for refereroptions array
 */
define("REFEREROPTION_SEP",":");


// Required options
/**
 * Seperator for required array
 */
define("REQUIRED_SEP",",");

// Mailoptions
/**
 * Default mailaddress to send the forminfo to
 */
define("DEFAULT_MAIL","herman@suijsmail.com");
/**
 * Default subject to use for the mail
 */
define("DEFAULT_SUBJECT","FH Mailscript");
/**
 * Default from to use for the mail
 */
define("DEFAULT_FROM","Website form <>");

// Setcookie options
/**
 * Define sperator
 */
define("COOKIE_SEP",",");

/**
 * Define expire time of cookies
 */
define("COOKIE_EXPIRE",time()+(5*24*60*60));

// Ready to go

/**********************************************************************
 * It is better to leave the rest of the file untouched
 **********************************************************************/
// Content definitions
define("CONTENT",1);
define("MAIL_CONTENT",1);
define("DISPLAY_CONTENT",2);
define("ERROR_CONTENT",3);
define("DEBUG_CONTENT",4);
define("REPLY_CONTENT",5);

// Var-array definitions
define("VARS",0);
define("ALL_VARS","VARS");
define("SHOW_VARS",1);
define("SYS_VARS",2);
define("USR_VARS",3);
define("COOKIE_VARS",4);

// Error level definitions
/**
 * Error level (depricated)
 */
define("EXIT_ACTION"1);
/**
 * Error level (depricated)
 */
define("EXIT_EXECUTION"2); // above this errorlevel wraps up and exits

/**
 * Error level
 */
define("ERR_DEBUG",1);
/**
 * Error level
 */
define("ERR_INP_CONT",2);
/**
 * Error level with exit
 */
define("ERR_INP_END",3);
/**
 * Error level
 */
define("ERR_CONF_CONT",4);
/**
 * Error level with exit
 */
define("ERR_CONF_END",5);
/**
 * Error level
 */
define("ERR_DEV_CONT",6);
/**
 * Error level with exit
 */
define("ERR_DEV_END",7);
/**
 * Error level
 */
define("ERR_CRIT_CONT",8);
/**
 * Error level with exit
 */
define("ERR_CRIT_END",9);

// Debug level definitions
/**
 * Constant name for debuglevel
 */
define("DB_INIT",-1);

/**
 * Constant name for debuglevel
 */
define("DB_ERROR",1);

/**
 * Constant name for debuglevel
 */
define("DB_WARN",2);

/**
 * Constant name for debuglevel
 */
define("DB_FLOW",3);

/**
 * Constant name for debuglevel
 */
define("DB_INPUT",4);

/**
 * Constant name for debuglevel
 */
define("DB_CONF",5);

/**
 * Constant name for debuglevel
 */
define("DB_XFLOW",6);

/**
 * Constant name for debuglevel
 */
define("DB_INFO",7);

/**
 * Constant name for debuglevel
 */
define("DB_DEV",8);

/**
 * Constant name for debuglevel
 */
define("DB_ALL",9);

// Definition of loglevels
/**
 * Constant name for loglevel
 */
define("LOG_REFERER",1);

/**
 * Constant name for loglevel
 */
define("LOG_EMAIL",2);

/**
 * Constant name for loglevel
 */
define("LOG_??",3);

/**
 * Constant name for loglevel
 */
define("LOG_VARIABLES",4);

/**
 * Constant name for loglevel
 */
define("LOG_ALL",9);

/**
 * Number of sub executionlevels
 */
define("STEP_EXECLEVEL",10);
/**
 * Number of top executionlevels
 * Be carefull: when setting smaller than 10. The execnumbers used in the
 * modules is build as follows: 10 means runlevel 1 step 0 (first), 19
 * means runlevel 1 step 9 (10th). If MAX_STEPS is set to 9 then 19, 29,
 * 29, etc are not executed anymore.
 */ 
define("MAX_STEPS",3);
/**
 * Number of executionsteps per module
 */
define("MAX_ACTION",3);
define("LOCAL_DIR",".");
/**
 * Modulefile extension
 */
define("MOD_EXT",".mod.php");
/**
 * Includefile extension
 */
define("DEF_EXT",".def.xml");
/**
 * Autoconfiguration optionname
 *
 * Because the file xml.inc.php is quite large and may downgrade the
 * performance of the whole script, you can turn of auto-configuration in
 * the configfile.mod.php (must become xml config one day) Config-options
 * numbered. This option can dynamically be turned on or off.
 */
define("CFG_AUTO_CONFIG",1);

/**
 * Regular expression to recognize an emailaddress
 */
define("REGEX_MAIL","(^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$)");

/**
 * Regular expression for URL
 */
define("REGEX_URL","^((http|ftp)://)?([-a-zA-Z0-9]+\.){1,2}([a-zA-Z]{2,4})(/[a-zA-Z0-9_?&/\.]*)*$");

/**
 * Regular expression for Time
 */
define("REGEX_TIME","^[0-2]?[0-9] ?[:] ?[0-5][0-9]( ?[:] ?+[0-5][0-9])$");

/**
 * Regular expression for Date
 */
define("REGEX_DATE","^([0-2]?[0-9]|3[01]) ?[/-] ?(0?[0-9]|1[012]) ?[/-] ?[0-9]{1 -,4}");

/**
 * Regular expression for Phone nrs
 */
define("REGEX_PHONE","^[-\+0-9\(\) ]+$"); // Worldwide accetable ?

/**
 * Regular expression to recognize commentlines in files
 */
define("COMMENT_LINE","(#|\/\/|\/\*| ?\*).*$");

/**
 * Define all boolean false values in options as a regex (case insensitive)
 */
define("_FALSE","(false|0)"); // true = !false

/**
 * Define addto_vars replace value
 */
define("REPLACE",true);
/**
 * Define addto_vars donot_replace value
 */
define("DONT_REPLACE",false);



//***** The order of the module-list to load is significant. 

/**
 * This module is the Ancestor object for all other module-objects
 *
 * It is needed for all modules, so it needs to be loaded first.
 */
$load_modules['modulebase'] = 'modulebase.inc.php';

/**
 * Application message handling
 *
 * It is needed for Error messages and Debug messages
 * Because of the order here, object Error can use Debug, but Debug can't
 * use Error (in its first function).
 */
$load_modules['message'] = 'message.inc.php';
/**
 * Debug
 *
 * Needed for all modules
 */
$load_modules['debug'] = 'debug.mes.php';
// Use debugdummy instead of debug if you want to completely turn off
// debugging. This can give the script a little performance enhancement.
//$load_modules['debug'] = 'debugdummy.mes.php'; // Needed for modules
$load_modules['error'] = 'error.mes.php'// Needed for modules

// Module interface structure and Option object
$load_modules['module'] = 'module.inc.php';

// Defaults based on class module
// Display class is necessary for debug and error to give output
$load_modules['display'] = 'display.mod.php';
$load_modules['debugopts'] = 'debug.mod.php';
$load_modules['config'] = 'config.mod.php';
$load_modules['mail'] = 'mail.mod.php';

// The actural FormHandler
$load_modules['handler'] = 'formhandler.inc.php'// FormHandler class

$info="This form was handled with $version written by Herman Suijs,
FormHandler is a free PHP Mailscript.\nFormHandler can be found at:
http://formhandler.sourceforge.net
http://freshmeat.net/projects/formhandler
http://sourceforge.net/projects/formhandler
http://opensourcedirectory.net/projects/formhandler"
;

function 
checkoutput()
{
  global 
$info;
  print(
"<!-- $info -->\n");
/* function checkoutput() */