mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Tidy up alt_auth plugin - mostly documentation, some code rationalisation, conversion to the 2.0 way, etc
This commit is contained in:
@@ -1,4 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
* Common admin/configuration functions for alt_auth plugin
|
||||||
|
*
|
||||||
|
* $URL$
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -6,6 +26,7 @@
|
|||||||
TODO:
|
TODO:
|
||||||
1. Header
|
1. Header
|
||||||
2. Support array of defaults for table
|
2. Support array of defaults for table
|
||||||
|
3. Get rid of all the globals (put into a class?)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -24,13 +45,23 @@ if (!is_object($euf))
|
|||||||
define('AUTH_UNKNOWN', 4);
|
define('AUTH_UNKNOWN', 4);
|
||||||
define('AUTH_NOT_AVAILABLE', 5);
|
define('AUTH_NOT_AVAILABLE', 5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of supported authentication methods
|
||||||
|
* Searches for files *_auth.php in the plugin directory
|
||||||
|
*
|
||||||
|
* @param boolean $incE107 - if TRUE, 'e107' is included as an authentication method.
|
||||||
|
*
|
||||||
|
* @return array of authentication methods in value fields
|
||||||
|
*/
|
||||||
function alt_auth_get_authlist($incE107 = TRUE)
|
function alt_auth_get_authlist($incE107 = TRUE)
|
||||||
{
|
{
|
||||||
$authlist = $incE107 ? array('e107') : array();
|
$authlist = $incE107 ? array('e107') : array();
|
||||||
$handle=opendir(e_PLUGIN.'alt_auth');
|
$handle = opendir(e_PLUGIN.'alt_auth');
|
||||||
while ($file = readdir($handle))
|
while ($file = readdir($handle))
|
||||||
{
|
{
|
||||||
if(preg_match("/^(.*)_auth\.php/",$file,$match))
|
if(preg_match("/^(.*)_auth\.php/", $file, $match))
|
||||||
{
|
{
|
||||||
$authlist[] = $match[1];
|
$authlist[] = $match[1];
|
||||||
}
|
}
|
||||||
@@ -40,6 +71,14 @@ function alt_auth_get_authlist($incE107 = TRUE)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return HTML for selector for authentication method
|
||||||
|
*
|
||||||
|
* @param string $name - the name of the selector
|
||||||
|
* @param string $curval - current value (if any)
|
||||||
|
* @param string $optlist - comma-separated list of options to be included as choices
|
||||||
|
*/
|
||||||
function alt_auth_get_dropdown($name, $curval = '', $options = '')
|
function alt_auth_get_dropdown($name, $curval = '', $options = '')
|
||||||
{
|
{
|
||||||
$optList = explode(',', $options);
|
$optList = explode(',', $options);
|
||||||
@@ -55,8 +94,12 @@ function alt_auth_get_dropdown($name, $curval = '', $options = '')
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// All user fields which might, just possibly, be transferred. The array key is the corresponding field in the E107 user database; code prefixes it with 'xf_' to get the parameter
|
|
||||||
// 'default' may be a single value to set the same for all connect methods, or an array to set different defaults.
|
/**
|
||||||
|
* All user fields which might, just possibly, be transferred. The array key is the corresponding field in the E107 user database; code prefixes it
|
||||||
|
* with 'xf_' to get the parameter
|
||||||
|
* 'default' may be a single value to set the same for all connect methods, or an array to set different defaults.
|
||||||
|
*/
|
||||||
$alt_auth_user_fields = array(
|
$alt_auth_user_fields = array(
|
||||||
'user_email' => array('prompt' => LAN_ALT_12, 'default' => 'user_email', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'mail'),
|
'user_email' => array('prompt' => LAN_ALT_12, 'default' => 'user_email', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'mail'),
|
||||||
'user_hideemail' => array('prompt' => LAN_ALT_13, 'default' => 'user_hideemail', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => '', method => 'bool1'),
|
'user_hideemail' => array('prompt' => LAN_ALT_13, 'default' => 'user_hideemail', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => '', method => 'bool1'),
|
||||||
@@ -68,15 +111,18 @@ $alt_auth_user_fields = array(
|
|||||||
'user_sess' => array('prompt' => LAN_ALT_19, 'default' => 'user_sess', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
'user_sess' => array('prompt' => LAN_ALT_19, 'default' => 'user_sess', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
||||||
'user_join' => array('prompt' => LAN_ALT_20, 'default' => 'user_join', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
|
'user_join' => array('prompt' => LAN_ALT_20, 'default' => 'user_join', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
|
||||||
'user_ban' => array('prompt' => LAN_ALT_21, 'default' => 'user_ban', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
'user_ban' => array('prompt' => LAN_ALT_21, 'default' => 'user_ban', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
||||||
'user_class' => array('prompt' => LAN_ALT_22, 'default' => 'user_class', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
'user_class' => array('prompt' => LAN_ALT_22, 'default' => 'user_class', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE)
|
||||||
'user_xup' => array('prompt' => LAN_ALT_23, 'default' => 'user_xup', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Returns a block of table rows with user DB fields and either checkboxes or entry boxes
|
|
||||||
// $tableType is the prefix used, without the following underscore
|
/**
|
||||||
// $frm is the form object to use to create the text
|
* Returns a block of table rows with user DB fields and either checkboxes or entry boxes
|
||||||
// $parm is the array of options for the current auth type as read from the DB
|
*
|
||||||
|
* @param string $tableType is the prefix used, without the following underscore
|
||||||
|
* @param $frm is the form object to use to create the text
|
||||||
|
* @param array $parm is the array of options for the current auth type as read from the DB
|
||||||
|
*/
|
||||||
function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
|
function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
|
||||||
{
|
{
|
||||||
global $alt_auth_user_fields;
|
global $alt_auth_user_fields;
|
||||||
@@ -124,7 +170,14 @@ function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns a list of all the user-related fields allowed as an array, whhere the key is the field name
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all the user-related fields allowed as an array, whhere the key is the field name
|
||||||
|
*
|
||||||
|
* @param string $tableType is the prefix used, without the following underscore
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function alt_auth_get_allowed_fields($tableType)
|
function alt_auth_get_allowed_fields($tableType)
|
||||||
{
|
{
|
||||||
global $alt_auth_user_fields;
|
global $alt_auth_user_fields;
|
||||||
@@ -142,13 +195,19 @@ function alt_auth_get_allowed_fields($tableType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Routine adds the extended user fields which may be involved into the table of field definitions, so that they're displayed
|
|
||||||
|
/**
|
||||||
|
* Routine adds the extended user fields which may be involved into the table of field definitions, so that they're displayed
|
||||||
|
*/
|
||||||
function add_extended_fields()
|
function add_extended_fields()
|
||||||
{
|
{
|
||||||
global $alt_auth_user_fields, $euf, $pref;
|
global $alt_auth_user_fields, $euf, $pref;
|
||||||
|
|
||||||
if (!isset($pref['auth_extended'])) return;
|
if (!isset($pref['auth_extended'])) return;
|
||||||
if (!$pref['auth_extended']) return;
|
if (!$pref['auth_extended']) return;
|
||||||
|
|
||||||
static $fieldsAdded = FALSE;
|
static $fieldsAdded = FALSE;
|
||||||
|
|
||||||
if ($fieldsAdded) return;
|
if ($fieldsAdded) return;
|
||||||
$xFields = $euf->user_extended_get_fieldList('','user_extended_struct_name');
|
$xFields = $euf->user_extended_get_fieldList('','user_extended_struct_name');
|
||||||
// print_a($xFields);
|
// print_a($xFields);
|
||||||
@@ -169,6 +228,10 @@ function add_extended_fields()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of the standard fields which may be displayed for any method.
|
||||||
|
*/
|
||||||
$common_fields = array(
|
$common_fields = array(
|
||||||
'server' => array('fieldname' => 'server', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_32, 'help' => ''),
|
'server' => array('fieldname' => 'server', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_32, 'help' => ''),
|
||||||
'uname' => array('fieldname' => 'username', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_33, 'help' => ''),
|
'uname' => array('fieldname' => 'username', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_33, 'help' => ''),
|
||||||
@@ -183,9 +246,21 @@ $common_fields = array(
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the HTML for all server-related fields required for configuration of a particular method.
|
||||||
|
* Each is a row of a table having two columns (no <table>...</table> etc added, so can be embedded in a larger table
|
||||||
|
*
|
||||||
|
* @param string $prefix is the prefix used, without the following underscore
|
||||||
|
* @param $frm is the form object to use
|
||||||
|
* @param array $parm is an array of the current values of each item
|
||||||
|
* @param string $fields is a list of the fields to display, separated by '|'. The names are the key values from $common_fields table
|
||||||
|
*
|
||||||
|
*/
|
||||||
function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pwd|db|table|ufield|pwfield')
|
function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pwd|db|table|ufield|pwfield')
|
||||||
{
|
{
|
||||||
global $common_fields;
|
global $common_fields;
|
||||||
|
|
||||||
$opts = explode('|',$fields);
|
$opts = explode('|',$fields);
|
||||||
$ret = '';
|
$ret = '';
|
||||||
foreach ($common_fields as $fn => $cf)
|
foreach ($common_fields as $fn => $cf)
|
||||||
@@ -204,7 +279,11 @@ function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pw
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Write all the options to the DB. $prefix must NOT have trailing underscore
|
/**
|
||||||
|
* Write all the options for a particular authentication type to the DB
|
||||||
|
*
|
||||||
|
* @var string $prefix - the prefix string representing the authentication type (currently importdb|e107db|otherdb|ldap|radius). Must NOT have a trailing underscore
|
||||||
|
*/
|
||||||
function alt_auth_post_options($prefix)
|
function alt_auth_post_options($prefix)
|
||||||
{
|
{
|
||||||
global $common_fields, $sql, $admin_log;
|
global $common_fields, $sql, $admin_log;
|
||||||
@@ -226,13 +305,13 @@ function alt_auth_post_options($prefix)
|
|||||||
if (strpos($k,$lprefix) === 0)
|
if (strpos($k,$lprefix) === 0)
|
||||||
{
|
{
|
||||||
$v = base64_encode(base64_encode($v));
|
$v = base64_encode(base64_encode($v));
|
||||||
if($sql -> db_Select("alt_auth", "*", "auth_type='{$prefix}' AND auth_parmname='{$k}' "))
|
if($sql -> db_Select('alt_auth', '*', "auth_type='{$prefix}' AND auth_parmname='{$k}' "))
|
||||||
{
|
{
|
||||||
$sql -> db_Update("alt_auth", "auth_parmval='{$v}' WHERE auth_type='{$prefix}' AND auth_parmname='{$k}' ");
|
$sql -> db_Update('alt_auth', "auth_parmval='{$v}' WHERE auth_type='{$prefix}' AND auth_parmname='{$k}' ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql -> db_Insert("alt_auth", "'{$prefix}','{$k}','{$v}' ");
|
$sql -> db_Insert('alt_auth', "'{$prefix}','{$k}','{$v}' ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,11 +321,61 @@ function alt_auth_post_options($prefix)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
// Return test form
|
* Get the HTML for a password type selector.
|
||||||
function alt_auth_test_form($prefix,$frm)
|
*
|
||||||
|
* @param string $name - name to be used for selector
|
||||||
|
* @param $frm - form object to use
|
||||||
|
* @param string $currentSelection - current value (if any)
|
||||||
|
* @param boolean $getExtended - return all supported password types if TRUE, 'core' password types if FALSE
|
||||||
|
*/
|
||||||
|
function altAuthGetPasswordSelector($name, $frm, $currentSelection = '', $getExtended = FALSE)
|
||||||
{
|
{
|
||||||
$text = $frm -> form_open("post", e_SELF, 'testform');
|
$password_methods = ExtendedPasswordHandler::GetPasswordTypes($getExtended);
|
||||||
|
$text .= $frm->form_select_open($name);
|
||||||
|
foreach($password_methods as $k => $v)
|
||||||
|
{
|
||||||
|
$sel = ($currentSelection == $k) ? " Selected='selected'" : '';
|
||||||
|
$text .= $frm -> form_option($v, $sel, $k);
|
||||||
|
}
|
||||||
|
$text .= $frm->form_select_close();
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get configuration parameters for an authentication method
|
||||||
|
*
|
||||||
|
* @param string $prefix - the method
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function altAuthGetParams($prefix)
|
||||||
|
{
|
||||||
|
$sql = e107::getDB();
|
||||||
|
|
||||||
|
$sql->db_Select('alt_auth', '*', "auth_type = '".$prefix."' ");
|
||||||
|
$parm = array();
|
||||||
|
while($row = $sql->db_Fetch())
|
||||||
|
{
|
||||||
|
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
||||||
|
}
|
||||||
|
return $parm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the HTML needed to display the test form.
|
||||||
|
*
|
||||||
|
* @param string $prefix - the type of connection being tested
|
||||||
|
* @param $frm - the form object to use
|
||||||
|
*
|
||||||
|
* if $_POST['testauth'] is set, attempts to validate the connection, and displays any returned values
|
||||||
|
*/
|
||||||
|
function alt_auth_test_form($prefix, $frm)
|
||||||
|
{
|
||||||
|
$text = $frm -> form_open('post', e_SELF, 'testform');
|
||||||
$text .= "<table style='width:96%' class='fborder'>
|
$text .= "<table style='width:96%' class='fborder'>
|
||||||
<tr><td colspan='2' class='forumheader2' style='text-align:center;'>".LAN_ALT_42."</td></tr>";
|
<tr><td colspan='2' class='forumheader2' style='text-align:center;'>".LAN_ALT_42."</td></tr>";
|
||||||
|
|
||||||
@@ -265,7 +394,7 @@ function alt_auth_test_form($prefix,$frm)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$log_result = $_login -> login($val_name, $_POST['passtovalidate'], $pass_vars, ($val_name == ''));
|
$log_result = $_login->login($val_name, $_POST['passtovalidate'], $pass_vars, ($val_name == ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_48;
|
$text .= "<tr><td class='forumheader3'>".LAN_ALT_48;
|
||||||
@@ -311,19 +440,19 @@ function alt_auth_test_form($prefix,$frm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_33."</td><td class='forumheader3'>";
|
$text .= "<tr><td class='forumheader3'>".LAN_ALT_33."</td><td class='forumheader3'>";
|
||||||
$text .= $frm -> form_text('nametovalidate', 35, '', 120);
|
$text .= $frm->form_text('nametovalidate', 35, '', 120);
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_34."</td><td class='forumheader3'>";
|
$text .= "<tr><td class='forumheader3'>".LAN_ALT_34."</td><td class='forumheader3'>";
|
||||||
$text .= $frm -> form_password('passtovalidate', 35, '', 120);
|
$text .= $frm->form_password('passtovalidate', 35, '', 120);
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
||||||
$text .= $frm -> form_button("submit", 'testauth', LAN_ALT_47);
|
$text .= $frm->form_button("submit", 'testauth', LAN_ALT_47);
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "</table>";
|
$text .= "</table>";
|
||||||
$text .= $frm -> form_close();
|
$text .= $frm->form_close();
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,14 +6,30 @@
|
|||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
|
* Alt_auth plugin - general configuration
|
||||||
|
*
|
||||||
* $URL$
|
* $URL$
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
@todo:
|
||||||
|
1. Change prefs handling
|
||||||
|
2. Change admin log references
|
||||||
|
*/
|
||||||
$eplug_admin = true;
|
$eplug_admin = true;
|
||||||
require_once('../../class2.php');
|
require_once('../../class2.php');
|
||||||
if(!getperms("P") || !plugInstalled('alt_auth'))
|
if(!getperms('P') || !e107::isInstalled('alt_auth'))
|
||||||
{
|
{
|
||||||
header('location:'.e_BASE.'index.php');
|
header('location:'.e_BASE.'index.php');
|
||||||
exit();
|
exit();
|
||||||
@@ -37,7 +53,7 @@ if(isset($_POST['updateprefs']))
|
|||||||
if ($admin_log->logArrayDiffs($temp, $pref, 'AUTH_01'))
|
if ($admin_log->logArrayDiffs($temp, $pref, 'AUTH_01'))
|
||||||
{
|
{
|
||||||
save_prefs(); // Only save if changes
|
save_prefs(); // Only save if changes
|
||||||
header("location:".e_SELF);
|
header('location:'.e_SELF);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +107,7 @@ else
|
|||||||
|
|
||||||
if(isset($message))
|
if(isset($message))
|
||||||
{
|
{
|
||||||
$ns -> tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
|
e107::getRender()->tablerender('', "<div style='text-align:center'><b>".$message."</b></div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = "
|
$text = "
|
||||||
@@ -125,9 +141,9 @@ $text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
|
|||||||
<td>".LAN_ALT_6.":<br /></td>
|
<td>".LAN_ALT_6.":<br /></td>
|
||||||
<td>
|
<td>
|
||||||
<select class='tbox' name='auth_noconn'>";
|
<select class='tbox' name='auth_noconn'>";
|
||||||
$sel = (!$pref['auth_noconn'] ? "" : " selected = 'selected' ");
|
$sel = (!$pref['auth_noconn'] ? '' : " selected = 'selected' ");
|
||||||
$text .= "<option value='0' {$sel} >".LAN_ALT_FAIL."</option>";
|
$text .= "<option value='0' {$sel} >".LAN_ALT_FAIL."</option>";
|
||||||
$sel = ($pref['auth_noconn'] ? " selected = 'selected' " : "");
|
$sel = ($pref['auth_noconn'] ? " selected = 'selected' " : '');
|
||||||
$text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
|
$text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
|
||||||
</select><div class='smalltext field-help'>".LAN_ALT_7."</div>
|
</select><div class='smalltext field-help'>".LAN_ALT_7."</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -149,7 +165,7 @@ $text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
|
|||||||
</form>
|
</form>
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
$ns -> tablerender(LAN_ALT_3, $text);
|
e107::getRender()->tablerender(LAN_ALT_3, $text);
|
||||||
|
|
||||||
|
|
||||||
if ($euf->userCount)
|
if ($euf->userCount)
|
||||||
@@ -190,13 +206,13 @@ if ($euf->userCount)
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>";
|
</div>";
|
||||||
$ns -> tablerender(LAN_ALT_60, $text);
|
e107::getRender()->tablerender(LAN_ALT_60, $text);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
require_once(e_ADMIN."footer.php");
|
require_once(e_ADMIN.'footer.php');
|
||||||
|
|
||||||
function alt_auth_conf_adminmenu()
|
function alt_auth_conf_adminmenu()
|
||||||
{
|
{
|
||||||
|
@@ -13,15 +13,26 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
define('AA_DEBUG',FALSE);
|
define('AA_DEBUG',FALSE);
|
||||||
define('AA_DEBUG1',FALSE);
|
define('AA_DEBUG1',FALSE);
|
||||||
|
|
||||||
|
|
||||||
//TODO convert to class constants
|
//TODO convert to class constants (but may be more useful as globals, perhaps within a general login manager scheme)
|
||||||
define('AUTH_SUCCESS', -1);
|
define('AUTH_SUCCESS', -1);
|
||||||
define('AUTH_NOUSER', 1);
|
define('AUTH_NOUSER', 1);
|
||||||
define('AUTH_BADPASSWORD', 2);
|
define('AUTH_BADPASSWORD', 2);
|
||||||
define('AUTH_NOCONNECT', 3);
|
define('AUTH_NOCONNECT', 3);
|
||||||
|
define('AUTH_UNKNOWN', 4);
|
||||||
|
define('AUTH_NOT_AVAILABLE', 5);
|
||||||
|
define('AUTH_NORESOURCE', 6); // Used to indicate, for example, that a required PHP module isn't loaded
|
||||||
|
|
||||||
class alt_login
|
class alt_login
|
||||||
{
|
{
|
||||||
@@ -30,7 +41,6 @@ class alt_login
|
|||||||
|
|
||||||
public function __construct($method, &$username, &$userpass)
|
public function __construct($method, &$username, &$userpass)
|
||||||
{
|
{
|
||||||
global $pref;
|
|
||||||
$this->e107 = e107::getInstance();
|
$this->e107 = e107::getInstance();
|
||||||
$newvals=array();
|
$newvals=array();
|
||||||
|
|
||||||
@@ -45,11 +55,11 @@ class alt_login
|
|||||||
|
|
||||||
if(isset($_login->Available) && ($_login->Available === FALSE))
|
if(isset($_login->Available) && ($_login->Available === FALSE))
|
||||||
{ // Relevant auth method not available (e.g. PHP extension not loaded)
|
{ // Relevant auth method not available (e.g. PHP extension not loaded)
|
||||||
$this->loginResult = AUTH_NOCONNECT;
|
$this->loginResult = AUTH_NOT_AVAILABLE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$login_result = $_login -> login($username, $userpass, $newvals, FALSE);
|
$login_result = $_login->login($username, $userpass, $newvals, FALSE);
|
||||||
|
|
||||||
if($login_result === AUTH_SUCCESS )
|
if($login_result === AUTH_SUCCESS )
|
||||||
{
|
{
|
||||||
@@ -61,7 +71,7 @@ class alt_login
|
|||||||
$username = mysql_real_escape_string($username);
|
$username = mysql_real_escape_string($username);
|
||||||
}
|
}
|
||||||
$username = preg_replace("/\sOR\s|\=|\#/", "", $username);
|
$username = preg_replace("/\sOR\s|\=|\#/", "", $username);
|
||||||
$username = substr($username, 0, varset($pref['loginname_maxlength'],30));
|
$username = substr($username, 0, e107::getPref('loginname_maxlength');
|
||||||
|
|
||||||
$aa_sql = e107::getDb('aa');
|
$aa_sql = e107::getDb('aa');
|
||||||
$userMethods = new UserHandler;
|
$userMethods = new UserHandler;
|
||||||
@@ -157,7 +167,7 @@ class alt_login
|
|||||||
if (!isset($db_vals['user_name'])) $db_vals['user_name'] = $username;
|
if (!isset($db_vals['user_name'])) $db_vals['user_name'] = $username;
|
||||||
if (!isset($db_vals['user_loginname'])) $db_vals['user_loginname'] = $username;
|
if (!isset($db_vals['user_loginname'])) $db_vals['user_loginname'] = $username;
|
||||||
if (!isset($db_vals['user_join'])) $db_vals['user_join'] = time();
|
if (!isset($db_vals['user_join'])) $db_vals['user_join'] = time();
|
||||||
$db_vals['user_class'] = varset($pref['initial_user_classes'],'');
|
$db_vals['user_class'] = e107::getPref('initial_user_classes');
|
||||||
if (!isset($db_vals['user_signature'])) $db_vals['user_signature'] = '';
|
if (!isset($db_vals['user_signature'])) $db_vals['user_signature'] = '';
|
||||||
if (!isset($db_vals['user_prefs'])) $db_vals['user_prefs'] = '';
|
if (!isset($db_vals['user_prefs'])) $db_vals['user_prefs'] = '';
|
||||||
if (!isset($db_vals['user_perms'])) $db_vals['user_perms'] = '';
|
if (!isset($db_vals['user_perms'])) $db_vals['user_perms'] = '';
|
||||||
@@ -193,17 +203,8 @@ class alt_login
|
|||||||
{ // Failure modes
|
{ // Failure modes
|
||||||
switch($login_result)
|
switch($login_result)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
case AUTH_NOUSER: // Now handled differently
|
|
||||||
if(!varset($pref['auth_nouser'],0))
|
|
||||||
{
|
|
||||||
$username=md5('xx_nouser_xx');
|
|
||||||
return LOGIN_ABORT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case AUTH_NOCONNECT:
|
case AUTH_NOCONNECT:
|
||||||
if(varset($pref['auth_noconn'], TRUE))
|
if(varset(e107::getPref('auth_noconn'), TRUE))
|
||||||
{
|
{
|
||||||
$this->loginResult = LOGIN_TRY_OTHER;
|
$this->loginResult = LOGIN_TRY_OTHER;
|
||||||
return;
|
return;
|
||||||
@@ -211,9 +212,8 @@ class alt_login
|
|||||||
$username=md5('xx_noconn_xx');
|
$username=md5('xx_noconn_xx');
|
||||||
$this->loginResult = LOGIN_ABORT;
|
$this->loginResult = LOGIN_ABORT;
|
||||||
return;
|
return;
|
||||||
break;
|
|
||||||
case AUTH_BADPASSWORD:
|
case AUTH_BADPASSWORD:
|
||||||
if(varset($pref['auth_badpassword'], TRUE))
|
if(varset(e107::getPref('auth_badpassword'), TRUE))
|
||||||
{
|
{
|
||||||
$this->loginResult = LOGIN_TRY_OTHER;
|
$this->loginResult = LOGIN_TRY_OTHER;
|
||||||
return;
|
return;
|
||||||
@@ -221,7 +221,6 @@ class alt_login
|
|||||||
$userpass=md5('xx_badpassword_xx');
|
$userpass=md5('xx_badpassword_xx');
|
||||||
$this->loginResult = LOGIN_ABORT; // Not going to magically be able to log in!
|
$this->loginResult = LOGIN_ABORT; // Not going to magically be able to log in!
|
||||||
return;
|
return;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->loginResult = LOGIN_ABORT; // catch-all just in case
|
$this->loginResult = LOGIN_ABORT; // catch-all just in case
|
||||||
@@ -232,7 +231,7 @@ class alt_login
|
|||||||
// Function to implement copy methods
|
// Function to implement copy methods
|
||||||
public function translate($method, $word)
|
public function translate($method, $word)
|
||||||
{
|
{
|
||||||
global $tp;
|
$tp = e107::getParser();
|
||||||
switch ($method)
|
switch ($method)
|
||||||
{
|
{
|
||||||
case 'bool1' :
|
case 'bool1' :
|
||||||
|
@@ -1,21 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* e107 DB authorisation for alt_auth plugin
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
|
|
* $Id$
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/e107db_auth.php,v $
|
*/
|
||||||
| $Revision$
|
|
||||||
| $Date$
|
/**
|
||||||
| $Author$
|
* e107 Alternate authorisation plugin
|
||||||
+----------------------------------------------------------------------------+
|
*
|
||||||
*/
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*
|
||||||
|
* This connects to a 'foreign' e107 user database to validate the user
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return values
|
return values
|
||||||
@@ -28,36 +33,51 @@
|
|||||||
|
|
||||||
class auth_login
|
class auth_login
|
||||||
{
|
{
|
||||||
|
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||||
var $Available;
|
public $ErrorText; // e107 error string on exit
|
||||||
var $ErrorText;
|
private $conf; // Configuration parameters
|
||||||
var $conf; // Configuration parameters
|
|
||||||
|
|
||||||
|
|
||||||
function auth_login()
|
/**
|
||||||
|
* Read configuration, initialise connection to remote e107 database
|
||||||
|
*
|
||||||
|
* @return AUTH_xxxx result code
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
global $sql;
|
|
||||||
$this->conf = array();
|
|
||||||
$this->ErrorText = '';
|
$this->ErrorText = '';
|
||||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'e107db' ");
|
$this->conf = altAuthGetParams('e107db');
|
||||||
while($row = $sql -> db_Fetch())
|
|
||||||
{
|
|
||||||
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
|
||||||
}
|
|
||||||
$this->Available = TRUE;
|
$this->Available = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add the reconnect function in here - might be needed
|
|
||||||
function makeErrorText($extra = '')
|
/**
|
||||||
|
* Retrieve and construct error strings
|
||||||
|
*
|
||||||
|
* @todo - test whether reconnect to DB is required (shouldn't be)
|
||||||
|
*/
|
||||||
|
private function makeErrorText($extra = '')
|
||||||
{
|
{
|
||||||
$this->ErrorText = $extra;
|
$this->ErrorText = $extra;
|
||||||
global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
//global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
||||||
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
|
//$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function login($uname, $pword, &$newvals, $connect_only = FALSE)
|
/**
|
||||||
|
* Validate login credentials
|
||||||
|
*
|
||||||
|
* @param string $uname - The user name requesting access
|
||||||
|
* @param string $pass - Password to use (usually plain text)
|
||||||
|
* @param pointer &$newvals - pointer to array to accept other data read from database
|
||||||
|
* @param boolean $connect_only - TRUE to simply connect to the database
|
||||||
|
*
|
||||||
|
* @return integer result (AUTH_xxxx)
|
||||||
|
*
|
||||||
|
* On a successful login, &$newvals array is filled with the requested data from the server
|
||||||
|
*/
|
||||||
|
public function login($uname, $pword, &$newvals, $connect_only = FALSE)
|
||||||
{
|
{
|
||||||
//Attempt to open connection to sql database
|
//Attempt to open connection to sql database
|
||||||
if(!$res = mysql_connect($this->conf['e107db_server'], $this->conf['e107db_username'], $this->conf['e107db_password']))
|
if(!$res = mysql_connect($this->conf['e107db_server'], $this->conf['e107db_username'], $this->conf['e107db_password']))
|
||||||
@@ -66,6 +86,7 @@ class auth_login
|
|||||||
return AUTH_NOCONNECT;
|
return AUTH_NOCONNECT;
|
||||||
}
|
}
|
||||||
//Select correct db
|
//Select correct db
|
||||||
|
|
||||||
if(!mysql_select_db($this->conf['e107db_database'], $res))
|
if(!mysql_select_db($this->conf['e107db_database'], $res))
|
||||||
{
|
{
|
||||||
mysql_close($res);
|
mysql_close($res);
|
||||||
@@ -95,7 +116,7 @@ class auth_login
|
|||||||
|
|
||||||
|
|
||||||
//Get record containing supplied login name
|
//Get record containing supplied login name
|
||||||
$qry = "SELECT ".implode(',',$sel_fields)." FROM ".$this->conf['e107db_prefix']."user WHERE {$user_field} = '{$uname}' AND `user_ban` = 0";
|
$qry = 'SELECT '.implode(',',$sel_fields)." FROM ".$this->conf['e107db_prefix']."user WHERE {$user_field} = '{$uname}' AND `user_ban` = 0";
|
||||||
// echo "Query: {$qry}<br />";
|
// echo "Query: {$qry}<br />";
|
||||||
if(!$r1 = mysql_query($qry))
|
if(!$r1 = mysql_query($qry))
|
||||||
{
|
{
|
||||||
@@ -103,7 +124,7 @@ class auth_login
|
|||||||
$this->makeErrorText('Lookup query failed');
|
$this->makeErrorText('Lookup query failed');
|
||||||
return AUTH_NOCONNECT;
|
return AUTH_NOCONNECT;
|
||||||
}
|
}
|
||||||
if(!$row = mysql_fetch_array($r1))
|
if (!$row = mysql_fetch_array($r1))
|
||||||
{
|
{
|
||||||
mysql_close($res);
|
mysql_close($res);
|
||||||
$this->makeErrorText('User not found');
|
$this->makeErrorText('User not found');
|
||||||
|
@@ -1,16 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* e107 DB configuration for alt_auth plugin
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
+----------------------------------------------------------------------------+
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
$eplug_admin = true;
|
$eplug_admin = true;
|
||||||
require_once('../../class2.php');
|
require_once('../../class2.php');
|
||||||
require_once(e_ADMIN.'auth.php');
|
require_once(e_ADMIN.'auth.php');
|
||||||
@@ -21,73 +29,63 @@ define('ALT_AUTH_ACTION', 'e107db');
|
|||||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||||
|
|
||||||
|
|
||||||
if($_POST['update'])
|
if($_POST['update'])
|
||||||
{
|
{
|
||||||
// $message = update_e107db_prefs();
|
|
||||||
$message = alt_auth_post_options('e107db');
|
$message = alt_auth_post_options('e107db');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($message)
|
if($message)
|
||||||
{
|
{
|
||||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
show_e107db_form();
|
show_e107db_form();
|
||||||
|
|
||||||
|
|
||||||
function show_e107db_form()
|
function show_e107db_form()
|
||||||
{
|
{
|
||||||
global $sql, $tp, $ns;
|
$ns = e107::getRender();
|
||||||
|
|
||||||
|
$parm = altAuthGetParams('e107db');
|
||||||
$password_methods = ExtendedPasswordHandler::GetPasswordTypes('core');
|
|
||||||
|
|
||||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'e107db' ");
|
|
||||||
$parm = array();
|
|
||||||
while($row = $sql->db_Fetch())
|
|
||||||
{
|
|
||||||
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$frm = new form;
|
$frm = new form;
|
||||||
$text = $frm -> form_open("post", e_SELF);
|
$text = $frm -> form_open('post', e_SELF);
|
||||||
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
|
$text .= "<table cellpadding='0' cellspacing='0' class='fborder'>
|
||||||
<colgroup span='2'>
|
<colgroup span='2'>
|
||||||
<col class='col-label' />
|
<col class='col-label' />
|
||||||
<col class='col-control' />
|
<col class='col-control' />
|
||||||
</colgroup>";
|
</colgroup>";
|
||||||
|
|
||||||
$text .= "<tr><td>".LAN_ALT_26."</td><td>";
|
$text .= "<tr><td class='forumheader3'>".LAN_ALT_26."</td><td class='forumheader3'>";
|
||||||
$text .= E107DB_LAN_1;
|
$text .= E107DB_LAN_1;
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= alt_auth_get_db_fields('e107db', $frm, $parm, 'server|uname|pwd|db|prefix|classfilt');
|
$text .= alt_auth_get_db_fields('e107db', $frm, $parm, 'server|uname|pwd|db|prefix|classfilt');
|
||||||
|
|
||||||
$text .= "<tr><td>".E107DB_LAN_9."</td><td>";
|
$text .= "<tr><td class='forumheader3'>".E107DB_LAN_9."</td><td class='forumheader3'>";
|
||||||
$text .= $frm -> form_select_open("e107db_password_method");
|
$text .= altAuthGetPasswordSelector('e107db_password_method', $frm, $parm['e107db_password_method'], FALSE);
|
||||||
foreach($password_methods as $k => $v)
|
|
||||||
{
|
|
||||||
$sel = ($parm['e107db_password_method'] == $k) ? " Selected" : "";
|
|
||||||
$text .= $frm -> form_option($v, $sel, $k);
|
|
||||||
}
|
|
||||||
$text .= $frm -> form_select_close();
|
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "<tr><td colspan='2'>".E107DB_LAN_11."</td></tr>";
|
$text .= "<tr><td colspan='2'><br />".E107DB_LAN_11."</td></tr>";
|
||||||
|
|
||||||
$text .= alt_auth_get_field_list('e107db',$frm, $parm, TRUE);
|
$text .= alt_auth_get_field_list('e107db',$frm, $parm, TRUE);
|
||||||
|
|
||||||
$text .= "</table><div class='buttons-bar center'>";
|
$text .= "</table><div class='buttons-bar center'>";
|
||||||
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
||||||
$text .= "</div>";
|
$text .= '</div>';
|
||||||
$text .= $frm -> form_close();
|
$text .= $frm -> form_close();
|
||||||
|
|
||||||
$ns -> tablerender(E107DB_LAN_10, $text);
|
$ns->tablerender(E107DB_LAN_10, $text);
|
||||||
|
|
||||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('e107db',$frm));
|
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('e107db',$frm));
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once(e_ADMIN."footer.php");
|
require_once(e_ADMIN.'footer.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
*
|
* Alt_Auth plugin - help
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/e_help.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/e_help.php,v $
|
||||||
* $Revision$
|
* $Revision$
|
||||||
@@ -14,6 +14,14 @@
|
|||||||
* $Author$
|
* $Author$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
define('ALT_AUTH_PATH', e_PLUGIN.'alt_auth/');
|
define('ALT_AUTH_PATH', e_PLUGIN.'alt_auth/');
|
||||||
|
@@ -2,17 +2,25 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
*
|
* Extended password handler for alt_auth plugin
|
||||||
*
|
*
|
||||||
* $URL$
|
* $URL$
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
EXTENDED PASSWORD HANDLER CLASS
|
EXTENDED PASSWORD HANDLER CLASS
|
||||||
- supports many password formats used on other systems
|
- supports many password formats used on other systems
|
||||||
- implements checking of existing passwords only
|
- implements checking of existing passwords only
|
||||||
@@ -23,54 +31,55 @@ To use:
|
|||||||
or, optionally:
|
or, optionally:
|
||||||
call CheckPassword(plaintext_password,login_name, stored_value, password_type)
|
call CheckPassword(plaintext_password,login_name, stored_value, password_type)
|
||||||
|
|
||||||
|
@todo:
|
||||||
To do:
|
1. Check that public/private declarations of functions are correct
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
|
||||||
require_once(e_HANDLER.'user_handler.php');
|
require_once(e_HANDLER.'user_handler.php');
|
||||||
|
|
||||||
|
|
||||||
|
// @todo make these class constants
|
||||||
|
define('PASSWORD_PHPBB_SALT',2);
|
||||||
|
define('PASSWORD_MAMBO_SALT',3);
|
||||||
|
define('PASSWORD_JOOMLA_SALT',4);
|
||||||
|
define('PASSWORD_GENERAL_MD5',5);
|
||||||
|
define('PASSWORD_PLAINTEXT',6);
|
||||||
|
define('PASSWORD_GENERAL_SHA1',7);
|
||||||
|
define('PASSWORD_WORDPRESS_SALT', 8);
|
||||||
|
define('PASSWORD_MAGENTO_SALT', 9);
|
||||||
|
|
||||||
|
// Supported formats:
|
||||||
|
define('PASSWORD_PHPBB_ID', '$H$'); // PHPBB salted
|
||||||
|
define('PASSWORD_ORIG_ID', '$P$'); // 'Original' code
|
||||||
|
define('PASSWORD_WORDPRESS_ID', '$P$'); // WordPress 2.8
|
||||||
|
|
||||||
define('PASSWORD_PHPBB_SALT',2);
|
|
||||||
define('PASSWORD_MAMBO_SALT',3);
|
|
||||||
define('PASSWORD_JOOMLA_SALT',4);
|
|
||||||
define('PASSWORD_GENERAL_MD5',5);
|
|
||||||
define('PASSWORD_PLAINTEXT',6);
|
|
||||||
define('PASSWORD_GENERAL_SHA1',7);
|
|
||||||
define('PASSWORD_WORDPRESS_SALT', 8);
|
|
||||||
define('PASSWORD_MAGENTO_SALT', 9);
|
|
||||||
|
|
||||||
// Supported formats:
|
|
||||||
define('PASSWORD_PHPBB_ID','$H$'); // PHPBB salted
|
|
||||||
define('PASSWORD_ORIG_ID','$P$'); // 'Original' code
|
|
||||||
define('PASSWORD_WORDPRESS_ID', '$P$'); // WordPress 2.8
|
|
||||||
|
|
||||||
|
|
||||||
class ExtendedPasswordHandler extends UserHandler
|
class ExtendedPasswordHandler extends UserHandler
|
||||||
{
|
{
|
||||||
var $itoa64; // Holds a string of 64 characters for base64 conversion
|
private $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; // Holds a string of 64 characters for base64 conversion
|
||||||
// var $iteration_count_log2; // Used to compute number of iterations in calculating hash
|
|
||||||
var $random_state = ''; // A (hopefully) random number
|
var $random_state = ''; // A (hopefully) random number
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor - just call parent
|
||||||
// Constructor
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
// Lookup string ready for base64 conversions
|
|
||||||
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
||||||
// Ancestor constructor
|
// Ancestor constructor
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return a number of random bytes as specified by $count
|
/**
|
||||||
function get_random_bytes($count)
|
* Return a number of random bytes as specified by $count
|
||||||
|
*/
|
||||||
|
private function get_random_bytes($count)
|
||||||
{
|
{
|
||||||
$this->random_state = md5($this->random_state.microtime().mt_rand(0,10000)); // This will 'auto seed'
|
$this->random_state = md5($this->random_state.microtime().mt_rand(0,10000)); // This will 'auto seed'
|
||||||
|
|
||||||
@@ -86,10 +95,14 @@ class ExtendedPasswordHandler extends UserHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Encode to base64 (each block of three 8-bit chars becomes 4 printable chars)
|
/**
|
||||||
// Use first $count characters of $input string
|
* Encode to base64 (each block of three 8-bit chars becomes 4 printable chars)
|
||||||
function encode64($input, $count)
|
* Use first $count characters of $input string
|
||||||
|
*/
|
||||||
|
private function encode64($input, $count)
|
||||||
{
|
{
|
||||||
|
return base64_encode(substr($input, 0, $count)); // @todo - check this works OK
|
||||||
|
/*
|
||||||
$output = '';
|
$output = '';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
do
|
do
|
||||||
@@ -106,14 +119,17 @@ class ExtendedPasswordHandler extends UserHandler
|
|||||||
} while ($i < $count);
|
} while ($i < $count);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Method for PHPBB3-style salted passwords, which begin '$H$', and WordPress-style salted passwords, which begin '$P$'
|
/**
|
||||||
// Given a plaintext password and the complete password/hash function (which includes any salt), calculate hash
|
* Method for PHPBB3-style salted passwords, which begin '$H$', and WordPress-style salted passwords, which begin '$P$'
|
||||||
// Returns FALSE on error
|
* Given a plaintext password and the complete password/hash function (which includes any salt), calculate hash
|
||||||
function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
|
* Returns FALSE on error
|
||||||
|
*/
|
||||||
|
private function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
|
||||||
{
|
{
|
||||||
$output = '*0';
|
$output = '*0';
|
||||||
if (substr($stored_password, 0, 2) == $output)
|
if (substr($stored_password, 0, 2) == $output)
|
||||||
@@ -173,15 +189,14 @@ class ExtendedPasswordHandler extends UserHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return array of supported password types - key is used internally, text is displayed
|
/**
|
||||||
function getPasswordTypes($include_core = FALSE)
|
* Return array of supported password types - key is used internally, text is displayed
|
||||||
|
*/
|
||||||
|
public function getPasswordTypes($includeExtended = TRUE)
|
||||||
{
|
{
|
||||||
$vals = array();
|
$vals = array();
|
||||||
if ($include_core)
|
|
||||||
{
|
|
||||||
$vals = array('md5' => IMPORTDB_LAN_7,'e107_salt' => IMPORTDB_LAN_8); // Methods supported in core
|
$vals = array('md5' => IMPORTDB_LAN_7,'e107_salt' => IMPORTDB_LAN_8); // Methods supported in core
|
||||||
}
|
if ($includeExtended)
|
||||||
if (is_bool($include_core))
|
|
||||||
{
|
{
|
||||||
$vals = array_merge($vals,array(
|
$vals = array_merge($vals,array(
|
||||||
'plaintext' => IMPORTDB_LAN_2,
|
'plaintext' => IMPORTDB_LAN_2,
|
||||||
@@ -191,15 +206,17 @@ class ExtendedPasswordHandler extends UserHandler
|
|||||||
'sha1' => IMPORTDB_LAN_6,
|
'sha1' => IMPORTDB_LAN_6,
|
||||||
'phpbb3_salt' => IMPORTDB_LAN_12,
|
'phpbb3_salt' => IMPORTDB_LAN_12,
|
||||||
'wordpress_salt' => IMPORTDB_LAN_13,
|
'wordpress_salt' => IMPORTDB_LAN_13,
|
||||||
'wordpress_salt' => IMPORTDB_LAN_14,
|
'magento_salt' => IMPORTDB_LAN_14,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return $vals;
|
return $vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return password type which relates to a specific foreign system
|
/**
|
||||||
function passwordMapping($ptype)
|
* Return password type which relates to a specific foreign system
|
||||||
|
*/
|
||||||
|
public function passwordMapping($ptype)
|
||||||
{
|
{
|
||||||
$maps = array(
|
$maps = array(
|
||||||
'plaintext' => PASSWORD_PLAINTEXT,
|
'plaintext' => PASSWORD_PLAINTEXT,
|
||||||
@@ -222,8 +239,20 @@ class ExtendedPasswordHandler extends UserHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extension of password validation -
|
/**
|
||||||
function CheckPassword($pword, $login_name, $stored_hash, $password_type = PASSWORD_DEFAULT_TYPE)
|
* Extension of password validation to handle more types
|
||||||
|
*
|
||||||
|
* @param string $pword - plaintext password as entered by user
|
||||||
|
* @param string $login_name - string used to log in (could actually be email address)
|
||||||
|
* @param string $stored_hash - required value for password to match
|
||||||
|
* @param integer $password_type - constant specifying the type of password to check against
|
||||||
|
*
|
||||||
|
* @return PASSWORD_INVALID|PASSWORD_VALID|string
|
||||||
|
* PASSWORD_INVALID if no match
|
||||||
|
* PASSWORD_VALID if valid password
|
||||||
|
* Return a new hash to store if valid password but non-preferred encoding
|
||||||
|
*/
|
||||||
|
public function CheckPassword($pword, $login_name, $stored_hash, $password_type = PASSWORD_DEFAULT_TYPE)
|
||||||
{
|
{
|
||||||
switch ($password_type)
|
switch ($password_type)
|
||||||
{
|
{
|
||||||
@@ -268,11 +297,11 @@ class ExtendedPasswordHandler extends UserHandler
|
|||||||
|
|
||||||
$pwHash = $salt ? md5($salt.$pword) : md5($pword);
|
$pwHash = $salt ? md5($salt.$pword) : md5($pword);
|
||||||
$stored_hash = $hash;
|
$stored_hash = $hash;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PASSWORD_E107_SALT :
|
case PASSWORD_E107_SALT :
|
||||||
return e107::getUserSession()->CheckPassword($password, $login_name, $stored_hash);
|
//return e107::getUserSession()->CheckPassword($password, $login_name, $stored_hash);
|
||||||
|
return parent::CheckPassword($password, $login_name, $stored_hash);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PASSWORD_PHPBB_SALT :
|
case PASSWORD_PHPBB_SALT :
|
||||||
|
@@ -1,21 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* imported DB authorisation for alt_auth plugin
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
|
|
* $Id$
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/importdb_auth.php,v $
|
*/
|
||||||
| $Revision$
|
|
||||||
| $Date$
|
/**
|
||||||
| $Author$
|
* e107 Alternate authorisation plugin
|
||||||
+----------------------------------------------------------------------------+
|
*
|
||||||
*/
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return values
|
return values
|
||||||
@@ -26,33 +29,47 @@
|
|||||||
AUTH_SUCCESS = valid login
|
AUTH_SUCCESS = valid login
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class auth_login
|
class auth_login
|
||||||
{
|
{
|
||||||
|
|
||||||
var $conf;
|
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||||
var $ErrorText;
|
public $ErrorText; // e107 error string on exit
|
||||||
|
private $conf; // Configuration parameters
|
||||||
|
|
||||||
function auth_login()
|
|
||||||
|
/**
|
||||||
|
* Read configuration
|
||||||
|
*
|
||||||
|
* @return AUTH_xxxx result code
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
global $sql;
|
|
||||||
$this->ErrorText = '';
|
$this->ErrorText = '';
|
||||||
$this->conf = array();
|
$this->conf = altAuthGetParams('importdb');
|
||||||
if (!$sql -> db_Select("alt_auth", "*", "auth_type = 'importdb' ")) return AUTH_NOCONNECT; // We should get at least one value
|
|
||||||
while ($row = $sql -> db_Fetch())
|
|
||||||
{
|
|
||||||
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
|
||||||
}
|
|
||||||
$this->Available = TRUE;
|
$this->Available = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function makeErrorText($extra = '')
|
private function makeErrorText($extra = '')
|
||||||
{
|
{
|
||||||
$this->ErrorText = $extra;
|
$this->ErrorText = $extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function login($uname, $pword, &$newvals, $connect_only = FALSE)
|
/**
|
||||||
|
* Validate login credentials
|
||||||
|
*
|
||||||
|
* @param string $uname - The user name requesting access
|
||||||
|
* @param string $pass - Password to use (usually plain text)
|
||||||
|
* @param pointer &$newvals - pointer to array to accept other data read from database
|
||||||
|
* @param boolean $connect_only - TRUE to simply connect to the database
|
||||||
|
*
|
||||||
|
* @return integer result (AUTH_xxxx)
|
||||||
|
*
|
||||||
|
* On a successful login, &$newvals array is filled with the requested data from the server
|
||||||
|
*/
|
||||||
|
public function login($uname, $pword, &$newvals, $connect_only = FALSE)
|
||||||
{
|
{
|
||||||
if ($connect_only) return AUTH_SUCCESS; // Big problem if can't connect to our own DB!
|
if ($connect_only) return AUTH_SUCCESS; // Big problem if can't connect to our own DB!
|
||||||
|
|
||||||
|
@@ -1,25 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* Alt_auth plugin - 'importdb' configuration
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
+----------------------------------------------------------------------------+
|
* $Id$
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
$eplug_admin = true;
|
$eplug_admin = true;
|
||||||
require_once('../../class2.php');
|
require_once('../../class2.php');
|
||||||
require_once(e_ADMIN.'auth.php');
|
require_once(e_ADMIN.'auth.php');
|
||||||
require_once(e_HANDLER.'form_handler.php');
|
require_once(e_HANDLER.'form_handler.php');
|
||||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_importdb_conf.php');
|
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_importdb_conf.php');
|
||||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||||
define("ALT_AUTH_ACTION", "importdb");
|
define('ALT_AUTH_ACTION', 'importdb');
|
||||||
require_once(e_PLUGIN."alt_auth/alt_auth_adminmenu.php");
|
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||||
require_once(e_PLUGIN."alt_auth/extended_password_handler.php");
|
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||||
|
|
||||||
|
|
||||||
if($_POST['update'])
|
if($_POST['update'])
|
||||||
@@ -30,7 +40,7 @@ if($_POST['update'])
|
|||||||
|
|
||||||
if($message)
|
if($message)
|
||||||
{
|
{
|
||||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
e107::getRender()->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,22 +48,13 @@ show_importdb_form();
|
|||||||
|
|
||||||
function show_importdb_form()
|
function show_importdb_form()
|
||||||
{
|
{
|
||||||
global $sql, $tp, $ns;
|
$ns = e107::getRender();
|
||||||
|
|
||||||
$password_methods = ExtendedPasswordHandler::GetPasswordTypes(FALSE);
|
|
||||||
|
|
||||||
|
|
||||||
// Get the parameters
|
$parm = altAuthGetParams('importdb');
|
||||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'importdb' ");
|
|
||||||
$parm = array();
|
|
||||||
while($row = $sql->db_Fetch())
|
|
||||||
{
|
|
||||||
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$frm = new form;
|
$frm = new form;
|
||||||
$text = $frm -> form_open("post", e_SELF);
|
$text = $frm -> form_open('post', e_SELF);
|
||||||
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
|
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
|
||||||
<colgroup span='2'>
|
<colgroup span='2'>
|
||||||
<col class='col-label' />
|
<col class='col-label' />
|
||||||
@@ -62,23 +63,10 @@ function show_importdb_form()
|
|||||||
|
|
||||||
|
|
||||||
$text .= "<tr><td colspan='2' class='forumheader3'>".IMPORTDB_LAN_11."</td></tr>";
|
$text .= "<tr><td colspan='2' class='forumheader3'>".IMPORTDB_LAN_11."</td></tr>";
|
||||||
/* $text .= $frm -> form_select_open("importdb_dbtype");
|
|
||||||
foreach($db_types as $k => $v)
|
|
||||||
{
|
|
||||||
$sel = ($parm['importdb_dbtype'] == $k) ? " Selected" : "";
|
|
||||||
$text .= $frm -> form_option($v, $sel, $k);
|
|
||||||
}
|
|
||||||
$text .= $frm -> form_select_close();
|
|
||||||
$text .= "</td></tr>";
|
|
||||||
*/
|
|
||||||
$text .= "<tr><td>".IMPORTDB_LAN_9."</td><td>";
|
$text .= "<tr><td>".IMPORTDB_LAN_9."</td><td>";
|
||||||
$text .= $frm -> form_select_open("importdb_password_method");
|
|
||||||
foreach($password_methods as $k => $v)
|
$text .= altAuthGetPasswordSelector('importdb_password_method', $frm, $parm['importdb_password_method'], TRUE);
|
||||||
{
|
|
||||||
$sel = ($parm['importdb_password_method'] == $k) ? " Selected" : "";
|
|
||||||
$text .= $frm -> form_option($v, $sel, $k);
|
|
||||||
}
|
|
||||||
$text .= $frm -> form_select_close();
|
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "</table><div class='buttons-bar center'>";
|
$text .= "</table><div class='buttons-bar center'>";
|
||||||
@@ -92,31 +80,8 @@ function show_importdb_form()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once(e_ADMIN."footer.php");
|
require_once(e_ADMIN.'footer.php');
|
||||||
|
|
||||||
/*
|
|
||||||
function update_importdb_prefs()
|
|
||||||
{
|
|
||||||
global $sql;
|
|
||||||
foreach($_POST as $k => $v)
|
|
||||||
{
|
|
||||||
$v = base64_encode(base64_encode($v));
|
|
||||||
|
|
||||||
if(preg_match("/importdb_/", $k))
|
|
||||||
{
|
|
||||||
if($sql -> db_Select("alt_auth", "*", "auth_type='importdb' AND auth_parmname='{$k}' "))
|
|
||||||
{
|
|
||||||
$sql -> db_Update("alt_auth", "auth_parmval='{$v}' WHERE auth_type='importdb' AND auth_parmname='{$k}' ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql -> db_Insert("alt_auth", "'importdb','{$k}','{$v}' ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "Settings Updated";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
function importdb_conf_adminmenu()
|
function importdb_conf_adminmenu()
|
||||||
{
|
{
|
||||||
|
@@ -14,6 +14,14 @@
|
|||||||
* $Author$
|
* $Author$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
define('LAN_AL_AUTH_01','Alt auth Settings changed');
|
define('LAN_AL_AUTH_01','Alt auth Settings changed');
|
||||||
define('LAN_AL_AUTH_02','Alt auth extended user classes changed');
|
define('LAN_AL_AUTH_02','Alt auth extended user classes changed');
|
||||||
define('LAN_AL_AUTH_03','Alt auth method settings changed');
|
define('LAN_AL_AUTH_03','Alt auth method settings changed');
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
@@ -12,6 +12,15 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
define('LAN_ALT_1', 'Primary authorisation type');
|
define('LAN_ALT_1', 'Primary authorisation type');
|
||||||
define('LAN_ALT_2', 'Update settings');
|
define('LAN_ALT_2', 'Update settings');
|
||||||
define('LAN_ALT_3', 'Choose Alternate Authorisation Type');
|
define('LAN_ALT_3', 'Choose Alternate Authorisation Type');
|
||||||
@@ -35,7 +44,7 @@ define('LAN_ALT_19', 'Photo field');
|
|||||||
define('LAN_ALT_20', 'Join date field');
|
define('LAN_ALT_20', 'Join date field');
|
||||||
define('LAN_ALT_21', 'Ban status field');
|
define('LAN_ALT_21', 'Ban status field');
|
||||||
define('LAN_ALT_22', 'Class membership field');
|
define('LAN_ALT_22', 'Class membership field');
|
||||||
define('LAN_ALT_23', 'XUP file field');
|
//define('LAN_ALT_23', 'XUP file field');
|
||||||
define('LAN_ALT_24', 'Password salt field');
|
define('LAN_ALT_24', 'Password salt field');
|
||||||
define('LAN_ALT_25', '(sometimes combined with password for added security)');
|
define('LAN_ALT_25', '(sometimes combined with password for added security)');
|
||||||
define('LAN_ALT_26', 'Database type:');
|
define('LAN_ALT_26', 'Database type:');
|
||||||
@@ -95,6 +104,18 @@ define('LAN_ALT_77', 'Only users in this class (on the database set above) are p
|
|||||||
define('LAN_ALT_78', 'Failed password action');
|
define('LAN_ALT_78', 'Failed password action');
|
||||||
define('LAN_ALT_79', 'If user exists in primary DB, but enters an incorrect password, how should that be handled?');
|
define('LAN_ALT_79', 'If user exists in primary DB, but enters an incorrect password, how should that be handled?');
|
||||||
|
|
||||||
|
define('IMPORTDB_LAN_2', 'Plain Text');
|
||||||
|
define('IMPORTDB_LAN_3', 'Joomla salted');
|
||||||
|
define('IMPORTDB_LAN_4', 'Mambo salted');
|
||||||
|
define('IMPORTDB_LAN_5', 'SMF (SHA1)');
|
||||||
|
define('IMPORTDB_LAN_6', 'Generic SHA1');
|
||||||
|
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
|
||||||
|
define('IMPORTDB_LAN_8', 'E107 salted (option 2.0 on)');
|
||||||
|
define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
|
||||||
|
define('IMPORTDB_LAN_13', 'WordPress salted');
|
||||||
|
define('IMPORTDB_LAN_14', 'Magento salted');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
define('LAN_ALT_FALLBACK', 'Use secondary authorisation');
|
define('LAN_ALT_FALLBACK', 'Use secondary authorisation');
|
||||||
define('LAN_ALT_FAIL', 'Failed login');
|
define('LAN_ALT_FAIL', 'Failed login');
|
||||||
|
@@ -1,5 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
* Language file
|
||||||
|
*
|
||||||
|
* $URL$
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
define('E107DB_LAN_1', 'E107 format database');
|
define('E107DB_LAN_1', 'E107 format database');
|
||||||
define('E107DB_LAN_9', 'Password Method:');
|
define('E107DB_LAN_9', 'Password Method:');
|
||||||
define('E107DB_LAN_10', 'Configure E107 db auth');
|
define('E107DB_LAN_10', 'Configure E107 db auth');
|
||||||
@@ -7,7 +29,7 @@ define('E107DB_LAN_11', 'Check the box against any field you wish to be transfer
|
|||||||
|
|
||||||
|
|
||||||
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
|
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
|
||||||
define('IMPORTDB_LAN_8', 'E107 salted (option 0.8 on)');
|
define('IMPORTDB_LAN_8', 'E107 salted (option 2.0 on)');
|
||||||
|
|
||||||
|
|
||||||
define('LAN_AUTHENTICATE_HELP','This authentication method is to be used with a second E107 database, which may use a different password format to this system. The
|
define('LAN_AUTHENTICATE_HELP','This authentication method is to be used with a second E107 database, which may use a different password format to this system. The
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
@@ -12,22 +12,32 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('IMPORTDB_LAN_1', 'Database type');
|
|
||||||
define('IMPORTDB_LAN_2', 'Plain Text');
|
/**
|
||||||
define('IMPORTDB_LAN_3', 'Joomla salted');
|
* e107 Alternate authorisation plugin
|
||||||
define('IMPORTDB_LAN_4', 'Mambo salted');
|
*
|
||||||
define('IMPORTDB_LAN_5', 'SMF (SHA1)');
|
* @package e107_plugins
|
||||||
define('IMPORTDB_LAN_6', 'Generic SHA1');
|
* @subpackage alt_auth
|
||||||
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
|
* @version $Id$;
|
||||||
define('IMPORTDB_LAN_8', 'E107 salted (option 0.8 on)');
|
*/
|
||||||
|
|
||||||
|
// Some password-related strings moved to admin_alt_auth.php for generic use
|
||||||
|
//define('IMPORTDB_LAN_1', 'Database type');
|
||||||
|
//define('IMPORTDB_LAN_2', 'Plain Text');
|
||||||
|
//define('IMPORTDB_LAN_3', 'Joomla salted');
|
||||||
|
//define('IMPORTDB_LAN_4', 'Mambo salted');
|
||||||
|
//define('IMPORTDB_LAN_5', 'SMF (SHA1)');
|
||||||
|
//define('IMPORTDB_LAN_6', 'Generic SHA1');
|
||||||
|
//define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
|
||||||
|
//define('IMPORTDB_LAN_8', 'E107 salted (option 2.0 on)');
|
||||||
define('IMPORTDB_LAN_9', 'Password Method:');
|
define('IMPORTDB_LAN_9', 'Password Method:');
|
||||||
define('IMPORTDB_LAN_10', 'Configure imported database password type');
|
define('IMPORTDB_LAN_10', 'Configure imported database password type');
|
||||||
define('IMPORTDB_LAN_11', 'This option is to be used when you have imported some other user-based system into E107.
|
define('IMPORTDB_LAN_11', 'This option is to be used when you have imported some other user-based system into E107.
|
||||||
It allows you to accept passwords encoded in the selected non-standard format.
|
It allows you to accept passwords encoded in the selected non-standard format.
|
||||||
Each user\'s password is converted to E107 format when they log in.');
|
Each user\'s password is converted to E107 format when they log in.');
|
||||||
define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
|
//define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
|
||||||
define('IMPORTDB_LAN_13', 'WordPress salted');
|
//define('IMPORTDB_LAN_13', 'WordPress salted');
|
||||||
define('IMPORTDB_LAN_14', 'Magento salted');
|
//define('IMPORTDB_LAN_14', 'Magento salted');
|
||||||
|
|
||||||
|
|
||||||
define('LAN_AUTHENTICATE_HELP','This authentication method is to be used <i>only</i> when you have imported a user database into E107, and the password is in an incompatible format. The
|
define('LAN_AUTHENTICATE_HELP','This authentication method is to be used <i>only</i> when you have imported a user database into E107, and the password is in an incompatible format. The
|
||||||
|
@@ -1,23 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
define("LDAPLAN_1", "Server address");
|
/*
|
||||||
define("LDAPLAN_2", "Base DN or Domain<br />LDAP - Enter BaseDN<br />AD - enter the fqdn eg ad.mydomain.co.uk");
|
* e107 website system
|
||||||
define("LDAPLAN_3", "LDAP Browsing user<br />Full context of the user who is able to search the directory.");
|
*
|
||||||
define("LDAPLAN_4", "LDAP Browsing password<br />Password for the LDAP Browsing user.");
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
define("LDAPLAN_5", "LDAP Version");
|
* Released under the terms and conditions of the
|
||||||
define("LDAPLAN_6", "Configure LDAP auth");
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
define("LDAPLAN_7", "eDirectory search filter:");
|
*
|
||||||
define("LDAPLAN_8", "This will be used to ensure the username is in the correct tree, <br />ie '(objectclass=inetOrgPerson)'");
|
* LDAP authorisation for alt_auth plugin - language file
|
||||||
define("LDAPLAN_9", "Current search filter will be:");
|
*
|
||||||
define("LDAPLAN_10", "Settings Updated");
|
* $URL$
|
||||||
define("LDAPLAN_11", "WARNING: It appears as if the ldap module is not currently available; setting your auth method to LDAP will probably not work!");
|
* $Id$
|
||||||
define("LDAPLAN_12", 'Server Type');
|
*/
|
||||||
define("LDAPLAN_13", 'Update settings');
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('LDAPLAN_1', 'Server address');
|
||||||
|
define('LDAPLAN_2', 'Base DN or Domain<br />LDAP - Enter BaseDN<br />AD - enter the fqdn eg ad.mydomain.co.uk');
|
||||||
|
define('LDAPLAN_3', 'LDAP Browsing user<br />Full context of the user who is able to search the directory.');
|
||||||
|
define('LDAPLAN_4', 'LDAP Browsing password<br />Password for the LDAP Browsing user.');
|
||||||
|
define('LDAPLAN_5', 'LDAP Version');
|
||||||
|
define('LDAPLAN_6', 'Configure LDAP auth');
|
||||||
|
define('LDAPLAN_7', 'eDirectory search filter:');
|
||||||
|
define('LDAPLAN_8', "This will be used to ensure the username is in the correct tree, <br />e.g. '(objectclass=inetOrgPerson)'");
|
||||||
|
define('LDAPLAN_9', 'Current search filter will be:');
|
||||||
|
define('LDAPLAN_10', 'Settings Updated');
|
||||||
|
define('LDAPLAN_11', 'WARNING: It appears that the ldap module is not currently available; setting your auth method to LDAP will probably not work!');
|
||||||
|
define('LDAPLAN_12', 'Server Type');
|
||||||
|
define('LDAPLAN_13', 'Update settings');
|
||||||
define('LDAPLAN_14', 'OU for AD (e.g. ou=itdept)');
|
define('LDAPLAN_14', 'OU for AD (e.g. ou=itdept)');
|
||||||
|
|
||||||
|
|
||||||
define('SHOW_COPY_HELP', TRUE);
|
define('SHOW_COPY_HELP', TRUE);
|
||||||
define('SHOW_CONVERSION_HELP', TRUE);
|
define('SHOW_CONVERSION_HELP', TRUE);
|
||||||
define('LAN_AUTHENTICATE_HELP','This method can be used to authenticate against most LDAP servers, including Novell\'s eDirectory and Microsoft\'s Active Directory. Refer to the wiki for further information.');
|
define('LAN_AUTHENTICATE_HELP','This method can be used to authenticate against most LDAP servers, including Novell\'s eDirectory and Microsoft\'s Active Directory. It requires that PHP\'s LDAP extension is loaded. Refer to the wiki for further information.');
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,14 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
define("OTHERDB_LAN_1", "Database Type:");
|
|
||||||
define("OTHERDB_LAN_2", "Server:");
|
/*
|
||||||
define("OTHERDB_LAN_3", "Username:");
|
* e107 website system
|
||||||
define("OTHERDB_LAN_4", "Password:");
|
*
|
||||||
define("OTHERDB_LAN_5", "Database");
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
define("OTHERDB_LAN_6", "Table");
|
* Released under the terms and conditions of the
|
||||||
define("OTHERDB_LAN_7", "Username Field:");
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
define("OTHERDB_LAN_8", "Password Field:");
|
*
|
||||||
define("OTHERDB_LAN_9", "Password Method:");
|
* Language file
|
||||||
define("OTHERDB_LAN_10", "Configure otherdb auth");
|
*
|
||||||
|
* $URL$
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
define('OTHERDB_LAN_1', 'Database Type:');
|
||||||
|
define('OTHERDB_LAN_2', 'Server:');
|
||||||
|
define('OTHERDB_LAN_3', 'Username:');
|
||||||
|
define('OTHERDB_LAN_4', 'Password:');
|
||||||
|
define('OTHERDB_LAN_5', 'Database');
|
||||||
|
define('OTHERDB_LAN_6', 'Table');
|
||||||
|
define('OTHERDB_LAN_7', 'Username Field:');
|
||||||
|
define('OTHERDB_LAN_8', 'Password Field:');
|
||||||
|
define('OTHERDB_LAN_9', 'Password Method:');
|
||||||
|
define('OTHERDB_LAN_10', 'Configure otherdb auth');
|
||||||
//define("OTHERDB_LAN_11", "To transfer a field value into the local database, specify the field name in the corresponding box below. Fields marked with
|
//define("OTHERDB_LAN_11", "To transfer a field value into the local database, specify the field name in the corresponding box below. Fields marked with
|
||||||
// an asterisk (*) are mandatory.<br />Leave the field blank for it not to be transferred at all");
|
// an asterisk (*) are mandatory.<br />Leave the field blank for it not to be transferred at all");
|
||||||
define('OTHERDB_LAN_12', 'Password Salt Field:');
|
define('OTHERDB_LAN_12', 'Password Salt Field:');
|
||||||
@@ -16,16 +40,6 @@ define('OTHERDB_LAN_13', '(Leave blank if not used)');
|
|||||||
define('OTHERDB_LAN_14', 'Email address Field:');
|
define('OTHERDB_LAN_14', 'Email address Field:');
|
||||||
define('OTHERDB_LAN_15', 'MySQL - generic database');
|
define('OTHERDB_LAN_15', 'MySQL - generic database');
|
||||||
|
|
||||||
define("IMPORTDB_LAN_2", 'Plain Text');
|
|
||||||
define("IMPORTDB_LAN_3", 'Joomla salted');
|
|
||||||
define("IMPORTDB_LAN_4", 'Mambo salted');
|
|
||||||
define("IMPORTDB_LAN_5", 'SMF (SHA1)');
|
|
||||||
define("IMPORTDB_LAN_6", 'Generic SHA1');
|
|
||||||
define("IMPORTDB_LAN_7", 'MD5 (E107 original)');
|
|
||||||
define("IMPORTDB_LAN_8", 'E107 salted (option 0.8 on)');
|
|
||||||
define("IMPORTDB_LAN_12", 'PHPBB2/PHPBB3 salted');
|
|
||||||
define("IMPORTDB_LAN_14", 'Magento salted');
|
|
||||||
|
|
||||||
|
|
||||||
define('SHOW_COPY_HELP', TRUE);
|
define('SHOW_COPY_HELP', TRUE);
|
||||||
define('SHOW_CONVERSION_HELP', TRUE);
|
define('SHOW_CONVERSION_HELP', TRUE);
|
||||||
|
@@ -1,4 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
* Language file
|
||||||
|
*
|
||||||
|
* $URL$
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
define('LAN_RADIUS_01', 'Server address');
|
define('LAN_RADIUS_01', 'Server address');
|
||||||
define('LAN_RADIUS_02', 'Shared secret');
|
define('LAN_RADIUS_02', 'Shared secret');
|
||||||
define('LAN_RADIUS_03', 'Server user');
|
define('LAN_RADIUS_03', 'Server user');
|
||||||
|
@@ -1,47 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* LDAP authorisation for alt_auth plugin
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
|
|
* $Id$
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_auth.php,v $
|
*/
|
||||||
| $Revision$
|
|
||||||
| $Date$
|
/**
|
||||||
| $Author$
|
* e107 Alternate authorisation plugin
|
||||||
+----------------------------------------------------------------------------+
|
*
|
||||||
*/
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
class auth_login
|
class auth_login
|
||||||
{
|
{
|
||||||
var $server;
|
private $server; // The LDAP server (array of possible servers)
|
||||||
var $dn;
|
private $dn; // LDAP domain
|
||||||
var $ou;
|
private $ou; // LDAP OU
|
||||||
var $usr;
|
private $usr; // User name to log on to server
|
||||||
var $pwd;
|
private $pwd; // Password to log on to server
|
||||||
var $serverType;
|
private $serverType; // Server type = LDAP/AD/eDirectory
|
||||||
var $ldapErrorCode;
|
public $ldapErrorCode; // LDAP error code on exit
|
||||||
var $ldapErrorText;
|
public $ldapErrorText; // LDAP error string on exit
|
||||||
var $ErrorText;
|
public $ErrorText; // e107 error string on exit
|
||||||
var $connection;
|
private $connection; // LDAP resource for connection
|
||||||
var $result;
|
private $ldapVersion; // Version of LDAP to use
|
||||||
var $ldapVersion;
|
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||||
var $Available;
|
private $filter; // Filter for eDirectory search
|
||||||
var $filter;
|
private $copyAttribs; // Any attributes which are to be copied on successful login
|
||||||
var $copyAttribs; // Any attributes which are to be copied on successful login
|
private $copyMethods; // Methods which are to be used to copy attributes
|
||||||
var $copyMethods;
|
|
||||||
|
|
||||||
function auth_login()
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read configuration, initialise connection to LDAP database
|
||||||
|
*
|
||||||
|
* @return AUTH_xxxx result code
|
||||||
|
*/
|
||||||
|
public function auth_login()
|
||||||
{
|
{
|
||||||
$this->copyAttribs = array();
|
$this->copyAttribs = array();
|
||||||
$this->copyMethods = array();
|
$this->copyMethods = array();
|
||||||
$sql = new db;
|
$sql = e107::getDB('altAuth');
|
||||||
$sql->db_Select("alt_auth", "*", "auth_type = 'ldap' ");
|
$sql->db_Select('alt_auth', '*', "auth_type = 'ldap' ");
|
||||||
while ($row = $sql->db_Fetch())
|
while ($row = $sql->db_Fetch())
|
||||||
{
|
{
|
||||||
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
||||||
@@ -55,7 +64,7 @@ class auth_login
|
|||||||
}
|
}
|
||||||
unset($row['auth_parmname']);
|
unset($row['auth_parmname']);
|
||||||
}
|
}
|
||||||
$this->server = explode(",", $ldap['ldap_server']);
|
$this->server = explode(',', $ldap['ldap_server']);
|
||||||
$this->serverType = $ldap['ldap_servertype'];
|
$this->serverType = $ldap['ldap_servertype'];
|
||||||
$this->dn = $ldap['ldap_basedn'];
|
$this->dn = $ldap['ldap_basedn'];
|
||||||
$this->ou = $ldap['ldap_ou'];
|
$this->ou = $ldap['ldap_ou'];
|
||||||
@@ -66,24 +75,35 @@ class auth_login
|
|||||||
|
|
||||||
if (!function_exists('ldap_connect'))
|
if (!function_exists('ldap_connect'))
|
||||||
{
|
{
|
||||||
$this->Available = false;
|
return AUTH_NORESOURCE;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->connect())
|
if (!$this->connect())
|
||||||
{
|
{
|
||||||
return AUTH_NOCONNECT;
|
return AUTH_NOCONNECT;
|
||||||
}
|
}
|
||||||
|
$this->Available = TRUE;
|
||||||
|
return AUTH_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeErrorText($extra = '')
|
|
||||||
|
/**
|
||||||
|
* Retrieve and construct error strings
|
||||||
|
*/
|
||||||
|
private function makeErrorText($extra = '')
|
||||||
{
|
{
|
||||||
$this->ldapErrorCode = ldap_errno($this->connection);
|
$this->ldapErrorCode = ldap_errno($this->connection);
|
||||||
$this->ldapErrorText = ldap_error($this->connection);
|
$this->ldapErrorText = ldap_error($this->connection);
|
||||||
$this->ErrorText = $extra . ' ' . $this->ldapErrorCode . ': ' . $this->ldapErrorText;
|
$this->ErrorText = $extra . ' ' . $this->ldapErrorCode . ': ' . $this->ldapErrorText;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect()
|
|
||||||
|
/**
|
||||||
|
* Connect to the LDAP server
|
||||||
|
*
|
||||||
|
* @return boolean TRUE for success, FALSE for failure
|
||||||
|
*/
|
||||||
|
public function connect()
|
||||||
{
|
{
|
||||||
foreach ($this->server as $key => $host)
|
foreach ($this->server as $key => $host)
|
||||||
{
|
{
|
||||||
@@ -104,7 +124,11 @@ class auth_login
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function close()
|
|
||||||
|
/**
|
||||||
|
* Close the connection to the LDAP server
|
||||||
|
*/
|
||||||
|
public function close()
|
||||||
{
|
{
|
||||||
if (!@ldap_close($this->connection))
|
if (!@ldap_close($this->connection))
|
||||||
{
|
{
|
||||||
@@ -117,6 +141,19 @@ class auth_login
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate login credentials
|
||||||
|
*
|
||||||
|
* @param string $uname - The user name requesting access
|
||||||
|
* @param string $pass - Password to use (usually plain text)
|
||||||
|
* @param pointer &$newvals - pointer to array to accept other data read from database
|
||||||
|
* @param boolean $connect_only - TRUE to simply connect to the server
|
||||||
|
*
|
||||||
|
* @return integer result (AUTH_xxxx)
|
||||||
|
*
|
||||||
|
* On a successful login, &$newvals array is filled with the requested data from the server
|
||||||
|
*/
|
||||||
function login($uname, $pass, &$newvals, $connect_only = false)
|
function login($uname, $pass, &$newvals, $connect_only = false)
|
||||||
{
|
{
|
||||||
/* Construct the full DN, eg:-
|
/* Construct the full DN, eg:-
|
||||||
@@ -248,8 +285,8 @@ class auth_login
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Login failed. Return false, together with the error code and text from
|
/* Login failed. Return error code.
|
||||||
** the LDAP server. The common error codes and reasons are listed below :
|
** The common error codes and reasons are listed below :
|
||||||
** (for iPlanet, other servers may differ)
|
** (for iPlanet, other servers may differ)
|
||||||
** 19 - Account locked out (too many invalid login attempts)
|
** 19 - Account locked out (too many invalid login attempts)
|
||||||
** 32 - User does not exist
|
** 32 - User does not exist
|
||||||
|
@@ -1,37 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* LDAP configuration for alt_auth plugin
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
|
|
* $Id$
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_conf.php,v $
|
*/
|
||||||
| $Revision$
|
|
||||||
| $Date$
|
/**
|
||||||
| $Author$
|
* e107 Alternate authorisation plugin
|
||||||
+----------------------------------------------------------------------------+
|
*
|
||||||
*/
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
$eplug_admin = true;
|
$eplug_admin = true;
|
||||||
require_once("../../class2.php");
|
require_once('../../class2.php');
|
||||||
require_once(e_ADMIN."auth.php");
|
require_once(e_ADMIN.'auth.php');
|
||||||
require_once(e_HANDLER."form_handler.php");
|
require_once(e_HANDLER.'form_handler.php');
|
||||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE."/admin_ldap_conf.php");
|
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_ldap_conf.php');
|
||||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||||
define('ALT_AUTH_ACTION', 'ldap');
|
define('ALT_AUTH_ACTION', 'ldap');
|
||||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||||
|
|
||||||
|
|
||||||
$server_types[1]="LDAP";
|
$server_types[1] = 'LDAP';
|
||||||
$server_types[2]="ActiveDirectory";
|
$server_types[2] = 'ActiveDirectory';
|
||||||
$server_types[3]="eDirectory";
|
$server_types[3] = 'eDirectory';
|
||||||
|
|
||||||
$ldap_ver[1]="2";
|
$ldap_ver[1]='2';
|
||||||
$ldap_ver[2]="3";
|
$ldap_ver[2]='3';
|
||||||
|
|
||||||
$message = '';
|
$message = '';
|
||||||
if($_POST['update'])
|
if($_POST['update'])
|
||||||
@@ -48,28 +52,24 @@ if(!function_exists('ldap_connect'))
|
|||||||
|
|
||||||
if($message)
|
if($message)
|
||||||
{
|
{
|
||||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$ldap['ldap_edirfilter'] == "";
|
$ldap = altAuthGetParams('ldap');
|
||||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'ldap' ");
|
if (!isset($ldap['ldap_edirfilter'])) $ldap['ldap_edirfilter'] == '';
|
||||||
while($row = $sql->db_Fetch())
|
|
||||||
{
|
|
||||||
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval'])); // Encoding is new for 0.8
|
|
||||||
}
|
|
||||||
//print_a($ldap);
|
//print_a($ldap);
|
||||||
|
|
||||||
$current_filter = "(&(cn=[USERNAME]){$ldap['ldap_edirfilter']})";
|
$current_filter = "(&(cn=[USERNAME]){$ldap['ldap_edirfilter']})";
|
||||||
|
|
||||||
$frm = new form;
|
$frm = new form;
|
||||||
$text = $frm -> form_open("post",e_SELF);
|
$text = $frm -> form_open('post',e_SELF);
|
||||||
$text .= "<table style='width:96%' class='fborder'>";
|
$text .= "<table style='width:96%' class='fborder'>";
|
||||||
$text .= "<tr><td class='forumheader3'>".LDAPLAN_12."</td><td class='forumheader3'>";
|
$text .= "<tr><td class='forumheader3'>".LDAPLAN_12."</td><td class='forumheader3'>";
|
||||||
$text .= $frm -> form_select_open("ldap_servertype");
|
$text .= $frm -> form_select_open("ldap_servertype");
|
||||||
foreach($server_types as $v)
|
foreach($server_types as $v)
|
||||||
{
|
{
|
||||||
$sel = ($ldap['ldap_servertype'] == $v) ? " Selected" : "";
|
$sel = ($ldap['ldap_servertype'] == $v) ? " Selected='selected'" : '';
|
||||||
$text .= $frm -> form_option($v, $sel, $v);
|
$text .= $frm -> form_option($v, $sel, $v);
|
||||||
}
|
}
|
||||||
$text .= $frm -> form_select_close();
|
$text .= $frm -> form_select_close();
|
||||||
@@ -98,7 +98,7 @@ $text .= $frm -> form_select_open("ldap_version");
|
|||||||
|
|
||||||
foreach($ldap_ver as $v)
|
foreach($ldap_ver as $v)
|
||||||
{
|
{
|
||||||
$sel = ($ldap['ldap_version'] == $v) ? " Selected" : "";
|
$sel = ($ldap['ldap_version'] == $v) ? " Selected='selected'" : "";
|
||||||
$text .= $frm -> form_option($v, $sel, $v);
|
$text .= $frm -> form_option($v, $sel, $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ $text .= $frm -> form_select_close();
|
|||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader3'>".LDAPLAN_7."<br /><span class='smalltext'>".LDAPLAN_8."</span></td><td class='forumheader3'>";
|
$text .= "<tr><td class='forumheader3'>".LDAPLAN_7."<br /><span class='smalltext'>".LDAPLAN_8."</span></td><td class='forumheader3'>";
|
||||||
$text .= $frm -> form_text("ldap_edirfilter", 35, $ldap['ldap_edirfilter'], 120);
|
$text .= $frm -> form_text('ldap_edirfilter', 35, $ldap['ldap_edirfilter'], 120);
|
||||||
$text .= "<br /><span class='smalltext'>".LDAPLAN_9."<br />".htmlentities($current_filter)."</span></td></tr>";
|
$text .= "<br /><span class='smalltext'>".LDAPLAN_9."<br />".htmlentities($current_filter)."</span></td></tr>";
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
|
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
|
||||||
@@ -115,16 +115,17 @@ $text .= "<br /><span class='smalltext'>".LDAPLAN_9."<br />".htmlentities($curre
|
|||||||
$text .= alt_auth_get_field_list('ldap',$frm, $ldap, FALSE);
|
$text .= alt_auth_get_field_list('ldap',$frm, $ldap, FALSE);
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
||||||
$text .= $frm -> form_button("submit", "update", LDAPLAN_13);
|
$text .= $frm -> form_button('submit', 'update', LDAPLAN_13);
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "</table>";
|
$text .= "</table>\n";
|
||||||
$text .= $frm -> form_close();
|
$text .= $frm -> form_close();
|
||||||
|
|
||||||
$ns -> tablerender(LDAPLAN_6,$text);
|
e107::getRender()->tablerender(LDAPLAN_6,$text);
|
||||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('ldap',$frm));
|
e107::getRender()->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('ldap',$frm));
|
||||||
|
|
||||||
|
require_once(e_ADMIN.'footer.php');
|
||||||
|
|
||||||
require_once(e_ADMIN."footer.php");
|
|
||||||
|
|
||||||
function ldap_conf_adminmenu()
|
function ldap_conf_adminmenu()
|
||||||
{
|
{
|
||||||
|
@@ -1,21 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* Alt_auth plugin - 'otherdb' authorisation handler
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
|
|
* $Id$
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/otherdb_auth.php,v $
|
*
|
||||||
| $Revision$
|
*/
|
||||||
| $Date$
|
|
||||||
| $Author$
|
/**
|
||||||
+----------------------------------------------------------------------------+
|
* e107 Alternate authorisation plugin
|
||||||
*/
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return values
|
return values
|
||||||
@@ -29,35 +33,53 @@
|
|||||||
class auth_login
|
class auth_login
|
||||||
{
|
{
|
||||||
|
|
||||||
var $Available;
|
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||||
var $ErrorText;
|
public $ErrorText; // e107 error string on exit
|
||||||
var $conf; // Configuration parameters
|
private $conf; // Configuration parameters
|
||||||
|
|
||||||
function auth_login()
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read configuration
|
||||||
|
*
|
||||||
|
* @return AUTH_xxxx result code
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
global $sql;
|
|
||||||
$this->conf = array();
|
|
||||||
$this->ErrorText = '';
|
$this->ErrorText = '';
|
||||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'otherdb' ");
|
$this->conf = altAuthGetParams('otherdb');
|
||||||
while($row = $sql -> db_Fetch())
|
|
||||||
{
|
|
||||||
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
|
||||||
}
|
|
||||||
$this->Available = TRUE;
|
$this->Available = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add the reconnect function in here - might be needed
|
|
||||||
function makeErrorText($extra = '')
|
/**
|
||||||
|
* Retrieve and construct error strings
|
||||||
|
*
|
||||||
|
* @todo - test whether reconnect to DB is required (shouldn't be)
|
||||||
|
*/
|
||||||
|
private function makeErrorText($extra = '')
|
||||||
{
|
{
|
||||||
$this->ErrorText = $extra;
|
$this->ErrorText = $extra;
|
||||||
global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
//global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
||||||
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
|
//$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function login($uname, $pword, &$newvals, $connect_only = FALSE)
|
/**
|
||||||
|
* Validate login credentials
|
||||||
|
*
|
||||||
|
* @param string $uname - The user name requesting access
|
||||||
|
* @param string $pass - Password to use (usually plain text)
|
||||||
|
* @param pointer &$newvals - pointer to array to accept other data read from database
|
||||||
|
* @param boolean $connect_only - TRUE to simply connect to the database
|
||||||
|
*
|
||||||
|
* @return integer result (AUTH_xxxx)
|
||||||
|
*
|
||||||
|
* On a successful login, &$newvals array is filled with the requested data from the server
|
||||||
|
*/
|
||||||
|
public function login($uname, $pword, &$newvals, $connect_only = FALSE)
|
||||||
{
|
{
|
||||||
//Attempt to open connection to sql database
|
//Attempt to open connection to sql database
|
||||||
if(!$res = mysql_connect($this->conf['otherdb_server'], $this->conf['otherdb_username'], $this->conf['otherdb_password']))
|
if(!$res = mysql_connect($this->conf['otherdb_server'], $this->conf['otherdb_username'], $this->conf['otherdb_password']))
|
||||||
|
@@ -1,54 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
* e107 website system
|
||||||
| e107 website system
|
*
|
||||||
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Released under the terms and conditions of the
|
||||||
| http://e107.org
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
|
*
|
||||||
|
|
* Alt_auth plugin - 'otherdb' configuration
|
||||||
| Released under the terms and conditions of the
|
*
|
||||||
| GNU General Public License (http://gnu.org).
|
* $URL$
|
||||||
+----------------------------------------------------------------------------+
|
* $Id$
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e107 Alternate authorisation plugin
|
||||||
|
*
|
||||||
|
* @package e107_plugins
|
||||||
|
* @subpackage alt_auth
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
$eplug_admin = true;
|
$eplug_admin = true;
|
||||||
require_once("../../class2.php");
|
require_once('../../class2.php');
|
||||||
require_once(e_ADMIN."auth.php");
|
require_once(e_ADMIN.'auth.php');
|
||||||
require_once(e_HANDLER."form_handler.php");
|
require_once(e_HANDLER.'form_handler.php');
|
||||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_otherdb_conf.php');
|
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_otherdb_conf.php');
|
||||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||||
define('ALT_AUTH_ACTION', 'otherdb');
|
define('ALT_AUTH_ACTION', 'otherdb');
|
||||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||||
|
|
||||||
|
|
||||||
if($_POST['update'])
|
if($_POST['update'])
|
||||||
{
|
{
|
||||||
// $message = update_otherdb_prefs();
|
|
||||||
$message = alt_auth_post_options('otherdb');
|
$message = alt_auth_post_options('otherdb');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($message)
|
if($message)
|
||||||
{
|
{
|
||||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
show_otherdb_form();
|
show_otherdb_form();
|
||||||
|
|
||||||
function show_otherdb_form()
|
function show_otherdb_form()
|
||||||
{
|
{
|
||||||
global $sql, $tp, $ns;
|
$ns = e107::getRender();
|
||||||
|
|
||||||
|
$parm = altAuthGetParams('otherdb');
|
||||||
$password_methods = ExtendedPasswordHandler::GetPasswordTypes(TRUE);
|
|
||||||
// $db_types = array("e107" => "mysql - e107 database", "mysql" => "mysql - generic database");
|
|
||||||
|
|
||||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'otherdb' ");
|
|
||||||
$parm = array();
|
|
||||||
while($row = $sql->db_Fetch())
|
|
||||||
{
|
|
||||||
$parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$frm = new form;
|
$frm = new form;
|
||||||
$text = $frm -> form_open("post", e_SELF);
|
$text = $frm -> form_open("post", e_SELF);
|
||||||
@@ -60,13 +62,9 @@ function show_otherdb_form()
|
|||||||
|
|
||||||
$text .= alt_auth_get_db_fields('otherdb', $frm, $parm, 'server|uname|pwd|db|table|ufield|pwfield|salt');
|
$text .= alt_auth_get_db_fields('otherdb', $frm, $parm, 'server|uname|pwd|db|table|ufield|pwfield|salt');
|
||||||
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_9."</td><td class='forumheader3'>";
|
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_9."</td><td class='forumheader3'>";
|
||||||
$text .= $frm -> form_select_open("otherdb_password_method");
|
|
||||||
foreach($password_methods as $k => $v)
|
$text .= altAuthGetPasswordSelector('otherdb_password_method', $frm, $parm['otherdb_password_method'], TRUE);
|
||||||
{
|
|
||||||
$sel = ($parm['otherdb_password_method'] == $k) ? " Selected" : "";
|
|
||||||
$text .= $frm -> form_option($v, $sel, $k);
|
|
||||||
}
|
|
||||||
$text .= $frm -> form_select_close();
|
|
||||||
$text .= "</td></tr>";
|
$text .= "</td></tr>";
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
|
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
|
||||||
@@ -74,10 +72,10 @@ function show_otherdb_form()
|
|||||||
$text .= alt_auth_get_field_list('otherdb',$frm, $parm, FALSE);
|
$text .= alt_auth_get_field_list('otherdb',$frm, $parm, FALSE);
|
||||||
|
|
||||||
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
||||||
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
$text .= $frm -> form_button('submit', 'update', LAN_ALT_UPDATESET);
|
||||||
$text .= "</td></tr>";
|
$text .= '</td></tr>';
|
||||||
|
|
||||||
$text .= "</table>";
|
$text .= '</table>';
|
||||||
$text .= $frm -> form_close();
|
$text .= $frm -> form_close();
|
||||||
|
|
||||||
$ns -> tablerender(OTHERDB_LAN_10, $text);
|
$ns -> tablerender(OTHERDB_LAN_10, $text);
|
||||||
@@ -85,7 +83,7 @@ function show_otherdb_form()
|
|||||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('otherdb',$frm));
|
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('otherdb',$frm));
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once(e_ADMIN."footer.php");
|
require_once(e_ADMIN.'footer.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -31,25 +31,26 @@ define('RADIUS_DEBUG',TRUE);
|
|||||||
class auth_login
|
class auth_login
|
||||||
{
|
{
|
||||||
|
|
||||||
var $server;
|
private $server;
|
||||||
var $secret;
|
private $secret;
|
||||||
var $port;
|
private $port;
|
||||||
var $usr;
|
private $usr;
|
||||||
var $pwd;
|
private $pwd;
|
||||||
var $ErrorText;
|
private $connection; // Handle to use on successful creation
|
||||||
var $connection; // Handle to use on successful creation
|
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||||
var $result;
|
public $ErrorText; // e107 error string on exit
|
||||||
var $Available;
|
|
||||||
|
|
||||||
function auth_login()
|
|
||||||
|
/**
|
||||||
|
* Read configuration, initialise connection to LDAP database
|
||||||
|
*
|
||||||
|
* @return AUTH_xxxx result code
|
||||||
|
*/
|
||||||
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->copyAttribs = array();
|
$this->copyAttribs = array();
|
||||||
$sql = new db;
|
$radius = altAuthGetParams('radius');
|
||||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'radius' ");
|
|
||||||
while($row = $sql -> db_Fetch())
|
|
||||||
{
|
|
||||||
$radius[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
|
||||||
}
|
|
||||||
$this->server = explode(',',$radius['radius_server']);
|
$this->server = explode(',',$radius['radius_server']);
|
||||||
$this->port = 1812; // Assume fixed port number for now - 1812 (UDP) is listed for servers, 1645 for authentification. (1646, 1813 for accounting)
|
$this->port = 1812; // Assume fixed port number for now - 1812 (UDP) is listed for servers, 1645 for authentification. (1646, 1813 for accounting)
|
||||||
// (A Microsoft app note says 1812 is the RFC2026-compliant port number. (http://support.microsoft.com/kb/230786)
|
// (A Microsoft app note says 1812 is the RFC2026-compliant port number. (http://support.microsoft.com/kb/230786)
|
||||||
@@ -66,18 +67,22 @@ class auth_login
|
|||||||
$this->ErrorText = '';
|
$this->ErrorText = '';
|
||||||
if(!function_exists('radius_auth_open'))
|
if(!function_exists('radius_auth_open'))
|
||||||
{
|
{
|
||||||
$this->Available = FALSE;
|
return AUTH_NORESOURCE;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this -> connect())
|
if(!$this -> connect())
|
||||||
{
|
{
|
||||||
return AUTH_NOCONNECT;
|
return AUTH_NOCONNECT;
|
||||||
}
|
}
|
||||||
|
$this->Available = TRUE;
|
||||||
|
return AUTH_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve and construct error strings
|
||||||
|
*/
|
||||||
function makeErrorText($extra = '')
|
function makeErrorText($extra = '')
|
||||||
{
|
{
|
||||||
$this->ErrorText = $extra.radius_strerror($this->connection) ;
|
$this->ErrorText = $extra.radius_strerror($this->connection) ;
|
||||||
@@ -88,9 +93,13 @@ class auth_login
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to connect to a radius server
|
||||||
|
*
|
||||||
|
* @return boolean TRUE for success, FALSE for failure
|
||||||
|
*/
|
||||||
function connect()
|
function connect()
|
||||||
{
|
{
|
||||||
// Try to connect to a radius server
|
|
||||||
if (!($this->connection = radius_auth_open()))
|
if (!($this->connection = radius_auth_open()))
|
||||||
{
|
{
|
||||||
$this->makeErrorText('RADIUS open failed: ') ;
|
$this->makeErrorText('RADIUS open failed: ') ;
|
||||||
@@ -109,6 +118,9 @@ class auth_login
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the connection to the Radius server
|
||||||
|
*/
|
||||||
function close()
|
function close()
|
||||||
{
|
{
|
||||||
if ( !radius_close( $this->connection)) // (Not strictly necessary, but tidy)
|
if ( !radius_close( $this->connection)) // (Not strictly necessary, but tidy)
|
||||||
@@ -124,6 +136,18 @@ class auth_login
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate login credentials
|
||||||
|
*
|
||||||
|
* @param string $uname - The user name requesting access
|
||||||
|
* @param string $pass - Password to use (usually plain text)
|
||||||
|
* @param pointer &$newvals - pointer to array to accept other data read from database
|
||||||
|
* @param boolean $connect_only - TRUE to simply connect to the server
|
||||||
|
*
|
||||||
|
* @return integer result (AUTH_xxxx)
|
||||||
|
*
|
||||||
|
* On a successful login, &$newvals array is filled with the requested data from the server
|
||||||
|
*/
|
||||||
function login($uname, $pass, &$newvals, $connect_only = FALSE)
|
function login($uname, $pass, &$newvals, $connect_only = FALSE)
|
||||||
{
|
{
|
||||||
// Create authentification request
|
// Create authentification request
|
||||||
|
Reference in New Issue
Block a user