Php program used to generate random user names in batches
/* Extract random values from dictionary files */
- $ File1 = "./Words. dic ";
- $ File2 = "./common_pass_mini.dic ";
- $ File3 = "./Sys_Month_Date.Dic ";
- $ Rfile = "./5.dic ";
- $ N = 2000;
// Extract the dictionary
- $ Basef = file ($ file1 );
- $ Extf = file ($ file2 );
- $ Extf2 = file ($ file3 );
- $ Bf_sum = (count ($ basef)-1 );
- $ Ef_sum = (count ($ extf)-1 );
- $ Ef2_sum = (count ($ extf2)-1 );
// Obtain the random user name
- For ($ I = 0; $ I <$ n; $ I ++)
- {
- $ Bn = crand (0, $ bf_sum );
- $ En = crand (0, $ ef_sum );
- $ En2 = crand (0, $ ef2_sum );
- $ Name = $ basef [$ bn]. "_". $ extf [$ en];
- $ Name = str_replace ("/r/n", "", $ name );
- $ All_name [] = $ name;
- }
// Write a file
- $ Result = implode ("/r/n", $ all_name );
- $ Fp = fopen ($ rfile, "a +") or die ('open $ rfile failed ');
- If (fwrite ($ fp, $ result )){
- Echo 'write user succeed! ';
- } Else {
- Echo 'write user failed ';
- }
// Generate a random number function
- Function crand ($ start, $ end)
- {
- Return mt_rand ($ start, $ end );
- }
- ?>
2. Merge the results of the preceding files.
/* Merge all generated results jbxue.com */
$ Result_file = "./result. dic ";
$ Fp = fopen ($ result_file, "a +") or die ("Open $ result_file failed ");
// Merge 1.dic ~ 5. dic
- For ($ I = 1; $ I <= 5; $ I ++)
- {
- $ Cur_file = file_get_contents ($ I. ". dic ");
- Fwrite ($ fp, $ cur_file );
- }
// Merge 10.dic ~ 11. dic
- For ($ I = 10; $ I <= 11; $ I ++)
- {
- $ Cur_file = file_get_contents ($ I. ". dic ");
- Fwrite ($ fp, $ cur_file );
- }
- Fclose ($ fp );
- Echo 'write succeed ';
- ?>
3. filter duplicate values and do not belong to 6 ~ Value between 16 and generate final available data
/* Generate the final result */
$ File = "./result. dic ";
- $ Target = "./target. dic ";
// Remove duplicate values
- $ Files = file ($ file );
- $ Files = array_unique ($ files );
// Determine whether the value is greater than 6 bits and less than 16 bits
- $ Sum = count ($ files );
- For ($ I = 0; $ I <$ sum; $ I ++)
- {
- If (strlen ($ files [$ I])> = 6 & strlen ($ files [$ I]) <= 16 ){
- $ Rs [] = $ files [$ I];
- } Else {
- Continue;
- }
- }
// Write the target file
- $ Result = implode ("", $ rs );
- $ Fp = fopen ($ target, "a +") or die ("Open $ target failed ");
- Fwrite ($ fp, $ result );
- Echo 'write succeed ';
- ?>
|