headerIP php,使用php运行ipconfig命令

I use this code to understand some information of visitors (clients). It has been running on my virtual server on Xampp, but I can`t run on my main server (host). I see just a blank page.

$info = system('ipconfig /all');

echo $info;

解决方案

this might help you

Server IP

You can get the server IP address from $_SERVER['SERVER_ADDR'].

Client IP address

You can get the client IP from $_SERVER['REMOTE_ADDR']

Edit: you ask in comments how to get the output of an external command - one way is to use backticks, e.g.

$ipAddress=$_SERVER['REMOTE_ADDR'];

$macAddr=false;

#run the external command, break output into lines

$arp=`arp -a $ipAddress`;

$lines=explode("\n", $arp);

#look for the output line describing our IP address

foreach($lines as $line)

{

$cols=preg_split('/\s+/', trim($line));

if ($cols[0]==$ipAddress)

{

$macAddr=$cols[1];

}

}

But what if the client isn't on a LAN?

Well, you're out of luck unless you can have the client volunteer that information and transmit via other means. See Peter G Mac's suggestion for using Javascript.

you can also try following command

// http://www.php.net/manual/en/function.exec.php#85930

$_ = null;

// If you care about the return value, use this:

passthru("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat",$_);

header('Content-Type: text/plain');

echo $_;

// if you don't care, just use this:

$_ = exec("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat");

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值