<?php
/*
 * php to deliver encryption key to remote NAS
 * Original author: Twisted world
 * Original source: https://forum.synology.com/enu/viewtopic.php?f=36&t=142308
 * bco, 2019-02-11
 */

// Build an array of trusted IP addresses...
$trusted=array('111.222.333.444');

// check if request is made from valid ip address
if (in_array($_SERVER['REMOTE_ADDR'], $trusted)) { 
	$password = array(
		'encrypted' => 'openssl-encrypted-key-aes-256-cbc',
	);
	$share=$_SERVER['QUERY_STRING']; // get the share name from the request
	echo $password[$share]; // echo the password, this will be grabbed by wget 
} else {
	echo '';
}
?>
