ispCP - Board - Support
Password generator for reseller when add user - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Contributions Area (/forum-40.html)
+--- Forum: Enhancements (/forum-43.html)
+--- Thread: Password generator for reseller when add user (/thread-5358.html)



Password generator for reseller when add user - itanium - 01-06-2009 07:53 AM

A small enhancement for reseller that generate an random password when you add a user.

[Image: i77_passgen.JPG]

Simply copy / paste the generate password in the password and password repeat case. The password is not added automatically

Code:

1). Create a passgen.php in /var/www/ispcp/gui/themes/omega_original/css

Code:
<?php
function createPassword($length) {
    $chars = "234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $i = 0;
    $password_gen = "";
    while ($i <= $length) {
        $password_gen .= $chars{mt_rand(0,strlen($chars))};
        $i++;
    }
    return $password_gen;
}
$password_gen = createPassword(8);

?>
<table style="text-align: left; width=200px;" border="0" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="background-color: rgb(255, 204, 204);">
<?=$password_gen?><br />
    </tr>
  </tbody>
</table>
<form action="passgen.php" method="get">
<input type="submit" value="Go" />
</form>

2). In /var/www/ispcp/gui/themes/omega_original/reseller edit user_add3.tpl and after:

Code:
<tr>
<td width="25">&nbsp;</td>
<td class="content2" width="200">{TR_USERNAME}</td>
<td class="content">{VL_USERNAME}</td>
</tr>

add this:

Code:
<tr>
<td width="25">&nbsp;</td>
<td class="content2" width="200">{TR_PASSWORD_GENERATOR}</td>
<td class="content">
<object type="text/html" data="{THEME_COLOR_PATH}/css/passgen.php"" width="100%" height="80px">
</object>
</td>
</tr>
<tr>

3.) In /var/www/ispcp/gui/reseller edit user_add3.php and after:

Code:
'TR_CORE_DATA' => tr('Core data'),

add this

Code:
'TR_PASSWORD_GENERATOR' => tr('Generate password'),

4.) Edit you language file (french exemple) and add:

Code:
Generate password = Générer Mot de passe

Enjoy Wink.

Ps: I'm not able to provided this file because i have hacked some part of this.
I will integrate this script in several place like ftp account creation, mysql mail ..


RE: Password generator for reseller when add user - BeNe - 01-07-2009 02:43 AM

Cool idea!
Thanks for it.

Greez BeNe


RE: Password generator for reseller when add user - RatS - 01-08-2009 12:42 AM

I did not got the point. We have already pw-generators, what's the difference?


RE: Password generator for reseller when add user - itanium - 01-08-2009 02:06 AM

Because the password is not visible and we can not choose the size of passwords. Here you can edit createPassword (8); by the number needed to configure the size of passwords and know the password.

Ps: To create a passwords for mysql, ftp,mail is also more practical


RE: Password generator for reseller when add user - RatS - 01-08-2009 02:21 AM

In my mind it is okay, that the reseller does not know the user password (even if it is auto generated). The last point sounds plausible, I will think about it, if it makes sense.


RE: Password generator for reseller when add user - itanium - 01-08-2009 02:27 AM

I agree with you on 1 point and that is why the password is not automatically added. It's just an option Wink


RE: Password generator for reseller when add user - floreno - 09-14-2009 10:03 PM

I proged another quicker method.
Function: On Click on Button "PWD-Gen", the password is generated and inserted in both password-fields; after that, it is allerted with JS for human-reading.
Just copy&paste the followind JS-Function to your file "/var/www/ispcp/gui/themes/omega_original/css/ispcp.js"

Code:
function pwd_gen(f){
        chars = "234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        sp = '';
        for (i=0; i < 10; i++) {
                sp = sp + chars.charAt(Math.random()*chars.length);
        }
        if(document.getElementsByName(f)[0])document.getElementsByName(f)[0].value = sp;
        if(document.getElementsByName(f+'_repeat')[0])document.getElementsByName(f+'_repeat')[0].value = sp;
        if(document.getElementsByName(f+'_rep')[0])document.getElementsByName(f+'_rep')[0].value = sp;
        alert("Neues Zufallspasswort: \""+sp+"\"");
}

Everywhere you want the "PWD-Gen" button just copy&paste the following HTML-Tag:

Code:
<input type="button" value="PW-Gen" onclick="pwd_gen('pass');">

Example:
Original-Code from "/var/www/ispcp/gui/themes/omega_original/client/mail_add.tpl":
Code:
<tr>
                <td nowrap="nowrap" class="content2" width="200">&nbsp;&nbsp;&nbsp;&nbsp;{TR_PASSWORD}</td>
                <td nowrap="nowrap" class="content"><input type="password" name="pass" value="" style="width:210px" class="textinput"></td>
              </tr>

Changed-Code:
Added <input type="button" value="PW-Gen" onclick="pwd_gen('pass');">
Code:
<tr>
                <td nowrap="nowrap" class="content2" width="200">&nbsp;&nbsp;&nbsp;&nbsp;{TR_PASSWORD}</td>
                <td nowrap="nowrap" class="content"><input type="password" name="pass" value="" style="width:210px" class="textinput"><input type="button" value="PW-Gen" onclick="pwd_gen('pass');"></td>
              </tr>



RE: Password generator for reseller when add user - Scrudj - 10-13-2009 07:20 AM

itanium

Thank you, great job!


RE: Password generator for reseller when add user - BeNe - 10-13-2009 03:41 PM

A Password Generator is also needed for creating a DB-User in my eyes.
I always use a local installed tool for it Rolleyes

Greez BeNe


RE: Password generator for reseller when add user - mafia - 05-11-2010 01:48 AM

Hello, first thanks a lot for this tutorial.

Can I ask if this script and instructions are always
updated at this time?ispCP 1.0.5