auth->check_module_permissions('mail'); header('Content-Type: text/xml; charset=utf-8'); header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); /** * This function fix PHP's messing up POST input containing characters space, dot, * open square bracket and others to be compatible with with the deprecated register_globals * @return array POST */ function getRealPOST() { $pairs = explode("&", file_get_contents("php://input")); $vars = array(); foreach ($pairs as $pair) { $nv = explode("=", $pair, 2); $name = urldecode($nv[0]); $value = $nv[1]; $vars[$name] = $value; } return $vars; } /** * This function formats the public-key * @param array $pubkey * @return string public-key */ function pub_key($pubkey) { $public_key=''; foreach($pubkey as $values) $public_key=$public_key.$values."\n"; return $public_key; } function get_public_key($private_key) { require_once('../../lib/classes/validate_dkim.inc.php'); $validate_dkim=new validate_dkim (); if($validate_dkim->validate_post('private',$private_key)) { /* validate the $_POST-value */ exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM 2> /dev/null',$pubkey,$result); $public_key=pub_key($pubkey); } else { $public_key='invalid key'; } return $public_key; } $_POST=getRealPOST(); switch ($_POST['action']) { case 'create': /* create DKIM Private-key */ exec('openssl rand -out /usr/local/ispconfig/server/temp/random-data.bin 4096 2> /dev/null', $output, $result); exec('openssl genrsa -rand /usr/local/ispconfig/server/temp/random-data.bin 1024 2> /dev/null', $privkey, $result); unlink("/usr/local/ispconfig/server/temp/random-data.bin"); foreach($privkey as $values) $private_key=$private_key.$values."\n"; break; case 'show': /* show the DNS-Record onLoad */ $private_key=$_POST['pkey']; break; } $public_key=get_public_key($private_key); $dns_record=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$public_key); echo "\n"; echo "\n"; echo "".$private_key."\n"; echo "".$public_key."\n"; echo "v=DKIM1; t=s; p=".$dns_record."\n"; echo "\n"; ?>