Skip to content

Instantly share code, notes, and snippets.

@maicong
Created November 20, 2015 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maicong/31fb674dbf2640574dea to your computer and use it in GitHub Desktop.
Save maicong/31fb674dbf2640574dea to your computer and use it in GitHub Desktop.
vote
<?php
function curl_get($url, $param = '', $cookie = ''){
$host = parse_url($url);
$site = $host['scheme']."://".$host['host'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_REFERER, $site);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat');
curl_setopt($ch, CURLOPT_HTTPHEADER , array('Cookie:'.$cookie,'Host:'.$host['host'], 'Origin:http://'.$host['host'], 'X-FORWARDED-FOR:1.2.4.8', 'X-FORWARDED-HOST:'.$host['host'], 'X-FORWARDED-SERVER:'.$host['host'])); // 伪造HTTP头
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
function get($key){
return isset($_GET[$key]) ? $_GET[$key] : null;
}
if(get('t') && get('vid')) {
$vid = get('vid');
$head = get_headers('http://www.daidainiu.net/index.php?g=Wap&m=Ddnvote&a=index&token=uglgsb1409637929&id=22',true);
$cookie = $head['Set-Cookie'][1];
preg_match('/ddnvotewechaid=%22(.*?)%22;/i', $cookie, $wechaid);
$url = 'http://www.daidainiu.net/index.php?g=Wap&m=Ddnvote&a=add_ddnvote&token=uglgsb1409637929&wecha_id='.$wechaid[1];
$param = 'wecha_id='.$wechaid[1].'&tid=22&chid='.$vid.'%2C&token=uglgsb1409637929&action=add_ddnvote&verifycode3=&other_name=&other_mobile=&other_msg=';
$tp = curl_get($url, $param, $cookie);
header('Content-Type:application/json; charset=utf-8');
$json = json_decode(preg_replace('/\x{feff}/iu', '', $tp),true);
$json['cookie'] = $cookie;
$json['wechaid'] = $wechaid[1];
echo json_encode($json);
exit();
}
?>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="cleartype" content="on">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<title>投一票</title>
<meta name="renderer" content="webkit">
<meta name="applicable-device" content="pc, mobile">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
</head>
<body>
<p>
<a href="http://www.daidainiu.net/index.php?g=Wap&amp;m=Ddnvote&amp;a=index&amp;token=uglgsb1409637929&amp;id=22" target="_blank">第十四届上海IT青年十大新锐评选活动</a>
</p>
<label>
<span>输入您要投票的ID号,投 刁董 请填 131:</span>
<input id="vid" type="number" value="131">
<input id="start" type="button" value="开始刷">
<input id="pause" type="button" value="暂停" disabled>
<input id="clear" type="button" value="清除">
<small>( <a href="?source">点我查看本源码</a> )</small>
</label>
<ol id="vote"></ol>
<script>
var timer,
start = document.getElementById('start'),
pause = document.getElementById('pause'),
clear = document.getElementById('clear'),
vote = function(){
var request = new XMLHttpRequest();
var li = document.createElement("li");
var vid = document.getElementById('vid').value;
li.innerText = '投票ing...';
request.open('GET', location.href + '?vid='+vid+'&t=' + (new Date()).valueOf(), true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
li.innerText = data.info+' ('+data.wechaid+')';
} else {
li.innerText = '投票失败';
}
};
request.onerror = function() {
li.innerText = '没有投到票';
};
request.send();
document.getElementById('vote').appendChild(li);
};
start.onclick = function(){
start.value = 'Running...';
start.setAttribute('disabled', true);
pause.removeAttribute('disabled');
vote();
timer = setInterval(function(){
vote();
}, 3000);
};
pause.onclick = function(){
clearInterval(timer);
start.value = '开始刷';
start.removeAttribute('disabled');
pause.setAttribute('disabled', true);
};
clear.onclick = function(){
document.getElementById('vote').innerHTML = '';
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment