<?php
//phpinfo();

// define user
$user = getenv("USER");
if ($user == "") putenv("USER=gui");

// includes
$path = preg_replace("/mLohn.*/", "mLohn", __FILE__);
set_include_path($path . PATH_SEPARATOR . get_include_path());
require_once 'gui/control/LohnControl.php';
require_once 'util/Logger.php';

// load configuration + class loader
include 'gui/control/ConfigurationData.php';
Config::setConfiguration($configurationData);

// Logging
$logger = Logger::getInstance();
$requestMethod = $_SERVER["REQUEST_METHOD"];
$logger->log(__FILE__, $requestMethod);
$logger->log(__FILE__, "GET-Variabeles:");
while ( list($key, $value) = each($_GET) ) {
	$logger->log(__FILE__, $key . " : " . $value);;
}
$logger->log(__FILE__, "POST-Variabeles:");
while ( list($key, $value) = each($_POST) ) {
	$logger->log(__FILE__, $key . " : " . $value);;
}
$logger->log(__FILE__,"Redirect-URL:".$_SERVER["REDIRECT_URL"]);

// call implementation
try {
	$control = new LohnControl();
	$control->doIt();
}
catch (Exception $e) {
	$logger->logException(__FILE__, $e);	
	echo "<html><body>Error occurred!</body></html>";
}