Skip to content

Commit

Permalink
Implemented re-keying of Groups. See PHPCRED-38
Browse files Browse the repository at this point in the history
  • Loading branch information
B Tasker committed Aug 7, 2014
1 parent 10648e7 commit c5a63b2
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions utils/rekey.php
Expand Up @@ -257,3 +257,46 @@ static function genKey($len){
die;
}




// Groups next, relatively straight forward

$output->_("Preparing to Re-Key Groups");
$db->setQuery("SELECT * FROM #__Groups");
$groups = $db->loadResults();
$cgroups = array();

foreach ($groups as $group){

$group->Name = $crypt->decrypt($group->Name,'Groups');
$cgroups[] = $group;
}

$output->_("Generating new encryption key");
$newkeys->keys->Groups = Utils::genKey($keylength);
$newkeys->writekeyfile();


foreach ($cgroups as $group){

$group->Name = $crypt->encrypt($group->Name,'Groups');
$sql = "UPDATE #__Groups SET `Name`='".$group->Name."' WHERE `id`=".(int)$group->id;
$db->setQuery($sql);
$db->runQuery();

}

unset($cgroups);
unset($groups);
$output->_("");
$confirm = $input->read("Groups have been re-keyed, Please log into the front end and ensure that you can view Group names correctly");

// Probably need to do a little more to hold the users hand here really
if ($confirm != "YES"){
$output->_("Aborting");
die;
}



0 comments on commit c5a63b2

Please sign in to comment.