Exemple #1
0
 /**
  * Generate a random username 
  * 
  * Used for local and guest users
  * 
  * @param string $prefix		local or guest
  * @return string
  */
 public static function genRandomUsername($prefix)
 {
     $string = "";
     // take value from session id
     if (self::$request instanceof Request) {
         $session_id = self::$request->getSession()->getId();
         if ($session_id != "") {
             $string = $session_id;
         }
     } else {
         $length = 10;
         $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
         $string = "";
         for ($p = 0; $p < $length; $p++) {
             $string .= $characters[mt_rand(0, strlen($characters) - 1)];
         }
     }
     return $prefix . '@' . $string;
 }