Skip to content

Instantly share code, notes, and snippets.

@hplc
Created April 6, 2017 11:21
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 hplc/8bfd00388c2c704b699770363e320794 to your computer and use it in GitHub Desktop.
Save hplc/8bfd00388c2c704b699770363e320794 to your computer and use it in GitHub Desktop.
Auto Vote by PHP
<?php
// $url_login = "http://192.168.1.6/weboa/sys/logon.aspx?stferNo=200&stferPassword=hehehe";
$url = "http://http://zhiye.jiaoshi.com.cn//admin/deal_vote.php?pid=49&type=1";
$file="cookie.txt";
echo postPage($url, "$postfields");
function getPage($url, $cookie_file = "cookie.txt") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
$tmp = curl_exec($ch);
curl_close($ch);
return $tmp;
// return iconv("UTF-8", "GB18030", $tmp);
// return iconv("UTF-8", "GBK", $tmp);
}
function postPage($posturl, $postfields, $cookie_file = "cookie.txt") {
$ch =curl_init();
curl_setopt($ch, CURLOPT_URL, $posturl);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_PROXY, '192.168.1.8:8080');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
$tmp = curl_exec($ch);
curl_close($ch);
return $tmp;
}
function cut_str($string, $sublen, $start = 0, $code = 'UTF-8') {
if($code == 'UTF-8') {
$pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/";
preg_match_all($pa, $string, $t_string);
if(count($t_string[0]) - $start > $sublen)
return join('', array_slice($t_string[0], $start, $sublen))."...";
return join('', array_slice($t_string[0], $start, $sublen));
}
else {
$start = $start*2;
$sublen = $sublen*2;
$strlen = strlen($string);
$tmpstr = '';
for($i=0; $i<$strlen; $i++) {
if($i>=$start && $i<($start+$sublen)) {
if(ord(substr($string, $i, 1))>129)
$tmpstr.= substr($string, $i, 2);
else
$tmpstr.= substr($string, $i, 1);
}
if(ord(substr($string, $i, 1))>129)
$i++;
}
if(strlen($tmpstr)<$strlen )
$tmpstr.= "...";
return $tmpstr;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment