<?php
require_once("../global/checkuser2.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站连接</title>
<link rel="stylesheet" href="index.css" />
<script src="../global/jquery-latest.min.js"></script>
<script src="weblink.js"></script>
<script>
function initselect(){
var ve = document.getElementById("typee").value;
var st = document.getElementById("type");
for(var i=0;i<st.options.length;i++){
  if(ve==st.options[i].value){
       st.selectedIndex = i;
       break;
  }
}
}
function initselect2(){
var vee = document.getElementById("userr").value;
var ste = document.getElementById("user");
for(var i=0;i<ste.options.length;i++){
  if(vee==ste.options[i].value){
       ste.selectedIndex = i;
       break;
  }
}
}
function initselect3(){
var vee = document.getElementById("linkstatee").value;
var ste = document.getElementById("linkstate");
for(var i=0;i<ste.options.length;i++){
  if(vee==ste.options[i].value){
       ste.selectedIndex = i;
       break;
  }
}
}
</script>
</head>

<body>
<div class="bigdiv">
<table cellspacing="0" cellpadding="0" style="font-size:14px;"><tr><td style="text-align:left;border-left:none;">您的位置：<a href="index.php">网站外链数据</a></td><td style="text-align:right;border-left:none;"><a href="add.php">添加链接</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="updateall.php">检查链接状态</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>
<div style="float:left;width:100%;border-bottom:2px solid #337abb;height:25px;font-size:14px;line-height:25px;"><ul>
<li style="float:left;width:100px;text-align:center;border:2px solid #337abb;border-top:1px solid #337abb;border-bottom:none;background:#337abb;margin-left:20px;display:inline;"><a href="index.php" style="color:#FFF;">网站外链数据</a></li>
</ul></div>
<div class="list">
<?php
if(isset($_GET["type"])){?>
<input type="hidden" id="typee" name="typee" value="<?=$_GET['type']?>"/>
<input type="hidden" id="userr" name="userr" value="<?=$_GET['user']?>"/>
<input type="hidden" id="linkstatee" name="linkstatee" value="<?=$_GET['linkstate']?>"/>
<?php } ?>

<table cellspacing="0" cellpadding="0">
<form action="" method="get" id="sform">
<tr style="background:#d3edf9;"><td style="width:15%;border-left:none;">网站标题</td><td style="width:25%;">链接地址</li>
<td><select id="type" name="type">
<option value="">链接类型</option>
<?php
             require_once("../global/connect.php");
			  $rss=mysql_query("select * from linktype");
			   if($rss){
			   while($row=mysql_fetch_array($rss)){?>
			   <option value="<?=$row['name']?>"><?=$row['name']?></option>
			 <?php }}?>
</select></td>
<td><select id="user" name="user">
<option value="">发布人</option>
<?php
			  $rs=mysql_query("select * from user");
			   if($rs){
			   while($row=mysql_fetch_array($rs)){?>
			   <option value="<?=$row['name']?>"><?=$row['name']?></option>
			 <?php }}?>
</select></td>
<td>PR</td><td>百度收录</td><td>加入日期</td><td>
<select id="linkstate" name="linkstate">
<option value="">连接</option>
<option value="yes">是</option>
<option value="no">否</option>
</select></td>
<td class='g'>操作</td></tr>
</form>
</table>
<script>initselect();initselect2();initselect3();</script>
<table cellspacing="0" cellpadding="0">
<?php
ob_start();
require_once("../global/page.class.php");
//搜索分页附加开始
$where="";
$type="";
$user="";
$linkstate="";
$sqltype="";
$sqluser="";
$sqllinkstate="";
if(isset($_GET["type"])){
$type=$_GET["type"];
$user=$_GET["user"];
$linkstate=$_GET["linkstate"];
$snum=0;
if($_GET["type"]!=""){
if($snum>0)
$sqltype="and linktype='$_GET[type]'";
else{
$sqltype="where linktype='$_GET[type]'";
$snum +=1;
}
}
if($_GET["user"]!=""){
if($snum>0)
$sqluser="and user='$_GET[user]'";
else{
$sqluser="where user='$_GET[user]'";
$snum +=1;}
}
if($_GET["linkstate"]!=""){
if($snum>0)
$sqllinkstate="and linkstate='$_GET[linkstate]'";
else{
$sqllinkstate="where linkstate='$_GET[linkstate]'";
$snum +=1;}
}
$where=$sqltype.$sqluser.$sqllinkstate;
}
//搜索分页附加结束
$total=mysql_num_rows(mysql_query("SELECT * FROM weblink $where")); 
$pageSize=15;
pageft($total,$pageSize,1,1,1,9,20,0);
$sql="SELECT * FROM  weblink $where order by id DESC limit $firstcount,$pageSize";
$sql=mysql_query($sql);
if($sql){ob_end_clean();
while($row=mysql_fetch_array($sql)){
$url="http://".str_replace("http://","",$row["url"]);
echo "<tr><td style=\"width:15%;border-left:none;text-align:left;\">&nbsp;<a href=\"$url\" target=\"_blank\">".$row["name"]."</a></td><td style=\"width:25%;text-align:left;word-break:break-all;\">&nbsp;".$row["url"]."</td><td>".$row["linktype"]."</td><td>".$row["user"]."</td><td>".$row["pr"]."</td><td style='color:green;'>".$row["baidu"]."</td><td>".$row["adddate"]."</td>";
if($row["linkstate"]=="yes")
echo "<td><img src='../images/yes.gif'</td>";
if($row["linkstate"]=="no")
echo "<td><img src='../images/no.gif'</td>";
echo "<td class='g'><a href=\"function.php?mod=delete&id=$row[id]\">[删除]</a><a href=\"modify.php?id=$row[id]\">[修改]</a></td></tr>";
}}else
echo "<tr><td style='width:100%text-align:center;color:red;border-left:none;'>没有符合要求的记录!</td></tr>";
ob_end_flush();
?>
</table>
<div id="page">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $pagenav;?></div>
<div style="width:100%;height:10px;"></div>
<div style="width:98%;margin:auto;overfollow:hidden;border:2px solid #ccc;line-height:25px;font-size:14px;">
&nbsp;&nbsp;&nbsp;&nbsp;功能使用帮助说明：<br />
&nbsp;&nbsp;1、此功能用于记录网站外链数据并检查外链是否存在。<br />
&nbsp;&nbsp;2、可通过连接类型、发布人、链接状态对记录进行筛选。其中百度收录、pr是链接地址所属网站数据。<br />
</div>
</div>
</div>
</body>
</html>
