<?php
include '../env.php';
require_once(LIB.'common.inc.php');
require_once(LIB.'Post.class.php');
$post = new Post();

if (!is_login()) {
	_a_log_fail('favorite', 'del', 'invalid auth');
	echo json_encode(FALSE);
	die;
}

$log_ret = _a_log2('favorite', 'del', array(
	'detail' => serialize($_POST),
	'target_id' => @$_POST['id']
));

if ($log_ret) {
	$ret = $post->deleteFavorite($_POST['id']);
	_a_log_write($log_ret, array('success' => $ret === FALSE ? '0' : '1'));

	echo json_encode($ret);
} else {
	echo json_encode(FALSE);
}
?>