增加作者搜索
This commit is contained in:
BIN
author.jpg
Normal file
BIN
author.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
132
search.php
132
search.php
@@ -4,10 +4,10 @@
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>乌云搜索|搜索结果</title>
|
||||
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<script type="text/javascript" src="bootstrap/js/jquery-3.1.0.min.js"></script>
|
||||
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap/search.css">
|
||||
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<script type="text/javascript" src="../bootstrap/js/jquery-3.1.0.min.js"></script>
|
||||
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="search.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="my-container">
|
||||
@@ -31,27 +31,29 @@ else{
|
||||
if(!isset($_GET['page'])){
|
||||
$page=1;
|
||||
}else{
|
||||
if(is_numeric($_GET['page'])&&is_int($_GET['page']+0)){
|
||||
$page=$_GET['page'];
|
||||
}
|
||||
else{
|
||||
$page=1;
|
||||
}
|
||||
$page=intval($_GET['page']);
|
||||
}
|
||||
if(!isset($_GET['kind'])){
|
||||
$kind='bugs';
|
||||
}
|
||||
else{
|
||||
if($_GET['kind']==='bugs'||$_GET['kind']==='drops'){
|
||||
if($_GET['kind']==='bugs'||$_GET['kind']==='drops'||$_GET['kind']==='author'){
|
||||
$kind=$_GET['kind'];
|
||||
}
|
||||
else{
|
||||
$kind='bugs';
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h3 style=\"display:inline-block;\">关键词【".$keywords."】的搜索结果:</h3>";
|
||||
#$sql="select * from bugs where title like ";
|
||||
#$res=$pdo->query($sql);
|
||||
#SELECT count(*) FROM `bugs` WHERE `title` LIKE \'%腾讯%\'
|
||||
#SELECT* FROM `bugs` WHERE `title` LIKE '%腾讯%' LIMIT 0,4
|
||||
#title,datas,author,doc,type
|
||||
|
||||
//mysql建立连接
|
||||
$db=new mysqli('localhost','root','','wooyun'); //localhost:3307
|
||||
$db=new mysqli('localhost','root','','wooyun');
|
||||
//sql对象错误检查
|
||||
if(mysqli_connect_errno()){
|
||||
echo '<br>Error:Please try again later.';
|
||||
@@ -59,32 +61,61 @@ if(mysqli_connect_errno()){
|
||||
}
|
||||
// 建立查询
|
||||
$db->set_charset("utf8");
|
||||
#drops
|
||||
//分页处理
|
||||
$query0="SELECT count(*) FROM `".$kind."` WHERE `title` LIKE '%".$keywords."%'";
|
||||
$num=$db->query($query0);
|
||||
$row=$num->fetch_row();
|
||||
$rows=$row[0]/15;
|
||||
if($row[0]%15==0){
|
||||
if($page>$row[0]/15){
|
||||
$page=1;
|
||||
}
|
||||
if($kind==='author'){
|
||||
$query0="SELECT count(*) FROM `bugs` WHERE author LIKE '%".$keywords."%'";
|
||||
$query1="SELECT count(*) FROM `drops` WHERE author LIKE '%".$keywords."%'";
|
||||
}
|
||||
else{
|
||||
if($page>$rows+1){
|
||||
$query0="SELECT count(*) FROM `".$kind."` WHERE `title` LIKE '%".$keywords."%'";
|
||||
}
|
||||
|
||||
$num=$db->query($query0);
|
||||
$row=$num->fetch_row();
|
||||
if($kind==="author"){
|
||||
$num1=$db->query($query1);
|
||||
$rows=$num->fetch_row();
|
||||
$row[0]+=$rows[0];
|
||||
}
|
||||
//得到总页数 $p
|
||||
if($row[0]%15!=0){
|
||||
$p=intval($row[0]/15)+1;
|
||||
}
|
||||
else{
|
||||
$p=$row[0]/15;
|
||||
}
|
||||
if($row[0]==0) $p=1;
|
||||
if($page>$p || $page<1){
|
||||
$page=1;
|
||||
}
|
||||
}
|
||||
echo "<h4 style=\"display:inline-block;\">共 ".$row[0]." 条记录</h4>";
|
||||
$start=($page-1)*15;
|
||||
$query="SELECT * FROM `".$kind."` WHERE `title` LIKE '%".$keywords."%' ORDER BY dates DESC LIMIT ".$start.",15";
|
||||
if($kind==='author'){
|
||||
$query="(SELECT doc,dates,title,type,author FROM `bugs` WHERE `author` LIKE '%".$keywords."%') UNION ALL (SELECT doc,dates,title,type,author FROM `drops` WHERE `author` LIKE '%".$keywords."%')ORDER BY dates DESC LIMIT ".$start.",15";
|
||||
}
|
||||
else{
|
||||
$query="SELECT * FROM `".$kind."` WHERE `title` LIKE '%".$keywords."%' ORDER BY dates DESC LIMIT ".$start.",15";
|
||||
}
|
||||
//执行查询
|
||||
$result=$db->query($query);
|
||||
//逐行分解result
|
||||
echo "<table class=\"table table-striped table-hover\">";
|
||||
#echo "<div>";
|
||||
echo "<div><table class=\"table table-striped table-hover\">";
|
||||
echo "<tr><td>提交时间</td><td>标题</td><td>漏洞类型</td><td>提交者</td><tr>";
|
||||
for($i=0;$i<$result->num_rows;$i++){
|
||||
$row_result=$result->fetch_object();
|
||||
echo "<tr onclick=\"window.open('/wooyun/".$kind."/".$row_result->doc."');\" style=\"cursor:pointer;\">";
|
||||
if($kind!="author"){
|
||||
echo "<tr onclick=\"window.open('./".$kind."/".$row_result->doc."');\" style=\"cursor:pointer;\">";
|
||||
}
|
||||
else{
|
||||
if($row_result->type=="binary" || $row_result->type=="mobile" || $row_result->type=="mobiledev" || $row_result->type=="database" || $row_result->type=="news" || $row_result->type=="papers" || $row_result->type=="pentesting" || $row_result->type=="tips" || $row_result->type=="tools" || $row_result->type=="web" || $row_result->type=="wireless" || $row_result->type=="safe"){
|
||||
echo "<tr onclick=\"window.open('./drops/".$row_result->doc."');\" style=\"cursor:pointer;\">";
|
||||
}
|
||||
else{
|
||||
echo "<tr onclick=\"window.open('./bugs/".$row_result->doc."');\" style=\"cursor:pointer;\">";
|
||||
}
|
||||
}
|
||||
$time0=str_split($row_result->dates,10);
|
||||
echo '<td>'.$time0[0].'</td>';
|
||||
echo '<td style="color:#01a8ff;">'.$row_result->title.'</td>';
|
||||
@@ -92,7 +123,7 @@ echo "<tr><td>提交时间</td><td>标题</td><td>漏洞类型</td><td>提交者
|
||||
echo '<td>'.$row_result->author.'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo "</table>";
|
||||
echo "</table></div>";
|
||||
// 显示result
|
||||
// 释放连接,关闭sql.
|
||||
$result->free();
|
||||
@@ -100,38 +131,41 @@ $db->close();
|
||||
//分页
|
||||
echo "<div class=\"pagination pagination-large my-page\">";
|
||||
echo "<ul>";
|
||||
if($row[0]%15==0){
|
||||
$total=$row[0]/15-1;
|
||||
}
|
||||
else{
|
||||
$total=($row[0]-$row[0]%15)/15;
|
||||
}
|
||||
$i=0;
|
||||
//首
|
||||
if($page==1){
|
||||
echo "<li class=\"disabled\"><a href=\"#\">«</a></li>";
|
||||
}
|
||||
else{
|
||||
}
|
||||
else{
|
||||
echo "<li><a href=\"search.php?kind=".$kind."&keywords=".$keywords."&page=".($page-1)."\">«</a></li>";
|
||||
}
|
||||
//中间处理
|
||||
if($p>17){
|
||||
if($page<9){
|
||||
$i=1;
|
||||
}
|
||||
if($total>20&&$page<=9){
|
||||
$total=17;
|
||||
elseif($page>=9 && $page+8<$p){
|
||||
$i=$page-8;
|
||||
}
|
||||
elseif($page+8>=$p){
|
||||
$i=$p-8;
|
||||
}
|
||||
$j=$i+17;
|
||||
}
|
||||
if($total>20&&$page>=9&&$page+8<=$total){
|
||||
$i=$page-9;
|
||||
$total=$page+8;
|
||||
else{
|
||||
$i=1;
|
||||
$j=$p;
|
||||
}
|
||||
if($total>20&&$page>=9&&$page+8>$total){
|
||||
$i=$total-17;
|
||||
}
|
||||
for(;$i<=$total;$i++){
|
||||
if($page==$i+1){
|
||||
echo "<li class=\"disabled\"><a href=\"search.php?kind=".$kind."&keywords=".$keywords."&page=".($i+1)."\">".($i+1)."</a></li>";
|
||||
//echo $p;
|
||||
for(;$i<=$j;$i++){
|
||||
if($page==$i){
|
||||
echo "<li class=\"disabled\"><a href=\"search.php?kind=".$kind."&keywords=".$keywords."&page=".$i."\">".$i."</a></li>";
|
||||
}
|
||||
else{
|
||||
echo "<li><a href=\"search.php?kind=".$kind."&keywords=".$keywords."&page=".($i+1)."\">".($i+1)."</a></li>";
|
||||
echo "<li><a href=\"search.php?kind=".$kind."&keywords=".$keywords."&page=".$i."\">".$i."</a></li>";
|
||||
}
|
||||
}
|
||||
if($page==$total+1){
|
||||
//尾
|
||||
if($page==$p || $p==0){
|
||||
echo "<li class=\"disabled\"><a href=\"#\">»</a></li>";
|
||||
}
|
||||
else{
|
||||
@@ -139,7 +173,7 @@ if($page==$total+1){
|
||||
}
|
||||
echo "</ul></div>";
|
||||
?>
|
||||
<h5>数据来源于wooyun.org</h5>
|
||||
<div><h5>数据来源于wooyun.org</h5></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user