<?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'){
    header('Content-Type:application/json; charset=utf-8');
    $name = POST('name');
    $api = POST('api');
    if (empty($name) || empty($api)){
        $arr = array('state'=>'no','msg'=>'所有项不能为空！');
    }else{
        if ($TFYT_DB->query("insert into ".PREFIX."video_api (`name`,`api`)values('{$name}','{$api}')")){
            $arr = array('state'=>'ok','msg'=>'添加成功！','id'=>$TFYT_DB->getInsertId());
        }else{
            $arr = array('state'=>'no','msg'=>'添加失败，请稍后再试！');
        }
    }
    exit(json_encode($arr));
}elseif (POST('action')=='del'){
    header('Content-Type:application/json; charset=utf-8');
    $id = POST('id');
    if (empty($id)){
        $arr = array('state'=>'no','msg'=>'系统找不到要删除的接口！');
    }else{
        if ($TFYT_DB->query("delete from ".PREFIX."video_api where id='{$id}'")){
            $arr = array('state'=>'ok','msg'=>'删除成功！');
        }else{
            $arr = array('state'=>'no','msg'=>'添加失败，请稍后再试！');
        }
    }
    exit(json_encode($arr));
}

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

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

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

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