1 <?php header('Content-Type:text/html; charset=utf-8');
2 function MakeCard()
3 {
4 set_time_limit(0);
5
6 //处理缓冲区
7 ob_end_clean();
8 ob_implicit_flush(true);
9 echo str_pad(" ", 256);
10
11 if(intval($_POST['num']>0)) $num=intval($_POST['num']); //数量
12 if(intval($_POST['point']>0)) $point=intval($_POST['point']); //点数
13 if(intval($_POST['batch']>0)) $batch=intval($_POST['batch']); //批号
14 if(($_POST['ym']!="")) $ym=$_POST['ym']; //发行年月
15 else $ym=date('ym');
16
17 if($num==0) return;
18
19 $num=$num*100; //卡的张数,即记录数
20
21 echo "<p>开始 ".date("H:i:s")." ";
22
23 for($i=1;$i<=$num;$i++)
24 {
25 $sn=sprintf("%02s%s%06s",$batch,$ym,$i);
26 $seek=mt_rand(0,9999).mt_rand(0,9999).mt_rand(0,9999); //12位
27 $start=mt_rand(0,20);
28 $str=strtoupper(substr(md5($seek),$start,12));
29 $str=str_replace("O",chr(mt_rand(65,78)),$str);
30 $str=str_replace("0",chr(mt_rand(65,78)),$str);
31 $row=array('sn'=>$sn,'password'=>$str,'created'=>time(),'point'=>$point);
32 //查重
33 //在这里加插入数据的代码.
34 print_r($row);
35 }
36 echo " 结束 ".date("H:i:s")."";
37 printf("<br>成功生成:%s万个 %s点 的密码</p>",$num/1e4,$point);
38 return $num;
39 } //函数结束
40
41 $_POST['num']=1;
42 $_POST['point']=10;
43 $_POST['batch']=10;
44 $_POST['ym']='1405';
45 echo MakeCard(); ?>