Home Backend Development PHP Tutorial php 统计在线人数,今日访问量,总访问量

php 统计在线人数,今日访问量,总访问量

Jun 20, 2016 pm 01:03 PM
entry online quot temp

代码如下:

<?php </p>header('Content-type: text/html; charset=utf-8');<br />$online_log = "count.dat"; //保存人数的文件,<br />$timeout = 30;//30秒内没动作者,认为掉线<br />$entries = file($online_log);<br /><br />$temp = array();<br /><br />for ($i=0;$i<count($entries);$i++) {<br />$entry = explode(",",trim($entries[$i]));<br />if (($entry[0] != $_SERVER["REMOTE_ADDR"]) && ($entry[1] > time())) {<br />array_push($temp,$entry[0].",".$entry[1]."\n"); //取出其他浏览者的信息,并去掉超时者,保存进$temp<br />}<br />}<br /><br />array_push($temp,$_SERVER["REMOTE_ADDR"].",".(time() + ($timeout))."\n"); //更新浏览者的时间<br />$users_online = count($temp); //计算在线人数<br /><br />$entries = implode("",$temp);<br />//写入文件<br />$fp = fopen($online_log,"w");<br />flock($fp,LOCK_EX); //flock() 不能在NFS以及其他的一些网络文件系统中正常工作<br />fputs($fp,$entries);<br />flock($fp,LOCK_UN);<br />fclose($fp);<br /><p>echo "当前在线".$users_online."人";</p><p>?></p>
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Teach you how to modify the temporary file location of Win7 Teach you how to modify the temporary file location of Win7 Jan 04, 2024 pm 11:25 PM

The temp folder is our temporary file storage location. The system will save temporary files to this folder. If there are too many temporary files, especially when the temp folder is on the system disk, it is likely to affect the system running speed. We can solve the problem by changing the temp location. Let’s take a look below. Tutorial on changing the location of win7temp 1. First, right-click "Computer" and open "Properties" 2. Click "Advanced System Settings" on the left 3. Click "Environment Variables" below 4. Select "temp" and click "Edit" 5. Then change Just change the "Variable Value" to the path that needs to be changed.

How to Fix Processor Thermal Trip Error in Windows 11/10 [Fix] How to Fix Processor Thermal Trip Error in Windows 11/10 [Fix] Apr 17, 2023 am 08:13 AM

Most of the devices, such as laptops and desktops, have been heavily used by young gamers and coders for a long time. The system sometimes hangs due to application overload. This forces users to shut down their systems. This mainly happens to players who install and play heavy games. When the system tries to boot after force shutdown, it throws an error on a black screen as shown below: Below are the warnings detected during this boot. These can be viewed in the settings on the event log page. Warning: Processor thermal trip. Press any key to continue. ..These types of warning messages are always thrown when the processor temperature of a desktop or laptop exceeds its threshold temperature. Listed below are the reasons why this happens on Windows systems. Many heavy applications are in

What does temp mean in computer? What does temp mean in computer? Sep 29, 2021 pm 04:39 PM

In computers, temp means "temporary folder", which contains many temporary files; its function is to temporarily save the user's work results in the application to prevent losses caused by accidents. Deleting temp files can free up hard disk storage space, but it will be slower to open the application for the first time after deletion.

Internal error: Unable to create temporary directory [Resolved] Internal error: Unable to create temporary directory [Resolved] Apr 17, 2023 pm 03:04 PM

Windows system allows users to install various types of applications on your system using executable/setup files. Recently, many Windows users have started complaining that they are receiving an error named INTERNALERROR:cannotCreateTemporaryDirectory on their systems while trying to install any application using an executable file. The problem is not limited to this but also prevents the users from launching any existing applications, which are also installed on the Windows system. Some possible reasons are listed below. Run the executable to install without granting administrator privileges. An invalid or different path was provided for the TMP variable. damaged system

What file is temp? What file is temp? Jan 05, 2021 am 10:43 AM

temp is a temporary folder. In the path "C:\Documents and Settings\Administrator\Local Settings\", many temporary files are placed here, including favorites, temporary files for browsing web pages, editing files, etc.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Webpack core concept entry configuration (entry) Webpack core concept entry configuration (entry) Aug 09, 2022 pm 07:00 PM

At the beginning of all processes, we need to specify one or more entries, which means telling Webpack which file in the source directory to start packaging from. The following article will give you an in-depth understanding of the entry configuration (entry) in the core concept of webpack. I hope it will be helpful to you!

Can I delete the temp folder? Can I delete the temp folder? Feb 19, 2024 am 10:13 AM

The temp folder is a folder that often appears in computer systems. It is used to temporarily store temporary files and temporary data generated during the operation of the computer system. In many operating systems, such as Windows, Linux, etc., a temp folder is created by default. So, can the temp folder be deleted? First, we need to understand the role of the temp folder. The temp folder is mainly used to store temporary files and data. These files and data usually have a short life cycle and are generally used for temporary storage.

See all articles