<?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]=='超级管理员'){}else{echo "<script>alert('无权限')</script><script>top.location.href='/$htlj/'</script>";exit;}
$sourl=ubo($_GET["url"]);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="gbk">
<title>主域名列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="format-detection" content="telephone=no">
<script src='/2019newui/js/jquery.min.js' type="text/javascript"></script>
<script src="/layui/layui.js"></script>
<link rel="stylesheet" href="/layui/css/houtai.css" media="all" />
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
<fieldset class="layui-elem-field">
<legend>主域名列表</legend>
<div class="layui-field-box">
<form class="layui-form" action="">
<div class="layui-form-item" style="text-align:center;">
<div class="layui-inline">
<div class="layui-input-inline">
<input autocomplete="off" class="layui-input" placeholder="请输入要查询的域名" type="text" name="url" value="<?php echo $sourl?>"  required lay-verify="required" >
</div>
</div>
<div class="layui-inline" style="text-align:left;">
<div class="layui-input-inline">
<button class="layui-btn"><i class="layui-icon">&#xe615;</i>查询</button>
</div>
</div>
</div>
</form>
<hr>
<div class="layui-btn-group">
<button class="layui-btn layui-btn-xs layui-btn-normal open_if"   w="20%" h="25%" u="/htaddzymurl/"  n="添加主域名"><i class="layui-icon">&#xe654;</i>添加主域名</button>
<button class="layui-btn layui-btn-xs layui-btn-normal open_if layui-btn-danger"    w="50%" h="56%"  u="/htplzym/"  n="批量添加主域名"><i class="layui-icon">&#xe654;</i>批量添加主域名</button>
</div>
<hr>
<table class="layui-table">
<thead>
<tr>
<th style="text-align:center;">ID编号</th>
<th style="text-align:center;">域名地址</th>
<th style="text-align:center;">使用次数</th>
<th style="text-align:center;">域名状态</th>
<th style="text-align:center;">是/否使用</th>
<th style="text-align:center;">添加时间</th>
<th style="text-align:center;">域名检测</th>
<th style="text-align:center;width:34px;">操作</th>
</tr> 
</thead>
<tbody>
<?php 
$page_size=10; 
$sql = "WHERE 1=1";
if($sourl){
$sql .=" and url='$sourl'";
}
$resultyttrt = mysql_query("select id from zym    ".$sql."  ");
$count = mysql_num_rows($resultyttrt); 
if($count == 0){echo '<tr> <td  colspan=18  style="text-align:center;"><center>没有记录</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  zym   ".$sql." order by zt desc   limit $offset, $page_size");
while ($a=mysql_fetch_array($query)) { 
?> 	
<tr>
<td style="text-align:center;"><?php echo $a[id]?></td>
<td style="text-align:center;"><?php echo $a[url]?></td>
<td style="text-align:center;"><?php echo $a[cs]?></td>
<td style="text-align:center;"><?php if($a[zt]=='正常'){?><span class="label label-success"><?php echo $a[zt]?></span><?php }else{?><span class="label label-warning"><?php echo $a[zt]?></span><?php }?></td>
<td style="text-align:center;" ><div class="layui-form"><input type="checkbox"  name="open"  data-id="<?php echo $a[id]?>"  lay-skin="switch" lay-filter="qx" lay-text="使用中|未使用" <?php if($a[qx]=="1"){?> checked<?php }?>></div></td>
<td style="text-align:center;"><?php echo $a[shijian]?></td>
<td  style="text-align:center;"><?php if($a[zt]=="正常"){?><a href="javascript:;" onClick="jc('<?php echo $a[url]?>','<?php echo $a[id]?>')">微信检测</a><?php }else{?>已被封<?php }?></td>
<td class="text-center"><div class="layui-btn-group"><button class="layui-btn layui-btn-xs layui-btn-danger"  onClick="sc('<?php echo $a[id]?>')"><i class="layui-icon">&#xe640;</i>删除</button></div></td>
</tr>
<?php 
} 
$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数 
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量 
if($page!=1){ 
if($sourl){
}else{
$keyt.="<a href=\""."/htzympage/1/\">首页</a>"; //首页 
$keyt.="<a href=\""."/htzympage/".($page-1)."/\">上一页 </a>"; //上一页 
}
}else { 
if($sourl){
}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){ 
if($sourl){
}else{
$keyt.='<a class="cur">'.$i.'</a>'; 
}
} else { 
if($sourl){
}else{
$keyt.="<a href=\""."/htzympage/".$i."/\">".$i."</a>"; 
}
} 
} 
if($page!=$pages){ 
if($sourl){
}else{
$keyt.="<a href=\""."/htzympage/".($page+1)."/\">下一页 </a> ";//下一页 
$keyt.="<a href=\""."/htzympage/{$pages}/\">尾页</a> "; //最后一页 
}
}else { 
if($sourl){
}else{
$keyt.="<p>下一页 </p>";//下一页 
$keyt.="<p>尾页</p>"; //最后一页 
} 
}
if($sourl){
}else{
$keyt.="<p class='pageRemark' >当前第 <b>$page</b> 页/共 <b>$pages</b> 页  共 <b>$count</b> 条数据 </p>"; //第几页,共几页 
}
?> 
</tbody>
</table>
</div>
<?php if($count =="0" or $count<$page_size){?>
<?php }else{?>
<div style="padding:0 20px;">
<div class="pagination">
<?php echo $keyt?>
</div>
</div>
<?php }?>
</fieldset>
</div>
</div>
</div>
<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<script>
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery', 'layer'], function(){
var form = layui.form
,layer = layui.layer
,layedit = layui.layedit
,element = layui.element
,$= layui.jquery
,laydate = layui.laydate;
form.on('switch(qx)', function (data) {
var qx = this.checked ? '1' : '0',
id = $(this).attr('data-id');
if(qx=='1'){
tip='使用吗？';
}else{
tip='取消使用吗？';
}

layer.confirm("确认要" +tip, { title: "确认" }, function (index) {
layer.close(index);
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id: id,lx:'zymzt',qx:qx},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('设置成功');
location.reload();
} 
},
error:function(){
}
});
}); 
});
});
$(function() {
$('.open_if').on('click', function () {
var u = $(this).attr('u');
var w = $(this).attr('w');
var h = $(this).attr('h');
var n = $(this).attr('n');
layer.open({
type: 2,
title: n,
shadeClose: true,
area: [w, h],
content: u
});
});
});
function sc(id) {
layer.confirm("确认要删除吗，删除后不能恢复", { title: "删除确认" }, function (index) {
layer.close(index);
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id: id,lx:'zymsc'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
}); 
}
function jc(url,id) {
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: 'zymjc', id:id},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading'); 
layer.msg(data.msg);
location.reload();
}else{
layer.closeAll('loading'); 
layer.msg(data.msg);
location.reload();
}
},
error:function(){
}
});
}
</script>
</body>
</html>