function qa_db_calc_passcheck($password, $salt)
/*
Return the expected value for the passcheck column given the $password and password $salt
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
return sha1(substr($salt, 0, 8).$password.substr($salt, 8));
}
function qa_db_user_create($email, $password, $handle, $level, $ip)
/*
Create a new user in the database with $email, $password, $handle, privilege $level, and $ip address
*/
{
require_once QA_INCLUDE_DIR.'king-util-string.php';
$salt=isset($password) ? qa_random_alphanum(16) : null;
qa_db_query_sub(
'INSERT INTO ^users (created, createip, email, passsalt, passcheck, level, handle, loggedin, loginip) '.
'VALUES (NOW(), COALESCE(INET_ATON($), 0), $, $, UNHEX($), #, $, NOW(), COALESCE(INET_ATON($), 0))',
$ip, $email, $salt, isset($password) ? qa_db_calc_passcheck($password, $salt) : null, (int)$level, $handle, $ip
);
return qa_db_last_insert_id();
}