php限制小程序访问,PHP投票小程序,防超时,防IP限制

//欢迎访问back.zhizhi123.com

//参考博文http://back.zhizhi123.com/?p=126

set_time_limit(0);//防止超时

function toupiao($i)

{

$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');

$url = "http://www.example.com/tea/love.php";

$ch = curl_init();

$data = array (

'id' => '13'

);

//设置来源地址,如果不设置,论坛服务器有可能有验证不允许回复

curl_setopt($ch,CURLOPT_REFERER,"http://www.example.com/tea/index.php?m=content&c=index&a=lists&catid=10");

//能保存cookie

curl_setopt($ch,CURLOPT_COOKIESESSION,true);

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)");

curl_setopt($ch, CURLOPT_PROXY, $proxy[$i]);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_URL,$url);

//为了支持cookie

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($ch);

if(curl_errno($ch))

{

echo 'Curl error: ' . curl_error($ch);

}

}

for($i=0;$i<=11;$i++)

{

echo "begin 第".$i."次投票";

toupiao($i);

echo 'end';

echo "";

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值