//
	error_reporting(E_ALL);
	ini_set('magic_quotes_runtime', false);
	if (ini_get('register_globals')) {
		exit("Error: register_globals must be set to Off in /etc/php.ini");
	}
	$AVANTFAX_VERSION	= '3.1.6';
	$INSTALLDIR	= realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR);
	define('USERSESSION',		'user');
	define('ADMIN_THEME_PATH',	'admin_theme');
	define('USER_THEME_PATH',	'main_theme');
	define('PLUGINS_PATH',		'plugins');
	define('ADMINTHEME_DIR',	$INSTALLDIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.ADMIN_THEME_PATH.DIRECTORY_SEPARATOR);
	define('USERTHEME_DIR',		$INSTALLDIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.USER_THEME_PATH.DIRECTORY_SEPARATOR);
	define('PLUGINS_DIR',		$INSTALLDIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.PLUGINS_PATH.DIRECTORY_SEPARATOR);
	if (file_exists($INSTALLDIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'local_config.php')) {
		include($INSTALLDIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'local_config.php');
	}
	if (!isset($dft_config_lang))
		$dft_config_lang = 'en';
	if (!isset($EMAIL_TPL))
		$EMAIL_TPL = 'en';
	if (!defined('AFDB_USER'))
		define('AFDB_USER',	'avantfax');
	if (!defined('AFDB_PASS'))
		define('AFDB_PASS',	'mysqlpassword');
	if (!defined('AFDB_NAME'))
		define('AFDB_NAME',	'avantfax');
	if (!defined('AFDB_ENGINE'))
		define('AFDB_ENGINE',	'mysql');
	if (!defined('AFDB_HOST'))
		define('AFDB_HOST',	'localhost');
	if (!defined('ADMIN_EMAIL'))
		define('ADMIN_EMAIL',	'root@localhost');
	if (!defined('RESTRICTED_USER_MODE'))
		define('RESTRICTED_USER_MODE', false);
	if (!defined('INBOX_LIST_MODEM'))
		define('INBOX_LIST_MODEM', false);
	if (!isset($FOCUS_ON_NEW_FAX))
		$FOCUS_ON_NEW_FAX	= false;
	if (!isset($FOCUS_ON_NEW_FAX_POPUP))
		$FOCUS_ON_NEW_FAX_POPUP	= false;
	if (!isset($FROM_COMPANY))
		$FROM_COMPANY		= '';
	if (!isset($FROM_LOCATION))
		$FROM_LOCATION		= '';
	if (!isset($FROM_FAXNUMBER))
		$FROM_FAXNUMBER		= '';
	if (!isset($FROM_VOICENUMBER))
		$FROM_VOICENUMBER	= '';
	if (!isset($DEFAULT_TSI_ID))
		$DEFAULT_TSI_ID		= '';
	if (!isset($BINARYDIR))
		$BINARYDIR			= '/usr/bin';

// This must be set here it is set nowhere else

	if (!isset($LIBDIR))
		$LIBDIR			= '/usr/lib/fax';
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	if (!isset($HYLAFAX_PREFIX))
		$HYLAFAX_PREFIX		= '/usr';
	if (!isset($HYLASPOOL))
		$HYLASPOOL			= '/var/spool/fax';
	if (!isset($HYLATIFF2PS))
		$HYLATIFF2PS		= false;
	if (!isset($FAXRMPWD))
		$FAXRMPWD			= 'hylafaxpassword';  // set during install for /var/spool/fax/etc/hosts.hfaxd
	if (!isset($FAXMAILUSER))
		$FAXMAILUSER		= 'faxmail';
	if (!isset($WWWUSER))
		$WWWUSER			= 'wwwrun';
	if (!isset($ENABLE_DL_TIFF))
		$ENABLE_DL_TIFF		= false;
	if (!isset($SHOW_ALL_CONTACTS))
		$SHOW_ALL_CONTACTS = true;
	if (!isset($NUM_PAGES_FOLLOW))
		$NUM_PAGES_FOLLOW = 0;
	if (!isset($SENDFAX_USE_COVERPAGE))
		$SENDFAX_USE_COVERPAGE = true;
	if (!isset($SENDFAX_REQUEUE_EMAIL))
		$SENDFAX_REQUEUE_EMAIL = true;
	if (!isset($PAPERSIZE))
		$PAPERSIZE = 'letter';
	if (!isset($CPAGE_LINELEN))
		$CPAGE_LINELEN = 80;
	if (!isset($ARCHIVEFAX2EMAIL))
		$ARCHIVEFAX2EMAIL = true;
	if (!isset($ARCHIVE_WIDE))
		$ARCHIVE_WIDE = true;
	if (!isset($PRINTFAXRCVD))
		$PRINTFAXRCVD	= false;
	if (!isset($PRINTERNAME))
		$PRINTERNAME		= '';
	if (!isset($PRINTCMD))
		$PRINTCMD			= '/usr/bin/lpr';
	if (!isset($PRINTFAX2PS))
		$PRINTFAX2PS		= '/usr/bin/fax2ps';
	if (!isset($PRINTFAXCMD))
		$PRINTFAXCMD		= "$PRINTFAX2PS %s | $PRINTCMD %s";
	if (!isset($PDFPRINTCMD))
		$PDFPRINTCMD		= '/usr/bin/lpr';
	if (!isset($FAXRCVD_PRINT_PDF))
		$FAXRCVD_PRINT_PDF	= false;
	if ($FAXRCVD_PRINT_PDF)
		$PRINTFAXCMD		= "$PRINTCMD %s %s";
	if (!isset($COVERPAGE_FILE))
		$COVERPAGE_FILE		= "cover.ps";
	if (!isset($USE_HTML_COVERPAGE))
		$USE_HTML_COVERPAGE	= false;
	if (!isset($HTML_COVERPAGE_FILE))
		$HTML_COVERPAGE_FILE	= "coverpage.html";
	if (!isset($HTML2PS))
		$HTML2PS = "/usr/bin/html2ps";
	define('COVERPAGE_MATCH', 'XXXX-');
	if (!isset($AVANTFAX_DEBUG))
		$AVANTFAX_DEBUG			= false;
	if (!isset($SHOWSERVER_DETAILS))
		$SHOWSERVER_DETAILS		= false;
	if (!isset($AVANTFAX_SERVERNAME)) {
		exec("hostname", $hostname);
		$AVANTFAX_SERVERNAME	= (array_key_exists('SERVER_NAME', $_SERVER)) ? $_SERVER['SERVER_NAME'] : implode("", $hostname);
	}
	if (!isset($SYSTEM_EMAIL_SIG_HTML)) //change
		$SYSTEM_EMAIL_SIG_HTML	= "AvantFAX -> 3111skyline";
	if (!isset($SYSTEM_EMAIL_SIG_TEXT))
		$SYSTEM_EMAIL_SIG_TEXT	= "www.3111skyline.com"; //change
	if (!defined('USE_SMTPSERVER'))
		define('USE_SMTPSERVER', false);
	if (!defined('SMTP_SERVER'))
		define('SMTP_SERVER', 'localhost');
	if (!defined('SMTP_PORT'))
		define('SMTP_PORT', 25);
	if (!defined('SMTP_AUTH'))
		define('SMTP_AUTH', false);
	if (!defined('SMTP_USERNAME'))
		define('SMTP_USERNAME', '');
	if (!defined('SMTP_PASSWORD'))
		define('SMTP_PASSWORD', '');
	if (!defined('SMTP_LOCALHOST'))
		define('SMTP_LOCALHOST', 'localhost');
	if (!isset($NOTIFY_INCLUDE_PDF))
		$NOTIFY_INCLUDE_PDF		= false;
	if (!isset($FAXRCVD_INCLUDE_THUMBNAIL))
		$FAXRCVD_INCLUDE_THUMBNAIL = true;
	if (!isset($ENABLE_DID_ROUTING))
		$ENABLE_DID_ROUTING		= false;
	if (!isset($CALLIDn_CIDNumber))
		$CALLIDn_CIDNumber		= 1;
	if (!isset($CALLIDn_CIDName))
		$CALLIDn_CIDName		= 2;
	if (!isset($CALLIDn_DIDNum))
		$CALLIDn_DIDNum			= 3;
	if (!isset($AUTOCONFDID))
		$AUTOCONFDID			= true;
	if (!defined('ENABLE_BARDECODE_SUPPORT'))
		define('ENABLE_BARDECODE_SUPPORT', false); //to enable barcode set to true
	if (!defined('BARDECODE_BINARY'))
		define('BARDECODE_BINARY', "/var/spool/hylafax/bin/bardecode");
	if (!defined('BARDECODE_COMMAND'))
		define('BARDECODE_COMMAND',	BARDECODE_BINARY." -t any -f %s");
	if (!defined('ENABLE_FAX_ANNOTATION'))
		define('ENABLE_FAX_ANNOTATION', false);
	if (!defined('ENABLE_OCR_SUPPORT'))
		define('ENABLE_OCR_SUPPORT', false); // to enable set to true
	if (!defined('OCR_BINARY'))
		define('OCR_BINARY', "/usr/local/bin/tesseract");
	if (!defined('OCR_COMMAND'))
		define('OCR_COMMAND', OCR_BINARY." %s %s -l %s");
	if (!defined('OCR_LANGUAGE'))
		define('OCR_LANGUAGE', "eng");
	if (!defined('EMAIL_ENCODING_TEXT'))
		define('EMAIL_ENCODING_TEXT', "Base64Encoding");
	if (!defined('EMAIL_ENCODING_HTML'))
		define('EMAIL_ENCODING_HTML', "Base64Encoding");
	if (!defined('EMAIL_ENCODING_CHARSET'))
		define('EMAIL_ENCODING_CHARSET', "UTF-8");
	if (!defined('FAXCOVER_DATE_FORMAT'))
		define('FAXCOVER_DATE_FORMAT', "%d.%m.%Y %H:%M");
	if (!defined('EMAIL_DATE_FORMAT'))
		define('EMAIL_DATE_FORMAT', "%d.%m.%Y %H:%M");
	if (!defined('ARCHIVE_DATE_FORMAT'))
		define('ARCHIVE_DATE_FORMAT', "'%d.%m.%Y %H:%i'");
	if (!defined('WHITEPAGES'))
		define('WHITEPAGES', 'http://www.whitepages.com/10001/search/ReversePhone?phone=');
	if (!defined('MAX_USERNAME_SIZE'))
		define('MAX_USERNAME_SIZE',	15);
	if (!defined('MAX_PASSWD_SIZE'))
		define('MAX_PASSWD_SIZE',	15);
	if (!defined('MIN_PASSWD_SIZE'))
		define('MIN_PASSWD_SIZE',	8);
	if (!defined('MAX_EMAIL_SIZE'))
		define('MAX_EMAIL_SIZE',	99);
	if (!defined('HAS_NEGATIVE_TIFF'))
		define('HAS_NEGATIVE_TIFF', false);
	function errorHandler($errno, $errstr, $errfile = NULL, $errline = NULL, array $errcontext = NULL) {
		var_dump(debug_backtrace());
		error_log("$errfile ($errline): $errstr");
		return false;
	}
	if ($AVANTFAX_DEBUG) {
		set_error_handler('errorHandler', E_USER_ERROR);
	}
	$HAS_MIME_FUNCTION	= function_exists('mime_content_type');
	$HAS_FILEINFO		= extension_loaded('fileinfo');
	if (!$HAS_FILEINFO) {
		$HAS_FILEINFO	= @dl('fileinfo.so');
	}
	$grep_function	= 'preg_match';
	if (extension_loaded('mbstring')) {
		mb_internal_encoding("UTF-8");
		$grep_function	= 'mb_ereg_match';
	}
	$ARCHIVE		= $INSTALLDIR.DIRECTORY_SEPARATOR.'faxes'.DIRECTORY_SEPARATOR.'recvd';
	$ARCHIVE_SENT	= $INSTALLDIR.DIRECTORY_SEPARATOR.'faxes'.DIRECTORY_SEPARATOR.'sent';
	$TMPDIR			= $INSTALLDIR.DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR;
	$PHONEBOOK		= $INSTALLDIR.DIRECTORY_SEPARATOR.'pbook.phb';
	$TIFFCP			= $BINARYDIR.DIRECTORY_SEPARATOR.'tiffcp';
	$TIFFCPG4		= $BINARYDIR.DIRECTORY_SEPARATOR.'tiffcp -c g4';
	$TIFFPS			= $BINARYDIR.DIRECTORY_SEPARATOR.'tiff2ps -2ap';
	$TIFFSPLIT		= $BINARYDIR.DIRECTORY_SEPARATOR.'tiffsplit';
	if (!isset($TIFF_TO_G4))
		$TIFF_TO_G4 = false;
	$CONVERT		= $BINARYDIR.DIRECTORY_SEPARATOR.'convert';
	$PNMSCALE		= $BINARYDIR.DIRECTORY_SEPARATOR.'pnmscale';
	$PNMDEPTH		= $BINARYDIR.DIRECTORY_SEPARATOR.'pnmdepth';
	$PPMTOGIF		= $BINARYDIR.DIRECTORY_SEPARATOR.'ppmtogif';
	$PSRESIZE		= $BINARYDIR.DIRECTORY_SEPARATOR.'psresize';
	if (!isset($DPI))
		$DPI		= 92;
	if (!isset($DPIS))
		$DPIS		= 200;
	$GS				= $BINARYDIR.DIRECTORY_SEPARATOR.'gs';
	$GSR			= "$GS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibility=1.4 -sPAPERSIZE=$PAPERSIZE";
	$GSN			= "$GS -q -dNOPAUSE -sPAPERSIZE=$PAPERSIZE -sDEVICE=pnm -r${DPI}x${DPI}";
	$GSN2			= "$GS -q -dNOPAUSE -sPAPERSIZE=$PAPERSIZE -sDEVICE=pnm";
	$GSTIFF			= "$GS -sDEVICE=tiffg4 -r${DPIS}x${DPIS} -dNOPAUSE -sPAPERSIZE=$PAPERSIZE";
	$GSCMD			= "$GS -dCompatibilityLevel=1.4 -dSAFER -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%s -sPAPERSIZE=$PAPERSIZE -f %s >/dev/null 2>/dev/null";
	if (!defined('ANN_GRAVITY'))
		define('ANN_GRAVITY', "southeast");
	$FAXINFO		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'sbin'.DIRECTORY_SEPARATOR.'faxinfo';
	$FAXSTAT		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'faxstat -s';
	$FAXADDUSER		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'sbin'.DIRECTORY_SEPARATOR.'faxadduser';
	$FAXDELUSER		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'sbin'.DIRECTORY_SEPARATOR.'faxdeluser';

// Here the change for faxgetty is implemented

	$FAXGETTY		= $LIBDIR.DIRECTORY_SEPARATOR.'faxgetty';
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

	$SENDFAX		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'sendfax';
	$FAXCOVER		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'faxcover';
	$FAXRM			= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'faxrm';
	$FAXALTER		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'faxalter';
	$EXPECT			= '/usr/bin/expect';
	$FAXSENDQ		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'faxstat -s';
	$FAXDONEQ		= $HYLAFAX_PREFIX.DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'faxstat -d';
	$SUDO			= $BINARYDIR.DIRECTORY_SEPARATOR.'sudo';
	$SYSTEM_IP		= (array_key_exists('SERVER_ADDR', $_SERVER)) ? $_SERVER['SERVER_ADDR'] : $AVANTFAX_SERVERNAME;
	$RESERVED_FAX_NUM = 'XXXXXXX';
	define('THUMBNAIL',		'thumb.gif');
	define('NOTHUMB',		'images/nothumb.gif');
	define('PDFNAME',		'fax.pdf');
	define('TIFFNAME',		'fax.tif');
	define('PREVIMG',		'prev');
	define('PREVIMGSFX',	'.gif');
	define('CONTACTFILETYPES',	"vCard (.vcf)");
	define('SENDFAXFILETYPES',	"PostScript (.ps), PDF (.pdf), TIFF (.tif), Text (.txt)");
	if (!defined('PREV_TN'))
		define('PREV_TN', 80);
	if(!defined('PREV_SP'))
		define('PREV_SP', 750);
	$NOTHUMBIMG = $INSTALLDIR.DIRECTORY_SEPARATOR.NOTHUMB;
	if ($ENABLE_DID_ROUTING) $AVANTFAX_VERSION .= '†';
	require_once 'functions.php';
	$upload_sizes	= get_max_fileupload();
	$SF_FILESIZE	= $upload_sizes['max'];
	$SF_MAXSIZE		= $upload_sizes['abbrev'];
	require_once "langs/$dft_config_lang.php";