<?php
// +----------------------------------------------------------------------
// | 天方夜谭 [ 世界上最好用的QQ秒赞系统 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014~2019 http://www.eirds.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 天方夜谭 <17404785@qq.com>
// +----------------------------------------------------------------------

//页面标题
define('Title', '网易云排行榜歌单管理');

//新增歌单
if (POST('action')=='add'){
    $music_id = POST('music_id');
    $remarks = POST('remarks');
    if (empty($music_id) || empty($remarks)){
        $msg = "<script language='javascript'>alert('所有项不能为空！');window.location.href='?Mould=Admin_Song';</script>";
    }else{
        if ($TFYT_DB->query("insert into ".PREFIX."website_toplist (`music_id`,`remarks`)values('{$music_id}','{$remarks}')")){
            $msg = "<script language='javascript'>alert('添加成功！');window.location.href='?Mould=Admin_Song';</script>";
        }else{
            $msg = "<script language='javascript'>alert('添加失败，请稍后再试！');window.location.href='?Mould=Admin_Song';</script>";
        }
    }
    exit($msg);
}elseif (GET('action')=='del'){
    $id = GET('id');
    if (empty($id)){
        $msg = "<script language='javascript'>alert('系统找不到要删除的歌单！');window.location.href='?Mould=Admin_Song';</script>";
    }else{
        if ($TFYT_DB->query("delete from ".PREFIX."website_toplist where id='{$id}'")){
            $msg = "<script language='javascript'>alert('删除成功！');window.location.href='?Mould=Admin_Song';</script>";
        }else{
            $msg = "<script language='javascript'>alert('删除失败，请稍后再试！');window.location.href='?Mould=Admin_Song';</script>";
        }
    }
    exit($msg);
}

//获取数据
$list = $TFYT_DB->get_results("select * from ".PREFIX."website_toplist order by id desc");

//加载头部
Load_Template(Mains.'head.php');

//加载视图
Load_Template(Mains.'admin_song.php');

//加载底部
Load_Template(Mains.'foot.php');