<?php
require_once("../../global/checkuser1.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="index.js"></script>
<script>
 function setCookie(sName,sValue,expireHours) {
  var cookieString = sName + "=" + escape(sValue);
  //;判断是否设置过期时间
  if (expireHours>0) {
    var date = new Date();
    date.setTime(date.getTime + expireHours * 3600 * 1000);
    cookieString = cookieString + "; expire=" + date.toGMTString();
  }
  document.cookie = cookieString+";path=/";
 }
function initselect(){
var ve = document.getElementById("diquu").value;
var st = document.getElementById("diqu");
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("paimingg").value;
var ste = document.getElementById("paiming");
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("serchh").value;
var ste = document.getElementById("serch");
ste.value=vee;
}
</script>
</head>

<body>
<?php
require_once("../../global/connect.php");
?>
<div class="bigdiv">
<?php
if(isset($_GET["diqu"])){?>
<input type="hidden" id="diquu" name="diquu" value="<?=$_GET['diqu']?>"/>
<input type="hidden" id="paimingg" name="paimingg" value="<?=$_GET['paiming']?>"/>
<input type="hidden" id="serchh" name="serchh" value="<?=$_GET['serch']?>"/>
<?php } ?>
<table cellspacing="0" cellpadding="0" style="font-size:14px;"><tr><td style="text-align:left;border-left:none;width:30%;">您的位置：关键字排名检测/<a href="index.php">精准排名</a></td>
<form action="" method="get" id="sform" name="sform">
<td style="border-left:none;width:40%;"><select id="diqu" name="diqu">
<option value="">地区</option>
<?php
$sqldiqu=mysql_query("select distinct area from paiming");
while($row=mysql_fetch_array($sqldiqu)){?>
<option value="<?=$row['area']?>"><?=$row['area']?></option>
<?php }?>
</select>
<select id="paiming" name="paiming">
<option value="">排名</option>
<?php
$sqlpaiming=mysql_query("select * from website");
while($row=mysql_fetch_array($sqlpaiming)){?>
<option value="<?=$row['surl']?>"><?=$row['surl']?></option>
<?php }?>
</select>
<input type="text" name="serch" id="serch" value="" style="width:200px;"/>
<input type="button" value="搜索" id="serchbtn"/></td>
</form><td style="text-align:right;border-left:none;width:29%;"><a href="add.php">添加关键字</a>&nbsp;&nbsp;&nbsp;&nbsp;<a style="color:#ccc;">更新全部排名</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>
<script>initselect();initselect2();initselect3();</script>
<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;margin-left:20px;display:inline;"><a onclick="setCookie('B','11')" href="../content/index.php">文章收录检测</a></li>
<li style="float:left;width:100px;text-align:center;border:2px solid #337abb;border-top:1px solid #337abb;border-bottom:none;background:#337abb;"><a style="color:#FFF;" href="../paiming/index.php" onclick="setCookie('B','12')">关键字排名</a></li>
<li style="float:left;width:100px;text-align:center;color:#ccc;">关键字生成</li>
</ul></div>
<div class="list">
<table cellspacing="0" cellpadding="0"><tr style="background:#d3edf9;"><td style='border-left:none;'>ID</td><td style="width:30%;">关键字</td><td>地区</td><td>百度指数</td>
<?php
$webrs=mysql_fetch_array(mysql_query("select * from website where type='友好'"));
$webrs2=mysql_query("select * from website where type='竞争'");
$num=mysql_num_rows(mysql_query("SELECT * FROM website where type='竞争'"));
?>
<td><?=$webrs["surl"]?></td>
<?php
$pm1="";
while($webrs3=mysql_fetch_array($webrs2)){
$pm1 .=$webrs3["surl"].",";
?>
<td><?=$webrs3["surl"]?></td>
<?php }?>
<td class="g">操作</td></tr></table>
<table cellspacing="0" cellpadding="0">
<?php
ob_start();
require_once("../../global/page.class.php");
$where="";
$diqu="";
$paiming="";
$serch="";
$sqldq="";
$sqlpm="";
$sqlsh="";
$orderby="order by id desc";
if(isset($_GET["diqu"])){
$diqu=$_GET["diqu"];
$paiming=$_GET["paiming"];
$serch=$_GET["serch"];
$snum=0;
if($_GET["diqu"]!=""){
if($snum>0)
$sqldq="and area='$_GET[diqu]'";
else{
$sqldq="where area='$_GET[diqu]'";
$snum +=1;
}
}
if($_GET["paiming"]!=""){
if($_GET["paiming"]==$webrs["surl"]){
$orderby="order by ranking1 asc";
}else{
$pm2=explode(",",$pm1);
if(count($pm2)>1){
if($_GET["paiming"]==$pm2[0])
$orderby="order by ranking2 asc";
}
if(count($pm2)>2){
if($_GET["paiming"]==$pm2[1])
$orderby="order by ranking3 asc";
}
if(count($pm2)>3){
if($_GET["paiming"]==$pm2[2])
$orderby="order by ranking4 asc";
}
}
}
if($_GET["serch"]!=""){
if($snum>0)
$sqlsh="and keyword like '%$_GET[serch]%'";
else{
$sqlsh="where keyword like '%$_GET[serch]%'";
$snum +=1;
}
}
$where=$sqldq.$sqlsh;
}
$pageSize=15;
$total=mysql_num_rows(mysql_query("SELECT * FROM paiming $where")); 
pageft($total,$pageSize,1,1,1,9,20,0);
$sql="SELECT * FROM  paiming $where $orderby limit $firstcount,$pageSize";
$sql=mysql_query($sql);
if($sql){ob_end_clean();
while($row=mysql_fetch_array($sql)){
echo "<tr><td style='border-left:none;'>".$row["id"]."</td><td style=\"width:30%;text-align:left;\">&nbsp;<a href=\"http://www.baidu.com/s?wd=$row[keyword]\" target=\"_blank\">".$row["keyword"]."</a>(<a href=\"singleupdate.php?id=$row[id]&keyword=$row[keyword]\">check</a>)"."</td><td>".$row["area"]."</td><td >".$row["zhishu"]."</td><td style='color:#f20bd4;'>".$row["ranking1"];
if($row["ranking1"]<$row["preranking1"]){
$chawei=$row["preranking1"]-$row["ranking1"];
echo "<font color=\"green\">(↑".$chawei.")</font>"."</td>";
}
if($row["ranking1"]>$row["preranking1"]){
$chawei=$row["ranking1"]-$row["preranking1"];
echo "<font color=\"red\">(↓".$chawei.")</font>"."</td>";
}
if($row["ranking1"]==$row["preranking1"]){
echo "</td>";
}
if($num==1)
echo "<td>".$row["ranking2"]."</td>";
if($num==2)
echo "<td>".$row["ranking2"]."</td>"."<td>".$row["ranking3"]."</td>";
if($num==3)
echo "<td>".$row["ranking2"]."</td>"."<td>".$row["ranking3"]."</td>"."<td>".$row["ranking4"]."</td>";
echo "<td class='g'><a href=\"function.php?mod=delete&id=$row[id]\">[删除]</a></td></tr>";
}}else
echo "<tr><td style='width:100%;color:red;text-align:center;border-left:none;'>没有符合该条件的记录!</td></tr>";
ob_end_flush();
?>
</table>
<div>&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、此功能用于查询关键字排名、百度指数，可批量查询。排名100以后的统一记录为100,排名0则表示有推广。<br />
&nbsp;&nbsp;2、受百度推广竞价影响，部分排名可能出现小误差，因此排名数据仅供参考。<br />
&nbsp;&nbsp;3、如需要最准确的排名，请点击关键字后的(check)打开百度页面查看排名。
</div>
</div>
</div>
</body>
</html>
