The code is as follows:
Function GetIP (){If (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ Cip = $ _ SERVER ["HTTP_CLIENT_IP"];}Elseif (! Empty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"]) {$ Cip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];}Elseif (! Empty ($ _ SERVER ["REMOTE_ADDR"]) {$ Cip = $ _ SERVER ["REMOTE_ADDR"];}Else {$
How does php obtain the local IP address ?? O (distinct _ distinct) O ~ How can I obtain the IP address of the local machine when I use the php command to execute the php file? It turns out that $ _ SERVER [] is not easy to use. thanks to O (cost _ priority) O ~ ------ Solution ------------------ if you are running on your computer, 127.0.0.1 is nothing more than 127.0.0.1. if you are running on a virtual space or SERVER, $ _ SERVER [ quot; how does php get the IP address of the local machine ??
(!fwrite ($FP, $line)) {
Die ("Write online list failed.");
}
Fclose ($FP);
}
Get people online
function Get_online_sum ()
{
if (file_exists (online_list)) {
$online _msg = file (online_list);
Return count ($online _msg);
} else {
return 0;
}
}
Get Current Login User IP
function Get_client_ip ()
{
if ($_server[' REMOTE_ADDR ']) {
$
There are many ways to obtain IP addresses in php. Next I will introduce how to use linux commands to obtain IP addresses and convert them into array output. Below I also introduce some common php IP address processing instances.
PHP obtains the Server IP Address
Run ifconfig in PHP to get the Linux Server IP address and output it as an array. The following code is used:
The Code is as follows:
Copy code
Function getServerIp () {// use ifconfig to read the Server IP addre
PHP curl counterfeit IP address and header information code instance, curlheader
Although curl is powerful, it can only forge $ _ SERVER ["HTTP_X_FORWARDED_FOR"]. For most IP address detection programs, it is difficult to forge $ _ SERVER ["REMOTE_ADDR:
First, the client. php code
Copy codeThe Code is as follows:$ Headers ['client-ip'] = '192. 103.229.40 ';$ Headers ['x-FORWARDED-FOR '] = '2017. 103.229.40 ';$ HeaderArr = array ();Foreach ($ headers as $ n => $ v ){$ HeaderArr [] = $ n. ':'. $ v
PHP obtains the server IP addressRun ifconfig in PHP to get the Linux server IP address and output it as an array. The following code is used: The code is as follows:Copy code Function getServerIp () {// use ifconfig to read the server IP address and output it as an array$ Ss = exec ('/sbin/ifconfig | sed-n's/^ *. * addr: \ ([0-9.] \ {7 ,\}\). * $/\ 1/p', $ arr );Return $ arr;}$ Ips = getServerIp ();Foreach ($ ips as $ k => $ v) {// filter IP addressesIf (substr ($ v, 127) = '
A variety of users really IP code is a PHP with the environment variables to determine the user's real IP address, well look at that paragraph for you.1: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 '];}Echo $onlineip;?>
2:function GetIP () {if (!empty ($_
sample.
Dialog [-- title] [-- backtitle]
[-- Clear] [-- separate-output] box-options
-- Title
Title text on the dialog box
-- Backtitle
Desktop background title
Box-options
Dialog currently provides yes/no box, menu box, input box, message box, text
There are nine widgets in box, info box, checklist box, radiolist box, and gauge box.
Exit Status
If you press Yes or OK, 0 is returned. No or Cancel returns 1. If
] [-- backtitle]
[-- Clear] [-- separate-output] box-options
-- Title
Title text on the dialog box
-- Backtitle
Desktop background title
Box-options
Dialog currently provides yes/no box, menu box, input box, message box, text
There are nine widgets in box, info box, checklist box, radiolist box, and gauge box.
Exit Status
If you press Yes or OK, 0 is returned. No or Cancel returns 1. If you press ESC or an error occurs,-1 is returned.
-- Yesn
address and target port in the request packet to a process of the rip and port of the back-end RS selected by the scheduling algorithm;Note the following questions:1.RIP and dip must be in the same network segment and should be a private IP address; The gateway to the RS should point to the dip;2. The request message and the response message must be forwarded by the Director, the director is easy to become a system performance bottleneck and trigger a single point of failure;3. Port redirection
IP address and destination port, remain unchanged throughout the message forwarding process4. Switch-------> vs: Send a message with the VIP address to VS, by statically binding the IP address and MAC address on the router.Switch--------> RS: Switch to Rs method, there are two ways: using the Arptables,rs kernel parameters (Arp_announce, Arp_ignore) on the RS5. Port redirection is not supported6. RS for Linux7. The RIP and VIP must be configured on the RS, and the VIP should be configured on th
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.