<?php
/*打开文件用于记录访问量,如果文件不存在自动创建*/
$counterFile = "counter.txt";
$fp = fopen($counterFile,"a+");
/*获取IP*/
$adress=$_SERVER["REMOTE_ADDR"];
/*统计访问量*/
$num = fgets($fp,5);
$num += 1;
print "您是第 "."$num"." 位访客,"." 您的IP是:["."$adress"."]";
/*关闭文件,重新以只写的方式打开*/
fclose($fp);
$fp=fopen($counterFile,"w");
/*更新变量$fp的值*/
fwrite($fp, $num);
fclose($fp);
?>
[使用方法]
Copy code to WordPress’s Appearance ->[Themes Editor] ->[Footer.php Theme Footer File]
Let’s see how it works.

2. Preservation of Visitors IP
[原码]
<?php
/*打开文件用于保存访客IP,如果文件不存在自动创建*/
$IPFile = "wp-IP.txt";
/*以追加方式打开文件*/
$fp = fopen($IPFile,"a");
/*获取访客IP*/
$adress=$_SERVER["REMOTE_ADDR"];
/*把IP写入文件*/
fwrite($fp, $adress);
/*界面美化和添加时间*/
fwrite($fp,"\r\n");
//date_default_timezone_set(PRC);
fwrite($fp,date("d-m-Y H:i:s"));
fwrite($fp,"\r\n");
fwrite($fp,"#-----------------#");
fwrite($fp,"\r\n");
//fclose($fp);
?>
[使用方法]
Copy code to WordPress’s Appearance ->[Themes Editor] ->[Footer.php Theme Footer File]
Let’s see how it works.
3. Use new page and add the code to the page
<--html-->
<a href="wp-IP.txt" target="show" rel="noopener noreferrer">IP访问记录</a>
<iframe name="show" id="show" width="300" height="500"/>
<--/html-->
4. Carnation tips
(1) The above two codes can be used separately or both, and it is suggested that they should be added otherwise only part II codes cannot be displayed on the website.
(2) The default time of acquisition in WordPress is 8 hours between Greenwich and Beijing, so a function should be added before the time statement is obtained
/Interface beautification and add time/
date_default_timezone_set(PRC);
Of these, the PRC represents the People ‘ s Republic of China.
In addition:
date_default_timezone_set(‘Asia/Shanghai’)
Singapore: Asia/Singapore
Continent: `Asia/Shanghai ‘ (Shanghai, Chongqing, Urumqi)
Hong Kong Taiwan region: Asia/Macao, Asia/Hong_Kong, Asia/Taipei (Hong Kong, Taipei)
未经允许不得转载:萌萌Apprentissage » Wordpress Addip Access Record
WordPress Summary of Moving Methods: Migration of Hosts and Replacement of Domain Names
How to set auto-optimize auto-autoptimize plugins for your WordPress site
Fix the Alt properties of Wordpress Google SEO search engine to optimize missing images
WordPress Configure Memcached Cache Course (no code required)
Use the tower panel to accelerate the optimization of the course on Wordpress 4 paces
Wordpress used redis or memcached to make site caches optimized.
Wordpress website moveovers to change domain name solutions
Method to change the default login page name for Wordpress wp-login