关键词
【{$keywords}】的搜索结果:";
//pdo连接mysql
try
{
$conn = new PDO("mysql:host={$config['host']};dbname={$config['database']};port={$config['port']};charset=utf8", $config['user'], $config['passwd']);
//echo "mysql:host={$config['host']};dbname={$config['database']}";
}
catch (PDOException $pe)
{
die("Could not connect to the database $dbname :" . $pe->getMessage());
}
//查询数目
if ($kind === 'author')
{
$query0 = "SELECT count(*) FROM `bugs` WHERE author LIKE '%{$keywords}%'";
$query1 = "SELECT count(*) FROM `drops` WHERE author LIKE '%{$keywords}%'";
$res0 = $conn->query($query0);
$res1 = $conn->query($query1);
$row = $res0->fetch(PDO::FETCH_NUM)[0] + $res1->fetch(PDO::FETCH_NUM)[0];
}
else
{
$query0="SELECT count(*) FROM `{$kind}` WHERE `title` LIKE '%{$keywords}%'";
$res0 = $conn->query($query0);
$row = $res0->fetch(PDO::FETCH_NUM)[0];
}
//得到总页数 $p
if ($row % 15 != 0)
{
$p = intval($row / 15) + 1;
}
else
{
$p = $row / 15;
}
if ($row == 0) $p = 1;
if ($page > $p || $page <1 ) $page = 1;
echo "
共 {$row} 条记录
";
$start = ($page - 1) * 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";
}
$res = $conn->query($query);
$resulte = $res->fetchAll(PDO::FETCH_ASSOC);
//var_dump($resulte);
//输出结果
echo '
';
echo '| 提交时间 | 标题 | 漏洞类型 | 提交者 |
';
foreach ($resulte as $rrr){
if ($kind != "author")
{
echo "
";
}
else
{
if (array_key_exists($rrr['type'], $drops))
{
echo "
";
}
else
{
echo "
";
}
}
$time0 = str_split($rrr['dates'], 10);
echo "| {$time0[0]} | ";
echo "{$rrr['title']} | ";
if (array_key_exists($rrr['type'], $drops))
{
echo "{$drops[$rrr['type']]} | ";
}
else
{
echo "{$rrr['type']} | ";
}
echo "{$rrr['author']} | ";
echo "
";
}
echo "
";
$conn = null;
//分页
echo '";
?>