<?
//-----------------------------------
// 版权所有:qzdc
//-----------------------------------
set_time_limit(0);
$uname = '你的帐号';$pwd = '你的密码';$site="http://www.im286.com";login();$formhash=gethash();
while(1){
parse(45);
// parse(27);
// if($i++>10) break;
}
echo "全部刷完";
function parse($fid){//刷当前版第一页
global $site,$formhash,$uname;
echo "------------开刷--------$fid------------ ";
$fd=file_get_contents("$site/forumdisplay.php?fid=$fid&page=");
$tagarr=array("论坛主题","<table width=");
$startpos = strpos($fd,$tagarr[0])+strlen($tagarr[0]);$endpos = strpos($fd,$tagarr[1],$startpos);//截取标记
$fd=substr($fd,$startpos,$endpos-$startpos);
preg_match_all("/"viewthread.php?tid=([d]*)&.*<td align="center">([d]*)</td>.*viewpro.*>(.*)</a>/sU",$fd,$fd);//print_r($fd);exit;
unset($fd[0]);
foreach($fd[1] as $key=>$val){
if($fd[3][$key]<>$uname) {
curladd($val,$fd[3][$key]);
echo "-------------".$fd[2][$key]."--贴----最后回复--".$fd[3][$key]."----------$val------- ";
sleep(15);
}else {
}
}
}
function curladd($threadid,$author){//写入
global $site,$formhash;
$add=time()%7==0?" {$author} 的帖子一定要顶":'';
$message=getanswer(getlastpost($threadid)).$add;
$b="action=reply&tid=$threadid&replysubmit=yes&formhash=$formhash&subject=&usesig=1&message=".urlencode($message);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_URL, "$site/post.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $b);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)");
curl_exec($ch);
curl_close ($ch);
}
function getlastpost($tid){//得到最后回复
global $site;
$url="$site/redirect.php?tid=$tid&goto=lastpost";
$fd=file_get_contents($url);
preg_match_all("/<span style="font-size: 12px">(.*)</span>/isU",$fd,$fd);
Return end($fd[1]);
}
function getanswer($con){//得到答案
$url=
"http://www.xiaoi.com/engine.isp?font=0&bold=0&italic=0&underline=0&fontColor=black&messageText=".urlencode($con)."&botid=popup-bot";
$fd=file_get_contents($url);
$startpos = strpos($fd,'</textarea>')+strlen('</textarea>');$endpos = strpos($fd,'</textarea>',$startpos);//截取标记
$fd=trim(str_replace('<textarea id="answer">','',substr($fd,$startpos,$endpos-$startpos)));
$fdrep=array(
"xiaoi.com"=>"read8.net",
"xiaoi"=>"read8",
"小I"=>"读吧.net",
"小i"=>"读吧.net",
);
foreach($fdrep as $key=>$val){
$fd=str_replace($key,$val,$fd);
}
Return $fd;
}
function login(){//登陆
global $uname,$pwd,$formhash,$site;
$strLoginData = "formhash=$formhash&loginfield=username&username=$uname&password=$pwd&loginsubmit=%CC%E1+%26%23160%3B+%BD%BB";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, "$site/logging.php?action=login");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strLoginData);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_exec($ch);
curl_close ($ch);
}
function gethash(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, "$site/post.php");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)");
curl_setopt($ch, CURLOPT_POSTFIELDS, "action=newthread&fid=45&extra=page%3D1");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
$fd=curl_exec($ch);
curl_close ($ch);
$tagarr=array('formhash" value="','"');
$startpos = strpos($fd,$tagarr[0])+strlen($tagarr[0]);$endpos = strpos($fd,$tagarr[1],$startpos);//截取标记
Return substr($fd,$startpos,$endpos-$startpos);
}