protected static function random($length)
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$pool = str_split($pool, 1);
$max = count($pool) - 1;
$str = '';
for ($i = 0; $i < $length; $i++) {
$str .= $pool[mt_rand(0, $max)];
}
if ($length > 1) {
if (ctype_alpha($str)) {
$str[mt_rand(0, $length - 1)] = chr(mt_rand(48, 57));
} elseif (ctype_digit($str)) {
$str[mt_rand(0, $length - 1)] = chr(mt_rand(65, 90));
}
}
return $str;
}