<?php
require_once("../check.php");
require_once("../../config.php");

$m="12";//每页显示的记录数
isset($_GET['page'])?$page=$_GET['page']:$page="1";//当前页数
$numsql = "select count(id) as num from dunling_pindao";
$numery = mysql_query($numsql,$config);
$numery = mysql_fetch_array($numery);
$zongjilushu = $numery['num'];//总记录数
$zy = (int)(($zongjilushu-1)/$m)+1;//总页数
$one = (int)($page-1)*$m;//当前页的首条记录
$articlesql = "select * from dunling_pindao order by id desc limit $one,$m";
$articleery = mysql_query($articlesql,$config);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>域名授权管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="../js/jquery-1.11.1.min.js"></script>
</head>
<body>
<script>
$(function(){
    
   
    
    
    $(".up").dblclick(function(){
        var text = $(this).text();
        $(this).html('<input class="upmenus" value=' + text +' >');
    });
    
    $(".update").click(function(){
        var id = $(this).parent().parent().find(".id").text();
        var upmenus = $(this).parent().parent().find(".up").find(".upmenus").val();
        $.post("../core/up_pindao.php",{
            id:id,
            title:upmenus
        },function(at,ad){
                    
        });
        $(this).parent().parent().find(".up").text(upmenus);
        
    });
    
    $("#add").click(function(){
        var menu = $("#addmenu").val();
        $.post("../core/add_pindao.php",{
            menu:menu
        },function(aa,bb){
            location.href='pindao.php';
        });
        
    });
   
    $(".del").click(function(){
    var id = $(this).parent().parent().find(".id").text();
    var title = $(this).parent().parent().find(".title").text();
    var ok = confirm('确定删除域名《' + title + '》频道吗?');
    if(ok){
        $.get("../core/del_pindao.php?id=" + id,function(a,b){
        if(a=="ok"){
        alert('删除成功!');
        $(".id:contains(" + id + ")").parent().remove();
        return false;
        }else{
        alert('删除数据出现失败!');
        return false;    
        }
        });
    }else{
        return false;
    }
    });

});

</script>
<style>
body{
    margin:0;
    padding:0;
    text-align:left;
}
#table{
    margin-left:20px;
    width:auto;
    max-width:1000px;
    min-height:35px;
    height:auto;
    display: table;
    line-height:35px;
    text-align:left;
    color: #505050;
    border-bottom:1px dashed #C9C9C9;
    font-size:14px;
}
#table:hover{
    background-color: #DDEEFF;
}
#table .id{
    width:100px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}

#table .kongzhi{
    width:180px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}
#table .title{
    width:740px;
    height:35px;
    line-height:35px;
    text-align:left;
    float:left;
}

#table .caozuo{
    width:100px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}
.update a{
    text-decoration:none;
    color: #00791F;
}
.update a:hover{
    text-decoration:none;
    color: #FF4646;
}
.del{
    color: #00791F;
}
.del:hover{
    color: #FF4646;
    cursor:pointer;
}

#p{
    margin-top:25px;
    margin-left:20px;
    width:auto;
    max-width:950px;
    min-height:50px;
    height:auto;
    display: table;
    line-height:50px;
    text-align:left;
    color: #505050;
    font-size:14px;
}
#p .page{
    width:950px;
    height:50px;
    line-height:50px;
    text-align:right;
}

#p .page li{
    text-align:center;
    display:inline;
    margin:0 5px 0 0px;
    float:left;
    height:50px;
}


#p .page li a{
    border-radius:3px;
    text-decoration: none;
    font-size:14px;
    color:#08246B;
    display: block;
    line-height: 30px;
    height:30px;
    padding-left: 12px;
    padding-right:12px;
    border:1px solid #08246B;
    box-shadow:0px 0px 3px 3px #DFDFDF;
}

#p .page li a:hover{
    border-radius:3px;
    width:auto;
    text-decoration: none;
    font-size:14px;
    color:#FFFFFF;
    display:table;
    line-height: 30px;
    height:30px;
    padding-left: 12px;
    padding-right:12px;
    background-color:#08246B;
}

#p .page li.dangqianye a{
    border-radius:3px;
    text-decoration: none;
    font-size:14px;
    color:#FFFFFF;
    display: block;
    line-height: 30px;
    height:30px;
    width:auto;
    padding-left: 12px;
    padding-right:12px;
    border:1px solid #08246B;
    background-color: #08246B;
}

#menu{
    margin-left:10px;
    margin-top:10px;
    display:table;
    color: #696969;
    font-size: 16px;
}
</style>



<div id="menu">新增域名:<input type="text" id="addmenu" /><input type="button" id="add" value="增加" />&nbsp;&nbsp;<span style="font-size: 12px;">不含http://</span></div>
<div id="table">
<div class="id"><strong>ID</strong></div>
<div class="title"><strong>域名地址</strong></div>
<div class="caozuo"><strong>操作</strong></div>
</div>
<?php
while($list = mysql_fetch_array($articleery)){
$title = strip_tags($list['url']);
$id = $list['id'];
$open = $list['open'];
if($open=="0"){
    $zt = "";
    $openpindao = '<input type="button" value="启用" class="open" id="'.$list['id'].'"  idz="1" />';
}else{
    $zt = "<img src=../images/open.png>";
    $openpindao = '<input type="button" value="关闭" class="open" id="'.$list['id'].'"  idz="0" />';
}
?>
<div id="table">
<div class="id"><?php echo $id;?></div>
<div class="title up" title="双击可进行修改"><?php echo $title;?></div>

<div class="caozuo"><span class="update">修改</a></span> | <span class="del">删除</span></div>
</div>
<?
}
?>
<div id="p">
<div class="page">
<?php
/*
$shangyiye = $page-1;
$xiayiye = $page+1;
if($page>"1"){
        echo '<li><a href="?page='.$shangyiye.'">上一页</a></li>';
        echo '<li><a href="?page=1">1</a></li>';
}
if($page>="6"){
for($pagea=$page-4;$pagea<=$page-1;$pagea++){
        echo '<li><a href="?page='.$pagea.'">'.$pagea.'</a></li>';
}
}
echo '<li class="dangqianye"><a href="?page='.$page.'">'.$page.'</a></li>';

     
if(($zy-$page)>="5"){
for($pageb=$page+1;$pageb<=$page+4;$pageb++){
        echo '<li><a href="?page='.$pageb.'">'.$pageb.'</a></li>';
}
}

if("5">=($zy-$page)){
for($pagec=$page+1;$pagec<=$zy-1;$pagec++){
        echo '<li><a href="?page='.$pagec.'">'.$pagec.'</a></li>';
}
}

if($page<$zy){
        echo '<li><a href="?page='.$zy.'">..'.$zy.'</a></li>';
        echo '<li><a href="?page='.$xiayiye.'">下一页</a></li>';
}
*/
?>
</div>
</div>
</body>