<?php
error_reporting(0); 
include("../../config/ht.php");
session_start();
if(!isset($_SESSION['username'])){echo "<script>alert('身份已失效,请重新登录!')</script><script>location.href='/fapian/'</script>";exit;}
$username=$_SESSION['username'];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>视频列表</title>
<SCRIPT language=javascript src="/2019newui/js/jquery.min.js"></SCRIPT>
<script src="/layui/layui.js"></script>
<link rel="stylesheet" href="/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="/2019newui/fp/style.css">
<link rel="stylesheet" href="/2019newui/fp/webuploader.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<div class="layui-logo"><span style="color:#fff;font-size:20px;font-family:"微软雅黑";">视频列表</span></div>
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item"><?php echo $username?></li>
</ul>
</div>
<div class="layui-side layui-bg-black">
<div class="layui-side-scroll">
<ul class="layui-nav layui-nav-tree"  lay-filter="test">
<li class="layui-nav-item layui-nav-itemed">
<a class="" href="javascript:;">功能菜单</a>
<dl class="layui-nav-child">
<dd class=""><a href="/fmain<?php echo $dshz?>">上传视频</a></dd>
<dd class="layui-this"><a href="/fshipin<?php echo $dshz?>">视频地址</a></dd>
</dl>
</li>
<li class="layui-nav-item "><a href="/ftui<?php echo $dshz?>">安全退出</a></li>
</ul>
</div>
</div>
<div class="layui-body">
<fieldset class="layui-elem-field layui-field-title" style=""><legend>视频列表</legend></fieldset>
<div class="layui-form">
<table class="layui-table">
<thead>
<tr>
<th width="20%"  style="text-align:center;" >视频名称</th>
<th width="6%"  style="text-align:center;" >预览视频</th>
<th width="10%"  style="text-align:center;" >发布时间</th>
<th width="10%"  style="text-align:center;" >状态</th>
</tr> 
</thead>
<tbody>
<?php 
$Page_size=11; 
$sql = "WHERE 1=1";
$sql .=" and username='$username' ";
$result = mysql_query("select id from  pian  ".$sql."");
$count = mysql_num_rows($result);
if($count == 0){
echo '<tr><td colspan="7" style="text-align:center;">没有记录</td></tr> ';
}
$page_count = ceil($count/$Page_size); 
$init=1; 
$page_len=7; 
$max_p=$page_count; 
$pages=$page_count; 

//判断当前页码 
if(empty($_GET['page'])||$_GET['page']<0){ 
$page=1; 
}else { 
$page=$_GET['page']; 
} 
$offset=$Page_size*($page-1); 
$query = mysql_query("select * from  pian  ".$sql."  order by id desc     limit $offset, $Page_size");
while ($a=mysql_fetch_array($query)) { 
?> 	
<tr>
<td  style="text-align:center;" ><input type="text" name="title[]" class="title  layui-input" data-id="<?php echo $a['id']?>" value="<?php echo $a['name']?>" style="width: 100%;text-align:center;"></td>
<td  style="text-align:center;" ><a  onClick="play('<?php echo $a[id]?>')" >点击预览视频</a></td>
<td  style="text-align:center;" ><?php echo $a[shijian]?></td>
<td  style="text-align:center;" ><?php echo $a[lx]?></td>
</tr>
<?php 
} 
$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数 
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量 
if($page!=1){ 

$keyt.="<a href=\""."/fshipinpage/1/\">首页</a>"; //首页 
$keyt.="<a href=\""."/fshipinpage/".($page-1)."/\">上一页 </a>"; //上一页 

}else { 
$keyt.="<p>首页</p>"; //首页 
$keyt.="<p>上一页 </p>"; //上一页  
} 
if($pages>$page_len){ 
//如果当前页小于等于左偏移 
if($page<=$pageoffset){ 
$init=1; 
$max_p = $page_len; 
}else{//如果当前页大于左偏移 
//如果当前页码右偏移超出最大分页数 
if($page+$pageoffset>=$pages+1){ 
$init = $pages-$page_len+1; 
}else{ 
//左右偏移都存在时的计算 
$init = $page-$pageoffset; 
$max_p = $page+$pageoffset; 
} 
} 
} 
for($i=$init;$i<=$max_p;$i++){ 
if($i==$page){ 
$keyt.='<a class="cur">'.$i.'</a>'; 
} else { 

$keyt.="<a href=\""."/fshipinpage/".$i."/\">".$i."</a>"; 

} 
} 
if($page!=$pages){ 

$keyt.="<a href=\""."/fshipinpage/".($page+1)."/\">下一页 </a> ";//下一页 
$keyt.="<a href=\""."/fshipinpage/{$pages}/\">尾页</a> "; //最后一页 

}else { 
$keyt.="<p>下一页 </p>";//下一页 
$keyt.="<p>尾页</p>"; //最后一页 
} 
$keyt.="<p class='pageRemark' >当前第 <b>$page</b> 页/共 <b>$pages</b> 页  共 <b>$count</b> 条数据 </p>"; //第几页,共几页 
?> 
</tbody>
</table>
<?php if($count =="0"){?>
<?php }else{?>
<div style="padding:0 20px;">
<div class="pagination">
<?php echo $keyt?>
</div>
</div>
<?php }?>
</div>
</div>
</div>
</div>
<script>
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery'], function(){
var form = layui.form
,layer = layui.layer
,layedit = layui.layedit
,element = layui.element
,laydate = layui.laydate
,$ = layui.jquery;
});
</script>
<script type="text/javascript">
function play(id) {
var url='/fplay_'+id+'<?php echo $dshz?>';
layer.open({
type: 2,
title: '视频预览',
shadeClose: true,
shade: 0.8,
area: ['500px', '390px'],
content:url
}); 
}
$(document).on('change', '.title', function(event) {
event.preventDefault();
var id  = $(this).attr('data-id'),
name  = $(this).val();
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
//更新标题
$.ajax({
type : "post",
url : "/fpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id: id, name: name},
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>