`
天梯梦
  • 浏览: 13634000 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

Moodl:集成密码,消除错误phpCAS error: phpCAS::client(): type mismatched for parameter $se

 
阅读更多

1. Generate Moodle password

 

For generating a moodle password , first of all include the the configuration page then use the script given below

$password = “new password”;
$moodle_password = md5($password.$CFG->passwordsaltmain);

 
$password is the actual password and the passwordsaltmain is a hash key generated at moodle installation.

 

原文: http://php-experts-code.blogspot.com/2011/03/generate-moodle-password.html

 

另一种方法是:

$moodle_password = hash_internal_user_password($password);

 

完全一样的效果!

 

2. phpCAS error: phpCAS::client(): type mismatched for parameter $server_version (should be `string') in C:\xmoodle\moodle\auth\cas\auth.php on line 170

 

这个关键在于属性"mnethostid", 这个值默认是0, 但是应该让其为1, 所以添加一个新的user,应该是:

$person               = new StdClass();
$person->auth         = 'manual';
$person->confirmed    = 1;
$person->mnethostid   = 1;  // 重点
$person->lastlogin    = time();
$person->currentlogin = time();

$person->username     = "newperson";
$person->password     = hash_internal_user_password('newperson');
//$person->idnumber   = $person->username;
$person->firstname    = "newperson";
$person->lastname     = "liang";
$person->email        = "newperson@gmail.com";
$person->city         = "sf";
$person->country      = "US";
$person->lang         = "en";

echo $person->id = $DB->insert_record('user', $person);

 

也可以去参考 https://moodle.org/mod/forum/discuss.php?d=73451, 可能会有其他的办法解决。

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics