Flex获取客户端IP地址(Java)
博客分类: Flex RIA
FlexJavaSpring
就是flex.messaging.FlexContext这个类有个静态方法:flex.messaging.FlexContext.getHttpRequest()
取到HttpRequest后面在拿getRemoteAddr就不用多说了:
flex.messaging.FlexContext.getHttpRequest().getRemoteAddr()就这么简单.呵呵。
我的环境是Java+spring+blazeds+flex+RemoteObject实现。
*********javascript获得主机名************************
<script language=javascript>
var wshNetwork = new ActiveXObject("WScript.Network");
alert("计算机名 = "+ wshNetwork.ComputerName);
</script>
****
<HTML>
<HEAD>
<TITLE>WMI Scripting HTML </TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=foo>
var value = "客户端硬件信息";
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");//CPU 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+ p.SystemName + "CPU:"+ p.Name +p.ProcessorID
var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");//硬盘序列号 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+"HD:"+p.signature
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");//主板信息
var e = new Enumerator (properties);
var p = e.item ();
//var value=value+"BB:"+ p.Product; //在一些机器在上无法读取
document.forms[0].txtMACAddr.value=unescape(MACAddr); //MAC
document.forms[0].txtIPAddr.value=unescape(IPAddr); //IP
//document.forms[0].txtDNSName.value=unescape(sDNSName); //主机名
document.forms[0].txtDNSName.value=value; //增加的部份包括CPU硬盘主板
document.formbar.submit();
</SCRIPT>
<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined") MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined") IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined") sDNSName = objObject.DNSHostName;
}
</SCRIPT>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
</HEAD>
<BODY>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT> </OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT>
<SCRIPT language=JScript>
var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</SCRIPT>
<FORM id="formfoo" name="formbar" action="mac.asp" method="post">
<INPUT type="hidden" value="00-11-11-B4-52-EF" name="txtMACAddr" size="10">
<INPUT type="hidden" value="210.42.38.50" name="txtIPAddr">
<INPUT type="hidden" value="zhupan" name="txtDNSName">
</FORM>
</BODY>
</HTML>
asp中
<%
Response.Write "txtDNSName=" & Request.form("txtDNSName") &"<BR>"
Response.Write "txtMACAddr=" & Request.form("txtMACAddr") &"<BR>"
Response.Write "txtIPAddr=" & Request.form("txtIPAddr") &"<BR>"
%>
拿别人的,方便自己看
博客分类: Flex RIA
FlexJavaSpring
就是flex.messaging.FlexContext这个类有个静态方法:flex.messaging.FlexContext.getHttpRequest()
取到HttpRequest后面在拿getRemoteAddr就不用多说了:
flex.messaging.FlexContext.getHttpRequest().getRemoteAddr()就这么简单.呵呵。
我的环境是Java+spring+blazeds+flex+RemoteObject实现。
*********javascript获得主机名************************
<script language=javascript>
var wshNetwork = new ActiveXObject("WScript.Network");
alert("计算机名 = "+ wshNetwork.ComputerName);
</script>
****
<HTML>
<HEAD>
<TITLE>WMI Scripting HTML </TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=foo>
var value = "客户端硬件信息";
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");//CPU 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+ p.SystemName + "CPU:"+ p.Name +p.ProcessorID
var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");//硬盘序列号 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+"HD:"+p.signature
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");//主板信息
var e = new Enumerator (properties);
var p = e.item ();
//var value=value+"BB:"+ p.Product; //在一些机器在上无法读取
document.forms[0].txtMACAddr.value=unescape(MACAddr); //MAC
document.forms[0].txtIPAddr.value=unescape(IPAddr); //IP
//document.forms[0].txtDNSName.value=unescape(sDNSName); //主机名
document.forms[0].txtDNSName.value=value; //增加的部份包括CPU硬盘主板
document.formbar.submit();
</SCRIPT>
<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined") MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined") IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined") sDNSName = objObject.DNSHostName;
}
</SCRIPT>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
</HEAD>
<BODY>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT> </OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT>
<SCRIPT language=JScript>
var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</SCRIPT>
<FORM id="formfoo" name="formbar" action="mac.asp" method="post">
<INPUT type="hidden" value="00-11-11-B4-52-EF" name="txtMACAddr" size="10">
<INPUT type="hidden" value="210.42.38.50" name="txtIPAddr">
<INPUT type="hidden" value="zhupan" name="txtDNSName">
</FORM>
</BODY>
</HTML>
asp中
<%
Response.Write "txtDNSName=" & Request.form("txtDNSName") &"<BR>"
Response.Write "txtMACAddr=" & Request.form("txtMACAddr") &"<BR>"
Response.Write "txtIPAddr=" & Request.form("txtIPAddr") &"<BR>"
%>
拿别人的,方便自己看