dtukyb8095 2012-05-18 16:57
浏览 38
已采纳

正常运行时远程计数器php

What I want is a little beyond of my basic knowledge on webdev.

Im looking for a way to develop a php counter to show me how much time there is an online computer on a network (as he ought to be settled by a ping to that machine i think).

example:

Computer 1: ONLINE - 02:45:02 h (still up-counting in realtime)

Given a refresh on the page, the state may change to:

Computer 1: OFFLINE - 00:00:00 h (maybe computer has turned off)

As another refreshing the page, the state may change to:

Computer 1: ONLINE - 00:00:01 h (again online, starting new count)

Ive already a ping function working.

Extra: I may need to register these changes of state in a kind of LOG, but I put that to the background for now!

edit: im asking it in php, but it could be done in a easy way, im listening you! Im srry for some english mistakes :)

I hope I have explained to me as well! Since already grateful for your attention.

  • 写回答

2条回答 默认 最新

  • doupo1865 2012-05-18 17:36
    关注

    Another option would be to have a simple ajax call that continually updates a database record based on the user's IP address. You could have it run every 10 seconds or 30 seconds or whatever you like. All you would need to do is create a MySQL table that stores the user's IP the datetime the entry was created then a last recorded datetime. Each ajax call it checks to see if there is a row with the same IP and a last recorded datetime within your interval (10 seconds or whatever you set it to), if so just update the last recorded datetime, if not insert a new row.

    On your php page you would then check for any records that had last recorded datetime within your setup interval (10 seconds for example) if so they you can use a javascript/jquery clock to show you the time that has elapsed since the datetime the record was created.

    Another option that would be easier is to simply install Google Analytics, they have a new Realtime feature where you can see in real-time who is on your site, what page they are looking at, etc...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧