<?php
error_reporting(0); 
include("../../config/ht.php");
session_start();
if(!isset($_SESSION['adminname'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
$adminname=$_SESSION['adminname'];
$type="where name='$adminname'";
$adminpd=queryall(admin,$type);
if(!$adminpd){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
if($adminpd[qx]=='超级管理员'   or $adminpd[qx]=='资源管理员'){}else{echo "<script>alert('无权限')</script><script>top.location.href='/$htlj/'</script>";exit;}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>添加外链</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/admin.css" media="all">
<link rel="stylesheet" href="/2019newui/houtai/css/peizhi.css" media="all">
<script src='/2019newui/js/jquery.min.js' type="text/javascript"></script>
<script src="/layui/layui.js"></script>
<link rel="stylesheet" type="text/css" href="/2019newui/houtai/css/api.css" />
<link rel="stylesheet" type="text/css" href="/2019newui/houtai/css/style.css" />
</head>
<body>
<body style="padding:10px;">
<div class="tplay-body-div">
<div class="layui-tab layui-tab-brief">
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<fieldset class="layui-elem-field">
<legend>批量添加外链</legend>
<div class="layui-field-box">
<hr>
<div class="layui-field-box">单条链接添加 直接添加即可 不要有空白行或换行</div>
<div class="layui-field-box">批量，多条之间通过换行隔开</div>
<div class="layui-field-box">添加外链仅支持MP4和M3U8格式视频文件</div>
<div class="layui-field-box">外链格式：视频名称$视频地址$图片地址</div>
<div class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">视频分类</label>
<div class="layui-input-block">
<select name="fl"    id='fl' >
<option value='请选择'>请选择</option>
<?php 
$result = mysql_query("SELECT * FROM fenlei");
$count = mysql_num_rows($result);
?>
<?php if($count == 0){?><option value='0'>暂无分类</option><?php }?>
<?php
$query = mysql_query("SELECT * FROM fenlei");
while($a = mysql_fetch_array($query)) {
?>  
<option value='<?php echo $a[id]?>'><?php echo $a[name]?></option>
<?php }?>
</select>
</div>
</div>
</div>
<div class="layui-form-item">
<textarea id='url' placeholder="外链格式：视频名称$视频地址$图片地址" style="height:270px;" class="layui-textarea"></textarea>
</div>
<a  class="layui-btn btnto"  style="width:100%;">添加</a>
<!--<fieldset class="layui-elem-field layui-field-title"><legend>文本文件导入</legend></fieldset>
<div class="layui-form-item">
<button type="button" class="layui-btn  layui-btn-normal" id="pl" style="width: 100%;"><i class="layui-icon layui-icon-upload"  style="font-size: 16px; color: #000;"></i>上传文件【TXT格式】</button>
</div>
</div>
</fieldset>-->
</div>
<script>
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery', 'upload', 'layer'], function(){
var form = layui.form
,layer   = layui.layer
,layedit = layui.layedit
,element = layui.element
,upload  = layui.upload
,$= layui.jquery
,laydate = layui.laydate;
upload.render({
elem: '#pl'
,url: '/htwlpltxt<?php echo $dshz?>'
,accept: 'file'
,exts: 'txt'
,size: 50000000
,done: function(res){
if(res.status=='true'){
layer.msg("导入成功！");
location.reload();
}else{
layer.msg(res.msg);
}
}
});
});
$('.btnto').on('click', function () {
var url = $("#url").val();
var fl = $("#fl").val();
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {url:url,lx:'api',fl:fl},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('添加成功');
location.reload();
}else{
layer.closeAll('loading');
layer.msg(data.msg);
} 
},
error:function(){
}
});
})
</script>
</body>
</html>