Bulk User Account Password Encryption

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 29, 2013   (RSS)

By gregThomas - May 29, 2013

Hi Steve,

Are you using the default accounts section to store users passwords? If so you can encrypt them easily by checking the encrypt passwords checkbox in the general settings area of CMS Builder. 

If you're storing the passwords in a different section you could use this script:

<?php

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  $records = mysql_select('section_name_here');


  echo 'Script Started!<br>';
  foreach($records as $record){
    echo 'Password encryped for record '.$record['num'].'<br>';
    if($record['password']){
      $passwordHash = getPasswordDigest($record['password']);
      mysql_update('blog', $record['num'], null, array('password' => $passwordHash));
    }
  }

  echo 'SCRIPT RAN SUCCESSFULLY, DO NOT RUN AGAIN!';
?>

So to get the script to run you just need to change section_name_here for the name of the section that contains your website members. 

Make sure you do a full back up of the database before running the script!

Also, if you run the script a second time it will encrypt the already encrypted passwords.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Steve99 - May 29, 2013

Hi Greg,

Awesome, thank you so much. It worked like a charm.

I was using a separate WSM table.

I had two passwords that were already encrypted so I copied them to notepad so I could reset them after running the script but they weren't affected.

Thanks again!

- Steve