<?php 
require_once 'yanzheng.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
<title>用户中心:天天链接网</title>
<meta name="keywords" content="<?=$site['keywords']?>"/>
<meta name="description" content="<?=$site['miaoshu']?>"/>
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/page.css">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/layer/layer.js"></script>
<script>

function upurl(id){
  layer.load();
//此处演示关闭
setTimeout(function(){
  layer.closeAll('loading');
}, 200000);


  $.get("user_upurl.php", { id: id },
  function(data){
   var str=data;
       str=str.trim();
    alert(str);
	window.location.href='user_my.php';
  });
}
//更新网站
function gourl(str){
window.open(str);
}

function sell(tid){
     $("#tid").val(tid);//设置要出售的ID
	 
	 layer.open({
	  type: 1,
	  title: false,
	  closeBtn: 1,
	  shadeClose: true,
	  skin: 'yourclass',
	  content: $('#tong')
	});
}


</script>

</head> 
<body>
<?php 
require_once 'head_user.php';	
?>

<div class="box">   

	
	<!--左边-->
		<div class="zuo">
	
			
			<?php 
				require_once 'user_left.php';	
			?>
		   
	
		
		</div>
		
	<!--左边-->
	
	<!--右边-->
		<div class="you">
		
		<a href="user_add.php"><button type="button" class="btn btn-primary">添加网站</button></a>
		

		
		 <table class="table table-bordered  table-responsive biaoge">
		 

		  <tbody>
		   <tr>
			  <td>站点名称</td>
			  <td>站点url</td>
			  <td>售价</td>
			  <td>百度收录</td>
			  <td>百度权重</td>			 
			  <td>微信</td>
			  <td>QQ</td>
			  <td>交换要求</td>
			  <td>更新网站</td>
			  <td>修改网站</td>
			</tr>
			
			<?php 

				// Page分页函数 
					$page = $_GET["page"]; 
			
					function Page($rows,$page_size){ 
					global $page,$select_from,$select_limit,$pagenav;
					$page_count = ceil($rows/$page_size); 
					if($page <= 1 || $page == '') $page = 1; 
					if($page >= $page_count) $page = $page_count; 
					$select_limit = $page_size; 
					$select_from = ($page - 1) * $page_size.','; 
					$pre_page = ($page == 1)? 1 : $page - 1; 
					$next_page= ($page == $page_count)? $page_count : $page + 1 ; 
					$pagenav .= "第 $page/$page_count 页 共 $rows 条记录 "; 
					$pagenav .= "<a href='?page=1'>首页</a> "; 
					$pagenav .= "<a href='?page=$pre_page'>前一页</a> "; 
					$pagenav .= "<a href='?page=$next_page'>后一页</a> "; 
					$pagenav .= "<a href='?page=$page_count'>末页</a>"; 
					$pagenav.="　跳到<select name='topage' size='1' onchange='window.location=\"?page=\"+this.value'>\n"; 
					for($i=1;$i<=$page_count;$i++){ 
					if($i==$page) $pagenav.="<option value='$i' selected>$i</option>\n"; 
					else $pagenav.="<option value='$i'>$i</option>\n"; 
					}
					$pagenav.="</select>"; 
					} // Page分页函数 
					// 使用示例 
					
					$num=query("select count(id) from url_data where user='$user'");		
										
					Page($num[0],10); 
					$sql = "select * from url_data where user='$user' order by id desc limit $select_from $select_limit"; 					
					$arr = listquery($sql);						
					foreach ($arr as $v) {
			
			?>
			
			<tr>
			  <td onClick="gourl('http://<?=$v['url']?>');"><?=$v['sitename']?></td>
			  <td onClick="gourl('http://<?=$v['url']?>');"><?=$v['url']?></td>
			  <td>
			  <?php $sell=$v['sell']; if($sell==0){echo '不出售';}else{echo $sell.'元';}?>
			  
			  </td>
			  <td><?=$v['baidu']?></td>
			  <td><?=$v['quanzhong']?></td>			
			  <td>			  
			  <?php 
			  $src=$v['weixin'];
			  if($src){
			  echo '<img src="'.$src.'" />';
			  }
			  ?>
			  </td>
			  <td><?=$v['qq']?></td>
			  <td><?=$v['yaoqiu']?></td>
			  <td>
			  <button  class="btn btn-success" onClick="upurl('<?=$v[id]?>');">更新网站</button>
			  <button  class="btn btn-warning" onClick="sell('<?=$v[id]?>');">出售</button>
			  </td>			
			  <td><a href="user_up.php?id=<?=$v[id]?>">修改网站</a>  <a href="user_del.php?id=<?=$v[id]?>">删除</a></td>
			</tr>
			
		   <?php
			}
			?>
			
		  </tbody>
		</table>
		
		<div class="row">
			 <div class="panel panel-default">
				<div class="panel-body">
					<?php
						echo $pagenav;           
					?>
				</div>
			</div>
		</div>
		
		</div>
	<!--右边-->



</div>


<div id="tong">
<form action="" method="POST">

	出售：<input name="sell" type="text" style="width:40px;" value="1">元/月
	<input name="tid" id="tid" type="hidden">		
	<input name="submit" type="submit" value="确定">
	 <font color="red">标价为0代表不出售</font>

</form>
</div>

<?php 


if($_POST['submit']){

	$sell=trim($_POST['sell']);	
	$tid=trim($_POST['tid']);
	

	mysql_query("update url_data set sell='$sell'  where id='$tid' and user='$user'");
	msg("操作成功",$onurl);
	
	
}
?>



<div class="row juzhong">

<?php require_once 'user_foot.php';	?>

</div>


</body>
 
</html>