<?php
session_start();

include('includes/ajax_check_login.php');

if( !isset($_POST['banner_id']) || ( $static_uint_banner_id = (int)$_POST['banner_id'] ) <= 0 )
	exit(json_encode(array('ErrCode'=>-1, 'ErrMessage'=>'輸入資料不足', 'RedirectURL'=>'')));

require_once('includes/common.php');

require_once('includes/admin.php');
$obj_class_admin = new class_admin();

if( !( $arr_banner = $obj_class_admin->get_banner_by_banner_id($static_uint_banner_id) ) )
	exit(json_encode(array('ErrCode'=>0, 'ErrMessage'=>'所選擇的廣告不存在！', 'RedirectURL'=>'')));
else if( !$obj_class_admin->delete_banner($static_uint_banner_id) )
	exit(json_encode(array('ErrCode'=>0, 'ErrMessage'=>'廣告刪除失敗！', 'RedirectURL'=>'')));
else
{
	unlink('../images/banners/' . $arr_banner[0]['BannerId'] . '.jpg');

	exit(json_encode(array('ErrCode'=>1, 'ErrMessage'=>'廣告刪除成功', 'RedirectURL'=>'')));
}
?>