Current time: 11-15-2024, 10:43 PM Hello There, Guest! (LoginRegister)


Post Reply 
Password generator for reseller when add user
Author Message
itanium Offline
Junior Member
*

Posts: 35
Joined: Apr 2007
Reputation: 0
Post: #1
Password generator for reseller when add user
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 ..
(This post was last modified: 01-07-2009 02:24 AM by itanium.)
01-06-2009 07:53 AM
Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #2
RE: Password generator for reseller when add user
Cool idea!
Thanks for it.

Greez BeNe
01-07-2009 02:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RatS Offline
Project Leader
******

Posts: 1,854
Joined: Oct 2006
Reputation: 17
Post: #3
RE: Password generator for reseller when add user
I did not got the point. We have already pw-generators, what's the difference?
01-08-2009 12:42 AM
Visit this user's website Find all posts by this user Quote this message in a reply
itanium Offline
Junior Member
*

Posts: 35
Joined: Apr 2007
Reputation: 0
Post: #4
RE: Password generator for reseller when add user
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
(This post was last modified: 01-08-2009 02:17 AM by itanium.)
01-08-2009 02:06 AM
Find all posts by this user Quote this message in a reply
RatS Offline
Project Leader
******

Posts: 1,854
Joined: Oct 2006
Reputation: 17
Post: #5
RE: Password generator for reseller when add user
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.
01-08-2009 02:21 AM
Visit this user's website Find all posts by this user Quote this message in a reply
itanium Offline
Junior Member
*

Posts: 35
Joined: Apr 2007
Reputation: 0
Post: #6
RE: Password generator for reseller when add user
I agree with you on 1 point and that is why the password is not automatically added. It's just an option Wink
01-08-2009 02:27 AM
Find all posts by this user Quote this message in a reply
floreno Offline


Posts: 1
Joined: Jul 2009
Reputation: 0
Post: #7
RE: Password generator for reseller when add user
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>
(This post was last modified: 09-14-2009 10:05 PM by floreno.)
09-14-2009 10:03 PM
Find all posts by this user Quote this message in a reply
Scrudj Offline
Junior Member
*

Posts: 15
Joined: Oct 2009
Reputation: 0
Post: #8
RE: Password generator for reseller when add user
itanium

Thank you, great job!
10-13-2009 07:20 AM
Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #9
RE: Password generator for reseller when add user
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
10-13-2009 03:41 PM
Visit this user's website Find all posts by this user Quote this message in a reply
mafia Offline
Banned

Posts: 170
Joined: May 2008
Post: #10
RE: Password generator for reseller when add user
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
05-11-2010 01:48 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 4 Guest(s)