后台增加访问IP记录

main
水墨寒 1 year ago
parent cf92ac52e3
commit 233e5dfed0

@ -0,0 +1,38 @@
<?php
$title = '访问记录';
include './head.php';
?>
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="card">
<div class="card-header"><h4>当天访问记录:</h4></div>
<div class="card-body">
<?php
//<div class="lyear-layout-content" id="main">
$date = date("Y-m-d");
$iptxt = "../include/IP/IP_".$date.".txt";
//$about = 'about.txt';
//本页内容请修改about.txt文件防止更新后index.php文件被覆盖
if(file_exists($iptxt)){
//文件存在,直接输出文件内容
echo file_get_contents($iptxt);
}
else {
//文件不存在
@file_put_contents($iptxt,'<h1>404</h1>');
echo file_get_contents($iptxt);
}
?>
</div>
</div>
</div>
</div>
</main>
<center><p class="footer"><?php echo $conf['copyright']?></p></center>
<?php
include './footer.php';
?>

@ -49,6 +49,7 @@ if($applyrows>0) {
<li class="nav-item active"> <a href="./group.php"><i class="mdi mdi-folder"></i>分组管理</a></li> <li class="nav-item active"> <a href="./group.php"><i class="mdi mdi-folder"></i>分组管理</a></li>
<li class="nav-item active"> <a href="./link.php"><i class="mdi mdi-web"></i>链接管理</a></li> <li class="nav-item active"> <a href="./link.php"><i class="mdi mdi-web"></i>链接管理</a></li>
<li class="nav-item active"> <a href="./pwd.php"><i class="mdi mdi-key-variant"></i>加密管理</a></li> <li class="nav-item active"> <a href="./pwd.php"><i class="mdi mdi-key-variant"></i>加密管理</a></li>
<li class="nav-item active"> <a href="./IP.php"><i class="mdi mdi-home-map-marker"></i>访问记录</a></li>
<li class="nav-item active"> <a href="./update.php"><i class="mdi mdi-update"></i>检查更新</a> </li> <li class="nav-item active"> <a href="./update.php"><i class="mdi mdi-update"></i>检查更新</a> </li>
<li> <a href="javascript:loginout()"><i class="mdi mdi-logout"></i> 退出登录</a> </li> <li> <a href="javascript:loginout()"><i class="mdi mdi-logout"></i> 退出登录</a> </li>
</ul> </ul>

@ -0,0 +1,36 @@
<?php include("../../include/common.php"); ?>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>本站访问记录 - <?php echo explode("-", $conf['title'])[0];?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link href="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/docsify/4.12.2/themes/vue.min.css" type="text/css" rel="stylesheet">
<style>body:not(.ready){overflow:auto!important}#main{max-width:90%}p.footer{margin-top:60px}p.footer a{text-decoration:none}</style>
</head>
<body>
<div class="markdown-section" id="main">
<h3>本站访问记录:</h3>
<?php
$date = date("Y-m-d");
$iptxt = "IP_".$date.".txt";
//$about = 'about.txt';
//本页内容请修改about.txt文件防止更新后index.php文件被覆盖
if(file_exists($iptxt)){
//文件存在,直接输出文件内容
echo file_get_contents($iptxt);
}
else {
//文件不存在
@file_put_contents($iptxt,'<h1>404</h1>');
echo file_get_contents($iptxt);
}
?>
<center><p class="footer"><?php echo $conf['copyright']?></p></center>
</div>
</body>
</html>

@ -49,4 +49,16 @@ if(strpos($_SERVER['REQUEST_URI'],'admin')==false){
//访总问 {$tjtotal} 本月 {$tjmonth} 昨日 {$tjyesterday} 今日 {$tjtoday} //访总问 {$tjtotal} 本月 {$tjmonth} 昨日 {$tjyesterday} 今日 {$tjtoday}
} }
} }
//记录访问IP
$time = date("Y-m-d H:i:s");//$time把访问时间记录下来 如果向把具体年份写出来请把y更改为Y
$date = date("Y-m-d");
//注意Y要是英文半角哦
$ip = $_SERVER["REMOTE_ADDR"];//$ip记录访问者IP
$save = "<li> IP:".$ip." "." 访问时间:".$time."</li> \n";//把上面两个结合并添加空格
//不想要空格可以删除$save中的." "
//echo $save;//echo 保存
file_put_contents("include/IP/"."IP_".$date.".txt",$save,FILE_APPEND);//通过$save保存至txt文档
//header('Location: http://xxx.xxx/index.html');
//跳转到主页不要照搬把xxx.xxx换成你的域名如果主页不是index.html的话要更换/index.html
//如果你的网站就是php的话请把旧主页更换为其他名字例如:a.php /index.html也要换成/a.php
?> ?>
Loading…
Cancel
Save