Procedure 1: extract data randomly from the dictionary and write a new file. (1.php)
Copy codeThe Code is as follows:
<? Php
/* 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 );
}
?>
Procedure 2: Merge the results of the preceding files. (2.php)
Copy codeThe Code is as follows:
<? Php
/* Merge all generated results jb51.net */
$ 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 ';
?>
Procedure 3: Filter duplicate values and do not belong to 6 ~ Value between 16 and generate the final result (3.php)
Copy codeThe Code is as follows:
<? Php
/* 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 ';
?>
Basically, you have created random usernames.