ooooyeahbabe Posted September 27, 2022 Share Posted September 27, 2022 The Root Password automatically generated by WHMCS for placing an order is too complicated, which leads to an error when the user creates a VPS of Windows OS, Quote Allowed special characters for windows VPS root password are : > ! @ # $ % ^ & * _ - + = ? and the password needs to be manually changed to pass. How to reduce this password or make it only contain complex special characters at most Quote ! @ # $ % ^ & * _ - + = ? So as to meet Windows requirements for passwords 0 Quote Link to comment Share on other sites More sharing options...
Trle94 Posted September 27, 2022 Share Posted September 27, 2022 Hello, Try this: <?php /** * Stronger Password Generator for WHMCS Provisioning v3 * * @package WHMCS * @copyright Katamaze * @link https://katamaze.com * @author Davide Mantenuto <info@katamaze.com> */ use WHMCS\Database\Capsule; add_hook('OverrideModuleUsernameGeneration', 1, function($vars) { $length['digit'] = '3'; // Number of digits in password $length['lower'] = '4'; // Number of UNIQUE lowercase characters in password $length['upper'] = '4'; // Number of UNIQUE uppercase characters in password $length['special'] = '2'; // Number of special characters in password // The same character cannot be used more than once (case sensitive) if ($length['lower'] + $length['upper'] == '26') { $length['lower'] = '13'; $length['upper'] = '13'; } $digits = '0123456789'; $chars = 'abcdefghijklmnopqrstuvwxyz'; $special = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters $digits = substr(str_shuffle($digits), 0, $length['digit']); $lower = substr(str_shuffle($chars), 0, $length['lower']); $upper = substr(str_shuffle(strtoupper(str_replace(str_split($lower), '', $chars) )), 0, $length['lower']); $special = substr(str_shuffle($special), 0, $length['special']); $password = str_shuffle($digits . $lower . $upper . $special); Capsule::table('tblhosting')->where('id', $vars['params']['serviceid'])->update(['password' => Encrypt($password)]); }); 1 Quote Link to comment Share on other sites More sharing options...
ooooyeahbabe Posted September 28, 2022 Author Share Posted September 28, 2022 21 hours ago, Trle94 said: Hello, Try this: <?php /** * Stronger Password Generator for WHMCS Provisioning v3 * * @package WHMCS * @copyright Katamaze * @link https://katamaze.com * @author Davide Mantenuto <info@katamaze.com> */ use WHMCS\Database\Capsule; add_hook('OverrideModuleUsernameGeneration', 1, function($vars) { $length['digit'] = '3'; // Number of digits in password $length['lower'] = '4'; // Number of UNIQUE lowercase characters in password $length['upper'] = '4'; // Number of UNIQUE uppercase characters in password $length['special'] = '2'; // Number of special characters in password // The same character cannot be used more than once (case sensitive) if ($length['lower'] + $length['upper'] == '26') { $length['lower'] = '13'; $length['upper'] = '13'; } $digits = '0123456789'; $chars = 'abcdefghijklmnopqrstuvwxyz'; $special = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters $digits = substr(str_shuffle($digits), 0, $length['digit']); $lower = substr(str_shuffle($chars), 0, $length['lower']); $upper = substr(str_shuffle(strtoupper(str_replace(str_split($lower), '', $chars) )), 0, $length['lower']); $special = substr(str_shuffle($special), 0, $length['special']); $password = str_shuffle($digits . $lower . $upper . $special); Capsule::table('tblhosting')->where('id', $vars['params']['serviceid'])->update(['password' => Encrypt($password)]); }); This is hook? 0 Quote Link to comment Share on other sites More sharing options...
ooooyeahbabe Posted September 28, 2022 Author Share Posted September 28, 2022 21 hours ago, Trle94 said: Hello, Try this: <?php /** * Stronger Password Generator for WHMCS Provisioning v3 * * @package WHMCS * @copyright Katamaze * @link https://katamaze.com * @author Davide Mantenuto <info@katamaze.com> */ use WHMCS\Database\Capsule; add_hook('OverrideModuleUsernameGeneration', 1, function($vars) { $length['digit'] = '3'; // Number of digits in password $length['lower'] = '4'; // Number of UNIQUE lowercase characters in password $length['upper'] = '4'; // Number of UNIQUE uppercase characters in password $length['special'] = '2'; // Number of special characters in password // The same character cannot be used more than once (case sensitive) if ($length['lower'] + $length['upper'] == '26') { $length['lower'] = '13'; $length['upper'] = '13'; } $digits = '0123456789'; $chars = 'abcdefghijklmnopqrstuvwxyz'; $special = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters $digits = substr(str_shuffle($digits), 0, $length['digit']); $lower = substr(str_shuffle($chars), 0, $length['lower']); $upper = substr(str_shuffle(strtoupper(str_replace(str_split($lower), '', $chars) )), 0, $length['lower']); $special = substr(str_shuffle($special), 0, $length['special']); $password = str_shuffle($digits . $lower . $upper . $special); Capsule::table('tblhosting')->where('id', $vars['params']['serviceid'])->update(['password' => Encrypt($password)]); }); Sorry , its not working my version is 8.5.1 0 Quote Link to comment Share on other sites More sharing options...
Trle94 Posted September 28, 2022 Share Posted September 28, 2022 What error do you get? And yes it is an hook. 0 Quote Link to comment Share on other sites More sharing options...
ooooyeahbabe Posted September 28, 2022 Author Share Posted September 28, 2022 1 minute ago, Trle94 said: What error do you get? And yes it is an hook. Nothing , it like din't work . still have another special string $digits = '0123456789'; $chars = 'abcdefghijklmnopqrstuvwxyz'; $special = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters 0 Quote Link to comment Share on other sites More sharing options...
ooooyeahbabe Posted September 28, 2022 Author Share Posted September 28, 2022 add_hook('OverrideModuleUsernameGeneration', 1, function($vars) should i change taht OverrideModuleUsernameGeneration ? 0 Quote Link to comment Share on other sites More sharing options...
Trle94 Posted September 28, 2022 Share Posted September 28, 2022 2 hours ago, ooooyeahbabe said: Capsule::table('tblhosting')->where('id', $vars['params']['serviceid'])->update(['password' => Encrypt($password)]); I believe there is problem with this part of updating db with new details... 0 Quote Link to comment Share on other sites More sharing options...
ooooyeahbabe Posted September 28, 2022 Author Share Posted September 28, 2022 46 minutes ago, Trle94 said: I believe there is problem with this part of updating db with new details... I create this in configureproduct.tpl now its working <script> function makeid(length) { var result = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var charactersLength = characters.length; for (var i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } function generatePass(pLength){ var keyListAlpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", keyListInt="123456789", keyListSpec="!@#$%^&*_-+=?", password=''; var len = Math.ceil(pLength/2); len = len - 1; var lenSpec = pLength-2*len; for (i=0;i<len;i++) { password+=keyListAlpha.charAt(Math.floor(Math.random()*keyListAlpha.length)); password+=keyListInt.charAt(Math.floor(Math.random()*keyListInt.length)); } for (i=0;i<lenSpec;i++) password+=keyListSpec.charAt(Math.floor(Math.random()*keyListSpec.length)); password=password.split('').sort(function(){return 0.5-Math.random()}).join(''); return password; } $(document).ready(function() { $('#inputHostname').val('' + makeid({/literal}{$hostname_interfix}{literal}) + '{/literal}{$hostname_prefix}{$hostname_suffix}{literal}') }); $(document).ready(function() { $('#inputRootpw').val(generatePass(14)); }); </script> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.