<?php
include '../env.php';
require_once(LIB.'common.inc.php');
if (! can_action('admin')) {
	_a_log_fail('layout', 'modify', 'invalid auth', array(
		'target_key' => @$_POST['page_name'].','.@$_POST['box_name']
	));
	echo json_encode(FALSE);
	die;
}
require_once(LIB.'Box.class.php');
$box = new Box();
$log_ret = _a_log2('layout', 'modify', array(
	'target_key' => @$_POST['page_name'].','.@$_POST['box_name'],
	'detail' => serialize($_POST)
));
if ($log_ret) {
	$ret = $box->updateLayout($_POST['page_name'], $_POST['box_name'], $_POST['has'], @$_POST['sort']);
	$box->updateLayoutCache();
	_a_log_write($log_ret, array('success' => $ret === FALSE ? '0' : '1'));
	echo json_encode($ret);
} else {
	echo json_encode(FALSE);
}
?>