简体   繁体   English

如何判断我的网络上的计算机是否已启用PHP?

[英]How can I tell if a machine on my network is on with PHP?

I want to write a PHP script similar to Enterprise Network Console , but for a LAN of PC's and devices instead of a WAN of servers. 我想写一个类似于企业网络控制台的PHP脚本,但是对于PC和设备的局域网而不是服务器的WAN。

I want to be able to check if the PC's, Copiers etc are connected to the network. 我希望能够检查PC,复印机等是否连接到网络。 I want to know even if they are off, however this is not possible as the PCs ignore packets unless it's a wake-on-lan packet, right? 我想知道即使它们已关闭,但这是不可能的,因为PC会忽略数据包,除非它是一个唤醒lan数据包,对吗?

What is the best way to check if a PC is on or off? 检查PC是打开还是关闭的最佳方法是什么? I used fSocketOpen() to test the servers however most of the PC's aren't servers. 我使用fSocketOpen()来测试服务器,但大多数PC都不是服务器。 They respond to pings but don't have ports open for connections, meaning PHP'ss fSocketOpen() won't work but pinging does. 他们响应ping但没有端口打开连接,这意味着PHP fSocketOpen()不起作用,但ping操作。

You can use system commands and catch the stdout for results. 您可以使用系统命令并捕获stdout以获得结果。

Just make a search for PHP's popen ( http://uk3.php.net/popen ) examples. 只需搜索PHP的popen( http://uk3.php.net/popen )示例。

echo run('ping 192.168.1.5');

function run($command) {
    $command .= ' 2>&1';
    $handle = popen($command, 'r');
    $log = '';

    while (!feof($handle)) {
        $line = fread($handle, 1024);
        $log .= $line;
    }

    pclose($handle);
    return $log;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我怎么知道我的PHP $ _Get最大值是什么 - How can I tell what my PHP $_Get max value is 如何确定必须将哪些外部模块安装到PHP才能在另一台计算机上复制配置? - How can I tell which external modules I have to install to PHP to replicate the configuration on another machine? 我怎么知道我的桌子是空的? - How can I tell if my table is empty? 如何判断我的PHP S3类putObjectFile()过程是否已完成? - How can I tell if my PHP S3 class putObjectFile() process has completed? 我如何才能知道php脚本在完成加载之前在做什么? - How can I tell what my php script is doing before it finishes loading? 如何判断我的内存是否已被PHP应用程序安全释放? - How can I tell if my memory has been released securely by a PHP application? PHP Facebook API。 如何通过API判断我的应用程序是否处于活动状态? - PHP Facebook API. How can I tell if my application is active via the API? 如何判断我的Apache2 + PHP是否使用CGI / FCGI? - How can I tell if my Apache2+PHP uses CGI/FCGI? 我的PHP脚本如何判断suhosin是否更改了请求变量? - How can my php script tell if suhosin changed request variables? 我的 PHP 脚本如何判断服务器是否忙? - How can my PHP script tell whether the server is busy?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM