<?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 gourl(str){
window.open(str);
}
</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>联系微信</td>
			  <td>联系QQ</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_huan where user='$user'");		
										
					Page($num[0],10); 
					$sql = "select * from url_huan where user='$user' order by id desc limit $select_from $select_limit"; 					
					$arr = listquery($sql);						
					foreach ($arr as $v) {
					$taurl=$v['taurl'];
					$row=query("select * from url_data where url='$taurl'");
			
			?>
			
			<tr>			 
			  <td onClick="gourl('http://<?=$v['taurl']?>');"><?=$v['taurl']?></td>
			  <td>
			   <?php 
			  $src=$row['weixin'];
			  if($src){
			  echo '<img src="'.$src.'" />';
			  }
			  ?>
			  </td>
			  <td><a href="http://wpa.qq.com/msgrd?v=3&uin=<?=$row['qq']?>&site=www.ttlinkw.com&menu=yes" class="l" target="_blank"><img src="http://wpa.qq.com/pa?p=1:<?=$row['qq']?>:4" title="QQ" /></a></td>		
			  <td><?=$row['yaoqiu']?></td>		
			  <td><a href="?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 class="row juzhong">

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

</div>


</body>
 
</html>


<?php 

$id=$_GET['id'];

if($id){
	$row=query("select * from url_huan where user='$user' and id='$id'");
	
	if($row){
	mysql_query("delete from url_huan where id='$id'");
	echo "<script>alert('删除成功');window.location.href='user_mysq.php';</script>";
	}else{
	echo "<script>alert('非法操作已记录你的IP地址');window.location.href='login.php';</script>";
	}

}

?>