at path:ROOT / clients / assets / js / whmcs / adminUtils.js
run:R W Run
2.97 KB
2026-04-08 19:29:25
R W Run
9 KB
2026-04-08 19:29:26
R W Run
1.49 KB
2026-04-08 19:29:25
R W Run
2.44 KB
2026-04-08 19:29:28
R W Run
5.28 KB
2026-04-08 19:29:28
R W Run
45 By
2026-04-08 19:29:27
R W Run
5.71 KB
2026-04-08 19:29:26
R W Run
4.91 KB
2026-04-08 19:29:25
R W Run
3.24 KB
2026-04-08 19:29:27
R W Run
24.58 KB
2026-04-08 19:29:26
R W Run
13.16 KB
2026-04-08 19:29:26
R W Run
5.46 KB
2026-04-08 19:29:27
R W Run
error_log
📄adminUtils.js
1/**
2 * General utilities module
3 *
4 * @copyright Copyright (c) WHMCS Limited 2005-2017
5 * @license http://www.whmcs.com/license/ WHMCS Eula
6 */
7(function(module) {
8 if (!WHMCS.hasModule('adminUtils')) {
9 WHMCS.loadModule('adminUtils', module);
10 }
11})(
12function () {
13 this.getAdminRouteUrl = function (path) {
14 return whmcsBaseUrl + "/index.php?rp=" + adminBaseRoutePath + path;
15 };
16
17 this.normaliseStringValue = function(status) {
18 return status ? status.toLowerCase().replace(/\s/g, '-') : '';
19 }
20
21 this.generatePassword = function(len) {
22 var charset = this.getPasswordCharacterSet();
23 var result = "";
24 for (var i = 0; len > i; i++)
25 result += charset[this.randomInt(charset.length)];
26 return result;
27 };
28 this.getPasswordCharacterSet = function() {
29 var rawCharset = '0123456789'
30 + 'abcdefghijklmnopqrstuvwxyz'
31 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
32 + '!#$%()*+,-.:;=@_|{ldelim}{rdelim}~';
33
34 // Parse UTF-16, remove duplicates, convert to array of strings
35 var charset = [];
36 for (var i = 0; rawCharset.length > i; i++) {
37 var c = rawCharset.charCodeAt(i);
38 if (0xD800 > c || c >= 0xE000) { // Regular UTF-16 character
39 var s = rawCharset.charAt(i);
40 if (charset.indexOf(s) == -1)
41 charset.push(s);
42 continue;
43 }
44 if (0xDC00 > c ? rawCharset.length > i + 1 : false) { // High surrogate
45 var d = rawCharset.charCodeAt(i + 1);
46 if (d >= 0xDC00 ? 0xE000 > d : false) { // Low surrogate
47 var s = rawCharset.substring(i, i + 2);
48 i++;
49 if (charset.indexOf(s) == -1)
50 charset.push(s);
51 continue;
52 }
53 }
54 throw new Error("Invalid UTF-16");
55 }
56 return charset;
57 };
58 this.randomInt = function(n) {
59 var x = this.randomIntMathRandom(n);
60 x = (x + this.randomIntBrowserCrypto(n)) % n;
61 return x;
62 };
63 this.randomIntMathRandom = function(n) {
64 var x = Math.floor(Math.random() * n);
65 if (0 > x || x >= n)
66 throw new Error("Arithmetic exception");
67 return x;
68 };
69 this.randomIntBrowserCrypto = function(n) {
70 var cryptoObject = null;
71
72 if ("crypto" in window)
73 cryptoObject = crypto;
74 else if ("msCrypto" in window)
75 cryptoObject = msCrypto;
76 else
77 return 0;
78
79 if (!("getRandomValues" in cryptoObject) || !("Uint32Array" in window) || typeof Uint32Array != "function")
80 cryptoObject = null;
81
82 if (cryptoObject == null)
83 return 0;
84
85 // Generate an unbiased sample
86 var x = new Uint32Array(1);
87 do cryptoObject.getRandomValues(x);
88 while (x[0] - x[0] % n > 4294967296 - n);
89 return x[0] % n;
90 };
91
92 return this;
93});
94