<?php

/*
 *  배너 삭제
 */
include_once './_common.php';
include_once './index.php';
$asktheme_upload_dir = G5_PATH . "/data/asktheme_attach";

if (!defined('_GNUBOARD_')) {
    exit;
}
if (!($token && get_session('ask_delete_token') == $token)) {
    alert('토큰 에러로 삭제 불가합니다.');
    exit;
}
if ($idx) {
    //첨부이미지 삭제
    $sql = "select * from ask_plugin_banner where ab_idx = '{$idx}' limit 1";
    $data = sql_fetch($sql);
    if ($data['ab_banner']) {
        unlink($asktheme_upload_dir . '/' . $data['ab_banner']);
    }
    $idx = sql_escape($idx);
    $sql = "delete from ask_plugin_banner where ab_idx = '{$idx}' limit 1";
    sql_query($sql);
    goto_url(G5_PLUGIN_URL . '/asktheme/plugin/banner/banner_list.php');
    exit;
} else {
    alert('잘못된 접속!!');
    exit;
}