mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
*** empty log message ***
This commit is contained in:
parent
ec7d2201cc
commit
863c3cd67c
@ -1,17 +1,7 @@
|
||||
CAS-module README
|
||||
|
||||
Please read comments from lib.php for auth/cas module
|
||||
The auth/cas/CAS is the PHPCAS project from http://esup-phpcas.sourceforge.net version 0.4.16-2
|
||||
The auth/cas module is using part of the /auth/ldap module. The /auth/ldap directory should exist.
|
||||
The auth/cas use the PHPCAS project from http://esup-phpcas.sourceforge.net
|
||||
|
||||
Other changes made:
|
||||
|
||||
/login/index.php -> detection of a CAS authentication.
|
||||
/login/index_form.html -> anonymous login and CAS login.
|
||||
/login/logout.php -> CAS logout.
|
||||
|
||||
/lang/en/auth.php -> new lines
|
||||
/lang/en/moodle.php -> new lines
|
||||
/lang/fr/auth.php -> new lines
|
||||
/lang/fr/moodle.php -> new lines
|
||||
|
||||
|
39
auth/cas/auth_ldap_sync_users.php
Normal file
39
auth/cas/auth_ldap_sync_users.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/** auth_ldap_sync_users.php
|
||||
*
|
||||
* This script is meant to be called from a cronjob to sync moodle with the LDAP
|
||||
* backend in those setups where the LDAP backend acts as 'master'.
|
||||
*
|
||||
* Recommended cron entry:
|
||||
* # 5 minutes past 4am
|
||||
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
|
||||
*
|
||||
* Notes:
|
||||
* - If you have a large number of users, you may want to raise the memory limits
|
||||
* by passing -d momory_limit=256M
|
||||
* - For debugging & better logging, you are encouraged to use in the command line:
|
||||
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
|
||||
*
|
||||
* Performance notes:
|
||||
* We have optimized it as best as we could for Postgres and mySQL, with 27K students
|
||||
* we have seen this take 10 minutes.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if(!empty($_SERVER['GATEWAY_INTERFACE'])){
|
||||
error_log("should not be called from apache!");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/auth/ldap/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
$CFG->debug=10;
|
||||
auth_sync_users(1000, true );
|
||||
|
||||
?>
|
@ -6,7 +6,7 @@
|
||||
optional_variable($config->cas_version,"");
|
||||
optional_variable($config->cas_baseuri,"");
|
||||
optional_variable($config->cas_language,"");
|
||||
optional_variable($config->cas_use_cas,"0");
|
||||
optional_variable($config->cas_use_cas,"");
|
||||
optional_variable($config->cas_create_user,"0");
|
||||
?>
|
||||
|
||||
@ -17,16 +17,15 @@
|
||||
</td>
|
||||
</tr>
|
||||
<TR VALIGN=TOP class="required">
|
||||
<TD ALIGN=RIGHT><P>cas_use_cas:</TD>
|
||||
<TD ALIGN=RIGHT><P>cas_enabled:</TD>
|
||||
<TD>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "cas_use_cas", $config->cas_use_cas, "");?>
|
||||
choose_from_menu ($options, "cas_enabled", $config->cas_enabled, get_string("no"),"","");?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_cas_use_cas","auth") ?>
|
||||
<?php print_string("auth_cas_enabled","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR valign="top" class="required">
|
||||
|
@ -2,7 +2,7 @@
|
||||
// version $Id$
|
||||
// Page for forbidden access from CAS
|
||||
require_once("../../config.php");
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
$errormsg = get_string("auth_cas_invalidcaslogin");
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite,
|
||||
$focus, "", true, "<div align=right>$langmenu</div>");
|
||||
include("forbidden.html");
|
||||
|
1
auth/cas/index_form.html
Normal file
1
auth/cas/index_form.html
Normal file
@ -0,0 +1 @@
|
||||
<table width="90%" border="0" cellspacing="10" cellpadding="5" align="center">
<tr>
<?php if ($show_instructions) { ?>
<td width="50%" class="headingblock">
<p align="center"><b><font size="3"><?php print_string("returningtosite") ?></font></b></p>
</td>
<td width="50%" class="headingblock">
<p align="center"><b><font size="3"><?php print_string("firsttime") ?></font></b></p>
</td>
<?php } ?>
</tr>
<tr>
<td width="50%" align="center" valign="top" class="generalbox">
<p><?php print_string("loginusing") ?>:<br />
(<?php print_string("cookiesenabled");?>)
<?php helpbutton("cookies", get_string("cookiesenabled"))?><br /><?php formerr($errormsg) ?>
</p>
<form action="index.php" method="post" name="login" id="login">
<table border="0" align="center" style="font-size: small">
<tr>
<td width="100%">
<input type="hidden" name="username" value="cas" />
<input type="hidden" name="password" value="cas" />
<input type="submit" value="<?php print_string("auth_cas_logincas") ?>" />
</td>
</tr>
</table>
</form>
<?php if ($CFG->guestloginbutton) { ?>
<hr width="80%" />
<p><?php print_string("someallowguest") ?>:</p>
<form action="index.php" method="post" name="guestlogin">
<input type="hidden" name="username" value="guest" />
<input type="hidden" name="password" value="guest" />
<input type="submit" value="<?php print_string("loginguest") ?>" />
</form>
<?php } ?>
<?php if ($CFG->changepassword or is_internal_auth() ) {
if (is_internal_auth()) {
$changepassword = "forgot_password.php";
$changebuttonname = get_string("senddetails");
} else {
$changepassword = $CFG->changepassword;
$changebuttonname = get_string("passwordrecovery");
}
?>
<hr width="80%" />
<p><?php print_string("forgotten") ?></p>
<form action="<?php p($changepassword) ?>" method="get" name="changepassword">
<input type="submit" value="<?php p($changebuttonname) ?>" />
</form>
<?php } ?>
</td>
<?php if ($show_instructions) { ?>
<td width="50%" valign="top" class="generalbox">
<?php switch ($CFG->auth) {
case "email":
print_string("loginsteps", "", "signup.php");
?>
<div align="center">
<form action="signup.php" method="get" name="signup">
<input type="submit" value="<?php print_string("startsignup") ?>" />
</form>
</div>
<?php break;
case "none":
print_string("loginstepsnone");
break;
default:
echo format_text($CFG->auth_instructions);
if (!function_exists('auth_user_login')) {
require_once("../auth/$CFG->auth/lib.php");
}
if (!empty($CFG->auth_user_create) and function_exists('auth_user_create') ){
?>
<div align="center">
<form action="signup.php" method="get" name="signup">
<input type="submit" value="<?php print_string("startsignup") ?>" />
</form>
</div>
<?php }
}
?>
</td></tr>
<?php } ?>
</table>
|
@ -7,9 +7,9 @@
|
||||
/* README!
|
||||
CAS Module
|
||||
This Module can be turn ON/OFF on admin screen.
|
||||
The moodle/login module have to be changed by the one in this directory
|
||||
The /login/index.php module is intercepted and replace with the login.php.
|
||||
And use the /auth/cas/index_form.html and /auth/cas/caslogin.php.
|
||||
This module is using the LDAP Module so you need the /auth/ldap directory.
|
||||
|
||||
*/
|
||||
|
||||
define("AUTH_METHOD", 'cas');
|
||||
@ -25,7 +25,7 @@ function auth_user_login ($username, $password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($CFG->auth == "cas" && $CFG->cas_use_cas == "1" ){
|
||||
if ($CFG->auth == "cas" && !empty($CFG->cas_enabled)){
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (get_user_info_from_db("username", $username)){
|
||||
return true;
|
||||
|
321
auth/cas/login.php
Normal file
321
auth/cas/login.php
Normal file
@ -0,0 +1,321 @@
|
||||
<?php
|
||||
// $Id: login.php
|
||||
// author: romualdLorthioir $
|
||||
//CHANGELOG:
|
||||
//05.03.2005 replace /login/index.php
|
||||
|
||||
require_once($CFG->dirroot.'/auth/cas/caslogin.php');
|
||||
|
||||
//Define variables used in page
|
||||
if (!$site = get_site()) {
|
||||
error("No site found!");
|
||||
}
|
||||
|
||||
if (empty($CFG->langmenu)) {
|
||||
$langmenu = "";
|
||||
} else {
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
}
|
||||
$langmenu = popup_form ("$wwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
}
|
||||
|
||||
$loginsite = get_string("loginsite");
|
||||
|
||||
|
||||
$frm = false;
|
||||
$user = false;
|
||||
if ((!empty($SESSION->wantsurl) and strstr($SESSION->wantsurl,'username=guest')) or $loginguest) {
|
||||
/// Log in as guest automatically (idea from Zbigniew Fiedorowicz)
|
||||
$frm->username = 'guest';
|
||||
$frm->password = 'guest';
|
||||
} else if (!empty($SESSION->wantsurl) && file_exists($CFG->dirroot.'/login/weblinkauth.php')) {
|
||||
// Handles the case of another Moodle site linking into a page on this site
|
||||
include($CFG->dirroot.'/login/weblinkauth.php');
|
||||
if (function_exists(weblink_auth)) {
|
||||
$user = weblink_auth($SESSION->wantsurl);
|
||||
}
|
||||
if ($user) {
|
||||
$frm->username = $user->username;
|
||||
} else {
|
||||
$frm = data_submitted();
|
||||
}
|
||||
} else {
|
||||
$frm = data_submitted();
|
||||
}
|
||||
|
||||
if ($frm and (get_moodle_cookie() == '')) { // Login without cookie
|
||||
|
||||
$errormsg = get_string("cookiesnotenabled");
|
||||
|
||||
} else if ($frm) { // Login WITH cookies
|
||||
|
||||
$frm->username = trim(moodle_strtolower($frm->username));
|
||||
|
||||
if (($frm->username == 'guest') and empty($CFG->guestloginbutton)) {
|
||||
$user = false; /// Can't log in as guest if guest button is disabled
|
||||
$frm = false;
|
||||
} else if (!$user) {
|
||||
if ($CFG->auth == "cas" && $frm->username != 'guest'){ /// Cas SSO case
|
||||
$user = cas_authenticate_user_login($frm->username, $frm->password);
|
||||
}else{
|
||||
$user = authenticate_user_login($frm->username, $frm->password);
|
||||
}
|
||||
}
|
||||
update_login_count();
|
||||
|
||||
if ($user) {
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
print_heading(get_string("mustconfirm"));
|
||||
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
|
||||
print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$USER = $user;
|
||||
if (!empty($USER->description)) {
|
||||
$USER->description = true; // No need to cart all of it around
|
||||
}
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security, store the site in the session
|
||||
sesskey(); // for added security, used to check script parameters
|
||||
|
||||
if ($USER->username == "guest") {
|
||||
$USER->lang = $CFG->lang; // Guest language always same as site
|
||||
$USER->firstname = get_string("guestuser"); // Name always in current language
|
||||
$USER->lastname = " ";
|
||||
}
|
||||
|
||||
if (!update_user_login_times()) {
|
||||
error("Wierd error: could not update login records");
|
||||
}
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
// Restore the calendar filters, if saved
|
||||
if(intval(get_user_preferences('calendar_persistflt', 0))) {
|
||||
include_once($CFG->dirroot.'/calendar/lib.php');
|
||||
calendar_set_filters_status(get_user_preferences('calendar_savedflt', 0xff));
|
||||
}
|
||||
|
||||
//Select password change url
|
||||
if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
|
||||
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
|
||||
} elseif($CFG->changepassword) {
|
||||
$passwordchangeurl=$CFG->changepassword;
|
||||
}
|
||||
|
||||
|
||||
// check whether the user should be changing password
|
||||
if (get_user_preferences('auth_forcepasswordchange', false)){
|
||||
if (isset($passwordchangeurl)) {
|
||||
redirect($passwordchangeurl);
|
||||
} else {
|
||||
error("You cannot proceed without changing your password.
|
||||
However there is no available page for changing it.
|
||||
Please contact your Moodle Administrator.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.SITEID;
|
||||
// We don't delete $SESSION->wantsurl yet, so we get there later
|
||||
|
||||
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
|
||||
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
} else {
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
// check if user password has expired
|
||||
// Currently supported only for ldap-authentication module
|
||||
if (isset($CFG->ldap_expiration) && $CFG->ldap_expiration == 1 ) {
|
||||
if (function_exists('auth_password_expire')){
|
||||
$days2expire = auth_password_expire($USER->username);
|
||||
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
} elseif (intval($days2expire) < 0 ) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset_login_count();
|
||||
|
||||
redirect($urltogo);
|
||||
|
||||
exit;
|
||||
|
||||
} else {
|
||||
if ($CFG->auth == "cas" ){ /// CAS error login
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
|
||||
}else{
|
||||
$errormsg = get_string("invalidlogin");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user=cas_automatic_authenticate($user);
|
||||
if ($user) {
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
print_heading(get_string("mustconfirm"));
|
||||
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
|
||||
print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$USER = $user;
|
||||
if (!empty($USER->description)) {
|
||||
$USER->description = true; // No need to cart all of it around
|
||||
}
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security, store the site in the session
|
||||
sesskey(); // for added security, used to check script parameters
|
||||
|
||||
if ($USER->username == "guest") {
|
||||
$USER->lang = $CFG->lang; // Guest language always same as site
|
||||
$USER->firstname = get_string("guestuser"); // Name always in current language
|
||||
$USER->lastname = " ";
|
||||
}
|
||||
|
||||
if (!update_user_login_times()) {
|
||||
error("Wierd error: could not update login records");
|
||||
}
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
// Restore the calendar filters, if saved
|
||||
if(intval(get_user_preferences('calendar_persistflt', 0))) {
|
||||
include_once($CFG->dirroot.'/calendar/lib.php');
|
||||
calendar_set_filters_status(get_user_preferences('calendar_savedflt', 0xff));
|
||||
}
|
||||
|
||||
//Select password change url
|
||||
if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
|
||||
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
|
||||
} elseif($CFG->changepassword) {
|
||||
$passwordchangeurl=$CFG->changepassword;
|
||||
}
|
||||
|
||||
|
||||
// check whether the user should be changing password
|
||||
if (get_user_preferences('auth_forcepasswordchange', false)){
|
||||
if (isset($passwordchangeurl)) {
|
||||
redirect($passwordchangeurl);
|
||||
} else {
|
||||
error("You cannot proceed without changing your password.
|
||||
However there is no available page for changing it.
|
||||
Please contact your Moodle Administrator.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$urltogo = $CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.SITEID;
|
||||
// We don't delete $SESSION->wantsurl yet, so we get there later
|
||||
|
||||
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
|
||||
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
} else {
|
||||
$urltogo = $CFG->wwwroot.'/'; /// Go to the standard home page
|
||||
unset($SESSION->wantsurl); /// Just in case
|
||||
}
|
||||
|
||||
// check if user password has expired
|
||||
// Currently supported only for ldap-authentication module
|
||||
if (isset($CFG->ldap_expiration) && $CFG->ldap_expiration == 1 ) {
|
||||
if (function_exists('auth_password_expire')){
|
||||
$days2expire = auth_password_expire($USER->username);
|
||||
if (intval($days2expire) > 0 && intval($days2expire) < intval($CFG->{$USER->auth.'_expiration_warning'})) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
} elseif (intval($days2expire) < 0 ) {
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset_login_count();
|
||||
|
||||
redirect($urltogo);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
if(!$CFG->guestloginbutton){
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($errormsg)) {
|
||||
$errormsg = "";
|
||||
}
|
||||
|
||||
if (empty($SESSION->wantsurl)) {
|
||||
$SESSION->wantsurl = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER["HTTP_REFERER"] : $CFG->wwwroot;
|
||||
}
|
||||
|
||||
if (get_moodle_cookie() == '') {
|
||||
set_moodle_cookie('nobody'); // To help search for cookies
|
||||
}
|
||||
|
||||
if (empty($frm->username)) {
|
||||
$frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
|
||||
$frm->password = "";
|
||||
}
|
||||
|
||||
if (!empty($frm->username)) {
|
||||
$focus = "login.password";
|
||||
} else {
|
||||
$focus = "login.username";
|
||||
}
|
||||
|
||||
if ($CFG->auth == "email" or $CFG->auth == "none" or chop($CFG->auth_instructions) <> "" ) {
|
||||
$show_instructions = true;
|
||||
} else {
|
||||
$show_instructions = false;
|
||||
}
|
||||
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=\"right\">$langmenu</div>");
|
||||
include($CFG->dirroot.'/auth/cas/index_form.html');
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
|
||||
// No footer on this page
|
||||
|
||||
?>
|
@ -1,125 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
optional_variable($id);
|
||||
|
||||
if ($id) {
|
||||
if (!$course = get_record("course", "id", $id)) {
|
||||
error("No such course!");
|
||||
}
|
||||
}
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
|
||||
validate_form($frm, $err);
|
||||
|
||||
check_for_restricted_user($frm->username);
|
||||
|
||||
update_login_count();
|
||||
|
||||
if (!count((array)$err)) {
|
||||
$username = $frm->username;
|
||||
$password = md5($frm->newpassword1);
|
||||
|
||||
$user = get_user_info_from_db("username", $username);
|
||||
|
||||
if (isguest($user->id)) {
|
||||
error("Can't change guest password!");
|
||||
}
|
||||
|
||||
if (set_field("user", "password", $password, "username", $username)) {
|
||||
$user->password = $password;
|
||||
} else {
|
||||
error("Could not set the new password");
|
||||
}
|
||||
|
||||
$USER = $user;
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
|
||||
reset_login_count();
|
||||
|
||||
$strpasswordchanged = get_string("passwordchanged");
|
||||
|
||||
if (!empty($course->id)) {
|
||||
add_to_log($course->id, "user", "change password", "view.php?id=$user->id&course=$course->id", "$user->id");
|
||||
$fullname = fullname($USER, true);
|
||||
print_header($strpasswordchanged, $strpasswordchanged,
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->
|
||||
<A HREF=\"$CFG->wwwroot/user/index.php?id=$course->id\">".get_string("participants")."</A> ->
|
||||
<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\">$fullname</A> -> $strpasswordchanged", $focus);
|
||||
notice($strpasswordchanged, "$CFG->wwwroot/user/view.php?id=$USER->id&course=$id");
|
||||
} else {
|
||||
$site = get_site();
|
||||
add_to_log($site->id, "user", "change password", "view.php?id=$user->id&course=$site->id", "$course->id");
|
||||
print_header($strpasswordchanged, $strpasswordchanged, $strpasswordchanged, "");
|
||||
notice($strpasswordchanged, "$CFG->wwwroot/");
|
||||
}
|
||||
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// We NEED to set this, because the form assumes it has a value!
|
||||
$frm->id = empty($course->id) ? 0 : $course->id;
|
||||
|
||||
if (empty($frm->username)) {
|
||||
$frm->username = get_moodle_cookie();
|
||||
}
|
||||
|
||||
if (!empty($frm->username)) {
|
||||
$focus = "form.password";
|
||||
} else {
|
||||
$focus = "form.username";
|
||||
}
|
||||
|
||||
$strchangepassword = get_string("changepassword");
|
||||
if (!empty($course->id)) {
|
||||
$fullname = fullname($USER, true);
|
||||
print_header($strchangepassword, $strchangepassword,
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->
|
||||
<A HREF=\"$CFG->wwwroot/user/index.php?id=$course->id\">".get_string("participants")."</A> ->
|
||||
<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\">$fullname</A> -> $strchangepassword", $focus);
|
||||
} else {
|
||||
print_header($strchangepassword, $strchangepassword, $strchangepassword, $focus);
|
||||
}
|
||||
|
||||
print_simple_box_start("center", "", $THEME->cellheading);
|
||||
include("change_password_form.html");
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* FUNCTIONS
|
||||
*****************************************************************************/
|
||||
function validate_form($frm, &$err) {
|
||||
|
||||
if (empty($frm->username))
|
||||
$err->username = get_string("missingusername");
|
||||
|
||||
else if (empty($frm->password))
|
||||
$err->password = get_string("missingpassword");
|
||||
|
||||
else if (!authenticate_user_login($frm->username, $frm->password))
|
||||
$err->password = get_string("wrongpassword");
|
||||
|
||||
if (empty($frm->newpassword1))
|
||||
$err->newpassword1 = get_string("missingnewpassword");
|
||||
|
||||
if (empty($frm->newpassword2))
|
||||
$err->newpassword2 = get_string("missingnewpassword");
|
||||
|
||||
else if ($frm->newpassword1 <> $frm->newpassword2)
|
||||
$err->newpassword2 = get_string("passwordsdiffer");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@ -1,48 +0,0 @@
|
||||
<p><b><?php print_string("allfieldsrequired") ?></b></p>
|
||||
<?php
|
||||
if (empty($frm->username)) {
|
||||
$frm->username = "";
|
||||
}
|
||||
if (empty($frm->password)) {
|
||||
$frm->password = "";
|
||||
}
|
||||
if (empty($frm->newpassword1)) {
|
||||
$frm->newpassword1 = "";
|
||||
}
|
||||
if (empty($frm->newpassword2)) {
|
||||
$frm->newpassword2 = "";
|
||||
}
|
||||
?>
|
||||
<form action="change_password.php" method="post" name="form" id="form">
|
||||
<table cellpadding="10">
|
||||
<tr valign="top">
|
||||
<td><p><?php print_string("username") ?>:</p></td>
|
||||
<td><input type="text" name="username" size="25" value="<?php p($frm->username) ?>" />
|
||||
<?php if (!empty($err->username)) { formerr($err->username); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><p><?php print_string("password") ?>:</p></td>
|
||||
<td><input type="password" name="password" size="25" value="<?php p($frm->password) ?>" />
|
||||
<?php if (!empty($err->password)) { formerr($err->password); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><p><?php print_string("newpassword") ?>:</p></td>
|
||||
<td><input type="password" name="newpassword1" size="25" value="<?php p($frm->newpassword1) ?>" />
|
||||
<?php if (!empty($err->newpassword1)) { formerr($err->newpassword1); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><p><?php print_string("newpassword") ?> (<?php print_string("again") ?>):</p></td>
|
||||
<td><input type="password" name="newpassword2" size="25" value="<?php p($frm->newpassword2) ?>" />
|
||||
<?php if (!empty($err->newpassword2)) { formerr($err->newpassword2); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="hidden" name="id" value="<?php p($frm->id)?>" />
|
||||
<input type="submit" value="<?php print_string("changepassword") ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
@ -1,69 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("../auth/$CFG->auth/lib.php");
|
||||
|
||||
if (isset($_GET['p']) and isset($_GET['s']) ) { # p = user.secret s = user.username
|
||||
|
||||
$user = get_user_info_from_db("username", $_GET['s']);
|
||||
|
||||
if (!empty($user)) {
|
||||
|
||||
if ($user->confirmed) {
|
||||
print_header(get_string("alreadyconfirmed"), get_string("alreadyconfirmed"), "", "");
|
||||
echo "<CENTER><H3>".get_string("thanks").", ". $user->firstname ." ". $user->lastname . "</H3>\n";
|
||||
echo "<H4>".get_string("alreadyconfirmed")."</H4>\n";
|
||||
echo "<H3> -> <A HREF=\"$CFG->wwwroot/course/\">".get_string("courses")."</A></H3>\n";
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($user->secret == $_GET['p']) { // They have provided the secret key to get in
|
||||
|
||||
if (!set_field("user", "confirmed", 1, "id", $user->id)) {
|
||||
error("Could not confirm this user!");
|
||||
}
|
||||
if (!set_field("user", "firstaccess", time(), "id", $user->id)) {
|
||||
error("Could not set this user's first access date!");
|
||||
}
|
||||
if (isset($CFG->auth_user_create) and $CFG->auth_user_create==1 and function_exists('auth_user_activate') ) {
|
||||
if (!auth_user_activate($user->username)) {
|
||||
error("Could not activate this user!");
|
||||
}
|
||||
}
|
||||
|
||||
// The user has confirmed successfully, let's log them in
|
||||
|
||||
if (!$USER = get_user_info_from_db("username", $user->username)) {
|
||||
error("Something serious is wrong with the database");
|
||||
}
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot;
|
||||
|
||||
if ( ! empty($SESSION->wantsurl) ) { // Send them where they were going
|
||||
$goto = $SESSION->wantsurl;
|
||||
unset($SESSION->wantsurl);
|
||||
redirect("$goto");
|
||||
}
|
||||
|
||||
print_header(get_string("confirmed"), get_string("confirmed"), "", "");
|
||||
echo "<CENTER><H3>".get_string("thanks").", ". $USER->firstname ." ". $USER->lastname . "</H3>\n";
|
||||
echo "<H4>".get_string("confirmed")."</H4>\n";
|
||||
echo "<H3> -> <A HREF=\"$CFG->wwwroot/course/\">".get_string("courses")."</A></H3>\n";
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
error("Invalid confirmation data");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error(get_string("errorwhenconfirming"));
|
||||
}
|
||||
|
||||
redirect("$CFG->wwwroot/");
|
||||
|
||||
?>
|
@ -1,102 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
optional_variable($p, "");
|
||||
optional_variable($s, "");
|
||||
|
||||
if (!empty($p) and !empty($s)) { // User trying to authenticate change password routine
|
||||
|
||||
update_login_count();
|
||||
|
||||
$user = get_user_info_from_db("username", "$s");
|
||||
|
||||
if (!empty($user)) {
|
||||
if ($user->secret == $p) { // They have provided the secret key to get in
|
||||
|
||||
if (isguest($user->id)) {
|
||||
error("Can't change guest password!");
|
||||
}
|
||||
|
||||
$user->emailstop = 0; // Send mail even if sending mail was forbidden
|
||||
|
||||
if (! reset_password_and_mail($user)) {
|
||||
error("Could not reset password and mail the new one to you");
|
||||
}
|
||||
|
||||
reset_login_count();
|
||||
|
||||
print_header(get_string("passwordsent"), get_string("passwordsent"), get_string("passwordsent"));
|
||||
|
||||
$a->email = $user->email;
|
||||
$a->link = "$CFG->wwwroot/login/change_password.php";
|
||||
notice(get_string("emailpasswordsent", "", $a), $a->link);
|
||||
}
|
||||
}
|
||||
error(get_string("error"));
|
||||
}
|
||||
|
||||
if ($frm = data_submitted()) { // Initial request for new password
|
||||
|
||||
validate_form($frm, $err);
|
||||
|
||||
if (count((array)$err) == 0) {
|
||||
|
||||
if (!$user = get_user_info_from_db("email", $frm->email)) {
|
||||
error("No such user with this address: $frm->email");
|
||||
}
|
||||
|
||||
if (empty($user->confirmed)) {
|
||||
error(get_string("confirmednot"));
|
||||
}
|
||||
|
||||
$user->secret = random_string(15);
|
||||
|
||||
if (!set_field("user", "secret", $user->secret, "id", $user->id)) {
|
||||
error("Could not set user secret string!");
|
||||
}
|
||||
|
||||
$user->emailstop = 0; // Send mail even if sending mail was forbidden
|
||||
|
||||
if (! send_password_change_confirmation_email($user)) {
|
||||
error("Could not send you an email to confirm the password change");
|
||||
}
|
||||
|
||||
print_header(get_string("passwordconfirmchange"), get_string("passwordconfirmchange"));
|
||||
|
||||
notice(get_string('emailpasswordconfirmsent', '', $user->email), "$CFG->wwwroot/");
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($frm->email)) {
|
||||
if ($username = get_moodle_cookie() ) {
|
||||
$frm->email = get_field("user", "email", "username", "$username");
|
||||
}
|
||||
}
|
||||
|
||||
print_header(get_string("senddetails"), get_string("senddetails"),
|
||||
"<A HREF=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</A> -> ".get_string("senddetails"),
|
||||
"form.email");
|
||||
include("forgot_password_form.html");
|
||||
print_footer();
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* FUNCTIONS
|
||||
*****************************************************************************/
|
||||
|
||||
function validate_form($frm, &$err) {
|
||||
|
||||
if (empty($frm->email))
|
||||
$err->email = get_string("missingemail");
|
||||
|
||||
else if (! validate_email($frm->email))
|
||||
$err->email = get_string("invalidemail");
|
||||
|
||||
else if (! record_exists("user", "email", $frm->email))
|
||||
$err->email = get_string("nosuchemail");
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -1,28 +0,0 @@
|
||||
<table cellpadding="20" align="center">
|
||||
<tr valign="top">
|
||||
|
||||
<td width="300" class="normal">
|
||||
<p><?php print_string("enteremailaddress") ?> </p>
|
||||
</td>
|
||||
|
||||
<td bgcolor="<?php p($THEME->cellheading)?>">
|
||||
<form action="<?php p("$CFG->wwwroot/login/forgot_password.php") ?>" method="post" name="form" id="form">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label"><?php print_string("email") ?>:</td>
|
||||
<td><input type="text" name="email" size="25" value="<?php p($frm->email) ?>" />
|
||||
<?php if (!empty($err->email)) {formerr($err->email);} ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("ok") ?>" />
|
||||
<input type="button" value="<?php print_string("cancel") ?>" onClick="javascript: history.go(-1)" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
@ -1,277 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once("../config.php");
|
||||
$cas_validate=false; //Modif SG - RL pour CAS
|
||||
optional_variable($loginguest, false); // determines whether visitors are logged in as guest automatically
|
||||
|
||||
// Check if the guest user exists. If not, create one.
|
||||
if (! record_exists("user", "username", "guest")) {
|
||||
$guest->auth = "manual";
|
||||
$guest->username = "guest";
|
||||
$guest->password = md5("guest");
|
||||
$guest->firstname = addslashes(get_string("guestuser"));
|
||||
$guest->lastname = " ";
|
||||
$guest->email = "root@localhost";
|
||||
$guest->description = addslashes(get_string("guestuserinfo"));
|
||||
$guest->confirmed = 1;
|
||||
$guest->lang = $CFG->lang;
|
||||
$guest->timemodified= time();
|
||||
|
||||
if (! $guest->id = insert_record("user", $guest)) {
|
||||
notify("Could not create guest user record !!!");
|
||||
}
|
||||
}
|
||||
|
||||
$frm = false;
|
||||
if ((!empty($SESSION->wantsurl) and strstr($SESSION->wantsurl,"username=guest")) or $loginguest) {
|
||||
/// Log in as guest automatically (idea from Zbigniew Fiedorowicz)
|
||||
$frm->username = "guest";
|
||||
$frm->password = "guest";
|
||||
} else {
|
||||
$frm = data_submitted();
|
||||
}
|
||||
|
||||
if ($frm) {
|
||||
$frm->username = trim(moodle_strtolower($frm->username));
|
||||
|
||||
if (($frm->username == 'guest') and empty($CFG->guestloginbutton)) {
|
||||
$user = false; /// Can't log in as guest if guest button is disabled
|
||||
$frm = false;
|
||||
} else {
|
||||
|
||||
|
||||
//Modif SG - RL pour CAS
|
||||
if ($CFG->auth == "cas" && $CFG->cas_use_cas == "1" && $frm->username != 'guest'){
|
||||
$cas_validate=true;
|
||||
|
||||
include_once('../auth/cas/CAS/CAS.php');
|
||||
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
phpCAS::setLang($CFG->cas_language);
|
||||
if (!phpCAS::isAuthenticated()){
|
||||
phpCAS::authenticateIfNeeded();
|
||||
}
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (get_user_info_from_db("username", phpCAS::getUser())){
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}else{
|
||||
//login as guest if CAS but not Moodle and not automatic creation
|
||||
if ($CFG->guestloginbutton){
|
||||
$user = authenticate_user_login('guest', 'guest');
|
||||
}else{
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
if ($user){
|
||||
$USER = $user;
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security
|
||||
|
||||
//$USER->username = phpCAS::getUser();
|
||||
set_moodle_cookie($USER->username);
|
||||
$wantsurl = $SESSION->wantsurl;
|
||||
unset($SESSION->wantsurl);
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$site = get_site();
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
|
||||
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) { /// Matches site address
|
||||
redirect($wantsurl);
|
||||
} else {
|
||||
redirect("$CFG->wwwroot/"); /// Go to the standard home page
|
||||
}
|
||||
|
||||
reset_login_count();
|
||||
die;
|
||||
}
|
||||
|
||||
}else{
|
||||
$user = authenticate_user_login($frm->username, $frm->password);
|
||||
}
|
||||
//Fin Modif SG - RL pour CAS
|
||||
|
||||
}
|
||||
update_login_count();
|
||||
|
||||
if ($user) {
|
||||
if (! $user->confirmed ) { // they never confirmed via email
|
||||
print_header(get_string("mustconfirm"), get_string("mustconfirm") );
|
||||
print_heading(get_string("mustconfirm"));
|
||||
print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
|
||||
print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$USER = $user;
|
||||
if (!empty($USER->description)) {
|
||||
$USER->description = true; // No need to cart all of it around
|
||||
}
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security, store the site in the session
|
||||
$USER->sesskey = random_string(10); // for added security, used to check script parameters
|
||||
|
||||
if ($USER->username == "guest") {
|
||||
$USER->lang = $CFG->lang; // Guest language always same as site
|
||||
$USER->firstname = get_string("guestuser"); // Name always in current language
|
||||
$USER->lastname = " ";
|
||||
}
|
||||
|
||||
|
||||
if (!update_user_login_times()) {
|
||||
error("Wierd error: could not update login records");
|
||||
}
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
|
||||
$wantsurl = $SESSION->wantsurl;
|
||||
|
||||
unset($SESSION->wantsurl);
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
add_to_log(SITEID, "user", "login", "view.php?id=$user->id&course=".SITEID, $user->id, 0, $user->id);
|
||||
|
||||
reset_login_count();
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$site = get_site();
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
|
||||
|
||||
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) { /// Matches site address
|
||||
redirect($wantsurl);
|
||||
|
||||
} else {
|
||||
redirect("$CFG->wwwroot/"); /// Go to the standard home page
|
||||
}
|
||||
|
||||
die;
|
||||
|
||||
} else {
|
||||
if ($CFG->auth == "cas" && $CFG->cas_use_cas == "1"){
|
||||
//Fin Modif SG - RL pour CAS Logout
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
|
||||
}else{
|
||||
$errormsg = get_string("invalidlogin");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Modif SG - RL pour CAS
|
||||
if ($CFG->auth == "cas" && $CFG->cas_use_cas == "1" && ! $cas_validate){
|
||||
|
||||
include_once('../auth/cas/CAS/CAS.php');
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
phpCAS::setLang($CFG->cas_language);
|
||||
if (!phpCAS::isAuthenticated() && !$CFG->guestloginbutton){
|
||||
phpCAS::authenticateIfNeeded();
|
||||
}
|
||||
if (phpCAS::isAuthenticated()){
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (get_user_info_from_db("username", phpCAS::getUser())){
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}else{
|
||||
//login as guest if CAS but not Moodle and not automatic creation
|
||||
if ($CFG->guestloginbutton){
|
||||
$user = authenticate_user_login('guest', 'guest');
|
||||
}else{
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$user = authenticate_user_login(phpCAS::getUser(), 'cas');
|
||||
}
|
||||
|
||||
if ($user){
|
||||
$USER = $user;
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot; // for added security
|
||||
|
||||
//$USER->username = phpCAS::getUser();
|
||||
set_moodle_cookie($USER->username);
|
||||
$wantsurl = $SESSION->wantsurl;
|
||||
unset($SESSION->wantsurl);
|
||||
unset($SESSION->lang);
|
||||
$SESSION->justloggedin = true;
|
||||
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$site = get_site();
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
|
||||
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) { /// Matches site address
|
||||
redirect($wantsurl);
|
||||
} else {
|
||||
redirect("$CFG->wwwroot/"); /// Go to the standard home page
|
||||
}
|
||||
|
||||
reset_login_count();
|
||||
die;
|
||||
} else {
|
||||
//Fin Modif SG - RL pour CAS Logout
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
phpCAS::logout("$CFG->wwwroot/auth/cas/forbidden.php");
|
||||
}
|
||||
}
|
||||
}
|
||||
//Fin Modif SG - RL pour CAS
|
||||
|
||||
if (empty($errormsg)) {
|
||||
$errormsg = "";
|
||||
}
|
||||
|
||||
if (empty($SESSION->wantsurl)) {
|
||||
$SESSION->wantsurl = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER["HTTP_REFERER"] : $CFG->wwwroot;
|
||||
}
|
||||
|
||||
if (empty($frm->username)) {
|
||||
$frm->username = get_moodle_cookie();
|
||||
$frm->password = "";
|
||||
}
|
||||
|
||||
if (!empty($frm->username)) {
|
||||
$focus = "login.password";
|
||||
} else {
|
||||
$focus = "login.username";
|
||||
}
|
||||
|
||||
if ($CFG->auth == "email" or $CFG->auth == "none" or chop($CFG->auth_instructions) <> "" ) {
|
||||
$show_instructions = true;
|
||||
} else {
|
||||
$show_instructions = false;
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("No site found!");
|
||||
}
|
||||
|
||||
if (empty($CFG->langmenu)) {
|
||||
$langmenu = "";
|
||||
} else {
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
}
|
||||
$langmenu = popup_form ("$wwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
}
|
||||
|
||||
$loginsite = get_string("loginsite");
|
||||
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite, $focus, "", true, "<div align=right>$langmenu</div>");
|
||||
|
||||
include("index_form.html");
|
||||
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
|
||||
// No footer on this page
|
||||
|
||||
|
||||
?>
|
@ -1,131 +0,0 @@
|
||||
<table width="90%" border="0" cellspacing="10" cellpadding="5" align="center" style="font-size: small">
|
||||
<tr>
|
||||
<?php if ($show_instructions) { ?>
|
||||
<td width="50%" bgcolor="<?php p($THEME->cellheading2) ?>" class="headingblock">
|
||||
<p align="center"><b><font size="3"><?php print_string("returningtosite") ?></font></b></p>
|
||||
</td>
|
||||
<td width="50%" bgcolor="<?php p($THEME->cellheading2) ?>" class="headingblock">
|
||||
<p align="center"><b><font size="3"><?php print_string("firsttime") ?></font></b></p>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%" align="center" valign="top" bgcolor="<?php p($THEME->cellcontent2) ?>" class="generalbox">
|
||||
<p><?php print_string("loginusing") ?>:<br />
|
||||
(<?php print_string("cookiesenabled");?>)
|
||||
<?php helpbutton("cookies", get_string("cookiesenabled"))?><br /><?php formerr($errormsg) ?>
|
||||
</p>
|
||||
|
||||
<?php if ($CFG->auth == "cas" && $CFG->cas_use_cas == "1") { ?>
|
||||
|
||||
<form action="index.php" method="post" name="login" id="login">
|
||||
<table border="0" align="center" style="font-size: small">
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<input type="hidden" name="username" value="cas" />
|
||||
<input type="hidden" name="password" value="cas" />
|
||||
<input type="submit" value="<?php print_string("logincas") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php }else{ ?>
|
||||
|
||||
<form action="index.php" method="post" name="login" id="login">
|
||||
<table border="0" align="center" style="font-size: small">
|
||||
<tr>
|
||||
<td width="80%">
|
||||
<table align="center" style="font-size: small">
|
||||
<tr>
|
||||
<td align="right">
|
||||
<p><?php print_string("username") ?>:</p>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="username" size="15" value="<?php p($frm->username) ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<p><?php print_string("password") ?>:</p>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" name="password" size="15" value="<?php p($frm->password) ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td width="20%">
|
||||
<input type="submit" value="<?php print_string("login") ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if ($CFG->guestloginbutton) { ?>
|
||||
<hr width="80%" />
|
||||
<p><?php print_string("someallowguest") ?>:</p>
|
||||
<p>
|
||||
<form action="index.php" method="post" name="guestlogin">
|
||||
<input type="hidden" name="username" value="guest" />
|
||||
<input type="hidden" name="password" value="guest" />
|
||||
<input type="submit" value="<?php print_string("loginguest") ?>" />
|
||||
</form>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($CFG->changepassword or is_internal_auth() ) {
|
||||
if (is_internal_auth()) {
|
||||
$changepassword = "forgot_password.php";
|
||||
$changebuttonname = get_string("senddetails");
|
||||
} else {
|
||||
$changepassword = $CFG->changepassword;
|
||||
$changebuttonname = get_string("passwordrecovery");
|
||||
}
|
||||
?>
|
||||
<hr width="80%" />
|
||||
<p><?php print_string("forgotten") ?></p>
|
||||
<p>
|
||||
<form action="<?php p($changepassword) ?>" method="get" name="changepassword">
|
||||
<input type="submit" value="<?php p($changebuttonname) ?>" />
|
||||
</form>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
</td>
|
||||
|
||||
<?php if ($show_instructions) { ?>
|
||||
<td width="50%" valign="top" bgcolor="<?php p($THEME->cellcontent2) ?>" class="generalbox">
|
||||
<?php switch ($CFG->auth) {
|
||||
case "email":
|
||||
echo "<p>".get_string("loginsteps", "", "signup.php")."</p>";
|
||||
?>
|
||||
<div align="center">
|
||||
<form action="signup.php" method="get" name="signup">
|
||||
<input type="submit" value="<?php print_string("startsignup") ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<?php break;
|
||||
case "none":
|
||||
echo "<p>".get_string("loginstepsnone")."</p>";
|
||||
break;
|
||||
default:
|
||||
echo format_text($CFG->auth_instructions);
|
||||
if (!function_exists('auth_user_login')) {
|
||||
require_once("../auth/$CFG->auth/lib.php");
|
||||
}
|
||||
if (!empty($CFG->auth_user_create) and function_exists('auth_user_create') ){
|
||||
?>
|
||||
<div align="center">
|
||||
<form action="signup.php" method="get" name="signup">
|
||||
<input type="submit" value="<?php print_string("startsignup") ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
</td></tr>
|
||||
<?php } ?>
|
||||
</table>
|
@ -1,27 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// Logs the user out and sends them to the home page
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
if (ini_get_bool("register_globals") and check_php_version("4.3.0")) {
|
||||
// This method is just to try to avoid silly warnings from PHP 4.3.0
|
||||
session_unregister("USER");
|
||||
session_unregister("SESSION");
|
||||
}
|
||||
|
||||
unset($_SESSION['USER']);
|
||||
unset($_SESSION['SESSION']);
|
||||
|
||||
unset($SESSION);
|
||||
unset($USER);
|
||||
|
||||
if ($CFG->auth == "cas"){
|
||||
require_once ('../auth/cas/CAS/CAS.php');
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
$backurl = $CFG->wwwroot;
|
||||
phpCAS::logout($backurl);
|
||||
}
|
||||
|
||||
redirect("$CFG->wwwroot/");
|
||||
|
||||
?>
|
@ -1,159 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("../auth/$CFG->auth/lib.php");
|
||||
|
||||
if ($CFG->auth != 'email' and (empty($CFG->auth_user_create) or !(function_exists('auth_user_create'))) ) {
|
||||
error("Sorry, you may not use this page.");
|
||||
}
|
||||
|
||||
if ($user = data_submitted()) {
|
||||
|
||||
$user->firstname = strip_tags($user->firstname);
|
||||
$user->lastname = strip_tags($user->lastname);
|
||||
$user->email = strip_tags($user->email);
|
||||
|
||||
validate_form($user, $err);
|
||||
$user->username= trim(moodle_strtolower($user->username));
|
||||
|
||||
if (count((array)$err) == 0) {
|
||||
$plainpass = $user->password;
|
||||
$user->password = md5($user->password);
|
||||
$user->confirmed = 0;
|
||||
$user->lang = current_language();
|
||||
$user->firstaccess = time();
|
||||
$user->secret = random_string(15);
|
||||
$user->auth = $CFG->auth;
|
||||
if (!empty($CFG->auth_user_create) and function_exists('auth_user_create') ){
|
||||
if (! auth_user_exists($user->username)) {
|
||||
if (! auth_user_create($user,$plainpass)) {
|
||||
error("Could not add user to authentication module!");
|
||||
}
|
||||
} else {
|
||||
error("User already exists on authentication database.");
|
||||
}
|
||||
}
|
||||
|
||||
if (! ($user->id = insert_record("user", $user)) ) {
|
||||
error("Could not add your record to the database!");
|
||||
}
|
||||
|
||||
if (! send_confirmation_email($user)) {
|
||||
error("Tried to send you an email but failed!");
|
||||
}
|
||||
|
||||
$emailconfirm = get_string("emailconfirm");
|
||||
print_header($emailconfirm, $emailconfirm, $emailconfirm);
|
||||
notice(get_string("emailconfirmsent", "", $user->email), "$CFG->wwwroot/");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($err)) {
|
||||
$focus = "form.".array_shift(array_flip(get_object_vars($err)));
|
||||
} else {
|
||||
$focus = "";
|
||||
}
|
||||
|
||||
if (empty($user->country) and !empty($CFG->country)) {
|
||||
$user->country = $CFG->country;
|
||||
}
|
||||
|
||||
$newaccount = get_string("newaccount");
|
||||
$login = get_string("login");
|
||||
|
||||
if (empty($CFG->langmenu)) {
|
||||
$langmenu = "";
|
||||
} else {
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
$langmenu = popup_form ("$CFG->wwwroot/login/signup.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
}
|
||||
|
||||
print_header($newaccount, $newaccount, "<A HREF=\"index.php\">$login</A> -> $newaccount", $focus, "", true, "<div align=right>$langmenu</div>");
|
||||
include("signup_form.html");
|
||||
print_footer();
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* FUNCTIONS
|
||||
*****************************************************************************/
|
||||
|
||||
function validate_form($user, &$err) {
|
||||
global $CFG;
|
||||
|
||||
if (empty($user->username)){
|
||||
$err->username = get_string("missingusername");
|
||||
} else{
|
||||
$user->username = trim(moodle_strtolower($user->username));
|
||||
if (record_exists("user", "username", $user->username)){
|
||||
$err->username = get_string("usernameexists");
|
||||
} else {
|
||||
if (empty($CFG->extendedusernamechars)) {
|
||||
$string = eregi_replace("[^(-\.[:alnum:])]", "", $user->username);
|
||||
if (strcmp($user->username, $string)) {
|
||||
$err->username = get_string("alphanumerical");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($CFG->auth_user_create) and $CFG->auth_user_create==1 and function_exists('auth_user_exists') ){
|
||||
if (auth_user_exists($user->username)) {
|
||||
$err->username = get_string("usernameexists");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($user->password)) {
|
||||
$err->password = get_string("missingpassword");
|
||||
}
|
||||
|
||||
if (empty($user->firstname)) {
|
||||
$err->firstname = get_string("missingfirstname");
|
||||
}
|
||||
|
||||
if (empty($user->lastname)) {
|
||||
$err->lastname = get_string("missinglastname");
|
||||
}
|
||||
|
||||
|
||||
if (empty($user->email)) {
|
||||
$err->email = get_string("missingemail");
|
||||
|
||||
} else if (! validate_email($user->email)) {
|
||||
$err->email = get_string("invalidemail");
|
||||
|
||||
} else if (record_exists("user", "email", $user->email)) {
|
||||
$err->email = get_string("emailexists")." <A HREF=forgot_password.php>".get_string("newpassword")."?</A>";
|
||||
}
|
||||
|
||||
|
||||
if (empty($user->email2)) {
|
||||
$err->email2 = get_string("missingemail");
|
||||
|
||||
} else if ($user->email2 != $user->email) {
|
||||
$err->email2 = get_string("invalidemail");
|
||||
}
|
||||
|
||||
|
||||
if (empty($user->city)) {
|
||||
$err->city = get_string("missingcity");
|
||||
}
|
||||
|
||||
if (empty($user->country)) {
|
||||
$err->country = get_string("missingcountry");
|
||||
}
|
||||
|
||||
if (empty($err->email)) {
|
||||
if ($error = email_is_not_allowed($user->email)) {
|
||||
$err->email = $error;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
if (empty($user->username)) {
|
||||
$user->username = "";
|
||||
}
|
||||
if (empty($user->password)) {
|
||||
$user->password = "";
|
||||
}
|
||||
if (empty($user->email)) {
|
||||
$user->email = "";
|
||||
}
|
||||
if (empty($user->email2)) {
|
||||
$user->email2 = "";
|
||||
}
|
||||
if (empty($user->firstname)) {
|
||||
$user->firstname = "";
|
||||
}
|
||||
if (empty($user->lastname)) {
|
||||
$user->lastname = "";
|
||||
}
|
||||
if (empty($user->city)) {
|
||||
$user->city = "";
|
||||
}
|
||||
if (empty($user->country)) {
|
||||
$user->country = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<table cellpadding="20" align="center"> <tr> <td bgcolor="<?php p($THEME->cellcontent2) ?>" class="generalbox">
|
||||
|
||||
<form action="signup.php" method="post" name="form" id="form">
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td colspan="2"><p><b><?php print_string("createuserandpass") ?>:</b></p></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("username") ?>:</p></td>
|
||||
<td><input type="text" name="username" size="12" value="<?php p($user->username) ?>" />
|
||||
<?php if (!empty($err->username)) { formerr($err->username); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("password") ?>:</p></td>
|
||||
<td><input type="password" name="password" size="12" value="<?php p($user->password) ?>" />
|
||||
<?php if (!empty($err->password)) { formerr($err->password); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td colspan="2"><p><br />
|
||||
<b><?php print_string("supplyinfo") ?>:</b><br />
|
||||
(<?php print_string("emailmustbereal") ?>)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("email") ?>:</p></td>
|
||||
<td><input type="text" name="email" size="25" value="<?php p($user->email) ?>" />
|
||||
<?php if (!empty($err->email)) { formerr($err->email); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("emailagain") ?>:</p></td>
|
||||
<td><input type="text" name="email2" size="25" value="<?php p($user->email2) ?>" />
|
||||
<?php if (!empty($err->email2)) { formerr($err->email2); } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("firstname") ?>:</p></td>
|
||||
<td><input type="text" name="firstname" size="25" value="<?php p($user->firstname) ?>" />
|
||||
<?php if (!empty($err->firstname)) { formerr($err->firstname);} ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("lastname") ?>:</p></td>
|
||||
<td><input type="text" name="lastname" size="25" value="<?php p($user->lastname) ?>" />
|
||||
<?php if (!empty($err->lastname)) { formerr($err->lastname);} ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("city") ?>:</p></td>
|
||||
<td><input type="text" name="city" size="25" value="<?php p($user->city) ?>" />
|
||||
<?php if (!empty($err->city)) { formerr($err->city);} ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align=right><p><?php print_string("country") ?>:</p></td>
|
||||
<td><?php choose_from_menu (get_list_of_countries(), "country", $user->country, get_string("selectacountry"), "", "") ?>
|
||||
<?php if (!empty($err->country)) { formerr($err->country);} ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("createaccount") ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</td></tr></table>
|
10
auth/cas/logout.php
Normal file
10
auth/cas/logout.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
// logout the user from CAS server (destroy the ticket)
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot.'/config.php');
|
||||
include_once($CFG->dirroot.'/lib/cas/CAS.php');
|
||||
phpCAS::client($CFG->cas_version,$CFG->cas_hostname,(Integer)$CFG->cas_port,$CFG->cas_baseuri);
|
||||
$backurl = $CFG->wwwroot;
|
||||
phpCAS::logout($backurl);
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user