我正在制作一个自定义joomla帐户创建脚本,该脚本也会生成一个用户邮寄的randon密码。帐户已创建,但密码始终无效。
我已经捕获了用户,电子邮件等
$password = rand(1000,99999);
$password2 = md5($password);
$query = "INSERT INTO jos_users (username,email,name,usertype,sendEmail,gid,params,registerDate,password)
VALUES (' $username','$email','$name','Registered','1','18','admin_language=
language=
editor=
helpsite=
timezone=0',NOW(),'$password2')";
$result = mysql_query($query);
$uid=mysql_insert_id();
ETC .................... ETC
我尝试了这些变化
sha1($_POST['pword']);
和
$password = rand(1000,9999);
$salt = md5(rand(1000,9999));
$password2 = md5($password.$salt).":".$salt;
当我发送USER $密码时,它是错误的并且无法登录。 我可能会遗漏一些东西。
/////////////////////////////full script just in case///////////////////////////////
$password = rand(1000,99999);
$password2 = md5($password);
die($password2);
$query = "INSERT INTO jos_users (username,email,name,usertype,sendEmail,gid,params,registerDate,password)
VALUES (' $username','$email','$name','Registered','1','18','admin_language=
language=
editor=
helpsite=
timezone=0',NOW(),'$password2')";
$result = mysql_query($query);
$uid=mysql_insert_id();
$query = "INSERT INTO #__spcClient (clientID,GSM,StartingUnits,Units) VALUES ('$uid','$GSM','$units','$units')";
$myfunctions->dbquery($query);
$query = "INSERT INTO jos_core_acl_aro (section_value,value,name) VALUES ('users','$uid','$name')";
$result = mysql_query($query);
$uid2=mysql_insert_id();
//$rowcount = $db->getAffectedRows($result);
$query = "INSERT INTO jos_core_acl_groups_aro_map (group_id,aro_id) VALUES ('18','".$uid2."')";
$result = mysql_query($query);
/////////////////////////////////////////////// /
答案 0 :(得分:2)
我不确定为什么你已经尝试了所有这些变化但是为了将来参考Joomla!您可以查看/libraries/joomla/user/
,尤其是您可能需要查看包含helper.php
方法的getCryptedPassword()
。默认加密('md5-hex')切换到此代码:
case 'md5-hex' :
default :
$encrypted = ($salt) ? md5($plaintext.$salt) : md5($plaintext);
return ($show_encrypt) ? '{MD5}'.$encrypted : $encrypted;
还需要查看bind()
中绑定提交数据的user.php
方法,并创建密码数组(包含salt和加密密码)。
$array['password'] = $crypt.':'.$salt;
答案 1 :(得分:0)
'$query = 'UPDATE #__users'
. ' SET password = '.$db->Quote($password)
. ' , activation = ""'
. ' WHERE id = '.(int) $id
. ' AND block = 0';
$db->setQuery($query);
// Save the password
$db->query();'