Hi,
We are an association and our Members have an account on our Website.
It is a Drupal 7 site. I want to create a process that keeps our Drupal Database updated from our Membership DB. Like Adding new members, setting a users access level, revoking access and address changes or what ever.
In the past on our Drupal 6 system I would upload a CSV file and run a php script to handle it. What I want to do now is have it do it in realtime as our membership data base gets changed, immediately update the Drupal Site.
I would like to access the Drupal MySql tables directly but in order to do that I need to convert the Drupal Password function to Xojo.
Here are the Password functions:
Documentation: https://api.drupal.org/api/drupal/includes!password.inc/function/user_hash_password/7
unction user_hash_password($password, $count_log2 = 0) {
if (empty($count_log2)) {
// Use the standard iteration count.
$count_log2 = variable_get('password_count_log2', DRUPAL_HASH_COUNT);
}
return _password_crypt('sha512', $password, _password_generate_salt($count_log2));
}
Documentation: https://api.drupal.org/api/drupal/includes!password.inc/function/_password_crypt/7
function _password_crypt($algo, $password, $setting) {
// The first 12 characters of an existing hash are its setting string.
$setting = substr($setting, 0, 12);
if ($setting[0] != '$' || $setting[2] != '$') {
return FALSE;
}
$count_log2 = _password_get_count_log2($setting);
// Hashes may be imported from elsewhere, so we allow != DRUPAL_HASH_COUNT
if ($count_log2 < DRUPAL_MIN_HASH_COUNT || $count_log2 > DRUPAL_MAX_HASH_COUNT) {
return FALSE;
}
$salt = substr($setting, 4, 8);
// Hashes must have an 8 character salt.
if (strlen($salt) != 8) {
return FALSE;
}
// Convert the base 2 logarithm into an integer.
$count = 1 << $count_log2;
// We rely on the hash() function being available in PHP 5.2+.
$hash = hash($algo, $salt . $password, TRUE);
do {
$hash = hash($algo, $hash . $password, TRUE);
} while (--$count);
$len = strlen($hash);
$output = $setting . _password_base64_encode($hash, $len);
// _password_base64_encode() of a 16 byte MD5 will always be 22 characters.
// _password_base64_encode() of a 64 byte sha512 will always be 86 characters.
$expected = 12 + ceil((8 * $len) / 6);
return (strlen($output) == $expected) ? substr($output, 0, DRUPAL_HASH_LENGTH) : FALSE;
}
The other possible way is to run the php inside of Xojo, Not sure how to do that but I thought I read somewhere that it can be done.
Thanks
Rich