优化访客统计功能

This commit is contained in:
LyLme 2022-02-22 02:54:24 +08:00
parent 97b4f55f47
commit 7252c8d886
1 changed files with 5 additions and 16 deletions

View File

@ -17,7 +17,7 @@ if(!$con =mysqli_connect($dbconfig['host'],$dbconfig['user'],$dbconfig['pwd'],$d
echo '连接数据库失败,['.mysqli_connect_errno().']'.mysqli_connect_error();
}
}
$GLOBALS['con'] = $con;
mysqli_query($con,"set sql_mode = ''");
//字符转换,读库
mysqli_query($con,"set character set 'utf8'");
@ -29,24 +29,13 @@ while($row = mysqli_fetch_assoc($rs)) {
$conf[$row['k']]=$row['v'];
}
if(strpos($_SERVER['REQUEST_URI'],'admin')==false){
if(!file_exists(SYSTEM_ROOT."log.txt")){
$one_file=fopen(SYSTEM_ROOT."log.txt","w+"); //建立一个统计文本,如果不存在就创建
fwrite(SYSTEM_ROOT."log.txt",1); //把数字1写入文本
fclose("$one_file");
}else{ //如果不是第一次访问直接读取内容,并+1,写入更新后再显示新的访客数
$num=file_get_contents(SYSTEM_ROOT."log.txt");
$num++;
file_put_contents(SYSTEM_ROOT."log.txt","$num");
//$pvnum=file_get_contents(SYSTEM_ROOT."log.txt");
}
}
$pvnum=file_get_contents(SYSTEM_ROOT."log.txt");
include_once(SYSTEM_ROOT."function.php");
include_once(SYSTEM_ROOT."member.php");
include_once(SYSTEM_ROOT."tj.php");
mysqli_query($con,'set names utf8');
$links = mysqli_query($con, "SELECT * FROM `lylme_links`");
$numrows=mysqli_num_rows($links);
$linksrows=mysqli_num_rows(mysqli_query($con, "SELECT * FROM `lylme_links`"));
$groupsrows=mysqli_num_rows(mysqli_query($con, "SELECT * FROM `lylme_groups`"));
?>