<?php
//=======================================================//
// Session check
//=======================================================//
require_once "../session/session_manage.php";

if ( sm_session_check_on_popup() == FALSE )
{
	//include "../php/msg_illegal_access.php";
	echo '-99';
	die();
}

$timemachine = $_POST['timemachinOnOff'];
$host_new = $_POST['host_name'];
$mac_addr = $_POST['mac_addr'];

if($timemachine == 'on')
{
	$res = exec('sudo nas-service enable timemachine on');
	$output = array();
	$res = exec("sudo nas-service set_timemachine $host_new $mac_addr", $output, $result);
	if ($result != '0') {
		echo "ng:tm_err";
		die();
	}
	$res = exec('sudo nas-service control timemachine start');
}
else
{
	$res = exec('sudo nas-service enable timemachine off');
	$res = exec('sudo nas-service control timemachine stop');
}

echo "ok:tm_ok";  //tm_err

?>
