moved randomstring method to admin_cmd

This commit is contained in:
Ralf Becker 2007-12-22 03:21:07 +00:00
parent b44a3f198b
commit 86621d7fe2
2 changed files with 25 additions and 25 deletions

View File

@ -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;
}
} }

View File

@ -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;
}
} }