Windows 2000 IP Configuration USAGE: ipconfig [/? | /all | /release [adapter] | /renew [adapter] | /flushdns | /registerdns | /showclassid adapter | /setclassid adapter [classidtoset] ] adapter Full name or pattern with '*' and '?' to 'match', * matches any character, ? matches one character. Options /? Display this help message. /all Display full configuration information. /release Release the IP address for the specified adapter. /renew Renew the IP address for the specified adapter. /flushdns Purges the DNS Resolver cache. /registerdns Refreshes all DHCP leases and re-registers DNS names /displaydns Display the contents of the DNS Resolver Cache. /showclassid Displays all the dhcp class IDs allowed for adapter. /setclassid Modifies the dhcp class id.The default is to display only the IP address, subnet mask and default gateway for each adapter bound to TCP/IP.For Release and Renew, if no adapter name is specified, then the IP address leases for all adapters bound to TCP/IP will be released or renewed.For SetClassID, if no class id is specified, then the classid is removed.Examples: > ipconfig ... Show information. > ipconfig /all ... Show detailed information > ipconfig /renew ... renew all adapaters > ipconfig /renew EL* ... renew adapters named EL.... > ipconfig /release *ELINK?21* ... release all matching adapters, eg. ELINK-21, myELELINKi21adapter.
@exec(" ifconfig > ip.dat",$a,$b);?>
@exec(" ifconfig > ip.dat",$a,$b);?>
这个没有看明白
怎么可以把机器的网卡号付给一个变量呢?
USAGE:
ipconfig [/? | /all | /release [adapter] | /renew [adapter]
| /flushdns | /registerdns
| /showclassid adapter
| /setclassid adapter [classidtoset] ] adapter Full name or pattern with '*' and '?' to 'match',
* matches any character, ? matches one character.
Options
/? Display this help message.
/all Display full configuration information.
/release Release the IP address for the specified adapter.
/renew Renew the IP address for the specified adapter.
/flushdns Purges the DNS Resolver cache.
/registerdns Refreshes all DHCP leases and re-registers DNS names
/displaydns Display the contents of the DNS Resolver Cache.
/showclassid Displays all the dhcp class IDs allowed for adapter.
/setclassid Modifies the dhcp class id.The default is to display only the IP address, subnet mask and
default gateway for each adapter bound to TCP/IP.For Release and Renew, if no adapter name is specified, then the IP address
leases for all adapters bound to TCP/IP will be released or renewed.For SetClassID, if no class id is specified, then the classid is removed.Examples:
> ipconfig ... Show information.
> ipconfig /all ... Show detailed information
> ipconfig /renew ... renew all adapaters
> ipconfig /renew EL* ... renew adapters named EL....
> ipconfig /release *ELINK?21* ... release all matching adapters,
eg. ELINK-21, myELELINKi21adapter.
@exec(" ifconfig > ip.dat",$a,$b);?>意思是调用Windows系统命令来知道的.
{
if(getenv('HTTP_CLIENT_IP'))
{
$onlineip = getenv('HTTP_CLIENT_IP');
}
elseif(getenv('HTTP_X_FORWARDED_FOR'))
{
$onlineip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif(getenv('REMOTE_ADDR'))
{
$onlineip = getenv('REMOTE_ADDR');
}
else
{
$onlineip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
}
return $onlineip;
}
@exec(" ifconfig > ip.dat",$a,$b);?>
你可能DOS学的不好,ifconfig >ip.dat就是把ifconfig命令产生的结果输入到ip.dat文件中,其实ip.dat文件是一个文本文件,你可以将此文件中的网卡地址用php分离出来。如果你还不明白,那么就在你的机器里的dos模式下用运行ifconfig >ip.dat,然后用windows的记事本打开就应该明白该怎么做了。
Windows IP ConfigurationEthernet adapter 本地连接 2: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.0.80 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.0.2只有IP信息,并没有网卡信息。
Windows IP Configuration
Host Name . . . . . . . . . . . . : billgates
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Mixed
IP Routing Enabled. . . . . . . . : Yes
WINS Proxy Enabled. . . . . . . . : NoEthernet adapter 本地连接 2:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Realtek RTL8139 Family PCI Fast Ethernet NIC #2
Physical Address. . . . . . . . . : 00-0A-EB-0E-79-F6
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.0.80
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.2
DNS Servers . . . . . . . . . . . : 202.99.96.68
192.168.0.2现在可以写到一个IP.dat的文件里了,
那我怎么把网卡号付给一个变量呢?
if ($data_array = file("ip.dat"))
{
while (list(,$tmp_str) = each($data_array))
{
if (strpos($tmp_str,'Physical Address')>0)
{
$phy_address = substr($tmp_str,strpos($tmp_str,'-')-2,17);
}
}
echo $phy_address; //变量 $phy_address 的值就是你要的网卡号了,在这
} //里显示为 00-0A-EB-0E-79-F6
else
{
echo "Error!";
}
?>
@exec(" ifconfig > ip.dat",$a,$b);
?>
这样生成的文件里面为什么什么都没有呢?
IP.dat打开后为空白文件。
@exec(" ipconfig/all > ip.dat");php在server端运行不可以获取不是客户端提交的信息,可以用js实现