• 批量生成卡号密码的php程序


     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(); ?>
  • 相关阅读:
    git忽略已提交过的文件方法
    去除git版本控制
    写博客的初衷
    Substring with Concatenation of All Words
    Course Schedule
    Reverse Words in a String--not finished yet
    Repeated DNA Sequences
    Maximum Product of Word
    Odd Even Linked List
    Reorder List
  • 原文地址:https://www.cnblogs.com/John727/p/4500104.html
Copyright © 2020-2023  润新知