Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Password generator mod

Asked Modified Viewed 3,299 times
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
asked
Junior Member

Hi.

In the registration interface the registrant can generate a strong password for himself.

Currently 12 character password is generated.
- Two lowercase letters
- Two uppercase
- Two number
- Two symbols

To use this mode, you need to modify three core files and create one new file.

Editing
/includes/api/index.php

Look for this
$endpoints = [
 "username-check" => "username_validation.php",
 "userpass-check" => "userpass_validation.php",
 'calling-codes' => 'calling_codes.php', //get
 'geomap-states' => 'states.php', //get


Change
$endpoints = [
 "username-check" => "username_validation.php",
 "userpass-check" => "userpass_validation.php",
 'calling-codes' => 'calling_codes.php', // get
 'geomap-states' => 'states.php', // get
 'password-recommender' => 'bltfmhu_password_generator.inc.php'



Create a new file here
/includes/api/

The name of the file
bltfmhu_password_generator.inc.php

Contents
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHP Fusion Inc
| https://phpfusion.com/
+--------------------------------------------------------+
| Filename: bltfmhu_password_generator.inc.php
| Title: Jelszó Generátor
| Version: 1.0.0
| CVS Version: 9.10.xxx
| PHP-Fusion Mods Builder
| Author: Mathias
| Web: https://fusion.bltfm.hu/
+--------------------------------------------------------+
| Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
defined('IN_FUSION') || exit;
/**
 * Password generator
 */
function password_generator($length = 12) {
   $ABC = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
   $_abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
   $num = ['0','1','2','3','4','5','6','7','8','9'];
   $spe = ['@','!','#','$','%','&','/','(',')','=','-','_','?','+','*','.',',',':',';']; // ,''
   $db_cha = $length/4;
   $cha = [];
   $cha_ = '';

   for ($i=0; $i < $db_cha; $i++) {
      shuffle($ABC);
      $rand_keys = array_rand($ABC, $db_cha);
      $cha[] = $ABC[$rand_keys[$i]];
      unset($ABC[$rand_keys[$i]]);
   }
   for ($i=0; $i < $db_cha; $i++) {
      shuffle($_abc);
      $rand_keys = array_rand($_abc, $db_cha);
      $cha[] = $_abc[$rand_keys[$i]];
      unset($_abc[$rand_keys[$i]]);
   }
   for ($i=0; $i < $db_cha; $i++) {
      shuffle($num);
      $rand_keys = array_rand($num, $db_cha);
      $cha[] = $num[$rand_keys[$i]];
      unset($num[$rand_keys[$i]]);
   }
   for ($i=0; $i < $db_cha; $i++) {
      shuffle($spe);
      $rand_keys = array_rand($spe, $db_cha);
      $cha[] = $spe[$rand_keys[$i]];
      unset($spe[$rand_keys[$i]]);
   }
   shuffle($cha);
   shuffle($cha);
   foreach($cha as $key => $val) {
      $cha_ .= $val;
   }
   return $cha_;
}

function xpassword_generator() {
   $result = [];
   $result['result'] = 'valid';
   $result['response'] = password_generator(12);
   header('Content-Type: application/json');
   echo json_encode($result);
}

/**
 * @uses xpassword_generator()
 */
fusion_add_hook('fusion_filters', 'xpassword_generator');



Editing
/includes/classes/PHPFusion/UserFields.php

Look for this
$this->info['user_password'] .= form_text('user_password1', $locale['u134a'], '', [
 'type' => 'password',
 'autocomplete_off' => 1,
 'inline' => TRUE,
 'max_length' => 64,
 'error_text' => $locale['u134'].$locale['u143a'],
 'required' => !$this->admin_mode,
 'ext_tip' => $locale['u147']
 ]
 );


Change
$this->info['user_password'] .= form_text('user_password1', $locale['u134a'], '', [
 'type' => 'password',
 'autocomplete_off' => 1,
 'inline' => TRUE,
 'max_length' => 64,
 'error_text' => $locale['u134'].$locale['u143a'],
 'required' => !$this->admin_mode,
 'ext_tip' => $locale['u147']."<div style='padding-top: 2px;'><button title='' id='modal_pwdgen' name='modal_pwdgen' type='button' value='".$locale['pwdgen00']."' class='btn btn-primary' style='padding: 5px;'>".$locale['pwdgen00']."</button></div>"
 ]
 );
/* BltFMHU MOD _PASSWORD_GENERATOR */
echo openmodal('pwdgen_modal', $locale['pwdgen00'], ['button_id' => 'modal_pwdgen']);

   echo form_text('pwd_inp', $locale['pwdgen01'], '',
      ['type' => 'text', 'inline' => TRUE, 'max_length' => 64, 'deactivate' => TRUE, 'append_button' => TRUE, 'append_value' => $locale['pwdgen02'], 'append_button_id' => 'cp_btn', 'append_form_value' => $locale['pwdgen02'], 'append_button_name' => 'cp_btn', 'append_class' => 'btn btn-default', 'append_type' => 'button']
   );

   echo form_checkbox('copy_check', $locale['pwdgen03'], '0', ['type' => 'checkbox', 'required' => TRUE, 'toggle' => FALSE, 'class' => 'row-center']);

   echo modalfooter("
      <div style='position: absolute;left:0;bottom: 0;padding: 5px;'>
      <a href='https://fusion.bltfm.hu/' title='".$locale['pwdgen05']."' >'window.open(this.href); return false;' onkeypress='window.open(this.href); return false;'><span>".$locale['pwdgen06']."</span></a></div>"
      .form_button('pwd_copy', $locale['pwdgen04'], 'pwd_copy', ['deactivate' => TRUE, 'type' => 'button', 'class' => 'btn-default']),
      TRUE
   );

   add_to_jquery("
      $.ajax({
         url: '".INCLUDES."api/?api=password-recommender',
         method: 'POST',
         data: '',
         dataType: 'json',
         success: function (e) {
            $('#pwd_inp').val(e.response);
         }
      });
      $('#modal_pwdgen').click(function () {
         if ($('#copy_check').is(':checked')) {
            $('#copy_check').prop('checked', false);
            $('#pwd_copy').addClass('disabled');
            $('#pwd_copy').attr('disabled', true);
            $.ajax({
               url: '".INCLUDES."api/?api=password-recommender',
               method: 'POST',
               data: '',
               dataType: 'json',
               success: function (e) {
                  $('#pwd_inp').val(e.response);
               }
            });
         }
      });
      $('input[type=checkbox]').bind('click', function () {
         if ($(this).is(':checked')) {
            $('#pwd_copy').removeClass('disabled');
            $('#pwd_copy').removeAttr('disabled');
         } else {
            $('#pwd_copy').addClass('disabled');
            $('#pwd_copy').attr('disabled', true);
         }
      });
      $('#cp_btn').click(function () {
         $.ajax({
            url: '".INCLUDES."api/?api=password-recommender',
            method: 'POST',
            data: '',
            dataType: 'json',
            success: function (e) {
               $('#pwd_inp').val(e.response);
            }
         });
      });
   ");
   add_to_jquery('
      function copyToClipboard(text) {
         var textArea = document.createElement("textarea");
         textArea.value = text;
         document.body.appendChild(textArea);
         textArea.select();
         try {
            var successful = document.execCommand("copy");
            var msg = successful ? "successful" : "unsuccessful";
            console.log("Copying text command was " + msg);
         } catch (err) {
            console.log("Oops, unable to copy", err);
         }
         document.body.removeChild(textArea);
      }
      $("#pwd_copy").click( function() {
         var clipboardText = "";
         clipboardText = $("#pwd_inp").val();
         copyToClipboard(clipboardText);
         $("#pwdgen_modal-Modal").modal("toggle");
         $("#user_password1").val(clipboardText);
         $("#user_password2").val(clipboardText);
      });
   ');

echo closemodal();
/* BltFMHU MOD _PASSWORD_GENERATOR END */



Editing
/locale/English/user_fields.php

Copy this to the end of the file
/* BltFMHU MOD _PASSWORD_GENERATOR */
$locale['pwdgen00'] = "Password generator";
$locale['pwdgen01'] = 'Suggested password';
$locale['pwdgen02'] = "Password generation";
$locale['pwdgen03'] = "You have copied this password to a safe place!";
$locale['pwdgen04'] = "Use a password";
$locale['pwdgen05'] = "v.1.0.0 Fusion.BltFm.hu";
$locale['pwdgen06'] = "v.1.0.0 by ".utf8_encode('đ');
/* BltFMHU MOD _PASSWORD_GENERATOR END */



You're done, use it
MathiasHU attached the following files:
bltfmhu_password_generator_100.zip [No information available / 84 Downloads]
MathiasHU attached the following image:
Image not found Image not found
0 replies

15 posts

R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

Something like this was added in v10. But it can be added directly to the form_text() function, so it can be used anywhere.
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

I have not seen v10
0 replies
R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

This version is not released and will take several years to develop. Btw. code is in a private repo, so only core developers have access to it. But well so far only Fred added things into it.
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

I understand, then I use my own code

Maybe you could get into a later Fusion version if you like the idea.
Edited by MathiasHU on 21-12-2021 22:12,
0 replies
R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

Password generator is not bad idea, but I would add it directly to form_text(). Perhaps it will be in the next v9 update.
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

All right.
0 replies
— 2 months later —
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

I have added it directly to form_text()
Test in progress
Edited by MathiasHU on 24-03-2022 22:19,
MathiasHU attached the following image:
Image not found
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

Hi.

In the registration interface the registrant can generate a strong password for himself.

Currently 16 character password is generated.
- Four lowercase letters
- Four uppercase
- Four number
- Four symbols

To use this mode, you need to modify three core files and create one new file.

Tested v9.10.20
Editing
/includes/api/index.php

Look for this
$endpoints = [
 "username-check" => "username_validation.php",
 "userpass-check" => "userpass_validation.php",
 'calling-codes' => 'calling_codes.php', //get
 'geomap-states' => 'states.php', //get


Change
$endpoints = [
 "username-check" => "username_validation.php",
 "userpass-check" => "userpass_validation.php",
 'calling-codes' => 'calling_codes.php', // get
 'geomap-states' => 'states.php', // get
 'password-recommender' => 'password_generator.inc.php'


Create a new file here
/includes/api/

The name of the file
password_generator.inc.php

Contents
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHP Fusion Inc
| https://phpfusion.com/
+--------------------------------------------------------+
| Filename: password_generator.inc.php
| Title: Password generator
| Version: 1.1.0
| CVS Version: 9.10.xxx
| PHP-Fusion Mods Builder
| Author: Mathias
| Web: https://fusion.bltfm.hu/
+--------------------------------------------------------+
| Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
defined('IN_FUSION') || exit;
/**
 * Password generator
 */
function password_generator($length = 16) {
   $ABC = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
   $_abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
   $num = ['0','1','2','3','4','5','6','7','8','9'];
   $spe = ['@','!','#','$','%','&','/','(',')','=','-','_','?','+','*','.',',',':',';'];
   $db_cha = $length/4;
   $cha = [];
   $cha_ = '';

   for ($i=0; $i < $db_cha; $i++) {
      shuffle($ABC);
      $rand_keys = array_rand($ABC, $db_cha);
      $cha[] = $ABC[$rand_keys[$i]];
      unset($ABC[$rand_keys[$i]]);
   }
   for ($i=0; $i < $db_cha; $i++) {
      shuffle($_abc);
      $rand_keys = array_rand($_abc, $db_cha);
      $cha[] = $_abc[$rand_keys[$i]];
      unset($_abc[$rand_keys[$i]]);
   }
   for ($i=0; $i < $db_cha; $i++) {
      shuffle($num);
      $rand_keys = array_rand($num, $db_cha);
      $cha[] = $num[$rand_keys[$i]];
      unset($num[$rand_keys[$i]]);
   }
   for ($i=0; $i < $db_cha; $i++) {
      shuffle($spe);
      $rand_keys = array_rand($spe, $db_cha);
      $cha[] = $spe[$rand_keys[$i]];
      unset($spe[$rand_keys[$i]]);
   }
   shuffle($cha);
   shuffle($cha);
   foreach($cha as $key => $val) {
      $cha_ .= $val;
   }
   return $cha_;
}

function xpassword_generator() {
   $result = [];
   //$result['result'] = 'invalid';
   $result['result'] = 'valid';
   $result['response'] = password_generator(16);
   header('Content-Type: application/json');
   echo json_encode($result);
}

/**
 * @uses xpassword_generator()
 */
fusion_add_hook('fusion_filters', 'xpassword_generator');



Editing
/includes/dynamics/includes/form_text.php

Look for this
'mask_options' => [],


Change
'mask_options' => [],
         'password_recommend' => TRUE


Look for this
if (!empty($options['data'])) {


Change
if ($options['input_id'] == 'user_password1') {
      $options['data'] = ['toggle'=>'tooltip'];
   }
if ($options['input_id'] == 'user_admin_password1') {
      $options['data'] = ['toggle'=>'atooltip'];
   }
 if (!empty($options['data'])) {


Look for this
$html .= "</span>n";

 } else if ($options['append_value']) {


Change
if ($options['password_recommend'] == TRUE) {
 if ($options['input_id'] == 'user_password1' || $options['input_id'] == 'user_admin_password1') {
 $html .= "<button id='".$options['input_id']."_pwdGenerator' name='".$options['input_id']."_pwdGenerator' type='button' value='".$locale['pwdgen00']."' class='btn btn-default'>".$locale['pwdgen00']."</button>";
            add_to_jquery("$('#".$options['input_id']."_pwdGenerator').on('click', function(e) {
                  $.ajax({
                     url: '".INCLUDES."api/?api=password-recommender',
                     method: 'POST',
                     data: '',
                     dataType: 'json',
                     success: function (e) {
                        if (".$options['input_id']." == user_password1) {
                           $('#user_password1').val(e.response);
                           $('#user_password2').val(e.response);
                           $('#user_password1').attr('title', '".$locale['pwdgen01']."');
                           $('[data-toggle="tooltip"]').tooltip('show');
                           $('#user_password1-field').addClass('has-success');
                           $('#user_password1').addClass('is-valid');
                        } else
                        if (".$options['input_id']." == user_admin_password1) {
                           $('#user_admin_password1').val(e.response);
                           $('#user_admin_password2').val(e.response);
                           $('#user_admin_password1').attr('title', '".$locale['pwdgen01']."');
                           $('[data-toggle="atooltip"]').tooltip('show');
                           $('#user_admin_password1-field').addClass('has-success');
                           $('#user_admin_password1').addClass('is-valid');
                        }
                     }
                  });
               });
            ");
 }
 }
 $html .= "</span>n";

 } else if ($options['append_value']) {


Editing
/locale/English/user_fields.php

Copy this to the end of the file
/* BltFMHU MOD _PASSWORD_GENERATOR */
$locale['pwdgen00'] = "Password Generator";
$locale['pwdgen01'] = "Copy the password to a safe place!";
/* BltFMHU MOD _PASSWORD_GENERATOR END */
Edited by MathiasHU on 26-03-2022 23:15,
MathiasHU attached the following files:
bltfmhu_password_generator_110.zip [No information available / 65 Downloads]
MathiasHU attached the following image:
Image not found Image not found
0 replies
— 6 months later —
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

Hi there.
I developed the mod again, it will be available soon if anyone is interested.

By clicking on the input field, you will be offered to generate a password.
There is also a setting option on the password generation interface. The setting option will be expanded a little further in the future.
0 replies
D
douwe_yntema
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
answered
Senior Member

same:


https://www.php-fusion.co.uk/infusions/forum/viewthread.php?thread_id=40166&highlight=password+generate&pid=208552#post_208552
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

Hi, the code I wrote is completely different.
The mode can also be useful during the registration and profile editing interface. Look, open the registration interface and start filling in the fields or just the password field

https://fusion.bltfm.hu/register.php
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

Sample

i.postimg.cc/Y40VxHyw/password-generator-sample-1.png


i.postimg.cc/mcnnX501/password-generator-sample-2.png


Soon ...
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Junior Member

Language file is waiting for verification. Someone?
MathiasHU attached the following file:
bltfmhu_password_generator_130.zip [No information available / 24 Downloads]
0 replies
H
helmuth
H
Danish translator of PHP-Fusion helmuth@php-fusion.dk
-----------------------------------------
All people are born alike - except Republicans and Democrats. (Groucho Marx)
Listen to the music... https://soundcloud.com/helmuth-mikkel...mikkelsen/
  • Senior Member, joined since
  • Contributed 706 posts on the community forums.
  • Started 219 threads in the forums
  • Answered 1 question
answered
Senior Member

Danish locales attached ;-)
helmuth attached the following file:
danish_2.zip [No information available / 18 Downloads]
0 replies
H
helmuth
H
Danish translator of PHP-Fusion helmuth@php-fusion.dk
-----------------------------------------
All people are born alike - except Republicans and Democrats. (Groucho Marx)
Listen to the music... https://soundcloud.com/helmuth-mikkel...mikkelsen/
  • Senior Member, joined since
  • Contributed 706 posts on the community forums.
  • Started 219 threads in the forums
  • Answered 1 question
answered
Senior Member

js file attached
helmuth attached the following file:
danish_4.zip [No information available / 19 Downloads]
0 replies

Category Forum

Addons Open Testing

Statistics

  • Views 0 views
  • Posts 15 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

H
H
Danish translator of PHP-Fusion helmuth@php-fusion.dk
-----------------------------------------
All people are born alike - except Republicans and Democrats. (Groucho Marx)
Listen to the music... https://soundcloud.com/helmuth-mikkel...mikkelsen/
  • Senior Member, joined since
  • Contributed 706 posts on the community forums.
  • Started 219 threads in the forums
  • Answered 1 question
D
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
R
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
M
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
  • Answered 1 question

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet