<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Log</title>
</head>

<body>

<?PHP
class Logger {
 
	protected $fh;
 
	public function __construct() {
		$this->fh = fopen('C:\xampp\htdocs\data\log_polyas.txt', 'a+');
	}
 
	public function log($msg) {
		if(!$this->fh) {
			throw new Exception('Unable to open log file for writing');
		}
		if(fwrite($this->fh, $msg . "\n") === false) {
			throw new Exception('Unable to write to log file.');
		}
	}
 
	public function __destruct() {
		fclose($this->fh);
	}
}

//$myarray = $_POST;
$logger = new Logger();
$logger-> log('

+++++++++++++++++++++++++' . '       ' . 'Fachschaftswahl:' . '       ');
$logger->log(date('m-d-Y H:i:s  ') . '       
Alle angelickten Kandidaten:');
//LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common;
$newline = "\n";
//$logger->log('voted for:' . $_POST);
$string = "";
//for($i = 0; $i < 3; $i++){
//	$string .= " " . $_POST[$i];  
//}
foreach($_POST as $key => $value)  
{ 
	$string .= '
	' . $key . ": " . $value . '
	'; 
}  
$logger->log($newline .  print_r($string, true));
//$logger->log('voted for:' . var_export($_POST, true));
//$logger->log('voted for:' . print_r($_POST, true));
$logger->log("\n" . '
');
//$logger->log('Hat mehr als 3 Stimmen gewählt:' . print_r($_GET, true) . '       ' );
//$logger->log('Time needed: ' . print_r($_POST, true));
//$logger->log('$_FILES: ' . print_r($_FILES, true));
?>
</body>
</html>
