<?php

# Parameters:
# u: user
# d: domain
#
# all additional parameters get directly passed to the mailto tag

// for PHP versions < PHP5, but not for complex multidimensional arrays
if (!function_exists('http_build_query')) {

	function http_build_query($formdata, $numeric_prefix = "")
	{
	   $arr = array();
	   foreach ($formdata as $key => $val)
	     $arr[] = urlencode($numeric_prefix.$key)."=".urlencode($val);
	   return implode($arr, "&");
	}

}

// get email address
$u = isset($_GET['u']) ? $_GET['u'] : trigger_error("No user specified",E_USER_ERROR);
$d = isset($_GET['d']) ? $_GET['d'] : trigger_error("No domain specified",E_USER_ERROR);

// get all other parameters
$s = $_GET;
unset($s['u']);
unset($s['d']);
$s = http_build_query($s);

// don't cache the output
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");		// Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");	// always modified
header("Cache-Control: no-store, no-cache, must-revalidate");	// HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);	// HTTP/1.1
header("Pragma: no-cache");					// HTTP/1.0
// forwarding the mailto address
header("Location: mailto:$u@$d?$s");

// additional text. is this valid?
header("Content-type: text/html");
echo "Please write an e-mail to: <br> Bitte schreiben Sie eine E-Mail an:<p>";
echo "<i>$u at $d</i><p>";
echo "(replace 'at' with @) <br> ('at' durch @ ersetzen)";

?>
