fetch1("select voteid,voteip,votetext,voteclass,doip,dotime from {$dbtbpre}enewsvote where voteid='$voteid'"); if(empty($r['voteid'])||empty($r['votetext'])) { printerror("NotVote","history.go(-1)",1); } $re=DoVote($r,$vote); $sql=$empire->query("update {$dbtbpre}enewsvote set votetext='".addslashes($re['votetext'])."',voteip='$re[voteip]',votenum=votenum+".$re['votetotal']." where voteid='$voteid'"); if($sql) { esetcookie("lastvotetime",time(),time()+3600*24);//设置最后发表时间 printerror("VoteSuccess","../tool/vote/?voteid=".$voteid,1); } else { printerror("DbError","history.go(-1)",1); } } //添加信息投票 function AddInfoVote($classid,$id,$vote){ global $empire,$dbtbpre,$class_r,$public_r; $classid=(int)$classid; $id=(int)$id; if(empty($id)||empty($classid)||!$class_r[$classid]['tbname']) { printerror("NotVote","history.go(-1)",1); } $lasttime=getcvar('lastivotetime'); if($lasttime) { if(time()-$lasttime<$public_r['revotetime']) { printerror("VoteOutTime","history.go(-1)",1); } } $pubid=ReturnInfoPubid($classid,$id); $r=$empire->fetch1("select id,voteip,votetext,voteclass,doip,dotime from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1"); if(empty($r['id'])||empty($r['votetext'])) { printerror("NotVote","history.go(-1)",1); } $re=DoVote($r,$vote); $sql=$empire->query("update {$dbtbpre}enewsinfovote set votetext='".addslashes($re['votetext'])."',voteip='$re[voteip]',votenum=votenum+".$re['votetotal']." where pubid='$pubid' limit 1"); if($sql) { esetcookie("lastivotetime",time(),time()+3600*24);//设置最后发表时间 printerror("VoteSuccess","../public/vote/?classid=$classid&id=$id",1); } else { printerror("DbError","history.go(-1)",1); } } //处理投票 function DoVote($r,$vote){ //投票期限 if($r['dotime']<>"0000-00-00") { $endtime=to_date($r['dotime']); if($endtimegettotal("select count(*) as total from {$dbtbpre}enewsf where tbname='".$class_r[$classid]['tbname']."' and (f='infopfen' or f='infopfennum')"); if(empty($fnum)) { $doajax==1?ajax_printerror('','','ErrorUrl',1):printerror('ErrorUrl','',1); } if($fen<1) { $fen=1; } if($fen>5) { $fen=5; } $sql=$empire->query("update {$dbtbpre}ecms_".$class_r[$classid]['tbname']." set infopfen=infopfen+$fen,infopfennum=infopfennum+1 where id='$id' and classid='$classid' limit 1"); if($sql) { esetcookie('lastforfenid',$classid.'n'.$id,time()+30*24*3600); //最后发布 if($doajax==1) { $nr=$empire->fetch1("select infopfen,infopfennum from {$dbtbpre}ecms_".$class_r[$classid]['tbname']." where id='$id' and classid='$classid' limit 1"); $infopfen=$nr[infopfennum]?round($nr[infopfen]/$nr[infopfennum]):0; ajax_printerror($infopfen,RepPostVar($add['ajaxarea']),'AddInfoPfen',1); } else { printerror('AddInfoPfen',EcmsGetReturnUrl(),1); } } else { $doajax==1?ajax_printerror('','','DbError',1):printerror('DbError','',1); } } ?>