PHP cross-platform Get server IP address Custom function sharing, PHPIP custom function
There is a need to refine a log mechanism to monitor the script execution status of machines from different servers, specifically for Windows and Linux and for Web and command-line mode to write a function to be compatible.
Write the following function to achieve the above requirements:
Copy the Code code as follows:fun
There are some ways to get the MAC address on the network as follows:1. Send the ARP command, using the returned MAC address buffer to get2. Use Networkinterface.getallnetworkinterfaces () to obtain all network cards (including virtual network cards) to obtain the appropriate MAC address3. Also available from the local registry:ManagementObjectSearcher Management
In fact, this is very simple, but I always want to use the Ipv6-test API to do a get user IP address things ... Unfortunately, JSON gets only the IP of the native server. Forget it, do not study, not to mention that the widget is also very useful. Google a bit, find this code, you can obtain the IP address based on the user environment.
For example, IPV6 access
ncb_cmd_cplt; #ifdef _WIN64 UCHAR ncb_reserve[18]; #else UCHAR ncb_reserve[10]; #endif HANDLE ncb_event; } NCB, *PNCB;
The focus is on Ncb_command members. The member told the NetBIOS what to do. We use three commands to detect the MAC address. Their definition of MSDN is as follows:
Command Description:
Ncbenum Windows nt/2000: Enumerates the number of network cards in the system. When this command is used, the Ncb_buffer member points t
Computer in use will inevitably encounter the problem of not networking, at this time need to IPv4 Internet Protocol settings, and in different operating systems to set the IPV4 mode is also different, then in Win7 flagship system how to IPV4 set to automatically obtain IP address?
Win7 flagship IPV4 automatically get IP address Setup method/step:
1, in the low
There are two ways to get the IP address of the client, getenv ("REMOTE_ADDR") and $_server[' REMOTE_ADDR ']
If server space is IIS then use $_server[' REMOTE_ADDR ']If server space is Apache then use getenv ("REMOTE_ADDR")
Summarize:Getenv ("REMOTE_ADDR") function in Apache can obtain the IP address, and in IIS, a little function, and $_server[' remote_addr '
Function:1. Get the current IP address,2. Call Sina API to obtain the current city.3. Convert Chinese to Pinyin and then jump.
Copy codeThe Code is as follows:Include './pinyin. php ';
// Obtain the current ip AddressFunction getIp (){$ Onlineip = '';If (getenv ('HTTP _ CLIENT_IP ') strcasecmp (getenv ('HTTP _ CLIENT_IP'), 'unknown ')){$ Onlineip = getenv ('HTTP _ CLIENT_IP ');} Elseif (getenv ('HTTP _ X_F
directory. ' function Getmac (IP) on Error Resume Next Dim Oscript Dim Ofilesys, Ofile Dim all, Sztempfile,ipc,phyc,typec Dim TempPath Set oscript = Server.CreateObject ("WSCRIPT. SHELL ") Set Ofilesys = Server.CreateObject ("Scripting.FileSystemObject") temppath= "d:\temp\" temporary directory sztempfile = TempPath amp; Ofilesys.gettempname () ' Get temporary file name call Oscript.run ("cmd.exe/c ping-n 2" amp; IP, 0, True) ' guarantee
This is the Upload class method:
public class Upload {public static String upload (formfile formfile,string dirpath,int port) {String savepath= "";String ip= "";try{String filename = formfile.getfilename (). Trim (); Filenameif (! "". equals (filename)) {InputStream ins = Formfile.getinputstream ();String currentpath=dirpath+ File.separatorchar + filename; File Save pathOutputStream OS = new FileOutputStream (Currentpath);int bytesread = 0;byte[] buffer = new byte[8192];while ((bytesread = ins.r
1 Get IPV4 Addresspublicstringgetlocalipaddress () { Stringaddress= "0";try{ Enumeration 2 Get IPV6 address publicstringgetlocalipaddress () { Stringaddress= "0";try{ EnumerationThis article is from the "Jackyanngo" blog, make sure to keep this source http://jackyanngo.blog.51cto.com/5263823/1614612[Android] Get IP
How to intercept the content to get the image address??
Meat content:
Maximum output power
350W
Rated Power
300
Power version
INTEL ATX12V 1.3 Version
Scope of application
Special power for Internet cafesSupports INTEL945, 965 Express chipset, Intel Core dual Core processor
Interface description
Acquiring a place of attribution via IP
Get IP Address
$ip = $_server[' remote_addr '); Automatically get the IP of the client
IP-Corresponding region
if (!empty ($_post[' IP ')) {
$ip = $_post[' IP '];
interface address, which returns an XML result set, 1;
$str = file_get_contents ("http://ip.taobao.com/servi
Get Client IP Address::functionGetIP () {if(!Empty($_server[' Http_client_ip '])){ return $_server[' Http_client_ip ']; }ElseIf(!Empty($_server[' Http_x_forvarded_for '])){ return $_server[' Http_x_forvarded_for '];}ElseIf(!Empty($_server[' REMOTE_ADDR '])){ return $_server[' REMOTE_ADDR '];}Else{ return"Unknown IP";} Pro, try my code, get the three forms
Methods to get parameters (using regular expressions)function Geturlparam (name) { var reg = new RegExp ("(^|)" + name + "= ([^]*] (|$)"); var r = window.location.search.substr (1). Match (reg); if (r!=null) return unescape (r[2]); return null;} How to useString url = "Localhost:8080/demo/index.html?id=123name=lxy"; Note that you use the key to make sure that the address has the corresponding keys to
JavaScript is a scripting language that can't manipulate files and read local information, so you want to get IP, and you need back-end technology. Here's how://获取本机的网络ip地址function jsonpCallback(res) { var ip = res.Ip; // ip地址 var aa = res.Isp.split("市"); var isp = aa[0]; // ip省份 alert(ip);}function getIntnetIP() { var JSONP=document.createElement("script"); JSONP.type="text/javascript"; JSONP.src="http://chaxun.1616.net/s.p
Method Two/sbin/ifconfig-a|grep inet|grep-v 127.0.0.1|grep-v Inet6|awk ' {print $} ' |tr-d ' addr: 'Method OneGet the native IP address and save it in a variablearg=ifconfig eth0 |grep "inet addr"| cut -f 2 -d ":"|cut -f 1 -d " " Ipaddr=
a r g e c h o
IpaddThis assumes that your interface name is eth0, it is possible that your interface is not this, you need to change it.Introduction to cut Parameters-D is used to define the del
The IFREQ structure is defined in/usr/include/net/if.h, used to configure IP addresses, activate interfaces, and configure interface information such as MTU.It contains the name and content of an interface-(a common body, possibly an IP address, broadcast address, subnet mask, mac number, MTU, or other content).The ifreq is included in the ifconf structure. The ifconf structure is usually used to hold infor
]: = TJContacts_PeopleColumns.JavaClass.DISPLAY_NAME;//Exit;//Selection: = Jstringtostring (TJContacts_PeopleColumns.JavaClass.DISPLAY_NAME) + ' like '% ' + AName + '% ';//end;////Exit;Selection: = jstringtostring (TJContacts_PeopleColumns.JavaClass.DISPLAY_NAME) +'Like "%'+ AName +'%"';//Select projection from contact database where selectionCursorcontactsphone: =SharedActivity.getContentResolver.query (TJCommonDataKinds_Phone.JavaClass.CONTENT_URI,Nil{projection {The name of the field to query
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.