From e64244ff6bf0ef8fc345d36449fb24bfc490cdcb Mon Sep 17 00:00:00 2001 From: Noor E Alam Date: Thu, 6 Feb 2020 17:59:45 +0600 Subject: [PATCH] hosting username as first 8 domain characters for set hosting username using first 8 domain characters before activating hosting order --- src/bb-modules/Servicehosting/Service.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/bb-modules/Servicehosting/Service.php b/src/bb-modules/Servicehosting/Service.php index 47f3f3c18..632e26e08 100644 --- a/src/bb-modules/Servicehosting/Service.php +++ b/src/bb-modules/Servicehosting/Service.php @@ -112,8 +112,8 @@ class Service implements InjectionAwareInterface if(isset($c['username']) && !empty($c['username'])) { $username = $c['username']; } else { - $username = $this->_generateUsername(); - } + $username = $this->_generateUsername($model->sld.$model->tld); + } $model->username = $username; $model->pass = $pass; @@ -383,14 +383,12 @@ class Service implements InjectionAwareInterface * Generate username by domain * */ - private function _generateUsername() + private function _generateUsername($domain_name) { - $num1 = rand(10000, 99999); - $num2 = rand(10000, 99999); - $username = $num1 . $num2; - $username = substr($username, 0, 8); // max length 8 - $username[0] = "u"; - + $username = preg_replace('/[^A-Za-z0-9]/', '', $domain_name); + $username = substr($username,0,7); + $randnum = rand(0, 9); + $username = $username . $randnum; return $username; } @@ -957,4 +955,4 @@ class Service implements InjectionAwareInterface } return $result; } -} \ No newline at end of file +}