123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Console\Commands;
- use App\Models\Meta;
- use App\Models\Serialize;
- use BlockMatrix\EosRpc\ChainFactory;
- use BlockMatrix\EosRpc\EosRpc;
- use BlockMatrix\EosRpc\WalletFactory;
- use Carbon\Carbon;
- use GuzzleHttp\Client;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Storage;
- use Org\Multilinguals\Apollo\Client\ApolloClient;
- use ZanySoft\Zip\Zip;
- class Generate extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'generate:randstr';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '生成序列串';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- ini_set('memory_limit','128M');
- $this->line('-----------start---------');
- $pass=[];
- $data=[];
- do{
- $str = $this->getRandomString(3);
- //生成3位,并且最少包含一位数字
- $preg = '/^(?=[a-z]*[0-9])(?=[0-9]*[a-z])[a-z0-9]{3,3}$/';
- if(preg_match($preg,$str)){
- if(!in_array($str,$pass)){
- $pass[] = $str;
- $data['serialize'] = $str;
- Serialize::create($data);
- }
- }
- }while (count($pass)<20000);
- $this->line('-----------end--------');
- }
- private function getRandomString($len, $chars=null)
- {
- if (is_null($chars)){
- $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
- }
- mt_srand(10000000*(double)microtime());
- for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++){
- $str .= $chars[mt_rand(0, $lc)];
- }
- return $str;
- }
- }
|