Home > Backend Development > PHP Tutorial > Sample code for php curl fake IP

Sample code for php curl fake IP

WBOY
Release: 2016-07-25 08:55:32
Original
992 people have browsed it
  1. #!/bin/awk -f
  2. #运行前
  3. BEGIN {
  4. FS = " ";
  5. count = 0;
  6. }
  7. #运行中
  8. {
  9. iparr[count ++] = $0;
  10. }
  11. #运行后
  12. END {
  13. printf(" printf("$iparr = array(n");
  14. for (i = 0; i < count; i ++) {
  15. printf("'%s' => '%s',n", iparr[i], iparr[i]);
  16. }
  17. printf(");n");
  18. }
复制代码

二,CURL使用

  1. /**
  2. * CURL fake IP address access
  3. * by bbs.it-home.org
  4. */
  5. require_once dirname(__FILE__) . "/iplib.php";
  6. $req_url = "test.com";
  7. foreach ($iparr as $forward => $cip) {
  8. $ch = curl_init();
  9. curl_setopt($ch, CURLOPT_URL, $req_url);
  10. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  11. "X-FORWARDED-FOR:$forward",
  12. "CLIENT-IP:$cip"
  13. ));
  14. curl_setopt($ch, CURLOPT_REFERER, 'http://blog.csdn.net/');
  15. curl_setopt($ch, CURLOPT_HEADER, 1);
  16. curl_exec($ch);
  17. curl_close($ch);
  18. }
复制代码

不足: 很多服务器端一般都采用了$_SERVER['REMOTE_ADDR']来获取客户端的真实ip,这是在传输层就已经决定的地址,无法通过CURL进行修改。 这点记录下,有好的办法再分享。



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template