<?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'){
    $name = POST('name');
    $qq = POST('qq');
    if (empty($name) || empty($qq)){
        $con = "<script language='javascript'>alert('所有项不能为空！');window.location.href='?Mould=Admin_Leader';</script>";
    }else{
        if ($TFYT_DB->query("insert into ".PREFIX."website_leader (`name`,`qq`)values('{$name}','{$qq}')")){
            $con = "<script language='javascript'>alert('添加成功！');window.location.href='?Mould=Admin_Leader';</script>";
        }else{
            $con = "<script language='javascript'>alert('添加失败，请稍后再试！');window.location.href='?Mould=Admin_Leader';</script>";
        }
    }
    exit($con);
}elseif (GET('action')=='del'){
    $id = GET('id');
    if (empty($id)){
        $con = "<script language='javascript'>alert('系统找不到要删除的客服！');window.location.href='?Mould=Admin_Leader';</script>";
    }else{
        if ($TFYT_DB->query("delete from ".PREFIX."website_leader where id='{$id}'")){
            $con = "<script language='javascript'>alert('删除成功！');window.location.href='?Mould=Admin_Leader';</script>";
        }else{
            $con = "<script language='javascript'>alert('删除失败，请稍后再试！');window.location.href='?Mould=Admin_Leader';</script>";
        }
    }
    exit($con);
}

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

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

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

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