1. rhizomatik
  2. elgg_firegpg

Source

elgg_firegpg / views / default / firegpg / encrypt.php

<?php
	global $CONFIG;
	function getAkfParam () {
		$ts = time();
		$token = generate_action_token($ts);
		return "__elgg_token={$token}&__elgg_ts={$ts}&akf";
	}

	function getAkf() {
		global $CONFIG;
		if (substr($CONFIG->wwwroot, 0, 5) == "https") {
			$protocol = "https://";
		} else {
			$protocol = "http://";
		}
		$fullUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		$meta=get_metadata_byname($_SESSION['user']->getGUID(),$fullUrl);
		return $meta->value;
	}
	
	function getKeyUrl() {
		global $CONFIG;
		return $CONFIG->wwwroot . "/mod/elggpg/raw.php";
	}
	
	echo elgg_view('firegpg/api');
?>

<script language="javascript" type="text/javascript">

$(document).ready(function() {
	var node = document.createElement('div');
	node.id = "firegpg-node";
	$('<?php echo $vars['form']?>').append(node);
	$('<?php echo $vars['form']?>').fireGPG({
		url : '<?php echo getKeyUrl() ?>',
		accessId : '<?php echo $vars['access_id']; ?>',
		keyId : '<?php echo $vars['keyid']; ?>',
		<?php if ($vars['accessidselector']) echo "accessIdSelector : '{$vars['accessidselector']}', "?>
		<?php if ($vars['keyidselector']) echo "keyIdSelector : '{$vars['keyidselector']}', "?>
		encryptFields : <?php echo json_encode($vars['fields']);?>,
		akf : '<?php echo getAkf(); ?>',
		akfParam : '<?php echo getAkfParam(); ?>'
	});
});

</script>