PHP投票小程式,防逾時,防IP限制

來源:互聯網
上載者:User
  1. //歡迎訪問back.zhizhi123.com
  2. //參考博文http://back.zhizhi123.com/?p=126
  3. set_time_limit(0);//防止逾時
  4. function toupiao($i)
  5. {
  6. $proxy = array('182.48.116.51:8080','110.177.63.191:9999','221.10.40.238:80','221.10.40.236:83','221.10.40.237:80','221.10.102.199:82','42.121.0.247:9999','42.121.28.111:3128','117.135.194.139:80','119.147.91.21:80','58.247.109.243:80','118.233.36.246:8585');
  7. $url = "http://www.example.com/tea/love.php";
  8. $ch = curl_init();
  9. $data = array (
  10. 'id' => '13'
  11. );
  12. //設定來源地址,如果不設定,論壇伺服器有可能有驗證不允許回複
  13. curl_setopt($ch,CURLOPT_REFERER,"http://www.example.com/tea/index.php?m=content&c=index&a=lists&catid=10");
  14. //能儲存cookie
  15. curl_setopt($ch,CURLOPT_COOKIESESSION,true);
  16. curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
  17. curl_setopt($ch, CURLOPT_PROXY, $proxy[$i]);
  18. curl_setopt($ch, CURLOPT_POST, 1);
  19. curl_setopt($ch, CURLOPT_HEADER, 0);
  20. curl_setopt($ch, CURLOPT_URL,$url);
  21. //為了支援cookie
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  23. $result = curl_exec($ch);
  24. if(curl_errno($ch))
  25. {
  26. echo 'Curl error: ' . curl_error($ch);
  27. }
  28. }
  29. for($i=0;$i<=11;$i++)
  30. {
  31. echo "begin 第".$i."次投票";
  32. toupiao($i);
  33. echo 'end';
  34. echo "
    ";
  35. }
複製代碼
PHP
  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.