From 233e5dfed02532c3a25f25347da40485e00bf0c6 Mon Sep 17 00:00:00 2001 From: yujinbing Date: Thu, 13 Jul 2023 11:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=A2=9E=E5=8A=A0=E8=AE=BF?= =?UTF-8?q?=E9=97=AEIP=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/IP.php | 38 ++++++++++++++++++++++++++++++++++++++ admin/head.php | 1 + admin/index.php | 2 +- include/IP/index.php | 36 ++++++++++++++++++++++++++++++++++++ include/tj.php | 12 ++++++++++++ 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 admin/IP.php create mode 100644 include/IP/index.php diff --git a/admin/IP.php b/admin/IP.php new file mode 100644 index 0000000..e8aa913 --- /dev/null +++ b/admin/IP.php @@ -0,0 +1,38 @@ + + +
+
+
+

当天访问记录:

+
+ +$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,'

404

'); + echo file_get_contents($iptxt); +} +?> +
+
+
+ +
+
+ + \ No newline at end of file diff --git a/admin/head.php b/admin/head.php index 17cedd9..dd8c10c 100644 --- a/admin/head.php +++ b/admin/head.php @@ -49,6 +49,7 @@ if($applyrows>0) { +
  • 退出登录
  • diff --git a/admin/index.php b/admin/index.php index f9165a2..36f8818 100644 --- a/admin/index.php +++ b/admin/index.php @@ -161,7 +161,7 @@ if($applyrows>0) {
  • 项目地址:https://github.com/LyLme/lylme_spage -
  • + diff --git a/include/IP/index.php b/include/IP/index.php new file mode 100644 index 0000000..d741a13 --- /dev/null +++ b/include/IP/index.php @@ -0,0 +1,36 @@ + + + + + 本站访问记录 - <?php echo explode("-", $conf['title'])[0];?> + + + + + + + +
    +

    本站访问记录:

    +404'); + echo file_get_contents($iptxt); +} +?> + +
    +
    + + \ No newline at end of file diff --git a/include/tj.php b/include/tj.php index ed4d6ec..c34dc1e 100644 --- a/include/tj.php +++ b/include/tj.php @@ -49,4 +49,16 @@ if(strpos($_SERVER['REQUEST_URI'],'admin')==false){ //访总问 {$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 = "
  • IP:".$ip." "." 访问时间:".$time."
  • \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 ?> \ No newline at end of file