mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
Version 1 du module CAS
This commit is contained in:
parent
4db5de0dfa
commit
3fb7e0a074
1114
auth/cas/CAS/CAS.php
Normal file
1114
auth/cas/CAS/CAS.php
Normal file
File diff suppressed because it is too large
Load Diff
190
auth/cas/CAS/PGTStorage/pgt-db.php
Normal file
190
auth/cas/CAS/PGTStorage/pgt-db.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file CAS/PGTStorage/pgt-db.php
|
||||
* Basic class for PGT database storage
|
||||
*/
|
||||
|
||||
// include phpDB library (the test was introduced in release 0.4.8 for
|
||||
// the integration into Tikiwiki).
|
||||
if (!class_exists('DB')) {
|
||||
include_once('DB.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @class PGTStorageDB
|
||||
* The PGTStorageDB class is a class for PGT database storage. An instance of
|
||||
* this class is returned by CASClient::SetPGTStorageDB().
|
||||
*
|
||||
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
|
||||
*
|
||||
* @ingroup internalPGTStorageDB
|
||||
*/
|
||||
|
||||
class PGTStorageDB extends PGTStorage
|
||||
{
|
||||
/**
|
||||
* @addtogroup internalPGTStorageDB
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* a string representing a PEAR DB URL to connect to the database. Written by
|
||||
* PGTStorageDB::PGTStorageDB(), read by getURL().
|
||||
*
|
||||
* @hideinitializer
|
||||
* @private
|
||||
*/
|
||||
var $_url='';
|
||||
|
||||
/**
|
||||
* This method returns the PEAR DB URL to use to connect to the database.
|
||||
*
|
||||
* @return a PEAR DB URL
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function getURL()
|
||||
{
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* The handle of the connection to the database where PGT's are stored. Written by
|
||||
* PGTStorageDB::init(), read by getLink().
|
||||
*
|
||||
* @hideinitializer
|
||||
* @private
|
||||
*/
|
||||
var $_link = null;
|
||||
|
||||
/**
|
||||
* This method returns the handle of the connection to the database where PGT's are
|
||||
* stored.
|
||||
*
|
||||
* @return a handle of connection.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function getLink()
|
||||
{
|
||||
return $this->_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the table where PGT's are stored. Written by
|
||||
* PGTStorageDB::PGTStorageDB(), read by getTable().
|
||||
*
|
||||
* @hideinitializer
|
||||
* @private
|
||||
*/
|
||||
var $_table = '';
|
||||
|
||||
/**
|
||||
* This method returns the name of the table where PGT's are stored.
|
||||
*
|
||||
* @return the name of a table.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function getTable()
|
||||
{
|
||||
return $this->_table;
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// DEBUGGING
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* This method returns an informational string giving the type of storage
|
||||
* used by the object (used for debugging purposes).
|
||||
*
|
||||
* @return an informational string.
|
||||
* @public
|
||||
*/
|
||||
function getStorageType()
|
||||
{
|
||||
return "database";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an informational string giving informations on the
|
||||
* parameters of the storage.(used for debugging purposes).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function getStorageInfo()
|
||||
{
|
||||
return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// CONSTRUCTOR
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* The class constructor, called by CASClient::SetPGTStorageDB().
|
||||
*
|
||||
* @param $cas_parent the CASClient instance that creates the object.
|
||||
* @param $user the user to access the data with
|
||||
* @param $password the user's password
|
||||
* @param $database_type the type of the database hosting the data
|
||||
* @param $hostname the server hosting the database
|
||||
* @param $port the port the server is listening on
|
||||
* @param $database the name of the database
|
||||
* @param $table the name of the table storing the data
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
|
||||
// call the ancestor's constructor
|
||||
$this->PGTStorage($cas_parent);
|
||||
|
||||
if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
|
||||
if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
|
||||
if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
|
||||
if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
|
||||
if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
|
||||
|
||||
// build and store the PEAR DB URL
|
||||
$this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$server.':'.$port.'/'.$database;
|
||||
|
||||
// XXX should use setURL and setTable
|
||||
phpCAS::traceEnd();
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// INITIALIZATION
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* This method is used to initialize the storage. Halts on error.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
// if the storage has already been initialized, return immediatly
|
||||
if ( $this->isInitialized() )
|
||||
return;
|
||||
// call the ancestor's method (mark as initialized)
|
||||
parent::init();
|
||||
|
||||
// try to connect to the database
|
||||
$this->_link = DB::connect($this->getURL());
|
||||
if ( DB::isError($this->_link) ) {
|
||||
phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
|
||||
}
|
||||
var_dump($this->_link);
|
||||
phpCAS::traceBEnd();
|
||||
}
|
||||
|
||||
/** @} */
|
||||
}
|
||||
|
||||
?>
|
236
auth/cas/CAS/PGTStorage/pgt-file.php
Normal file
236
auth/cas/CAS/PGTStorage/pgt-file.php
Normal file
@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file CAS/PGTStorage/pgt-file.php
|
||||
* Basic class for PGT file storage
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class PGTStorageFile
|
||||
* The PGTStorageFile class is a class for PGT file storage. An instance of
|
||||
* this class is returned by CASClient::SetPGTStorageFile().
|
||||
*
|
||||
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
|
||||
*
|
||||
* @ingroup internalPGTStorageFile
|
||||
*/
|
||||
|
||||
class PGTStorageFile extends PGTStorage
|
||||
{
|
||||
/**
|
||||
* @addtogroup internalPGTStorageFile
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* a string telling where PGT's should be stored on the filesystem. Written by
|
||||
* PGTStorageFile::PGTStorageFile(), read by getPath().
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
var $_path;
|
||||
|
||||
/**
|
||||
* This method returns the name of the directory where PGT's should be stored
|
||||
* on the filesystem.
|
||||
*
|
||||
* @return the name of a directory (with leading and trailing '/')
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function getPath()
|
||||
{
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* a string telling the format to use to store PGT's (plain or xml). Written by
|
||||
* PGTStorageFile::PGTStorageFile(), read by getFormat().
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
var $_format;
|
||||
|
||||
/**
|
||||
* This method returns the format to use when storing PGT's on the filesystem.
|
||||
*
|
||||
* @return a string corresponding to the format used (plain or xml).
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function getFormat()
|
||||
{
|
||||
return $this->_format;
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// DEBUGGING
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* This method returns an informational string giving the type of storage
|
||||
* used by the object (used for debugging purposes).
|
||||
*
|
||||
* @return an informational string.
|
||||
* @public
|
||||
*/
|
||||
function getStorageType()
|
||||
{
|
||||
return "file";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an informational string giving informations on the
|
||||
* parameters of the storage.(used for debugging purposes).
|
||||
*
|
||||
* @return an informational string.
|
||||
* @public
|
||||
*/
|
||||
function getStorageInfo()
|
||||
{
|
||||
return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// CONSTRUCTOR
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* The class constructor, called by CASClient::SetPGTStorageFile().
|
||||
*
|
||||
* @param $cas_parent the CASClient instance that creates the object.
|
||||
* @param $format the format used to store the PGT's (`plain' and `xml' allowed).
|
||||
* @param $path the path where the PGT's should be stored
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function PGTStorageFile($cas_parent,$format,$path)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
// call the ancestor's constructor
|
||||
$this->PGTStorage($cas_parent);
|
||||
|
||||
if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
|
||||
if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
|
||||
|
||||
// check that the path is an absolute path
|
||||
if ( $path[0] != '/' ) {
|
||||
phpCAS::error('an absolute path is needed for PGT storage to file');
|
||||
}
|
||||
|
||||
// store the path (with a leading and trailing '/')
|
||||
$path = preg_replace('|[/]*$|','/',$path);
|
||||
$path = preg_replace('|^[/]*|','/',$path);
|
||||
$this->_path = $path;
|
||||
|
||||
// check the format and store it
|
||||
switch ($format) {
|
||||
case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
|
||||
case CAS_PGT_STORAGE_FILE_FORMAT_XML:
|
||||
$this->_format = $format;
|
||||
break;
|
||||
default:
|
||||
phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
|
||||
}
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// INITIALIZATION
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* This method is used to initialize the storage. Halts on error.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
// if the storage has already been initialized, return immediatly
|
||||
if ( $this->isInitialized() )
|
||||
return;
|
||||
// call the ancestor's method (mark as initialized)
|
||||
parent::init();
|
||||
phpCAS::traceEnd();
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// PGT I/O
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* This method returns the filename corresponding to a PGT Iou.
|
||||
*
|
||||
* @param $pgt_iou the PGT iou.
|
||||
*
|
||||
* @return a filename
|
||||
* @private
|
||||
*/
|
||||
function getPGTIouFilename($pgt_iou)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
return $this->getPath().$pgt_iou.'.'.$this->getFormat();
|
||||
phpCAS::traceEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
|
||||
* warning on error.
|
||||
*
|
||||
* @param $pgt the PGT
|
||||
* @param $pgt_iou the PGT iou
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function write($pgt,$pgt_iou)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
$fname = $this->getPGTIouFilename($pgt_iou);
|
||||
if ( $f=fopen($fname,"w") ) {
|
||||
if ( fputs($f,$pgt) === FALSE ) {
|
||||
phpCAS::error('could not write PGT to `'.$fname.'\'');
|
||||
}
|
||||
fclose($f);
|
||||
} else {
|
||||
phpCAS::error('could not open `'.$fname.'\'');
|
||||
}
|
||||
phpCAS::traceEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method reads a PGT corresponding to a PGT Iou and deletes the
|
||||
* corresponding file.
|
||||
*
|
||||
* @param $pgt_iou the PGT iou
|
||||
*
|
||||
* @return the corresponding PGT, or FALSE on error
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function read($pgt_iou)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
$pgt = FALSE;
|
||||
$fname = $this->getPGTIouFilename($pgt_iou);
|
||||
if ( !($f=fopen($fname,"r")) ) {
|
||||
phpCAS::trace('could not open `'.$fname.'\'');
|
||||
} else {
|
||||
if ( ($pgt=fgets($f)) === FALSE ) {
|
||||
phpCAS::trace('could not read PGT from `'.$fname.'\'');
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
// delete the PGT file
|
||||
@unlink($fname);
|
||||
|
||||
phpCAS::traceEnd($pgt);
|
||||
return $pgt;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
188
auth/cas/CAS/PGTStorage/pgt-main.php
Normal file
188
auth/cas/CAS/PGTStorage/pgt-main.php
Normal file
@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file CAS/PGTStorage/pgt-main.php
|
||||
* Basic class for PGT storage
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class PGTStorage
|
||||
* The PGTStorage class is a generic class for PGT storage. This class should
|
||||
* not be instanciated itself but inherited by specific PGT storage classes.
|
||||
*
|
||||
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
|
||||
*
|
||||
* @ingroup internalPGTStorage
|
||||
*/
|
||||
|
||||
class PGTStorage
|
||||
{
|
||||
/**
|
||||
* @addtogroup internalPGTStorage
|
||||
* @{
|
||||
*/
|
||||
|
||||
// ########################################################################
|
||||
// CONSTRUCTOR
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* The constructor of the class, should be called only by inherited classes.
|
||||
*
|
||||
* @param $cas_parent the CASclient instance that creates the current object.
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
function PGTStorage($cas_parent)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
if ( !$cas_parent->isProxy() ) {
|
||||
phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy');
|
||||
}
|
||||
phpCAS::traceEnd();
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// DEBUGGING
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* This virtual method returns an informational string giving the type of storage
|
||||
* used by the object (used for debugging purposes).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function getStorageType()
|
||||
{
|
||||
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
|
||||
}
|
||||
|
||||
/**
|
||||
* This virtual method returns an informational string giving informations on the
|
||||
* parameters of the storage.(used for debugging purposes).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
function getStorageInfo()
|
||||
{
|
||||
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// ERROR HANDLING
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* string used to store an error message. Written by PGTStorage::setErrorMessage(),
|
||||
* read by PGTStorage::getErrorMessage().
|
||||
*
|
||||
* @hideinitializer
|
||||
* @private
|
||||
* @deprecated not used.
|
||||
*/
|
||||
var $_error_message=FALSE;
|
||||
|
||||
/**
|
||||
* This method sets en error message, which can be read later by
|
||||
* PGTStorage::getErrorMessage().
|
||||
*
|
||||
* @param $error_message an error message
|
||||
*
|
||||
* @protected
|
||||
* @deprecated not used.
|
||||
*/
|
||||
function setErrorMessage($error_message)
|
||||
{
|
||||
$this->_error_message = $error_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an error message set by PGTStorage::setErrorMessage().
|
||||
*
|
||||
* @return an error message when set by PGTStorage::setErrorMessage(), FALSE
|
||||
* otherwise.
|
||||
*
|
||||
* @public
|
||||
* @deprecated not used.
|
||||
*/
|
||||
function getErrorMessage()
|
||||
{
|
||||
return $this->_error_message;
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// INITIALIZATION
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* a boolean telling if the storage has already been initialized. Written by
|
||||
* PGTStorage::init(), read by PGTStorage::isInitialized().
|
||||
*
|
||||
* @hideinitializer
|
||||
* @private
|
||||
*/
|
||||
var $_initialized = FALSE;
|
||||
|
||||
/**
|
||||
* This method tells if the storage has already been intialized.
|
||||
*
|
||||
* @return a boolean
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
function isInitialized()
|
||||
{
|
||||
return $this->_initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* This virtual method initializes the object.
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->_initialized = TRUE;
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// PGT I/O
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* This virtual method stores a PGT and its corresponding PGT Iuo.
|
||||
* @note Should never be called.
|
||||
*
|
||||
* @param $pgt the PGT
|
||||
* @param $pgt_iou the PGT iou
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
function write($pgt,$pgt_iou)
|
||||
{
|
||||
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
|
||||
}
|
||||
|
||||
/**
|
||||
* This virtual method reads a PGT corresponding to a PGT Iou and deletes
|
||||
* the corresponding storage entry.
|
||||
* @note Should never be called.
|
||||
*
|
||||
* @param $pgt_iou the PGT iou
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
function read($pgt_iou)
|
||||
{
|
||||
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
}
|
||||
|
||||
// include specific PGT storage classes
|
||||
include_once(dirname(__FILE__).'/pgt-file.php');
|
||||
include_once(dirname(__FILE__).'/pgt-db.php');
|
||||
|
||||
?>
|
1887
auth/cas/CAS/client.php
Normal file
1887
auth/cas/CAS/client.php
Normal file
File diff suppressed because it is too large
Load Diff
278
auth/cas/CAS/domxml-php4-php5.php
Normal file
278
auth/cas/CAS/domxml-php4-php5.php
Normal file
@ -0,0 +1,278 @@
|
||||
<?php
|
||||
/**
|
||||
* @file domxml-php4-php5.php
|
||||
* Require PHP5, uses built-in DOM extension.
|
||||
* To be used in PHP4 scripts using DOMXML extension.
|
||||
* Allows PHP4/DOMXML scripts to run on PHP5/DOM.
|
||||
* (Requires PHP5/XSL extension for domxml_xslt functions)
|
||||
*
|
||||
* Typical use:
|
||||
* <pre>
|
||||
* {
|
||||
* if (version_compare(PHP_VERSION,'5','>='))
|
||||
* require_once('domxml-php4-to-php5.php');
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Version 1.5.5, 2005-01-18, http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
|
||||
*
|
||||
* ------------------------------------------------------------------<br>
|
||||
* Written by Alexandre Alapetite, http://alexandre.alapetite.net/cv/
|
||||
*
|
||||
* Copyright 2004, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
|
||||
* http://creativecommons.org/licenses/by-sa/2.0/fr/
|
||||
* http://alexandre.alapetite.net/divers/apropos/#by-sa
|
||||
* - Attribution. You must give the original author credit
|
||||
* - Share Alike. If you alter, transform, or build upon this work,
|
||||
* you may distribute the resulting work only under a license identical to this one
|
||||
* - The French law is authoritative
|
||||
* - Any of these conditions can be waived if you get permission from Alexandre Alapetite
|
||||
* - Please send to Alexandre Alapetite the modifications you make,
|
||||
* in order to improve this file for the benefit of everybody
|
||||
*
|
||||
* If you want to distribute this code, please do it as a link to:
|
||||
* http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
|
||||
*/
|
||||
|
||||
function domxml_new_doc($version) {return new php4DOMDocument('');}
|
||||
function domxml_open_file($filename) {return new php4DOMDocument($filename);}
|
||||
function domxml_open_mem($str)
|
||||
{
|
||||
$dom=new php4DOMDocument('');
|
||||
$dom->myDOMNode->loadXML($str);
|
||||
return $dom;
|
||||
}
|
||||
function xpath_eval($xpath_context,$eval_str,$contextnode=null) {return $xpath_context->query($eval_str,$contextnode);}
|
||||
function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document);}
|
||||
|
||||
class php4DOMAttr extends php4DOMNode
|
||||
{
|
||||
function php4DOMAttr($aDOMAttr) {$this->myDOMNode=$aDOMAttr;}
|
||||
function Name() {return $this->myDOMNode->name;}
|
||||
function Specified() {return $this->myDOMNode->specified;}
|
||||
function Value() {return $this->myDOMNode->value;}
|
||||
}
|
||||
|
||||
class php4DOMDocument extends php4DOMNode
|
||||
{
|
||||
function php4DOMDocument($filename='')
|
||||
{
|
||||
$this->myDOMNode=new DOMDocument();
|
||||
if ($filename!='') $this->myDOMNode->load($filename);
|
||||
}
|
||||
function create_attribute($name,$value)
|
||||
{
|
||||
$myAttr=$this->myDOMNode->createAttribute($name);
|
||||
$myAttr->value=$value;
|
||||
return new php4DOMAttr($myAttr,$this);
|
||||
}
|
||||
function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);}
|
||||
function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);}
|
||||
function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);}
|
||||
function create_text_node($content) {return new php4DOMNode($this->myDOMNode->createTextNode($content),$this);}
|
||||
function document_element() {return new php4DOMElement($this->myDOMNode->documentElement,$this);}
|
||||
function dump_file($filename,$compressionmode=false,$format=false) {return $this->myDOMNode->save($filename);}
|
||||
function dump_mem($format=false,$encoding=false) {return $this->myDOMNode->saveXML();}
|
||||
function get_element_by_id($id) {return new php4DOMElement($this->myDOMNode->getElementById($id),$this);}
|
||||
function get_elements_by_tagname($name)
|
||||
{
|
||||
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
|
||||
$nodeSet=array();
|
||||
$i=0;
|
||||
if (isset($myDOMNodeList))
|
||||
while ($node=$myDOMNodeList->item($i))
|
||||
{
|
||||
$nodeSet[]=new php4DOMElement($node,$this);
|
||||
$i++;
|
||||
}
|
||||
return $nodeSet;
|
||||
}
|
||||
function html_dump_mem() {return $this->myDOMNode->saveHTML();}
|
||||
function root() {return new php4DOMElement($this->myDOMNode->documentElement,$this);}
|
||||
}
|
||||
|
||||
class php4DOMElement extends php4DOMNode
|
||||
{
|
||||
function get_attribute($name) {return $this->myDOMNode->getAttribute($name);}
|
||||
function get_elements_by_tagname($name)
|
||||
{
|
||||
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
|
||||
$nodeSet=array();
|
||||
$i=0;
|
||||
if (isset($myDOMNodeList))
|
||||
while ($node=$myDOMNodeList->item($i))
|
||||
{
|
||||
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
|
||||
$i++;
|
||||
}
|
||||
return $nodeSet;
|
||||
}
|
||||
function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);}
|
||||
function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);}
|
||||
function set_attribute($name,$value) {return $this->myDOMNode->setAttribute($name,$value);}
|
||||
function tagname() {return $this->myDOMNode->tagName;}
|
||||
}
|
||||
|
||||
class php4DOMNode
|
||||
{
|
||||
var $myDOMNode;
|
||||
var $myOwnerDocument;
|
||||
function php4DOMNode($aDomNode,$aOwnerDocument)
|
||||
{
|
||||
$this->myDOMNode=$aDomNode;
|
||||
$this->myOwnerDocument=$aOwnerDocument;
|
||||
}
|
||||
function __get($name)
|
||||
{
|
||||
if ($name=='type') return $this->myDOMNode->nodeType;
|
||||
elseif ($name=='tagname') return $this->myDOMNode->tagName;
|
||||
elseif ($name=='content') return $this->myDOMNode->textContent;
|
||||
else
|
||||
{
|
||||
$myErrors=debug_backtrace();
|
||||
trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function append_child($newnode) {return new php4DOMElement($this->myDOMNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);}
|
||||
function append_sibling($newnode) {return new php4DOMElement($this->myDOMNode->parentNode->appendChild($newnode->myDOMNode),$this->myOwnerDocument);}
|
||||
function attributes()
|
||||
{
|
||||
$myDOMNodeList=$this->myDOMNode->attributes;
|
||||
$nodeSet=array();
|
||||
$i=0;
|
||||
if (isset($myDOMNodeList))
|
||||
while ($node=$myDOMNodeList->item($i))
|
||||
{
|
||||
$nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
|
||||
$i++;
|
||||
}
|
||||
return $nodeSet;
|
||||
}
|
||||
function child_nodes()
|
||||
{
|
||||
$myDOMNodeList=$this->myDOMNode->childNodes;
|
||||
$nodeSet=array();
|
||||
$i=0;
|
||||
if (isset($myDOMNodeList))
|
||||
while ($node=$myDOMNodeList->item($i))
|
||||
{
|
||||
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
|
||||
$i++;
|
||||
}
|
||||
return $nodeSet;
|
||||
}
|
||||
function children() {return $this->child_nodes();}
|
||||
function clone_node($deep=false) {return new php4DOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);}
|
||||
function first_child() {return new php4DOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);}
|
||||
function get_content() {return $this->myDOMNode->textContent;}
|
||||
function has_attributes() {return $this->myDOMNode->hasAttributes();}
|
||||
function has_child_nodes() {return $this->myDOMNode->hasChildNodes();}
|
||||
function insert_before($newnode,$refnode) {return new php4DOMElement($this->myDOMNode->insertBefore($newnode->myDOMNode,$refnode->myDOMNode),$this->myOwnerDocument);}
|
||||
function is_blank_node()
|
||||
{
|
||||
$myDOMNodeList=$this->myDOMNode->childNodes;
|
||||
$i=0;
|
||||
if (isset($myDOMNodeList))
|
||||
while ($node=$myDOMNodeList->item($i))
|
||||
{
|
||||
if (($node->nodeType==XML_ELEMENT_NODE)||
|
||||
(($node->nodeType==XML_TEXT_NODE)&&!ereg('^([[:cntrl:]]|[[:space:]])*$',$node->nodeValue)))
|
||||
return false;
|
||||
$i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function last_child() {return new php4DOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);}
|
||||
function new_child($name,$content)
|
||||
{
|
||||
$mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
|
||||
$mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($content));
|
||||
$this->myDOMNode->appendChild($mySubNode);
|
||||
return new php4DOMElement($mySubNode,$this->myOwnerDocument);
|
||||
}
|
||||
function next_sibling() {return new php4DOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);}
|
||||
function node_name() {return $this->myDOMNode->localName;}
|
||||
function node_type() {return $this->myDOMNode->nodeType;}
|
||||
function node_value() {return $this->myDOMNode->nodeValue;}
|
||||
function owner_document() {return $this->myOwnerDocument;}
|
||||
function parent_node() {return new php4DOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);}
|
||||
function prefix() {return $this->myDOMNode->prefix;}
|
||||
function previous_sibling() {return new php4DOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);}
|
||||
function remove_child($oldchild) {return new php4DOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);}
|
||||
function replace_child($oldnode,$newnode) {return new php4DOMElement($this->myDOMNode->replaceChild($oldnode->myDOMNode,$newnode->myDOMNode),$this->myOwnerDocument);}
|
||||
function set_content($text)
|
||||
{
|
||||
if (($this->myDOMNode->hasChildNodes())&&($this->myDOMNode->firstChild->nodeType==XML_TEXT_NODE))
|
||||
$this->myDOMNode->removeChild($this->myDOMNode->firstChild);
|
||||
return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text));
|
||||
}
|
||||
}
|
||||
|
||||
class php4DOMNodelist
|
||||
{
|
||||
var $myDOMNodelist;
|
||||
var $nodeset;
|
||||
function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
|
||||
{
|
||||
$this->myDOMNodelist=$aDOMNodelist;
|
||||
$this->nodeset=array();
|
||||
$i=0;
|
||||
if (isset($this->myDOMNodelist))
|
||||
while ($node=$this->myDOMNodelist->item($i))
|
||||
{
|
||||
$this->nodeset[]=new php4DOMElement($node,$aOwnerDocument);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class php4DOMXPath
|
||||
{
|
||||
var $myDOMXPath;
|
||||
var $myOwnerDocument;
|
||||
function php4DOMXPath($dom_document)
|
||||
{
|
||||
$this->myOwnerDocument=$dom_document;
|
||||
$this->myDOMXPath=new DOMXPath($dom_document->myDOMNode);
|
||||
}
|
||||
function query($eval_str,$contextnode)
|
||||
{
|
||||
if (isset($contextnode)) return new php4DOMNodelist($this->myDOMXPath->query($eval_str,$contextnode->myDOMNode),$this->myOwnerDocument);
|
||||
else return new php4DOMNodelist($this->myDOMXPath->query($eval_str),$this->myOwnerDocument);
|
||||
}
|
||||
function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
|
||||
}
|
||||
|
||||
if (extension_loaded('xsl'))
|
||||
{//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
|
||||
function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));}
|
||||
function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);}
|
||||
function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));}
|
||||
class php4DomXsltStylesheet
|
||||
{
|
||||
var $myxsltProcessor;
|
||||
function php4DomXsltStylesheet($dom_document)
|
||||
{
|
||||
$this->myxsltProcessor=new xsltProcessor();
|
||||
$this->myxsltProcessor->importStyleSheet($dom_document);
|
||||
}
|
||||
function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
|
||||
{
|
||||
foreach ($xslt_parameters as $param=>$value)
|
||||
$this->myxsltProcessor->setParameter('',$param,$value);
|
||||
$myphp4DOMDocument=new php4DOMDocument();
|
||||
$myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
|
||||
return $myphp4DOMDocument;
|
||||
}
|
||||
function result_dump_file($dom_document,$filename)
|
||||
{
|
||||
$html=$dom_document->myDOMNode->saveHTML();
|
||||
file_put_contents($filename,$html);
|
||||
return $html;
|
||||
}
|
||||
function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
27
auth/cas/CAS/languages/english.php
Normal file
27
auth/cas/CAS/languages/english.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file languages/english.php
|
||||
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
|
||||
* @sa @link internalLang Internationalization @endlink
|
||||
* @ingroup internalLang
|
||||
*/
|
||||
|
||||
$this->_strings = array(
|
||||
CAS_STR_USING_SERVER
|
||||
=> 'using server',
|
||||
CAS_STR_AUTHENTICATION_WANTED
|
||||
=> 'CAS Authentication wanted!',
|
||||
CAS_STR_LOGOUT
|
||||
=> 'CAS logout wanted!',
|
||||
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
|
||||
=> 'You should already have been redirected to the CAS server. Click <a href="%s">here</a> to continue.',
|
||||
CAS_STR_AUTHENTICATION_FAILED
|
||||
=> 'CAS Authentication failed!',
|
||||
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
|
||||
=> '<p>You were not authenticated.</p><p>You may submit your request again by clicking <a href="%s">here</a>.</p><p>If the problem persists, you may contact <a href="mailto:%s">the administrator of this site</a>.</p>',
|
||||
CAS_STR_SERVICE_UNAVAILABLE
|
||||
=> 'The service `<b>%s</b>\' is not available (<b>%s</b>).'
|
||||
);
|
||||
|
||||
?>
|
28
auth/cas/CAS/languages/french.php
Normal file
28
auth/cas/CAS/languages/french.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file languages/english.php
|
||||
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
|
||||
* @sa @link internalLang Internationalization @endlink
|
||||
* @ingroup internalLang
|
||||
*/
|
||||
|
||||
$this->_strings = array(
|
||||
CAS_STR_USING_SERVER
|
||||
=> 'utilisant le serveur',
|
||||
CAS_STR_AUTHENTICATION_WANTED
|
||||
=> 'Authentication CAS nécessaire !',
|
||||
CAS_STR_LOGOUT
|
||||
=> 'Déconnexion demandée !',
|
||||
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
|
||||
=> 'Vous auriez du etre redirigé(e) vers le serveur CAS. Cliquez <a href="%s">ici</a> pour continuer.',
|
||||
CAS_STR_AUTHENTICATION_FAILED
|
||||
=> 'Authentification CAS infructueuse !',
|
||||
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
|
||||
=> '<p>Vous n\'avez pas été authentifié(e).</p><p>Vous pouvez soumettre votre requete à nouveau en cliquant <a href="%s">ici</a>.</p><p>Si le problème persiste, vous pouvez contacter <a href="mailto:%s">l\'administrateur de ce site</a>.</p>',
|
||||
CAS_STR_SERVICE_UNAVAILABLE
|
||||
=> 'Le service `<b>%s</b>\' est indisponible (<b>%s</b>)'
|
||||
|
||||
);
|
||||
|
||||
?>
|
27
auth/cas/CAS/languages/greek.php
Normal file
27
auth/cas/CAS/languages/greek.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file languages/greek.php
|
||||
* @author Vangelis Haniotakis <haniotak at ucnet.uoc.gr>
|
||||
* @sa @link internalLang Internationalization @endlink
|
||||
* @ingroup internalLang
|
||||
*/
|
||||
|
||||
$this->_strings = array(
|
||||
CAS_STR_USING_SERVER
|
||||
=> '÷ñçóéìïðïéåßôáé ï åîõðçñåôçôÞò',
|
||||
CAS_STR_AUTHENTICATION_WANTED
|
||||
=> 'Áðáéôåßôáé ç ôáõôïðïßçóç CAS!',
|
||||
CAS_STR_LOGOUT
|
||||
=> 'Áðáéôåßôáé ç áðïóýíäåóç áðü CAS!',
|
||||
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
|
||||
=> 'Èá Ýðñåðå íá åß÷áôå áíáêáôåõèõíèåß óôïí åîõðçñåôçôÞ CAS. ÊÜíôå êëßê <a href="%s">åäþ</a> ãéá íá óõíå÷ßóåôå.',
|
||||
CAS_STR_AUTHENTICATION_FAILED
|
||||
=> 'Ç ôáõôïðïßçóç CAS áðÝôõ÷å!',
|
||||
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
|
||||
=> '<p>Äåí ôáõôïðïéçèÞêáôå.</p><p>Ìðïñåßôå íá îáíáðñïóðáèÞóåôå, êÜíïíôáò êëßê <a href="%s">åäþ</a>.</p><p>Åáí ôï ðñüâëçìá åðéìåßíåé, åëÜôå óå åðáöÞ ìå ôïí <a href="mailto:%s">äéá÷åéñéóôÞ</a>.</p>',
|
||||
CAS_STR_SERVICE_UNAVAILABLE
|
||||
=> 'Ç õðçñåóßá `<b>%s</b>\' äåí åßíáé äéáèÝóéìç (<b>%s</b>).'
|
||||
);
|
||||
|
||||
?>
|
24
auth/cas/CAS/languages/languages.php
Normal file
24
auth/cas/CAS/languages/languages.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file languages/languages.php
|
||||
* Internationalization constants
|
||||
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
|
||||
* @sa @link internalLang Internationalization @endlink
|
||||
* @ingroup internalLang
|
||||
*/
|
||||
|
||||
//@{
|
||||
/**
|
||||
* a phpCAS string index
|
||||
*/
|
||||
define("CAS_STR_USING_SERVER", 1);
|
||||
define("CAS_STR_AUTHENTICATION_WANTED", 2);
|
||||
define("CAS_STR_LOGOUT", 3);
|
||||
define("CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED", 4);
|
||||
define("CAS_STR_AUTHENTICATION_FAILED", 5);
|
||||
define("CAS_STR_YOU_WERE_NOT_AUTHENTICATED", 6);
|
||||
define("CAS_STR_SERVICE_UNAVAILABLE", 7);
|
||||
//@}
|
||||
|
||||
?>
|
@ -1,6 +1,7 @@
|
||||
CAS-module README
|
||||
|
||||
Please read comments from lib.php for auth/CAS module
|
||||
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
|
||||
|
||||
Other changes made:
|
||||
|
||||
@ -13,4 +14,3 @@ Other changes made:
|
||||
/lang/fr/auth.php -> new lines
|
||||
/lang/fr/moodle.php -> new lines
|
||||
|
||||
All modifications are commented by //Modif SG - RL pour CAS.
|
||||
|
1376
auth/cas/commonlib.php
Normal file
1376
auth/cas/commonlib.php
Normal file
File diff suppressed because it is too large
Load Diff
376
auth/cas/config.html
Normal file
376
auth/cas/config.html
Normal file
@ -0,0 +1,376 @@
|
||||
<?php
|
||||
require_once('languages.php');
|
||||
if (!isset($config->cas_hostname)) {
|
||||
$config->cas_hostname = "";
|
||||
}
|
||||
if (!isset($config->cas_port)) {
|
||||
$config->cas_port = "";
|
||||
}
|
||||
if (!isset($config->cas_version)) {
|
||||
$config->cas_version = "";
|
||||
}
|
||||
if (!isset($config->cas_baseuri)) {
|
||||
$config->cas_baseuri = "";
|
||||
}
|
||||
if (!isset($config->cas_language)) {
|
||||
$config->cas_language = "";
|
||||
}
|
||||
if (!isset($config->cas_use_cas)) {
|
||||
$config->cas_use_cas = "0";
|
||||
}
|
||||
if (!isset($config->cas_create_user)) {
|
||||
$config->cas_create_user = "0";
|
||||
}
|
||||
?>
|
||||
|
||||
<?PHP
|
||||
if (!isset($config->ldap_host_url)) {
|
||||
$config->ldap_host_url = "";
|
||||
}
|
||||
if (!isset($config->ldap_contexts)) {
|
||||
$config->ldap_contexts = "";
|
||||
}
|
||||
if (!isset($config->ldap_user_attribute)) {
|
||||
$config->ldap_user_attribute = "";
|
||||
}
|
||||
if (!isset($config->ldap_search_sub)) {
|
||||
$config->ldap_search_sub = "";
|
||||
}
|
||||
if (!isset($config->ldap_bind_dn)) {
|
||||
$config->ldap_bind_dn = "";
|
||||
}
|
||||
if (!isset($config->ldap_bind_pw)) {
|
||||
$config->ldap_bind_pw = "";
|
||||
}
|
||||
if (empty($config->ldap_version)) {
|
||||
$config->ldap_version = "2";
|
||||
}
|
||||
if (empty($config->ldap_memberattribute)) {
|
||||
$config->ldap_memberattribute = "";
|
||||
}
|
||||
if (empty($config->ldap_creators)) {
|
||||
$config->ldap_creators = "";
|
||||
}
|
||||
if (empty($config->ldap_create_context)) {
|
||||
$config->ldap_create_context = "";
|
||||
}
|
||||
if (empty($config->ldap_objectclass)) {
|
||||
$config->ldap_objectclass = "";
|
||||
}
|
||||
if (empty($config->auth_user_guid)) {
|
||||
$config->auth_user_guid = "";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>cas_use_cas:</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, "");?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_cas_use_cas","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>cas_hostname:</TD>
|
||||
<TD>
|
||||
<INPUT name=cas_hostname TYPE=text SIZE=30 VALUE="<?php echo $config->cas_hostname?>">
|
||||
<?php if (isset($err["cas_hostname"])) formerr($err["cas_hostname"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_cas_hostname","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>cas_baseuri:</TD>
|
||||
<TD>
|
||||
<INPUT name=cas_baseuri TYPE=text SIZE=30 VALUE="<?php echo $config->cas_baseuri?>">
|
||||
<?php if (isset($err["cas_baseuri"])) formerr($err["cas_baseuri"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_cas_baseuri","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>cas_port:</TD>
|
||||
<TD>
|
||||
<INPUT name=cas_port TYPE=text SIZE=30 VALUE="<?php echo $config->cas_port?>">
|
||||
<?php if (isset($err["cas_port"])) formerr($err["cas_port"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_cas_port","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>cas_version:</TD>
|
||||
<TD>
|
||||
<INPUT name=cas_version TYPE=text SIZE=30 VALUE="<?php echo $config->cas_version?>">
|
||||
<?php if (isset($err["cas_version"])) formerr($err["cas_version"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_cas_version","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>cas_language:</TD>
|
||||
<TD>
|
||||
<?php choose_from_menu ($CASLANGUAGES, "cas_language", $config->cas_language, "");?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_cas_language","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>cas_create_user:</TD>
|
||||
<TD>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "cas_create_user", $config->cas_create_user, "");?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_cas_create_user","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_host_url:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_host_url TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_host_url?>">
|
||||
<?php if (isset($err["ldap_host_url"])) formerr($err["ldap_host_url"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_host_url","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_version:</TD>
|
||||
<TD>
|
||||
<?php
|
||||
$versions[2] = "2";
|
||||
$versions[3] = "3";
|
||||
choose_from_menu($versions, "ldap_version", $config->ldap_version, "");
|
||||
if (isset($err["ldap_version"])) formerr($err["ldap_version"]);
|
||||
?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_version","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_contexts:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_contexts TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_contexts?>">
|
||||
<?php if (isset($err["ldap_contexts"])) formerr($err["ldap_contexts"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_contexts","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_user_attribute:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_user_attribute TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_user_attribute?>">
|
||||
<?php if (isset($err["ldap_user_attribute"])) formerr($err["ldap_user_attribute"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_user_attribute","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_objectclass:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_objectclass TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_objectclass?>">
|
||||
<?php if (isset($err["ldap_objectclass"])) formerr($err["ldap_objectclass"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_objectclass","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_search_sub TYPE=text SIZE=1 VALUE="<?php echo $config->ldap_search_sub?>">
|
||||
<?php if (isset($err["ldap_search_sub"])) formerr($err["ldap_search_sub"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_search_sub","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_dn TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_dn?>">
|
||||
<?php if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_bind_dn","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_pw:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_pw TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_pw?>">
|
||||
<?php if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_bind_pw","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_memberattribute:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_memberattribute TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_memberattribute?>">
|
||||
<?php if (isset($err["ldap_memberattribute"])) formerr($err["ldap_memberattribute"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_memberattribute","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_creators:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_creators TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_creators?>">
|
||||
<?php if (isset($err["ldap_creators"])) formerr($err["ldap_creators"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_creators","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_create_context:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_create_context TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_create_context?>">
|
||||
<?php if (isset($err["ldap_create_context"])) formerr($err["ldap_create_context"]); ?>
|
||||
</TD><TD>
|
||||
<?php print_string("auth_ldap_create_context","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("firstname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_firstname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_firstname?>">
|
||||
</TD>
|
||||
<TD rowspan=12 VALIGN=CENTER>
|
||||
<?php print_string("auth_ldapextrafields","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("lastname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lastname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lastname?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("email") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_email" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_email?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 1:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone1" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone1?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 2:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone2" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone2?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("department") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_department" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_department?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("address") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_address" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_address?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("city") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_city" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_city?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("country") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_country" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_country?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("description") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_description" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_description?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("idnumber") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_idnumber" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_idnumber?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("language") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lang" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lang?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("guid") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_guid" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_guid?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
|
||||
|
||||
|
8
auth/cas/forbidden.html
Normal file
8
auth/cas/forbidden.html
Normal file
@ -0,0 +1,8 @@
|
||||
<table width="90%" border="0" cellspacing="10" cellpadding="5" align="center" style="font-size: small">
|
||||
<tr>
|
||||
<td width="50%" bgcolor="<?php p($THEME->cellheading2) ?>" class="headingblock">
|
||||
<p align="center"><b><font size="3"><?php formerr($errormsg) ?></font></b></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
12
auth/cas/forbidden.php
Normal file
12
auth/cas/forbidden.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// version $Id$
|
||||
// Page for forbidden access from CAS
|
||||
require_once("../../config.php");
|
||||
$errormsg = get_string("invalidcaslogin");
|
||||
print_header("$site->fullname: $loginsite", "$site->fullname", $loginsite,
|
||||
$focus, "", true, "<div align=right>$langmenu</div>");
|
||||
include("forbidden.html");
|
||||
print_footer();
|
||||
exit;
|
||||
?>
|
||||
|
10
auth/cas/languages.php
Normal file
10
auth/cas/languages.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?PHP
|
||||
// version $Id$
|
||||
// List of CAS langages.
|
||||
// You can add langages in /CAS/langage.
|
||||
// Please send them to http://esup-phpcas.sourceforge.net
|
||||
$CASLANGUAGES = array (
|
||||
"greek" => "Modern Greek",
|
||||
"english" => "English",
|
||||
"french" => "French");
|
||||
?>
|
74
auth/cas/lib.php
Normal file
74
auth/cas/lib.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?PHP
|
||||
// $Id: lib.php
|
||||
// author: romualdLorthioir $
|
||||
//CHANGELOG:
|
||||
//05.02.2005 Added CAS module
|
||||
|
||||
/* README!
|
||||
CAS Module
|
||||
This Module can be turn ON/OFF on admin screen.
|
||||
The /login module have to be changed to.
|
||||
This module is using the LDAP Module so you need the /auth/ldap directory.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
define("AUTH_METHOD", 'cas');
|
||||
require_once($CFG->dirroot.'/auth/cas/commonlib.php');
|
||||
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
/// Returns true if the username and password work
|
||||
/// and false if they don't
|
||||
|
||||
global $CFG;
|
||||
if (!$username or !$password) { // Don't allow blank usernames or passwords
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($CFG->auth == "cas" && $CFG->cas_use_cas == "1" ){
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (get_user_info_from_db("username", $username)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$ldap_connection = auth_ldap_connect();
|
||||
|
||||
if ($ldap_connection) {
|
||||
$ldap_user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
|
||||
//if ldap_user_dn is empty, user does not exist
|
||||
if(!$ldap_user_dn){
|
||||
ldap_close($ldap_connection);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to bind with current username and password
|
||||
$ldap_login = ldap_bind($ldap_connection, $ldap_user_dn, $password);
|
||||
ldap_close($ldap_connection);
|
||||
if ($ldap_login) {
|
||||
if ($CFG->cas_create_user=="0"){
|
||||
if (get_user_info_from_db("username", $username)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ldap_close($ldap_connection);
|
||||
error("LDAP part of CAS-module cannot connect to server: $CFG->ldap_host_url");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
125
auth/cas/login/change_password.php
Normal file
125
auth/cas/login/change_password.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
?>
|
48
auth/cas/login/change_password_form.html
Normal file
48
auth/cas/login/change_password_form.html
Normal file
@ -0,0 +1,48 @@
|
||||
<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>
|
69
auth/cas/login/confirm.php
Normal file
69
auth/cas/login/confirm.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?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/");
|
||||
|
||||
?>
|
102
auth/cas/login/forgot_password.php
Normal file
102
auth/cas/login/forgot_password.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
28
auth/cas/login/forgot_password_form.html
Normal file
28
auth/cas/login/forgot_password_form.html
Normal file
@ -0,0 +1,28 @@
|
||||
<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>
|
277
auth/cas/login/index.php
Normal file
277
auth/cas/login/index.php
Normal file
@ -0,0 +1,277 @@
|
||||
<?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
|
||||
|
||||
|
||||
?>
|
131
auth/cas/login/index_form.html
Normal file
131
auth/cas/login/index_form.html
Normal file
@ -0,0 +1,131 @@
|
||||
<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>
|
27
auth/cas/login/logout.php
Normal file
27
auth/cas/login/logout.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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/");
|
||||
|
||||
?>
|
159
auth/cas/login/signup.php
Normal file
159
auth/cas/login/signup.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
|
||||
?>
|
96
auth/cas/login/signup_form.html
Normal file
96
auth/cas/login/signup_form.html
Normal file
@ -0,0 +1,96 @@
|
||||
<?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>
|
Loading…
x
Reference in New Issue
Block a user