PHP uses CURL to forge IP addresses and sources

Source: Internet
Author: User
Tags how to use curl
: This article describes how to use CURL to forge IP addresses and sources in PHP. For more information about PHP tutorials, see.
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"];

The above section describes how to use CURL to forge IP addresses and sources in PHP, including related content, and hope to help those who are interested in PHP tutorials.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.