Although Curl is powerful, but can only forge $_server["Http_x_forwarded_for"], for most IP address detection program, $_server["REMOTE_ADDR" is difficult to be forged:
First, it's client.php code.
Copy Code code as follows:
$headers [' client-ip '] = ' 202.103.229.40 ';
$headers [' x-forwarded-for '] = ' 202.103.229.40 ';
$HEADERARR = Array ();
foreach ($headers as $n => $v) {
$HEADERARR [] = $n. ': '. $v;
}
Ob_start ();
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://localhost/curl/server.php");
curl_setopt ($ch, Curlopt_httpheader, $HEADERARR); Constructing IP
curl_setopt ($ch, Curlopt_referer, "http://www.163.com/"); Structural antecedents
curl_setopt ($ch, Curlopt_header, 1);
Curl_exec ($ch);
Curl_close ($ch);
$out = Ob_get_contents ();
Ob_clean ();
Echo $out;
And then the server.php.
Copy Code code as follows:
function GetIP () {
if (!emptyempty ($_server["HTTP_CLIENT_IP"]))
$cip = $_server["Http_client_ip"];
else if (!emptyempty ($_server["http_x_forwarded_for"]))
$cip = $_server["Http_x_forwarded_for"];
else if (!emptyempty ($_server["REMOTE_ADDR"]))
$cip = $_server["REMOTE_ADDR"];
Else
$cip = "Unable to get!" ";
return $CIP;
}
echo "<br> Access IP:". GetIP (). " <br> ";
echo "<br> access:". $_server["Http_referer"];