Jump to content

Quick Password Generator


ike

Recommended Posts

  • 1 month later...
  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Suggestions

 

Include: password_generator.js

 

( see attach file: clientareachangepw.tpl.jpg )

 

// compatibility for the template clientareachangepw.tpl

 

function GeneratePassword2() {

var p = GetRandomPassword();

var e = document.getElementsByName("newpw");

if (e.length>0) {

e[0].value = p;

if (e[0].type == "password") changeInputType(e[0],"text");

}

// For a "confirm password" field

e = document.getElementsByName("confirmpw");

if (e.length>0) {

e[0].value = p;

if (e[0].type == "password") changeInputType(e[0],"text");

}

}

 

in clientareachangepw.tpl

 

<input type="button" value="Gerar Senha" onclick="GeneratePassword2();"/>

 

 

Another suggestion:

 

/clientregister.tpl ( see attach file: clientregister.tpl.jpg )

 

Congratulations

 

I have applied these changes and they work well however one issue i found is the password strength meter then doesnt show how strong the pass is

 

anyone know how to sort that?

Link to comment
Share on other sites

  • 2 months later...

Is there any way to get this little addon implemented for use on the promotion code screen?

 

Would be handy to generate random strings for promotion codes rather than have to think up corny little codes like "autumsale" and "get20off" etc.

 

Could someone maybe write a little script for that?

 

Cheers :)

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 3 months later...
  • 6 months later...
  • 1 month later...
  • 1 month later...
  • 4 weeks later...

pwgen 1.0

http://www.whmcs.com/members/communityaddons.php?action=viewmod&id=35

Works great - the download link is missing. I still have the zip file I downloaded last year. Where can we make it available to everyone again?

 

Note: In WHMCS version 5.X edit the /admin/templates/blend/header.tpl file for the admin side password features - it works great - should be a standard feature in WHMCS.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

to get the PW meter to work in V5 change password_generator.js as follows

 

// Adding this for the password strength meter
// This is copied in part from /whmcs/includes/jscript/pwstrength.js
$("#password").keyup(function () {
       var pw = $("#password").val();
       var pwlength=(pw.length);
       if(pwlength>5)pwlength=5;
       var numnumeric=pw.replace(/[0-9]/g,"");
       var numeric=(pw.length-numnumeric.length);
       if(numeric>3)numeric=3;
       var symbols=pw.replace(/\W/g,"");
       var numsymbols=(pw.length-symbols.length);
       if(numsymbols>3)numsymbols=3;
       var numupper=pw.replace(/[A-Z]/g,"");
       var upper=(pw.length-numupper.length);
       if(upper>3)upper=3;
       var pwstrength=((pwlength*10)-20)+(numeric*10)+(numsymbols*15)+(upper*10);
       if(pwstrength<0){pwstrength=0}
       if(pwstrength>100){pwstrength=100}
       $("#pwstrengthbox").removeClass("weak moderate strong");
       $("#pwstrengthbox").html("Strong");
       $("#pwstrengthbox").addClass("strong");
       if (pwstrength<75) {
           $("#pwstrengthbox").html("Moderate");
          $("#pwstrengthbox").addClass("moderate");
       }
       if (pwstrength<30) {
           $("#pwstrengthbox").html("Weak");
           $("#pwstrengthbox").addClass("weak");
       }
   });
// End copied code

 

and

 

// Call the password keyup function (if it exists) to update the pw strength meter on the order checkout page
$("#password").keyup();

 

But it would be good to get this integrated into the main system

Link to comment
Share on other sites

  • 3 weeks later...

Yes the link on the English WHMCS site is not working.

 

However, you can find it here on the WHMCS Brazil site (wow these guys really are international!

It's originally in Portuguese (hence the google translate link) so you need to translate a few words back to English (easy)

 

You will need to amend the code (OK, Medium, Strong) in the JS file and also change the Generate button text - other than that it's good!

 

Here's the link: scroll down the page to the Password Generator part.

 

http://translate.google.com/translate?sl=auto&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fwww.whmcs.blog.br%2Ftag%2Fsenha%2F&act=url

 

The download link is here for the zip file (www.whmcs.blog.br/wp-content/plugins/download-monitor/download.php?id=26)

Edited by sol2010
Link to comment
Share on other sites

  • 2 weeks later...

So i can confirm this works.... following the instructions properly the only thing that does not work is the CLIENTAREAPWCHANGE and the CLIENTAREAREGISTER does not work, when you click on Generate Password button it does nothing i think its because it has something to do with the hidden asterix fields.

 

If anyone can get this working let me know.

Link to comment
Share on other sites

  • 1 month later...
So i can confirm this works.... following the instructions properly the only thing that does not work is the CLIENTAREAPWCHANGE and the CLIENTAREAREGISTER does not work, when you click on Generate Password button it does nothing i think its because it has something to do with the hidden asterix fields.

 

If anyone can get this working let me know.

 

I'm having the same issue ... works in Admin but in cart button does nothing

Link to comment
Share on other sites

We've been using this for a while now; however, to maintain PCI compliant, does anyone know how to include symbols in addition to the alphanumeric passwords.

 

We've added chars += "\!\@,\%\~\=\)\(\;\$"; to the function GetRandomCharacter() { but it still doesn't include the symbol.

 

Thanks

Link to comment
Share on other sites

Hi Frank,

 

Thanks for the help. We have modified the previous code so symbols are now generating (I have included the code below), unfortunately we do not have it working in v5.0 Client Area yet.

 

 

// AddAutoPasswordButtons: Look for password boxes and add a generate password button next to them
function AddAutoPasswordButtons() {
// Don't add the Generate button to certain pages where it wouldn't make sense
var NoGenerate = [
'WHMCS - Servers',
'WHMCS - Support Ticket Departments'
];
for (i=0; i<NoGenerate.length; i++) if (document.title == NoGenerate[i]) return;

// Get the Password text box, if there is one
var e = document.getElementsByName("password");
if (e.length>0)
{
var b = document.createElement("input");
b.type = "button";
b.value = "Generate";
b.onclick = GeneratePassword;
e[0].parentNode.appendChild(b);
}
}

// GeneratePassword: Generate a password and place it in a textbox
function GeneratePassword() {
var p = GetRandomPassword();
var e = document.getElementsByName("password");
if (e.length>0) {
e[0].value = p;
if (e[0].type == "password") e[0].type = "text";
}
// For a "confirm password" field
e = document.getElementsByName("password2");
if (e.length>0) {
e[0].value = p;
if (e[0].type == "password") e[0].type = "text";
}
}

// GetRandomNumber: Get a random number between two specified numbers
function GetRandomNumber(lbound,ubound) {
return (Math.floor(Math.random() * (ubound-lbound)) + lbound);
}

// GetRandomCharacter: Get a random character
function GetRandomCharacter() {
var chars = ""; // Choose your character sets below
chars += "0123456789";
chars += "abcdefghijklmnopqrstuvwxyz";
chars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
chars += "\!\@,\%\~\=\)\(\;\$";

return chars.charAt(GetRandomNumber(0,chars.length));
}

//puts each character from the string str in arr and returns a new array
function PushArray(arr, str) {
var a = [];
for (var i = 0; i < str.length; i++)
a[a.length] = str.charAt(i);
arr[arr.length] = a;
return arr;
}

//does the actual generating
function GenerateRandomPasswords(length, letters, uppercase, numbers, punctuation, printable) {
var pass_length = parseInt(length);
if (pass_length < 1 || pass_length > 256) return false;

var needed_charsets = [];
if (printable === true) {
var print_chars = [];
for (var i = 32; i < 127; i++)
print_chars[print_chars.length] = String.fromCharCode(i);
needed_charsets[0] = print_chars;
} else {
if (letters === true) PushArray(needed_charsets, "qwertyuiopasdfghjklzxcvbnm");
if (uppercase === true) PushArray(needed_charsets, "QWERTYUIOPASDFGHJKLZXCVBNM");
if (numbers === true) PushArray(needed_charsets, "0123456789");
if (punctuation === true) PushArray(needed_charsets, ":;,.?!");
}

if (0 == needed_charsets.length) return false;

//var quantity = 3;

if (pass_length < needed_charsets.length) pass_length = needed_charsets.length;

var result = "";
//for (var i = 0; i < quantity; i++) {
var p;
while (true) {
p = [];
var used_charsets = [];
for (var j = 0; j < needed_charsets.length; ++j) used_charsets[j] = false;

for (var j = 0; j < pass_length; ++j) {
var k = Math.floor(Math.random()*needed_charsets.length);
var available_chars = needed_charsets[k];
p[j] = available_chars[Math.floor(Math.random()*available_chars.length)];
used_charsets[k] = true;
}

var all_charsets_used = true;
for (var j = 0; j < needed_charsets.length; ++j) all_charsets_used = all_charsets_used && used_charsets[j];
if (all_charsets_used) break;
}

for (var j = 0; j < pass_length; j++) {
var ch = p[j];
if ("<" == ch) ch = "<";
if (">" == ch) ch = ">";
result += ch;
}
//result += '<br />';
//alert(result);
//}

return result;
}

// GetRandomPassword: Get a random password
function GetRandomPassword() {
/*
var p = "";
for (i=0; i<8; i++) p += GetRandomCharacter();
return p;
*/
return GenerateRandomPasswords(8, true, true, true, true, false);
}

//------------------------------------------------------------------------------

// Adding events to onLoad
// Source: http://onlinetools.org/articles/unobtrusivejavascript/chapter4.html
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}

// Hook AddAutoPasswordButtons to window load
addEvent(window,'load',AddAutoPasswordButtons);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated