laohan213写的“江西人民满意品牌学校”评选活动刷票系统

本文介绍了一款基于PHP编写的简单刷票程序,该程序通过发送HTTP请求模拟投票过程。主要内容包括程序的工作原理、关键代码段及投票结果的保存方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

上面的刷票程序是改进后的,原来的主要代码如下:

<?php

$host   = "dev.jxnews.com.cn";
$port   = "80";
$msg    = "POST /dev05/school/dx_insert.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*
Referer: http://dev.jxnews.com.cn/dev05/school/dx.php
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)
Host: dev.jxnews.com.cn
Content-Length: 144
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: univip=123456

dx=109&dx=113&dx=114&dx=115&dx=116&dx=117&dx=118&dx=119
&dx=120&dx=111&randnum=123456&choiceid=111
&typ=4&Submit=+++%CC%E1+%BD%BB+%D1%A1+%CF%EE+++
";


wfile(
date('Y-M-d H:i:s',time()) . "<br> ");
for($i = 1;$i<=3;$i++){
    
$fp = fsockopen($host, $port, $errno, $errstr,10);
    
if(!$fp){
        
echo("" . $i . "票:投票失败!<br> ");
        
echo("errstr:" . $errstr . "  errn" . $errno);
    }
else{
        
fputs($fp,"$msg");
        
if(!feof($fp)){
            
$fback  = fgets($fp,128);
            
if(ereg('/s*/', $fback)){ //这里采用简化处理,认为连接成功,则投票成功!
                echo("" . $i . "票:投票成功!<br> ");
            }
            wfile(
$fback);
        }
        
fclose($fp);
        
sleep(1);//缓冲,太快的话,怕他们受不了。^_^

    }
}

//对投票返回结果,偶保存了一下。^_^一下是保存函数。使用追加方式的存储,有兴趣可以看看。

function wfile($content, $file = "pollresult.txt", $mode='a+') {
    
$oldmask = umask(0);
    
$fp = fopen($file, $mode);
    
if (!$fpreturn false;
    
fwrite($fp,$content);
    
fclose($fp);
    
umask($oldmask);
    
return true;
}

?>

大概的咚咚就这样了。^_^

有兴趣的朋友们欢迎一起交流。 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值