| Server IP : 188.114.97.2 / Your IP : 104.23.243.200 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/nicolasj/www/sms.formationlangues.be/application/helpers/ |
Upload File : |
<?php
function ae_gen_password($syllables = 3, $use_prefix = false)
{
// Define function unless it is already exists
if (!function_exists('ae_arr'))
{
// This function returns random array element
function ae_arr(&$arr)
{
return $arr[rand(0, sizeof($arr)-1)];
}
}
// 20 prefixes
$prefix = array('aero', 'anti', 'auto', 'bi', 'bio',
'cine', 'deca', 'demo', 'dyna', 'eco',
'ergo', 'geo', 'gyno', 'hypo', 'kilo',
'mega', 'tera', 'mini', 'nano', 'duo');
// 10 random suffixes
$suffix = array('dom', 'ity', 'ment', 'sion', 'ness',
'ence', 'er', 'ist', 'tion', 'or');
// 8 vowel sounds
$vowels = array('a', 'o', 'e', 'i', 'y', 'u', 'ou', 'oo');
// 20 random consonants
$consonants = array('w', 'r', 't', 'p', 's', 'd', 'f', 'g', 'h', 'j',
'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'qu');
$password = $use_prefix?ae_arr($prefix):'';
$password_suffix = ae_arr($suffix);
for($i=0; $i<$syllables; $i++)
{
// selecting random consonant
$doubles = array('n', 'm', 't', 's');
$c = ae_arr($consonants);
if (in_array($c, $doubles)&&($i!=0)) { // maybe double it
if (rand(0, 2) == 1) // 33% probability
$c .= $c;
}
$password .= $c;
//
// selecting random vowel
$password .= ae_arr($vowels);
if ($i == $syllables - 1) // if suffix begin with vovel
if (in_array($password_suffix[0], $vowels)) // add one more consonant
$password .= ae_arr($consonants);
}
// selecting random suffix
$password .= $password_suffix;
return $password;
}
?>