PHP uses CURL to forge IP addresses and sources, and PHPCURL to forge IP addresses
1. php requests 2.php. 1. php code: $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, "http: // localhost/2.php"); curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('x-FORWARDED-FOR: 8.8.8.8 ', 'client-IP: 8.8.8.8'); // construct IPcurl_setopt ($ ch, CURLOPT_REFERER, "http://www.gosoa.com.cn /"); // construct curl_setopt ($ ch, CURLOPT_HEADER, 1); $ out = curl_exec ($ ch); curl_close ($ ch); 2. the php code is as follows: function getClientIp () {if (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) $ ip = $ _ SERVER ["HTTP_CLIENT_IP"]; else if (! Empty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"]) $ ip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"]; else if (! Empty ($ _ SERVER ["REMOTE_ADDR"]) $ ip = $ _ SERVER ["REMOTE_ADDR"]; else $ ip = "err"; return $ ip ;} echo "IP :". getClientIp (). ""; echo "referer :". $ _ SERVER ["HTTP_REFERER"];