<?php 
require_once 'conn.php';
require_once 'function.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><?=$site['sitename']?></title>
<meta name="keywords" content="<?=$site['keywords']?>"/>
<meta name="description" content="<?=$site['description']?>"/>

<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="page.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="open.css">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
function squrl(id){
  $.get("user_squrl.php", { id: id },
  function(data){
    alert(data);
	
  });
}

function gaise(id){
   document.getElementById(id).style.color='red';
}


function gourl(str){
window.open(str);
}
</script>
</head>
 
<body>  

<?php 
require_once 'head.php';
$type=$_GET['type'];
$yaoqiu=$_GET['yaoqiu'];
if($type){
 echo "<script>window.onload=function(){gaise('".$type."');}</script>";
 $m=" where type='$type' ";
}
if($yaoqiu){
 echo "<script>window.onload=function(){gaise('".$yaoqiu."');}</script>";
 $m=" where yaoqiu='$yaoqiu' ";
}
?>



<div class="container">
  <div class="box">  	
  
   <!-- 友情链接板块 -->
   <div class="row">
	
		 <table class="table table-bordered  table-responsive ">
			   				
				 <tr>
					<td>网站类别</td>
					<td>
						<div class="quanzhong">
							<a href="link.php">全部</a>	
							<?php		    						
							$arr=listquery("select * from url_type order by id asc");		
							foreach ($arr as $v) {
							 ?>
							 	<a href="?type=<?=$v['type']?>" id="<?=$v['type']?>"><?=$v['type']?></a>					
						   <?php
						   }		  
						   ?>	
						
						 </div>
					</td>
				  </tr>
				  
				  
				  <tr>
				  <td width="150">交换要求</td>
				  <td>
					   <div class="quanzhong">
						   <a href="?yaoqiu=来者不拒" id="来者不拒">来者不拒</a>						 
						</div>
				  </td>			 
				</tr>
				  
		 </table>

	   <table class="table table-bordered  table-responsive biaoge">
		   <tr>
			  <td>站点名称</td>
			  <td>站点url</td>
			  <td>百度收录</td>
			  <td>百度权重</td>
			  <td>网站类别</td>
			  <td>扫码交换</td>
			  <td>QQ交换</td>
			  <td>交换要求</td>
			  <td>申请交换</td>
			</tr>
			
			<?php 

		// Page分页函数 
			$page = $_GET["page"]; 
					 	
			require_once('page.class.php'); //分页类
			$showrow = 10; //一页显示的行数
			$curpage = empty($_GET['page']) ? 1 : $_GET['page']; //当前的页,还应该处理非数字的情况
			$url = "?page={page}"; //分页地址，如果有检索条件 ="?page={page}&q=".$_GET['q']
			//省略了链接mysql的代码，测试时自行添加
			$sql = "SELECT * FROM url_data $m";
			$total = mysql_num_rows(mysql_query($sql)); //记录总条数
			if (!empty($_GET['page']) && $total != 0 && $curpage > ceil($total / $showrow))
				$curpage = ceil($total_rows / $showrow); //当前页数大于最后页数，取最后一页
			//获取数据
			$sql .= " order by id desc LIMIT " . ($curpage - 1) * $showrow . ",$showrow;";
		//	$query = mysql_query($sql);
			$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><?=$v['baidu']?></td>
			  <td><img src="images/qz/bds<?=$v['quanzhong']?>.gif" /></td>
			  <td>
			   <?=$v['type']?>
			  </td>
			  <td>
			  <?php 
			  $src=$v['weixin'];
			  if($src){
			  echo '<img src="'.$src.'" />';
			  }
			  ?>
			  </td>
			  <td><a href="http://wpa.qq.com/msgrd?v=3&uin=<?=$v['qq']?>&site=www.ttlinkw.com&menu=yes" class="l" target="_blank"><img src="http://wpa.qq.com/pa?p=1:<?=$v['qq']?>:4" title="QQ" /></a></td>
			   <td><?=$v['yaoqiu']?></td>
			  <td>
				  <button  class="btn btn-success" onClick="squrl('<?=$v[id]?>');">申请</button>
				   <?php
					  $taurl=$v['url'];
					  $pan=query("select * from url_huan where user='$user' and taurl='$taurl'");
					  if($pan){
					   echo '<font color=blue>已申请</font>';
					  }
				  ?>
			  </td>						 
			</tr>			
		   <?php
			}
			?>
		</table>
		
   </div>
   <!-- 友情链接板块 -->
   
   <div class="row">
		
	 <?php
	    $houzhui='&type='.$_GET[type].'&yaoqiu='.$_GET[yaoqiu].'';
		$page = new page($total, $showrow, $curpage, $url, 2,$houzhui);
		echo $page->myde_write();

	?>

	</div>
	
	 
	 
	<?php 
	require_once 'foot.php';
	?>
	
	<!--我的代码结束-->
  </div>
</div>

	<!--txl2u--><!--3r9fw-->	 
</div>
</body>
</html>

