1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 04:40:44 +02:00

Issue #84 - review/tidy up alt_auth plugin.

Further testing needed.
This commit is contained in:
SteveD
2013-01-21 22:08:48 +00:00
parent 25da842c5e
commit 5457247787
14 changed files with 2599 additions and 2489 deletions

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2012 e107 Inc (e107.org) * Copyright (C) 2008-2013 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)
* *
@@ -31,11 +31,6 @@ TODO:
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
if (!is_object(vartrue($euf)))
{
require_once(e_HANDLER.'user_extended_class.php');
$euf = new e107_user_extended;
}
define('AUTH_SUCCESS', -1); define('AUTH_SUCCESS', -1);
@@ -46,8 +41,23 @@ if (!is_object(vartrue($euf)))
define('AUTH_NOT_AVAILABLE', 5); define('AUTH_NOT_AVAILABLE', 5);
require_once(e_HANDLER.'user_extended_class.php');
require_once(e_PLUGIN.'alt_auth/alt_auth_login_class.php'); // Has base methods class
/**
class alt_auth_admin extends alt_auth_base
{
private $euf = FALSE;
public function __construct()
{
$this->euf = new e107_user_extended;
}
/**
* Get list of supported authentication methods * Get list of supported authentication methods
* Searches for files *_auth.php in the plugin directory * Searches for files *_auth.php in the plugin directory
* *
@@ -55,34 +65,34 @@ if (!is_object(vartrue($euf)))
* *
* @return array of authentication methods in value fields * @return array of authentication methods in value fields
*/ */
function alt_auth_get_authlist($incE107 = TRUE) public 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];
} }
} }
closedir($handle); closedir($handle);
return $authlist; return $authlist;
} }
/** /**
* Return HTML for selector for authentication method * Return HTML for selector for authentication method
* *
* @param string $name - the name of the selector * @param string $name - the name of the selector
* @param string $curval - current value (if any) * @param string $curval - current value (if any)
* @param string $optlist - comma-separated list of options to be included as choices * @param string $optlist - comma-separated list of options to be included as choices
*/ */
function alt_auth_get_dropdown($name, $curval = '', $options = '') public function alt_auth_get_dropdown($name, $curval = '', $options = '')
{ {
$optList = explode(',', $options); $optList = explode(',', $options);
$authList = array_merge($optList, alt_auth_get_authlist(FALSE)); $authList = array_merge($optList, $this->alt_auth_get_authlist(FALSE));
$ret = "<select class='tbox' name='{$name}'>\n"; $ret = "<select class='tbox' name='{$name}'>\n";
foreach ($authList as $v) foreach ($authList as $v)
{ {
@@ -91,16 +101,16 @@ function alt_auth_get_dropdown($name, $curval = '', $options = '')
} }
$ret .= "</select>\n"; $ret .= "</select>\n";
return $ret; return $ret;
} }
/** /**
* All user fields which might, just possibly, be transferred. The array key is the corresponding field in the E107 user database; code prefixes it * 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 * 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. * '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( private $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'),
'user_name' => array('prompt' => LAN_ALT_14, 'default' => 'user_name', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''), 'user_name' => array('prompt' => LAN_ALT_14, 'default' => 'user_name', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
@@ -112,22 +122,21 @@ $alt_auth_user_fields = array(
'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)
); );
/** /**
* Returns a block of table rows with user DB fields and either checkboxes or entry boxes * Returns a block of table rows with user DB fields and either checkboxes or entry boxes
* *
* @param string $tableType is the prefix used, without the following underscore * @param string $tableType is the prefix used, without the following underscore
* @param $frm is the form object to use to create the text * @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 * @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) public function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
{ {
global $alt_auth_user_fields;
$ret = ''; $ret = '';
foreach ($alt_auth_user_fields as $f => $v) foreach ($this->alt_auth_user_fields as $f => $v)
{ {
if (varsettrue($v['showAll']) || varsettrue($v[$tableType])) if (varsettrue($v['showAll']) || varsettrue($v[$tableType]))
{ {
@@ -139,7 +148,7 @@ function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
$ret .= "<br /><span class='smalltext'>".$v['help']."</span>"; $ret .= "<br /><span class='smalltext'>".$v['help']."</span>";
} }
$ret .= "</td><td$log>"; $ret .= "</td><td$log>";
// $fieldname = $tableType.'_'.$v['optname']; // $fieldname = $tableType.'_'.$v['optname'];
$fieldname = $tableType.'_xf_'.$f; // Name of the input box $fieldname = $tableType.'_xf_'.$f; // Name of the input box
$value = varset($v['default'],''); $value = varset($v['default'],'');
if (is_array($value)) if (is_array($value))
@@ -148,7 +157,7 @@ function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
} }
if (isset($v[$tableType.'_field'])) $value = $v[$tableType.'_field']; if (isset($v[$tableType.'_field'])) $value = $v[$tableType.'_field'];
if (isset($parm[$fieldname])) $value = $parm[$fieldname]; if (isset($parm[$fieldname])) $value = $parm[$fieldname];
// echo "Field: {$fieldname} => {$value}<br />"; // echo "Field: {$fieldname} => {$value}<br />";
if ($asCheckboxes) if ($asCheckboxes)
{ {
$ret .= $frm -> form_checkbox($fieldname, 1, $value); $ret .= $frm -> form_checkbox($fieldname, 1, $value);
@@ -160,48 +169,47 @@ function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
{ {
$fieldMethod = $tableType.'_pm_'.$f; // Processing method ID code $fieldMethod = $tableType.'_pm_'.$f; // Processing method ID code
$method = varset($parm[$fieldMethod],''); $method = varset($parm[$fieldMethod],'');
$ret .= '&nbsp;&nbsp;'.alt_auth_processing($fieldMethod,$v['method'], $method); $ret .= '&nbsp;&nbsp;'.$this->alt_auth_processing($fieldMethod,$v['method'], $method);
} }
} }
$ret .= "</td></tr>\n"; $ret .= "</td></tr>\n";
} }
} }
return $ret; return $ret;
} }
/** /**
* 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 * @param string $tableType is the prefix used, without the following underscore
* *
* @return array * @return array
*/ */
function alt_auth_get_allowed_fields($tableType) public function alt_auth_get_allowed_fields($tableType)
{ {
global $alt_auth_user_fields;
$ret = array(); $ret = array();
foreach ($alt_auth_user_fields as $f => $v) foreach ($this->alt_auth_user_fields as $f => $v)
{ {
if (varsettrue($v['showAll']) || varsettrue($v[$tableType])) if (varsettrue($v['showAll']) || varsettrue($v[$tableType]))
{ {
// $fieldname = $tableType.'_'.$v['optname']; // $fieldname = $tableType.'_'.$v['optname'];
$fieldname = $tableType.'_xf_'.$f; // Name of the input box $fieldname = $tableType.'_xf_'.$f; // Name of the input box
$ret[$fieldname] = '1'; $ret[$fieldname] = '1';
} }
} }
return $ret; return $ret;
} }
/** /**
* 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() public function add_extended_fields()
{ {
global $alt_auth_user_fields, $euf, $pref; global $pref;
if (!isset($pref['auth_extended'])) return; if (!isset($pref['auth_extended'])) return;
if (!$pref['auth_extended']) return; if (!$pref['auth_extended']) return;
@@ -209,14 +217,14 @@ function add_extended_fields()
static $fieldsAdded = FALSE; static $fieldsAdded = FALSE;
if ($fieldsAdded) return; if ($fieldsAdded) return;
$xFields = $euf->user_extended_get_fieldList('','user_extended_struct_name'); $xFields = $this->euf->user_extended_get_fieldList('','user_extended_struct_name');
// print_a($xFields); // print_a($xFields);
$fields = explode(',',$pref['auth_extended']); $fields = explode(',',$pref['auth_extended']);
foreach ($fields as $f) foreach ($fields as $f)
{ {
if (isset($xFields[$f])) if (isset($xFields[$f]))
{ {
$alt_auth_user_fields['x_'.$f] = array('prompt' => varset($xFields[$f]['user_extended_struct_text'],'').' ('.$f.')', $this->alt_auth_user_fields['x_'.$f] = array('prompt' => varset($xFields[$f]['user_extended_struct_text'],'').' ('.$f.')',
'default' => varset($xFields[$f]['default'],''), 'default' => varset($xFields[$f]['default'],''),
'optional' => TRUE, 'optional' => TRUE,
'showAll' => TRUE, // Show for all methods - in principle, its likely to be wanted for all 'showAll' => TRUE, // Show for all methods - in principle, its likely to be wanted for all
@@ -225,14 +233,14 @@ function add_extended_fields()
} }
} }
$fieldsAdded = TRUE; $fieldsAdded = TRUE;
} }
/** /**
* List of the standard fields which may be displayed for any method. * List of the standard fields which may be displayed for any method.
*/ */
$common_fields = array( private $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' => ''),
'pwd' => array('fieldname' => 'password', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_34, 'help' => ''), 'pwd' => array('fieldname' => 'password', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_34, 'help' => ''),
@@ -243,11 +251,11 @@ $common_fields = array(
'pwfield'=> array('fieldname' => 'password_field','size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_38, 'help' => ''), 'pwfield'=> array('fieldname' => 'password_field','size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_38, 'help' => ''),
'salt' => array('fieldname' => 'password_salt','size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_24, 'help' => LAN_ALT_25), 'salt' => array('fieldname' => 'password_salt','size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_24, 'help' => LAN_ALT_25),
'classfilt' => array('fieldname' => 'filter_class', 'size' => 10, 'max_size' => 8, 'prompt' => LAN_ALT_76, 'help' => LAN_ALT_77) 'classfilt' => array('fieldname' => 'filter_class', 'size' => 10, 'max_size' => 8, 'prompt' => LAN_ALT_76, 'help' => LAN_ALT_77)
); );
/** /**
* Return the HTML for all server-related fields required for configuration of a particular method. * 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 * Each is a row of a table having two columns (no <table>...</table> etc added, so can be embedded in a larger table
* *
@@ -257,13 +265,11 @@ $common_fields = array(
* @param string $fields is a list of the fields to display, separated by '|'. The names are the key values from $common_fields table * @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') public function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pwd|db|table|ufield|pwfield')
{ {
global $common_fields;
$opts = explode('|',$fields); $opts = explode('|',$fields);
$ret = ''; $ret = '';
foreach ($common_fields as $fn => $cf) foreach ($this->common_fields as $fn => $cf)
{ {
if (in_array($fn,$opts)) if (in_array($fn,$opts))
{ {
@@ -276,21 +282,21 @@ function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pw
} }
} }
return $ret; return $ret;
} }
/** /**
* Write all the options for a particular authentication type to the DB * 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 * @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) public function alt_auth_post_options($prefix)
{ {
global $common_fields, $sql, $admin_log; $sql = e107::getDb();
$lprefix = $prefix.'_'; $lprefix = $prefix.'_';
$user_fields = alt_auth_get_allowed_fields($prefix); // Need this list in case checkboxes for parameters $user_fields = $this->alt_auth_get_allowed_fields($prefix); // Need this list in case checkboxes for parameters
foreach ($user_fields as $k => $v) foreach ($user_fields as $k => $v)
{ {
if (!isset($_POST[$k])) if (!isset($_POST[$k]))
@@ -316,13 +322,13 @@ function alt_auth_post_options($prefix)
} }
} }
} }
$admin_log->log_event('AUTH_03',$prefix,E_LOG_INFORMATIVE,''); e107::getAdminLog()->log_event('AUTH_03',$prefix,E_LOG_INFORMATIVE,'');
return LAN_ALT_UPDATED; return LAN_ALT_UPDATED;
} }
/** /**
* Get the HTML for a password type selector. * Get the HTML for a password type selector.
* *
* @param string $name - name to be used for selector * @param string $name - name to be used for selector
@@ -330,8 +336,8 @@ function alt_auth_post_options($prefix)
* @param string $currentSelection - current value (if any) * @param string $currentSelection - current value (if any)
* @param boolean $getExtended - return all supported password types if TRUE, 'core' password types if FALSE * @param boolean $getExtended - return all supported password types if TRUE, 'core' password types if FALSE
*/ */
function altAuthGetPasswordSelector($name, $frm, $currentSelection = '', $getExtended = FALSE) public function altAuthGetPasswordSelector($name, $frm, $currentSelection = '', $getExtended = FALSE)
{ {
$password_methods = ExtendedPasswordHandler::GetPasswordTypes($getExtended); $password_methods = ExtendedPasswordHandler::GetPasswordTypes($getExtended);
$text = ""; $text = "";
$text .= $frm->form_select_open($name); $text .= $frm->form_select_open($name);
@@ -342,32 +348,12 @@ function altAuthGetPasswordSelector($name, $frm, $currentSelection = '', $getExt
} }
$text .= $frm->form_select_close(); $text .= $frm->form_select_close();
return $text; 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. * Return the HTML needed to display the test form.
* *
* @param string $prefix - the type of connection being tested * @param string $prefix - the type of connection being tested
@@ -375,8 +361,8 @@ function altAuthGetParams($prefix)
* *
* if $_POST['testauth'] is set, attempts to validate the connection, and displays any returned values * if $_POST['testauth'] is set, attempts to validate the connection, and displays any returned values
*/ */
function alt_auth_test_form($prefix, $frm) public function alt_auth_test_form($prefix, $frm)
{ {
$text = $frm -> form_open('post', e_SELF, 'testform'); $text = $frm -> form_open('post', e_SELF, 'testform');
$text .= "<table class='table adminform'> $text .= "<table class='table adminform'>
<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>";
@@ -450,22 +436,22 @@ function alt_auth_test_form($prefix, $frm)
$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 .= e107::getForm()->admin_button('testauth', LAN_ALT_47,'other'); $text .= e107::getForm()->admin_button('testauth', LAN_ALT_47,'other');
$text .= "</td></tr>"; $text .= "</td></tr>";
$text .= "</table>"; $text .= "</table>";
$text .= $frm->form_close(); $text .= $frm->form_close();
return $text; return $text;
} }
//----------------------------------------------- //-----------------------------------------------
// VALUE COPY METHOD SELECTION // VALUE COPY METHOD SELECTION
//----------------------------------------------- //-----------------------------------------------
$procListOpts = array( private $procListOpts = array(
'none' => LAN_ALT_70, 'none' => LAN_ALT_70,
'bool1' => LAN_ALT_71, 'bool1' => LAN_ALT_71,
'ucase' => LAN_ALT_72, 'ucase' => LAN_ALT_72,
@@ -474,22 +460,23 @@ $procListOpts = array(
'ucwords' => LAN_ALT_75 'ucwords' => LAN_ALT_75
); );
// Return a 'select' box for available processing methods /**
function alt_auth_processing($selName, $allowed='*', $curVal='') * Return a 'select' box for available processing methods
{ */
global $procListOpts; public function alt_auth_processing($selName, $allowed='*', $curVal='')
{
if (($allowed == 'none') || ($allowed == '')) return ''; if (($allowed == 'none') || ($allowed == '')) return '';
if ($allowed == '*') if ($allowed == '*')
{ {
$valid = $procListOpts; // We just want all the array keys to exist! $valid = $this->procListOpts; // We just want all the array keys to exist!
} }
else else
{ {
$valid = array_flip(explode(',',$allowed)); $valid = array_flip(explode(',', $allowed));
$valid['none'] = '1'; // Make sure this key exists - value doesn't matter $valid['none'] = '1'; // Make sure this key exists - value doesn't matter
} }
$ret = "<select class='tbox' name='{$selName}' id='{$selName}'>\n"; $ret = "<select class='tbox' name='{$selName}' id='{$selName}'>\n";
foreach ($procListOpts as $k => $v) foreach ($this->procListOpts as $k => $v)
{ {
if (isset($valid[$k])) if (isset($valid[$k]))
{ {
@@ -498,24 +485,25 @@ function alt_auth_processing($selName, $allowed='*', $curVal='')
} }
} }
$ret .= "</select>\n"; $ret .= "</select>\n";
// $ret .= $selName.':'.$curVal; // $ret .= $selName.':'.$curVal;
return $ret; return $ret;
}
} }
function alt_auth_adminmenu() function alt_auth_adminmenu()
{ {
global $authlist; echo ' ';
echo " ";
if(!is_array($authlist)) if(!is_array($authlist))
{ {
$authlist = alt_auth_get_authlist(); $authlist = alt_auth_admin::alt_auth_get_authlist();
} }
define("ALT_AUTH_ACTION", "main"); define('ALT_AUTH_ACTION', 'main');
$var['main']['text'] = LAN_ALT_31; $var['main']['text'] = LAN_ALT_31;
$var['main']['link'] = e_PLUGIN."alt_auth/alt_auth_conf.php"; $var['main']['link'] = e_PLUGIN.'alt_auth/alt_auth_conf.php';
show_admin_menu("alt auth", ALT_AUTH_ACTION, $var); show_admin_menu('alt auth', ALT_AUTH_ACTION, $var);
$var = array(); $var = array();
foreach($authlist as $a) foreach($authlist as $a)
{ {

View File

@@ -44,6 +44,8 @@ require_once(e_HANDLER.'user_extended_class.php');
$euf = new e107_user_extended; $euf = new e107_user_extended;
$pref = e107::pref('core');
if(isset($_POST['updateprefs'])) if(isset($_POST['updateprefs']))
{ {
unset($temp); unset($temp);
@@ -53,7 +55,7 @@ if(isset($_POST['updateprefs']))
$temp['auth_badpassword'] = intval($_POST['auth_badpassword']); $temp['auth_badpassword'] = intval($_POST['auth_badpassword']);
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 @TODO:
header('location:'.e_SELF); header('location:'.e_SELF);
exit; exit;
} }
@@ -70,7 +72,7 @@ if(isset($_POST['updateeufs']))
$au = implode(',',$authExtended); $au = implode(',',$authExtended);
if ($au != $pref['auth_extended']) if ($au != $pref['auth_extended'])
{ {
$pref['auth_extended'] = $au; $pref['auth_extended'] = $au; // @TODO:
save_prefs(); save_prefs();
$admin_log->log_event('AUTH_02',$au,''); $admin_log->log_event('AUTH_02',$au,'');
} }
@@ -90,11 +92,11 @@ if (isset($pref['auth_nouser']))
} }
unset($pref['auth_nouser']); unset($pref['auth_nouser']);
if (!isset($pref['auth_badpassword'])) $pref['auth_badpassword'] = 0; if (!isset($pref['auth_badpassword'])) $pref['auth_badpassword'] = 0;
save_prefs(); save_prefs(); // @TODO
} }
$authlist = alt_auth_get_authlist(); $authlist = alt_auth_admin::alt_auth_get_authlist();
if (isset($pref['auth_extended'])) if (isset($pref['auth_extended']))
{ {
$authExtended = explode(',',$pref['auth_extended']); $authExtended = explode(',',$pref['auth_extended']);
@@ -111,6 +113,10 @@ if(isset($message))
e107::getRender()->tablerender('', "<div style='text-align:center'><b>".$message."</b></div>"); e107::getRender()->tablerender('', "<div style='text-align:center'><b>".$message."</b></div>");
} }
$altAuthAdmin = new alt_auth_admin();
$text = " $text = "
<div> <div>
<form method='post' action='".e_SELF."'> <form method='post' action='".e_SELF."'>
@@ -122,7 +128,7 @@ $text = "
<tr> <tr>
<td>".LAN_ALT_1.": </td> <td>".LAN_ALT_1.": </td>
<td>". <td>".
alt_auth_get_dropdown('auth_method', $pref['auth_method'], 'e107')." $altAuthAdmin->alt_auth_get_dropdown('auth_method', $pref['auth_method'], 'e107')."
</td> </td>
</tr> </tr>
@@ -154,7 +160,7 @@ $text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
<td>".LAN_ALT_8.":<br /> <td>".LAN_ALT_8.":<br />
</td> </td>
<td>".alt_auth_get_dropdown('auth_method2', $pref['auth_method2'], 'none')." <td>".$altAuthAdmin->alt_auth_get_dropdown('auth_method2', $pref['auth_method2'], 'none')."
<div class='smalltext field-help'>".LAN_ALT_9."</div> <div class='smalltext field-help'>".LAN_ALT_9."</div>
</td> </td>
</tr> </tr>

View File

@@ -34,6 +34,41 @@ define('AUTH_UNKNOWN', 4);
define('AUTH_NOT_AVAILABLE', 5); define('AUTH_NOT_AVAILABLE', 5);
define('AUTH_NORESOURCE', 6); // Used to indicate, for example, that a required PHP module isn't loaded define('AUTH_NORESOURCE', 6); // Used to indicate, for example, that a required PHP module isn't loaded
/**
* Methods used by a number of alt_auth classes.
* The login authorisation classes are descendants of this one.
* Admin functions also use it - a little extra overhead by including this file, but less of a problem for admin
*/
class alt_auth_base
{
public function __construct()
{
}
/**
* Get configuration parameters for an authentication method
*
* @param string $prefix - the method
*
* @return array
*/
public 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;
}
}
class alt_login class alt_login
{ {
protected $e107; protected $e107;

View File

@@ -31,7 +31,7 @@
AUTH_SUCCESS = valid login AUTH_SUCCESS = valid login
*/ */
class auth_login class auth_login extends alt_auth_base
{ {
public $Available = FALSE; // Flag indicates whether DB connection available public $Available = FALSE; // Flag indicates whether DB connection available
public $ErrorText; // e107 error string on exit public $ErrorText; // e107 error string on exit
@@ -46,7 +46,7 @@ class auth_login
public function __construct() public function __construct()
{ {
$this->ErrorText = ''; $this->ErrorText = '';
$this->conf = altAuthGetParams('e107db'); $this->conf = $this->altAuthGetParams('e107db');
$this->Available = TRUE; $this->Available = TRUE;
} }

View File

@@ -30,27 +30,22 @@ 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(vartrue($_POST['update']))
class alt_auth_e107db extends alt_auth_admin
{ {
$message = alt_auth_post_options('e107db');
} public function __construct()
{
}
if(vartrue($message)) public function showForm()
{ {
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
}
show_e107db_form();
function show_e107db_form()
{
$ns = e107::getRender(); $ns = e107::getRender();
$parm = altAuthGetParams('e107db'); $parm = $this->altAuthGetParams('e107db');
$frm = new form; $frm = new form;
$text = $frm -> form_open('post', e_SELF); $text = $frm -> form_open('post', e_SELF);
@@ -64,28 +59,46 @@ function show_e107db_form()
$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 .= $this->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>".E107DB_LAN_9."</td><td>";
$text .= altAuthGetPasswordSelector('e107db_password_method', $frm, $parm['e107db_password_method'], FALSE); $text .= $this->altAuthGetPasswordSelector('e107db_password_method', $frm, $parm['e107db_password_method'], FALSE);
$text .= "</td></tr>"; $text .= "</td></tr>";
$text .= "<tr><td colspan='2'><br />".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 .= $this->alt_auth_get_field_list('e107db',$frm, $parm, TRUE);
$text .= "</table><div class='buttons-bar center'>"; $text .= "</table><div class='buttons-bar center'>";
$text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update'); $text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
// $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,$this->alt_auth_test_form('e107db',$frm));
}
} }
$e107dbAdmin = new alt_auth_e107db();
if(vartrue($_POST['update']))
{
$message = $e107dbAdmin->alt_auth_post_options('e107db');
}
if(vartrue($message))
{
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
}
$e107dbAdmin->showForm();
require_once(e_ADMIN.'footer.php'); require_once(e_ADMIN.'footer.php');

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2012 e107 Inc (e107.org) * Copyright (C) 2008-2013 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)
* *

View File

@@ -30,7 +30,7 @@
*/ */
class auth_login class auth_login extends alt_auth_base
{ {
public $Available = FALSE; // Flag indicates whether DB connection available public $Available = FALSE; // Flag indicates whether DB connection available
@@ -46,7 +46,7 @@ class auth_login
public function __construct() public function __construct()
{ {
$this->ErrorText = ''; $this->ErrorText = '';
$this->conf = altAuthGetParams('importdb'); $this->conf = $this->altAuthGetParams('importdb');
$this->Available = TRUE; $this->Available = TRUE;
} }

View File

@@ -32,26 +32,21 @@ 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(vartrue($_POST['update']))
class alt_auth_otherdb extends alt_auth_admin
{ {
// $message = update_importdb_prefs();
$message = alt_auth_post_options('importdb');
}
if(vartrue($message)) public function __construct()
{ {
e107::getRender()->tablerender("","<div style='text-align:center;'>".$message."</div>"); }
}
show_importdb_form(); public function showForm()
{
function show_importdb_form()
{
$ns = e107::getRender(); $ns = e107::getRender();
$parm = $this->altAuthGetParams('importdb');
$parm = altAuthGetParams('importdb');
$frm = new form; $frm = new form;
$text = $frm -> form_open('post', e_SELF); $text = $frm -> form_open('post', e_SELF);
@@ -65,7 +60,7 @@ function show_importdb_form()
$text .= "<tr><td colspan='2'>".IMPORTDB_LAN_11."</td></tr>"; $text .= "<tr><td colspan='2'>".IMPORTDB_LAN_11."</td></tr>";
$text .= "<tr><td>".IMPORTDB_LAN_9."</td><td>"; $text .= "<tr><td>".IMPORTDB_LAN_9."</td><td>";
$text .= altAuthGetPasswordSelector('importdb_password_method', $frm, $parm['importdb_password_method'], TRUE); $text .= $this->altAuthGetPasswordSelector('importdb_password_method', $frm, $parm['importdb_password_method'], TRUE);
$text .= "</td></tr>"; $text .= "</td></tr>";
@@ -76,10 +71,29 @@ function show_importdb_form()
$ns -> tablerender(IMPORTDB_LAN_10, $text); $ns -> tablerender(IMPORTDB_LAN_10, $text);
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('importdb',$frm)); $ns->tablerender(LAN_ALT_40.LAN_ALT_41, $this->alt_auth_test_form('importdb',$frm));
}
} }
$otherDbAdmin = new alt_auth_otherdb();
if(vartrue($_POST['update']))
{
// $message = update_importdb_prefs();
$message = $otherDbAdmin->alt_auth_post_options('importdb');
}
if(vartrue($message))
{
e107::getRender()->tablerender("","<div style='text-align:center;'>".$message."</div>");
}
$otherDbAdmin->showForm();
require_once(e_ADMIN.'footer.php'); require_once(e_ADMIN.'footer.php');

View File

@@ -20,7 +20,7 @@
* @version $Id$; * @version $Id$;
*/ */
class auth_login class auth_login extends alt_auth_base
{ {
private $server; // The LDAP server (array of possible servers) private $server; // The LDAP server (array of possible servers)
private $dn; // LDAP domain private $dn; // LDAP domain
@@ -49,11 +49,10 @@ class auth_login
{ {
$this->copyAttribs = array(); $this->copyAttribs = array();
$this->copyMethods = array(); $this->copyMethods = array();
$sql = e107::getDB('altAuth'); $ldap = $this->altAuthGetParams('ldap');
$sql->db_Select('alt_auth', '*', "auth_type = 'ldap' ");
while ($row = $sql->db_Fetch()) foreach ($ldap as $row)
{ {
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
if ((strpos($row['auth_parmname'], 'ldap_xf_') === 0) && $ldap[$row['auth_parmname']]) // Attribute to copy on successful login if ((strpos($row['auth_parmname'], 'ldap_xf_') === 0) && $ldap[$row['auth_parmname']]) // Attribute to copy on successful login
{ {
$this->copyAttribs[substr($row['auth_parmname'], strlen('ldap_xf_'))] = $ldap[$row['auth_parmname']]; // Key = LDAP attribute. Value = e107 field name $this->copyAttribs[substr($row['auth_parmname'], strlen('ldap_xf_'))] = $ldap[$row['auth_parmname']]; // Key = LDAP attribute. Value = e107 field name
@@ -62,7 +61,6 @@ class auth_login
{ // Any fields with non-null 'copy' methods { // Any fields with non-null 'copy' methods
$this->copyMethods[substr($row['auth_parmname'], strlen('ldap_pm_'))] = $ldap[$row['auth_parmname']]; // Key = e107 field name. Value = copy method $this->copyMethods[substr($row['auth_parmname'], strlen('ldap_pm_'))] = $ldap[$row['auth_parmname']]; // Key = e107 field name. Value = copy method
} }
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'];

View File

@@ -31,17 +31,104 @@ require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
$mes = e107::getMessage(); $mes = e107::getMessage();
$server_types[1] = 'LDAP';
$server_types[2] = 'ActiveDirectory';
$server_types[3] = 'eDirectory';
$ldap_ver[1]='2'; class alt_auth_ldap extends alt_auth_admin
$ldap_ver[2]='3'; {
public function __construct()
{
}
public function showForm($mes)
{
$server_types[1] = 'LDAP';
$server_types[2] = 'ActiveDirectory';
$server_types[3] = 'eDirectory';
$ldap_ver[1]='2';
$ldap_ver[2]='3';
$ldap = $this->altAuthGetParams('ldap');
if (!isset($ldap['ldap_edirfilter'])) $ldap['ldap_edirfilter'] == '';
//print_a($ldap);
$current_filter = "(&(cn=[USERNAME]){$ldap['ldap_edirfilter']})";
$frm = new form;
$text = $frm -> form_open('post',e_SELF);
$text .= "<table class='table adminform'>";
$text .= "<tr><td>".LDAPLAN_12."</td><td>";
$text .= $frm -> form_select_open("ldap_servertype");
foreach($server_types as $v)
{
$sel = (vartrue($ldap['ldap_servertype']) == $v) ? " Selected='selected'" : '';
$text .= $frm -> form_option($v, $sel, $v);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_1."</td><td>";
$text .= $frm -> form_text("ldap_server", 35, vartrue($ldap['ldap_server']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_2."</td><td>";
$text .= $frm -> form_text("ldap_basedn", 35, vartrue($ldap['ldap_basedn']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_14."</td><td>";
$text .= $frm -> form_text("ldap_ou", 35, vartrue($ldap['ldap_ou']), 60);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_3."</td><td>";
$text .= $frm -> form_text("ldap_user", 35, vartrue($ldap['ldap_user']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_4."</td><td>";
$text .= $frm -> form_text("ldap_passwd", 35, vartrue($ldap['ldap_passwd']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_5."</td><td>";
$text .= $frm -> form_select_open("ldap_version");
foreach($ldap_ver as $v)
{
$sel = ($ldap['ldap_version'] == $v) ? " Selected='selected'" : "";
$text .= $frm -> form_option($v, $sel, $v);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_7."<br /><span class='smalltext'>".LDAPLAN_8."</span></td><td>";
$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 .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
$this->add_extended_fields();
$text .= $this->alt_auth_get_field_list('ldap',$frm, $ldap, FALSE);
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
$text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
//$text .= $frm -> form_button('submit', 'update', LDAPLAN_13);
$text .= "</td></tr>";
$text .= "</table>\n";
$text .= $frm -> form_close();
e107::getRender()->tablerender(LDAPLAN_6, $mes->render(). $text);
e107::getRender()->tablerender(LAN_ALT_40.LAN_ALT_41, $this->alt_auth_test_form('ldap',$frm));
}
}
$ldapAdmin = new alt_auth_ldap();
$message = ''; $message = '';
if(vartrue($_POST['update'])) if(vartrue($_POST['update']))
{ {
$message .= alt_auth_post_options('ldap'); $message .= $ldapAdmin->alt_auth_post_options('ldap');
} }
@@ -57,76 +144,8 @@ if($message)
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>'); e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
} }
$ldapAdmin->showForm($mes);
$ldap = altAuthGetParams('ldap');
if (!isset($ldap['ldap_edirfilter'])) $ldap['ldap_edirfilter'] == '';
//print_a($ldap);
$current_filter = "(&(cn=[USERNAME]){$ldap['ldap_edirfilter']})";
$frm = new form;
$text = $frm -> form_open('post',e_SELF);
$text .= "<table class='table adminform'>";
$text .= "<tr><td>".LDAPLAN_12."</td><td>";
$text .= $frm -> form_select_open("ldap_servertype");
foreach($server_types as $v)
{
$sel = (vartrue($ldap['ldap_servertype']) == $v) ? " Selected='selected'" : '';
$text .= $frm -> form_option($v, $sel, $v);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_1."</td><td>";
$text .= $frm -> form_text("ldap_server", 35, vartrue($ldap['ldap_server']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_2."</td><td>";
$text .= $frm -> form_text("ldap_basedn", 35, vartrue($ldap['ldap_basedn']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_14."</td><td>";
$text .= $frm -> form_text("ldap_ou", 35, vartrue($ldap['ldap_ou']), 60);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_3."</td><td>";
$text .= $frm -> form_text("ldap_user", 35, vartrue($ldap['ldap_user']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_4."</td><td>";
$text .= $frm -> form_text("ldap_passwd", 35, vartrue($ldap['ldap_passwd']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_5."</td><td>";
$text .= $frm -> form_select_open("ldap_version");
foreach($ldap_ver as $v)
{
$sel = ($ldap['ldap_version'] == $v) ? " Selected='selected'" : "";
$text .= $frm -> form_option($v, $sel, $v);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td>".LDAPLAN_7."<br /><span class='smalltext'>".LDAPLAN_8."</span></td><td>";
$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 .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>";
add_extended_fields();
$text .= alt_auth_get_field_list('ldap',$frm, $ldap, FALSE);
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
$text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
//$text .= $frm -> form_button('submit', 'update', LDAPLAN_13);
$text .= "</td></tr>";
$text .= "</table>\n";
$text .= $frm -> form_close();
e107::getRender()->tablerender(LDAPLAN_6, $mes->render(). $text);
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');

View File

@@ -30,7 +30,7 @@
AUTH_SUCCESS = valid login AUTH_SUCCESS = valid login
*/ */
class auth_login class auth_login extends alt_auth_base
{ {
public $Available = FALSE; // Flag indicates whether DB connection available public $Available = FALSE; // Flag indicates whether DB connection available
@@ -47,7 +47,7 @@ class auth_login
public function __construct() public function __construct()
{ {
$this->ErrorText = ''; $this->ErrorText = '';
$this->conf = altAuthGetParams('otherdb'); $this->conf = $this->altAuthGetParams('otherdb');
$this->Available = TRUE; $this->Available = TRUE;
} }

View File

@@ -31,26 +31,23 @@ 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(vartrue($_POST['update']))
class alt_auth_otherdb extends alt_auth_admin
{ {
$message = alt_auth_post_options('otherdb');
}
public function __construct()
if(vartrue($message)) {
{ }
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
}
show_otherdb_form();
function show_otherdb_form() public function showForm()
{ {
$ns = e107::getRender(); $ns = e107::getRender();
$parm = altAuthGetParams('otherdb'); $parm = $this->altAuthGetParams('otherdb');
$frm = new form; $frm = new form;
$text = $frm -> form_open("post", e_SELF); $text = $frm -> form_open("post", e_SELF);
@@ -60,16 +57,16 @@ function show_otherdb_form()
$text .= OTHERDB_LAN_15; $text .= OTHERDB_LAN_15;
$text .= "</td></tr>"; $text .= "</td></tr>";
$text .= alt_auth_get_db_fields('otherdb', $frm, $parm, 'server|uname|pwd|db|table|ufield|pwfield|salt'); $text .= $this->alt_auth_get_db_fields('otherdb', $frm, $parm, 'server|uname|pwd|db|table|ufield|pwfield|salt');
$text .= "<tr><td>".OTHERDB_LAN_9."</td><td>"; $text .= "<tr><td>".OTHERDB_LAN_9."</td><td>";
$text .= altAuthGetPasswordSelector('otherdb_password_method', $frm, $parm['otherdb_password_method'], TRUE); $text .= $this->altAuthGetPasswordSelector('otherdb_password_method', $frm, $parm['otherdb_password_method'], TRUE);
$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>";
$text .= alt_auth_get_field_list('otherdb',$frm, $parm, FALSE); $text .= $this->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 .= e107::getForm()->admin_button("update", LAN_UPDATE,'update'); $text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
@@ -80,9 +77,28 @@ function show_otherdb_form()
$ns -> tablerender(OTHERDB_LAN_10, $text); $ns -> tablerender(OTHERDB_LAN_10, $text);
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('otherdb',$frm)); $ns->tablerender(LAN_ALT_40.LAN_ALT_41, $this->alt_auth_test_form('otherdb',$frm));
}
} }
$otherdbAdmin = new alt_auth_otherdb();
if(vartrue($_POST['update']))
{
$message = $otherdbAdmin->alt_auth_post_options('otherdb');
}
if(vartrue($message))
{
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
}
$otherdbAdmin->showForm($mes);
require_once(e_ADMIN.'footer.php'); require_once(e_ADMIN.'footer.php');

View File

@@ -27,10 +27,10 @@ Potential enhancements:
Error recfrom: 10054 - winsock error for 'connection reset' Error recfrom: 10054 - winsock error for 'connection reset'
*/ */
define('RADIUS_DEBUG',TRUE); define('RADIUS_DEBUG',FALSE);
class auth_login
{
class auth_login extends alt_auth_base
{
private $server; private $server;
private $secret; private $secret;
private $port; private $port;
@@ -49,7 +49,7 @@ class auth_login
function __construct() function __construct()
{ {
$this->copyAttribs = array(); $this->copyAttribs = array();
$radius = altAuthGetParams('radius'); $radius = $this->altAuthGetParams('radius');
$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)

View File

@@ -3,7 +3,7 @@
+ ----------------------------------------------------------------------------+ + ----------------------------------------------------------------------------+
| e107 website system | e107 website system
| |
| Copyright (C) 2008-2009 e107 Inc (e107.org) | Copyright (C) 2008-2013 e107 Inc (e107.org)
| http://e107.org | http://e107.org
| |
| |
@@ -26,11 +26,64 @@ define("ALT_AUTH_ACTION", "radius");
require_once(e_PLUGIN."alt_auth/alt_auth_adminmenu.php"); require_once(e_PLUGIN."alt_auth/alt_auth_adminmenu.php");
$mes = e107::getMessage(); $mes = e107::getMessage();
class alt_auth_radius extends alt_auth_admin
{
private $radius;
public function __construct()
{
}
public function readOptions()
{
$this->radius = $this->altAuthGetParams('radius');
}
public function showForm($mes)
{
$ns = e107::getRender();
$frm = new form;
$text = $frm->form_open('post',e_SELF);
$text .= "<table class='table adminform'>";
$text .= "<tr><td>".LAN_RADIUS_01."</td><td>";
$text .= $frm->form_text('radius_server', 35, vartrue($this->radius['radius_server']), 120);
$text .= "</td></tr>\n";
$text .= "<tr><td>".LAN_RADIUS_02."</td><td>";
$text .= $frm->form_text('radius_secret', 35, vartrue($this->radius['radius_secret']), 200);
$text .= "</td></tr>\n";
$tmp = $this->alt_auth_get_field_list('radius', $frm, $this->radius, FALSE);
if ($tmp)
{
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>\n".$tmp;
unset($tmp);
}
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
// $text .= $frm -> form_button("submit", "update", LAN_ALT_2);
$text .= e107::getForm()->admin_button('update', LAN_UPDATE,'update');
$text .= "</td></tr>\n";
$text .= "</table>\n";
$text .= $frm->form_close();
$ns->tablerender(LAN_RADIUS_06, $mes->render().$text);
$ns->tablerender(LAN_ALT_40.LAN_ALT_41, $this->alt_auth_test_form('radius',$frm));
}
}
$message = ''; $message = '';
$radiusAdmin = new alt_auth_radius();
if(vartrue($_POST['update'])) if(vartrue($_POST['update']))
{ {
// $message .= alt_auth_post_options('radius'); // $message .= alt_auth_post_options('radius');
$mes->addSuccess(alt_auth_post_options('radius')); $mes->addSuccess($radiusAdmin->alt_auth_post_options('radius'));
} }
@@ -43,47 +96,15 @@ if (!extension_loaded('radius'))
if($message) if($message)
{ {
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>"); $ns->tablerender('',"<div style='text-align:center;'>".$message."</div>");
} }
$radiusAdmin->readOptions();
$sql -> db_Select("alt_auth", "*", "auth_type = 'radius' "); $radiusAdmin->showForm($mes);
while($row = $sql->db_Fetch())
{
$radius[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval'])); // Encoding is new for 0.8
}
$frm = new form;
$text = $frm -> form_open("post",e_SELF);
$text .= "<table class='table adminform'>";
$text .= "<tr><td>".LAN_RADIUS_01."</td><td>";
$text .= $frm -> form_text("radius_server", 35, vartrue($radius['radius_server']), 120);
$text .= "</td></tr>";
$text .= "<tr><td>".LAN_RADIUS_02."</td><td>"; require_once(e_ADMIN.'footer.php');
$text .= $frm -> form_text('radius_secret', 35, vartrue($radius['radius_secret']), 200);
$text .= "</td></tr>";
$tmp = alt_auth_get_field_list('radius',$frm, vartrue($ldap), FALSE);
if ($tmp)
{
$text .= "<tr><td class='forumheader2' colspan='2'>".LAN_ALT_27."</td></tr>".$tmp;
unset($tmp);
}
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
// $text .= $frm -> form_button("submit", "update", LAN_ALT_2);
$text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
$text .= "</td></tr>";
$text .= "</table>";
$text .= $frm -> form_close();
$ns -> tablerender(LAN_RADIUS_06, $mes->render() . $text);
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('radius',$frm));
require_once(e_ADMIN."footer.php");
function radius_conf_adminmenu() function radius_conf_adminmenu()