<!DOCTYPE html>
<html>
<head>
<title>BLOG</title>
<meta charset="utf-8">
<!--样式表-->
<?php $serverIP = gethostbyname($_SERVER['SERVER_NAME']);
?>
<link rel="stylesheet" href="https://<?php echo $serverIP;?>/blog/styles/index.css">
</head>
<body>
<!--导航栏-->
<div class="navbar">
<a href="https://<?php echo $serverIP;?>/blog" class="active">首页</a>
<a href="https://<?php echo $serverIP;?>/blog/content/DatabaseQuery.php">数据库查询</a>
<!--文件操作-->
<div class="dropdown">
<a href="#news" class="dropbtn">文件操作</a>
<div class="dropdown-content">
<a href="https://<?php echo $serverIP;?>/blog/content/FileUpLoad.php">文件上传</a>
<a href="https://<?php echo $serverIP;?>/blog/content/FileDownLoad.php">文件下载</a>
<a href="https://<?php echo $serverIP;?>/blog/content/FileDelete.php">文件删除</a>
<a href="https://<?php echo $serverIP;?>/blog/content/FileRead&Write.php">文件读取和写入</a>
</div>
</div>
<!--连接维持-->
<div class="dropdown">
<a href="#news" class="dropbtn">连接维持</a>
<div class="dropdown-content">
<a href="https://<?php echo $serverIP;?>/blog/content/COOKIE.php">COOKIE</a>
<a href="https://<?php echo $serverIP;?>/blog/content/SESSION.php">SESSION</a>
</div>
</div>
<!--JS-Ajax-->
<div class="dropdown">
<a href="#news" class="dropbtn">JS-Ajax</a>
<div class="dropdown-content">
<a href="https://<?php echo $serverIP;?>/blog/content/js_upfiles.php">文件上传</a>
<a href="https://<?php echo $serverIP;?>/blog/content/js_login.php">登录</a>
<a href="https://<?php echo $serverIP;?>/blog/content/js_shop.php">购物商城</a>
</div>
</div>
</div>
<hr>
<!--搜索-->
<form action="" method="post" enctype="multipart/form-data">
<label for="search">搜索</label>
<input type="search" name="search">
<input type="submit" value="搜索">
</form>
<?php
$n=$_COOKIE['user'];echo $n;
include("/opt/lampp/htdocs/blog/config/conn.php");
if(isset($_POST['search']) && $_POST['search']!==''){
$x=$_POST['search'];
$sql = "SELECT * FROM blog_db.posts WHERE title like '%$x%'";
$result = mysqli_query($conn, $sql);
echo "查询 $x 的结果:<br>";
echo '查询总数量: '.mysqli_num_rows($result).'<br><br>';
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result)) {
echo "post_id:".$row['post_id'];
echo "<br>";
echo "author_id:".$row['author_id'];
echo "<br>";
echo "title:".$row['title'];
echo "<br>";
echo "slug:".$row['slug'];
echo "<br>";
echo "content:".$row['content'];
echo "<br>";
echo "created_at:".$row['created_at'];
echo "<br>";
echo "updated_at:".$row['updated_at'];
echo "<br><br>";
}
} else {
echo "0 结果";
}
mysqli_close($conn);
}
?>
<!--留言板-->
<div>
<h2>留言板</h2>
<form action="" method="POST">
<textarea name="msg" rows="10" cols="50"></textarea><br>
<input type="submit" value="留言">
</form>
<?php
if(isset($_POST['msg']) && $_POST['msg']!==''){
$msg=$_POST['msg'];
//echo $msg;
include("/opt/lampp/htdocs/blog/config/conn.php");
$sql = "SELECT * FROM blog_db.messages";
$result = mysqli_query($conn, $sql);
//print_r($result);
$sql = "INSERT INTO messages (message) values(\"$msg\")";
mysqli_query($conn, $sql);
mysqli_close($conn);
}
?>
<div style="padding:10px;background:#bfffcb;color:#ea5151">
<?php
include("/opt/lampp/htdocs/blog/config/conn.php");
$sql = "SELECT * FROM blog_db.messages";
$result = mysqli_query($conn, $sql);
//print_r($result);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result)) {
echo $row['message']."<br>";
}
}else{
echo "无留言!";
}
mysqli_close($conn);
?>
</div>
</div>
<!--展示源码-->
<h1>展示源码</h1>
<button class="source" style="float:left">源码</button>
<div class="source" style="float:left">
<?php
show_source(__file__);
?>
</div>
<?php system('whoami');?>
</body>
</html>