mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
moved randomstring method to admin_cmd
This commit is contained in:
parent
b44a3f198b
commit
86621d7fe2
@ -988,4 +988,29 @@ abstract class admin_cmd
|
|||||||
throw new egw_exception_no_permission($msg,0);
|
throw new egw_exception_no_permission($msg,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a rand string, eg. to generate passwords
|
||||||
|
*
|
||||||
|
* @param int $len=16
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static function randomstring($len=16)
|
||||||
|
{
|
||||||
|
static $usedchars = array(
|
||||||
|
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
|
||||||
|
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
|
||||||
|
'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
|
||||||
|
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
|
||||||
|
'@','!','$','%','&','/','(',')','=','?',';',':','#','_','-','<',
|
||||||
|
'>','|','{','[',']','}', // dont add \,'" as we have problems dealing with them
|
||||||
|
);
|
||||||
|
|
||||||
|
$str = '';
|
||||||
|
for($i=0; $i < $len; $i++)
|
||||||
|
{
|
||||||
|
$str .= $usedchars[mt_rand(0,count($usedchars)-1)];
|
||||||
|
}
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,29 +356,4 @@ abstract class setup_cmd extends admin_cmd
|
|||||||
|
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a rand string, eg. to generate passwords
|
|
||||||
*
|
|
||||||
* @param int $len=16
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
static function randomstring($len=16)
|
|
||||||
{
|
|
||||||
static $usedchars = array(
|
|
||||||
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
|
|
||||||
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
|
|
||||||
'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
|
|
||||||
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
|
|
||||||
'@','!','$','%','&','/','(',')','=','?',';',':','#','_','-','<',
|
|
||||||
'>','|','{','[',']','}', // dont add \,'" as we have problems dealing with them
|
|
||||||
);
|
|
||||||
|
|
||||||
$str = '';
|
|
||||||
for($i=0; $i < $len; $i++)
|
|
||||||
{
|
|
||||||
$str .= $usedchars[mt_rand(0,count($usedchars)-1)];
|
|
||||||
}
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user