php 文件 actionscript 计算机属性 RAM 处理器信息

标签 php actionscript ip

我只是想知道 php 中是否有一种方法可以检索服务器的属性,例如计算机名称、内存、处理器信息。

这些信息将被加载到 ActionScript 中。

我已经用这种方式创建了一个 php 文件来了解服务器的 IP 地址,就像网上教程文章中所述的那样:

<?php //Opening Tag, tell PHP server to interpret the following lines as php code 
$ip = $_SERVER['REMOTE_ADDR']; //Sets the ip variable, its value is a method that will get the user ip
echo $ip; //The echo keyword outputs the assigned string, in this case the ip variable 
?>

我已成功将 IP 地址的值回显或显示到我的 Flash 应用程序。现在,我不知道如何知道服务器的计算机名称、内存和处理器信息。

这里有人知道 php 中的代码来显示我需要的信息吗?

编辑: 感谢您的快速回复。

这就是答案。我们必须使用exec命令。 (考虑到php没有配置安全功能或者被关闭)

了解一台电脑的计算机名称。

<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?> 

对于PC的CPU和内存:

<?php

function GetProgCpuUsage($program)
 {
     if(!$program) return -1;

    $c_pid = exec("ps aux | grep ".$program." | grep -v grep | grep -v su | awk {'print $3'}");
     return $c_pid;
 }

function GetProgMemUsage($program)
 {
     if(!$program) return -1;

    $c_pid = exec("ps aux | grep ".$program." | grep -v grep | grep -v su | awk {'print $4'}");
     return $c_pid;
 }



    echo "CPU use of Program: ".GetProgCpuUsage($randomprogram)."%";
     echo "Memuse of Program: ".GetProgMemUsage($randomprogram)."%";

?>

您可以更多地引用此信息的来源。 来源:http://php.net/manual/en/function.exec.php

最佳答案

在服务器中创建一个脚本,该脚本将获取其硬件信息并将其显示给您。之后通过 actionscript 调用此脚本并显示信息。

要获取硬件信息,您需要系统命令。您必须使用exec函数来运行系统命令。

要获取 Windows 操作系统的系统信息,请使用此命令 systeminfoSystem info for windowsOS

关于php 文件 actionscript 计算机属性 RAM 处理器信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16297173/

相关文章:

php - 在 MySQL 数据库中存储 IP 地址(IPv4 和 IPv6)

php - 填充 PHP 数组 : check for index first?

php - 如何抓取特定的API数据

javascript - 使用 css 和 js 重新设计登录表单后卡在登录页面上

php - 使用循环仅显示每个 DISTINCT 字段值一次

javascript - actionscript p2p - 聊天如何创建多个连接并向所有/任何连接发送消息

javascript - ActionScript 就像 JavaScript?

javascript - 通过第三方网络服务获取客户端 IP 地址

ios - Flex ActionScript3 FileStream.writeObject 在 iOS 中静默失败 - 我做错了什么?

c++ - 是否有库函数来确定 IP 地址(IPv4 和 IPv6)在 C/C++ 中是私有(private)的还是本地的?