How to set the limit of browsing per ip several times per day by php
This article mainly introduces php how to set the limit of browsing several times a day for each ip, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Php to achieve several times a day for each ip browsing method: 1, through the "CREATE TABLE ip_log ()" to create a table; 2, set when the user visits to record ip information, the initial value of browsing times is 1 to 3, when the number of browsing pages is equal to the set value, users are not allowed to access.
This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer
The implementation idea of using php to limit the number of pages viewed per ip per day
Implementation idea: first, create a table, such as the following
CREATE TABLE ip_log (ip_log_ip VARCHAR (40), ip_log_date DATE, ip_log_visits TINYINT (1), ip_log_page varchar (255), PRIMARY KEY (ip_log_page,ip_log_ip,ip_log_date),)
Then, write code to record the ip information when the user visits, and the initial value of the number of browsing is 1
When the number of browsed pages is equal to the set value, user access is not allowed.
Finally, you can run a cron table at 00:00 every night to delete all the data, such as using truncate
Thank you for reading this article carefully. I hope the article "how to set the limit for browsing several times per ip per day" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!