mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 05:37:32 +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,398 +1,527 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
/*
|
||||
TODO:
|
||||
1. Header
|
||||
2. Support array of defaults for table
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
if (!is_object($euf))
|
||||
{
|
||||
require_once(e_HANDLER.'user_extended_class.php');
|
||||
$euf = new e107_user_extended;
|
||||
}
|
||||
|
||||
|
||||
define('AUTH_SUCCESS', -1);
|
||||
define('AUTH_NOUSER', 1);
|
||||
define('AUTH_BADPASSWORD', 2);
|
||||
define('AUTH_NOCONNECT', 3);
|
||||
define('AUTH_UNKNOWN', 4);
|
||||
define('AUTH_NOT_AVAILABLE', 5);
|
||||
|
||||
function alt_auth_get_authlist($incE107 = TRUE)
|
||||
{
|
||||
$authlist = $incE107 ? array('e107') : array();
|
||||
$handle=opendir(e_PLUGIN.'alt_auth');
|
||||
while ($file = readdir($handle))
|
||||
{
|
||||
if(preg_match("/^(.*)_auth\.php/",$file,$match))
|
||||
{
|
||||
$authlist[] = $match[1];
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
return $authlist;
|
||||
}
|
||||
|
||||
|
||||
function alt_auth_get_dropdown($name, $curval = '', $options = '')
|
||||
{
|
||||
$optList = explode(',', $options);
|
||||
$authList = array_merge($optList, alt_auth_get_authlist(FALSE));
|
||||
$ret = "<select class='tbox' name='{$name}'>\n";
|
||||
foreach ($authList as $v)
|
||||
{
|
||||
$sel = ($curval == $v ? " selected = 'selected' " : '');
|
||||
$ret .= "<option value='{$v}'{$sel} >{$v}</option>\n";
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
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 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(
|
||||
'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_name' => array('prompt' => LAN_ALT_14, 'default' => 'user_name', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
|
||||
'user_login' => array('prompt' => LAN_ALT_15, 'default' => 'user_login', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'sn'),
|
||||
'user_customtitle'=> array('prompt' => LAN_ALT_16, 'default' => 'user_customtitle', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
||||
'user_signature' => array('prompt' => LAN_ALT_17, 'default' => 'user_signature', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
||||
'user_image' => array('prompt' => LAN_ALT_18, 'default' => 'user_image', '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_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_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
|
||||
// $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)
|
||||
{
|
||||
global $alt_auth_user_fields;
|
||||
$ret = '';
|
||||
foreach ($alt_auth_user_fields as $f => $v)
|
||||
{
|
||||
if (varsettrue($v['showAll']) || varsettrue($v[$tableType]))
|
||||
{
|
||||
$ret .= "<tr><td class='forumheader3'>";
|
||||
if ($v['optional'] == FALSE) $ret .= '* ';
|
||||
$ret .= $v['prompt'].':';
|
||||
if (isset($v['help']))
|
||||
{
|
||||
$ret .= "<br /><span class='smalltext'>".$v['help']."</span>";
|
||||
}
|
||||
$ret .= "</td><td class='forumheader3'>";
|
||||
// $fieldname = $tableType.'_'.$v['optname'];
|
||||
$fieldname = $tableType.'_xf_'.$f; // Name of the input box
|
||||
$value = varset($v['default'],'');
|
||||
if (is_array($value))
|
||||
{
|
||||
$value = varset($value[$tableType],'');
|
||||
}
|
||||
if (isset($v[$tableType.'_field'])) $value = $v[$tableType.'_field'];
|
||||
if (isset($parm[$fieldname])) $value = $parm[$fieldname];
|
||||
// echo "Field: {$fieldname} => {$value}<br />";
|
||||
if ($asCheckboxes)
|
||||
{
|
||||
$ret .= $frm -> form_checkbox($fieldname, 1, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret .= $frm -> form_text($fieldname, 35, $value, 120);
|
||||
if (isset($v['method']) && $v['method'])
|
||||
{
|
||||
$fieldMethod = $tableType.'_pm_'.$f; // Processing method ID code
|
||||
$method = varset($parm[$fieldMethod],'');
|
||||
$ret .= ' '.alt_auth_processing($fieldMethod,$v['method'], $method);
|
||||
}
|
||||
}
|
||||
$ret .= "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
// Returns a list of all the user-related fields allowed as an array, whhere the key is the field name
|
||||
function alt_auth_get_allowed_fields($tableType)
|
||||
{
|
||||
global $alt_auth_user_fields;
|
||||
$ret = array();
|
||||
foreach ($alt_auth_user_fields as $f => $v)
|
||||
{
|
||||
if (varsettrue($v['showAll']) || varsettrue($v[$tableType]))
|
||||
{
|
||||
// $fieldname = $tableType.'_'.$v['optname'];
|
||||
$fieldname = $tableType.'_xf_'.$f; // Name of the input box
|
||||
$ret[$fieldname] = '1';
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
// 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()
|
||||
{
|
||||
global $alt_auth_user_fields, $euf, $pref;
|
||||
if (!isset($pref['auth_extended'])) return;
|
||||
if (!$pref['auth_extended']) return;
|
||||
static $fieldsAdded = FALSE;
|
||||
if ($fieldsAdded) return;
|
||||
$xFields = $euf->user_extended_get_fieldList('','user_extended_struct_name');
|
||||
// print_a($xFields);
|
||||
$fields = explode(',',$pref['auth_extended']);
|
||||
foreach ($fields as $f)
|
||||
{
|
||||
if (isset($xFields[$f]))
|
||||
{
|
||||
$alt_auth_user_fields['x_'.$f] = array('prompt' => varset($xFields[$f]['user_extended_struct_text'],'').' ('.$f.')',
|
||||
'default' => varset($xFields[$f]['default'],''),
|
||||
'optional' => TRUE,
|
||||
'showAll' => TRUE, // Show for all methods - in principle, its likely to be wanted for all
|
||||
'method' => '*' // Specify all convert methods - have little idea what may be around
|
||||
);
|
||||
}
|
||||
}
|
||||
$fieldsAdded = TRUE;
|
||||
}
|
||||
|
||||
|
||||
$common_fields = array(
|
||||
'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' => ''),
|
||||
'pwd' => array('fieldname' => 'password', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_34, 'help' => ''),
|
||||
'db' => array('fieldname' => 'database', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_35, 'help' => ''),
|
||||
'table' => array('fieldname' => 'table', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_36, 'help' => ''),
|
||||
'prefix' => array('fieldname' => 'prefix', 'size' => 35, 'max_size' => 35, 'prompt' => LAN_ALT_39, 'help' => ''),
|
||||
'ufield' => array('fieldname' => 'user_field','size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_37, '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),
|
||||
'classfilt' => array('fieldname' => 'filter_class', 'size' => 10, 'max_size' => 8, 'prompt' => LAN_ALT_76, 'help' => LAN_ALT_77)
|
||||
);
|
||||
|
||||
|
||||
function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pwd|db|table|ufield|pwfield')
|
||||
{
|
||||
global $common_fields;
|
||||
$opts = explode('|',$fields);
|
||||
$ret = '';
|
||||
foreach ($common_fields as $fn => $cf)
|
||||
{
|
||||
if (in_array($fn,$opts))
|
||||
{
|
||||
$ret .= "<tr><td class='forumheader3'>".$cf['prompt'];
|
||||
if ($cf['help']) $ret .= "<br /><span class='smalltext'>".$cf['help']."</span>";
|
||||
$ret .= "</td><td class='forumheader3'>";
|
||||
$ret .= $frm -> form_text($prefix.'_'.$cf['fieldname'], $cf['size'], $parm[$prefix.'_'.$cf['fieldname']], $cf['max_size']);
|
||||
$ret .= "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write all the options to the DB. $prefix must NOT have trailing underscore
|
||||
function alt_auth_post_options($prefix)
|
||||
{
|
||||
global $common_fields, $sql, $admin_log;
|
||||
$lprefix = $prefix.'_';
|
||||
|
||||
$user_fields = alt_auth_get_allowed_fields($prefix); // Need this list in case checkboxes for parameters
|
||||
foreach ($user_fields as $k => $v)
|
||||
{
|
||||
if (!isset($_POST[$k]))
|
||||
{
|
||||
$_POST[$k] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we can post everything
|
||||
foreach($_POST as $k => $v)
|
||||
{
|
||||
if (strpos($k,$lprefix) === 0)
|
||||
{
|
||||
$v = base64_encode(base64_encode($v));
|
||||
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}' ");
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql -> db_Insert("alt_auth", "'{$prefix}','{$k}','{$v}' ");
|
||||
}
|
||||
}
|
||||
}
|
||||
$admin_log->log_event('AUTH_03',$prefix,E_LOG_INFORMATIVE,'');
|
||||
return LAN_ALT_UPDATED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Return test form
|
||||
function alt_auth_test_form($prefix,$frm)
|
||||
{
|
||||
$text = $frm -> form_open("post", e_SELF, 'testform');
|
||||
$text .= "<table style='width:96%' class='fborder'>
|
||||
<tr><td colspan='2' class='forumheader2' style='text-align:center;'>".LAN_ALT_42."</td></tr>";
|
||||
|
||||
if (isset($_POST['testauth']))
|
||||
{
|
||||
// Try and connect to DB/server, and maybe validate user name
|
||||
require_once(e_PLUGIN.'alt_auth/'.$prefix.'_auth.php');
|
||||
$_login = new auth_login;
|
||||
$log_result = AUTH_UNKNOWN;
|
||||
$pass_vars = array();
|
||||
$val_name = trim(varset($_POST['nametovalidate'],''));
|
||||
|
||||
if(isset($_login->Available) && ($_login->Available === FALSE))
|
||||
{ // Relevant auth method not available (e.g. PHP extension not loaded)
|
||||
$log_result = AUTH_NOT_AVAILABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$log_result = $_login -> login($val_name, $_POST['passtovalidate'], $pass_vars, ($val_name == ''));
|
||||
}
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_48;
|
||||
if ($val_name)
|
||||
{
|
||||
$text .= "<br />".LAN_ALT_49.$val_name.'<br />'.LAN_ALT_50;
|
||||
if (varset($_POST['passtovalidate'],'')) $text .= str_repeat('*',strlen($_POST['passtovalidate'])); else $text .= LAN_ALT_51;
|
||||
}
|
||||
$text .= "</td><td class='forumheader3'>";
|
||||
switch ($log_result)
|
||||
{
|
||||
case AUTH_SUCCESS :
|
||||
$text .= LAN_ALT_58;
|
||||
if (count($pass_vars))
|
||||
{
|
||||
$text .= '<br />'.LAN_ALT_59;
|
||||
foreach ($pass_vars as $k => $v)
|
||||
{
|
||||
$text .= '<br /> '.$k.'=>'.$v;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AUTH_NOUSER :
|
||||
$text .= LAN_ALT_52.LAN_ALT_55;
|
||||
break;
|
||||
case AUTH_BADPASSWORD :
|
||||
$text .= LAN_ALT_52.LAN_ALT_56;
|
||||
break;
|
||||
case AUTH_NOCONNECT :
|
||||
$text .= LAN_ALT_52.LAN_ALT_54;
|
||||
break;
|
||||
case AUTH_UNKNOWN :
|
||||
$text .= LAN_ALT_52.LAN_ALT_53;
|
||||
break;
|
||||
case AUTH_NOT_AVAILABLE :
|
||||
$text .= LAN_ALT_52.LAN_ALT_57;
|
||||
break;
|
||||
default :
|
||||
$text .= "Coding error";
|
||||
}
|
||||
if (isset($_login ->ErrorText)) $text .= '<br />'.$_login ->ErrorText;
|
||||
$text .= "</td></tr>";
|
||||
}
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_33."</td><td class='forumheader3'>";
|
||||
$text .= $frm -> form_text('nametovalidate', 35, '', 120);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_34."</td><td class='forumheader3'>";
|
||||
$text .= $frm -> form_password('passtovalidate', 35, '', 120);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
||||
$text .= $frm -> form_button("submit", 'testauth', LAN_ALT_47);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "</table>";
|
||||
$text .= $frm -> form_close();
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// VALUE COPY METHOD SELECTION
|
||||
//-----------------------------------------------
|
||||
|
||||
$procListOpts = array(
|
||||
'none' => LAN_ALT_70,
|
||||
'bool1' => LAN_ALT_71,
|
||||
'ucase' => LAN_ALT_72,
|
||||
'lcase' => LAN_ALT_73,
|
||||
'ucfirst' => LAN_ALT_74,
|
||||
'ucwords' => LAN_ALT_75
|
||||
);
|
||||
|
||||
// Return a 'select' box for available processing methods
|
||||
function alt_auth_processing($selName, $allowed='*', $curVal='')
|
||||
{
|
||||
global $procListOpts;
|
||||
if (($allowed == 'none') || ($allowed == '')) return '';
|
||||
if ($allowed == '*')
|
||||
{
|
||||
$valid = $procListOpts; // We just want all the array keys to exist!
|
||||
}
|
||||
else
|
||||
{
|
||||
$valid = array_flip(explode(',',$allowed));
|
||||
$valid['none'] = '1'; // Make sure this key exists - value doesn't matter
|
||||
}
|
||||
$ret = "<select class='tbox' name='{$selName}' id='{$selName}'>\n";
|
||||
foreach ($procListOpts as $k => $v)
|
||||
{
|
||||
if (isset($valid[$k]))
|
||||
{
|
||||
$s = ($curVal == $k) ? " selected='selected'" : '';
|
||||
$ret .= "<option value='{$k}'{$s}>{$v}</option>\n";
|
||||
}
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
// $ret .= $selName.':'.$curVal;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
function alt_auth_adminmenu()
|
||||
{
|
||||
global $authlist;
|
||||
echo " ";
|
||||
if(!is_array($authlist))
|
||||
{
|
||||
$authlist = alt_auth_get_authlist();
|
||||
}
|
||||
define("ALT_AUTH_ACTION", "main");
|
||||
|
||||
$var['main']['text'] = LAN_ALT_31;
|
||||
$var['main']['link'] = e_PLUGIN."alt_auth/alt_auth_conf.php";
|
||||
show_admin_menu("alt auth", ALT_AUTH_ACTION, $var);
|
||||
$var = array();
|
||||
foreach($authlist as $a)
|
||||
{
|
||||
if($a != 'e107')
|
||||
{
|
||||
$var[$a]['text'] = LAN_ALT_30.$a;
|
||||
$var[$a]['link'] = e_PLUGIN."alt_auth/{$a}_conf.php";
|
||||
}
|
||||
}
|
||||
show_admin_menu(LAN_ALT_29, ALT_AUTH_ACTION, $var);
|
||||
}
|
||||
?>
|
||||
<?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$;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
TODO:
|
||||
1. Header
|
||||
2. Support array of defaults for table
|
||||
3. Get rid of all the globals (put into a class?)
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
if (!is_object($euf))
|
||||
{
|
||||
require_once(e_HANDLER.'user_extended_class.php');
|
||||
$euf = new e107_user_extended;
|
||||
}
|
||||
|
||||
|
||||
define('AUTH_SUCCESS', -1);
|
||||
define('AUTH_NOUSER', 1);
|
||||
define('AUTH_BADPASSWORD', 2);
|
||||
define('AUTH_NOCONNECT', 3);
|
||||
define('AUTH_UNKNOWN', 4);
|
||||
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)
|
||||
{
|
||||
$authlist = $incE107 ? array('e107') : array();
|
||||
$handle = opendir(e_PLUGIN.'alt_auth');
|
||||
while ($file = readdir($handle))
|
||||
{
|
||||
if(preg_match("/^(.*)_auth\.php/", $file, $match))
|
||||
{
|
||||
$authlist[] = $match[1];
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
return $authlist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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 = '')
|
||||
{
|
||||
$optList = explode(',', $options);
|
||||
$authList = array_merge($optList, alt_auth_get_authlist(FALSE));
|
||||
$ret = "<select class='tbox' name='{$name}'>\n";
|
||||
foreach ($authList as $v)
|
||||
{
|
||||
$sel = ($curval == $v ? " selected = 'selected' " : '');
|
||||
$ret .= "<option value='{$v}'{$sel} >{$v}</option>\n";
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
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
|
||||
* 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(
|
||||
'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_name' => array('prompt' => LAN_ALT_14, 'default' => 'user_name', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
|
||||
'user_login' => array('prompt' => LAN_ALT_15, 'default' => 'user_login', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'sn'),
|
||||
'user_customtitle'=> array('prompt' => LAN_ALT_16, 'default' => 'user_customtitle', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
||||
'user_signature' => array('prompt' => LAN_ALT_17, 'default' => 'user_signature', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
||||
'user_image' => array('prompt' => LAN_ALT_18, 'default' => 'user_image', '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_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)
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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 $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)
|
||||
{
|
||||
global $alt_auth_user_fields;
|
||||
$ret = '';
|
||||
foreach ($alt_auth_user_fields as $f => $v)
|
||||
{
|
||||
if (varsettrue($v['showAll']) || varsettrue($v[$tableType]))
|
||||
{
|
||||
$ret .= "<tr><td class='forumheader3'>";
|
||||
if ($v['optional'] == FALSE) $ret .= '* ';
|
||||
$ret .= $v['prompt'].':';
|
||||
if (isset($v['help']))
|
||||
{
|
||||
$ret .= "<br /><span class='smalltext'>".$v['help']."</span>";
|
||||
}
|
||||
$ret .= "</td><td class='forumheader3'>";
|
||||
// $fieldname = $tableType.'_'.$v['optname'];
|
||||
$fieldname = $tableType.'_xf_'.$f; // Name of the input box
|
||||
$value = varset($v['default'],'');
|
||||
if (is_array($value))
|
||||
{
|
||||
$value = varset($value[$tableType],'');
|
||||
}
|
||||
if (isset($v[$tableType.'_field'])) $value = $v[$tableType.'_field'];
|
||||
if (isset($parm[$fieldname])) $value = $parm[$fieldname];
|
||||
// echo "Field: {$fieldname} => {$value}<br />";
|
||||
if ($asCheckboxes)
|
||||
{
|
||||
$ret .= $frm -> form_checkbox($fieldname, 1, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret .= $frm -> form_text($fieldname, 35, $value, 120);
|
||||
if (isset($v['method']) && $v['method'])
|
||||
{
|
||||
$fieldMethod = $tableType.'_pm_'.$f; // Processing method ID code
|
||||
$method = varset($parm[$fieldMethod],'');
|
||||
$ret .= ' '.alt_auth_processing($fieldMethod,$v['method'], $method);
|
||||
}
|
||||
}
|
||||
$ret .= "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
global $alt_auth_user_fields;
|
||||
$ret = array();
|
||||
foreach ($alt_auth_user_fields as $f => $v)
|
||||
{
|
||||
if (varsettrue($v['showAll']) || varsettrue($v[$tableType]))
|
||||
{
|
||||
// $fieldname = $tableType.'_'.$v['optname'];
|
||||
$fieldname = $tableType.'_xf_'.$f; // Name of the input box
|
||||
$ret[$fieldname] = '1';
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
global $alt_auth_user_fields, $euf, $pref;
|
||||
|
||||
if (!isset($pref['auth_extended'])) return;
|
||||
if (!$pref['auth_extended']) return;
|
||||
|
||||
static $fieldsAdded = FALSE;
|
||||
|
||||
if ($fieldsAdded) return;
|
||||
$xFields = $euf->user_extended_get_fieldList('','user_extended_struct_name');
|
||||
// print_a($xFields);
|
||||
$fields = explode(',',$pref['auth_extended']);
|
||||
foreach ($fields as $f)
|
||||
{
|
||||
if (isset($xFields[$f]))
|
||||
{
|
||||
$alt_auth_user_fields['x_'.$f] = array('prompt' => varset($xFields[$f]['user_extended_struct_text'],'').' ('.$f.')',
|
||||
'default' => varset($xFields[$f]['default'],''),
|
||||
'optional' => TRUE,
|
||||
'showAll' => TRUE, // Show for all methods - in principle, its likely to be wanted for all
|
||||
'method' => '*' // Specify all convert methods - have little idea what may be around
|
||||
);
|
||||
}
|
||||
}
|
||||
$fieldsAdded = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List of the standard fields which may be displayed for any method.
|
||||
*/
|
||||
$common_fields = array(
|
||||
'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' => ''),
|
||||
'pwd' => array('fieldname' => 'password', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_34, 'help' => ''),
|
||||
'db' => array('fieldname' => 'database', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_35, 'help' => ''),
|
||||
'table' => array('fieldname' => 'table', 'size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_36, 'help' => ''),
|
||||
'prefix' => array('fieldname' => 'prefix', 'size' => 35, 'max_size' => 35, 'prompt' => LAN_ALT_39, 'help' => ''),
|
||||
'ufield' => array('fieldname' => 'user_field','size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_37, '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),
|
||||
'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.
|
||||
* 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')
|
||||
{
|
||||
global $common_fields;
|
||||
|
||||
$opts = explode('|',$fields);
|
||||
$ret = '';
|
||||
foreach ($common_fields as $fn => $cf)
|
||||
{
|
||||
if (in_array($fn,$opts))
|
||||
{
|
||||
$ret .= "<tr><td class='forumheader3'>".$cf['prompt'];
|
||||
if ($cf['help']) $ret .= "<br /><span class='smalltext'>".$cf['help']."</span>";
|
||||
$ret .= "</td><td class='forumheader3'>";
|
||||
$ret .= $frm -> form_text($prefix.'_'.$cf['fieldname'], $cf['size'], $parm[$prefix.'_'.$cf['fieldname']], $cf['max_size']);
|
||||
$ret .= "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
global $common_fields, $sql, $admin_log;
|
||||
$lprefix = $prefix.'_';
|
||||
|
||||
$user_fields = alt_auth_get_allowed_fields($prefix); // Need this list in case checkboxes for parameters
|
||||
foreach ($user_fields as $k => $v)
|
||||
{
|
||||
if (!isset($_POST[$k]))
|
||||
{
|
||||
$_POST[$k] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we can post everything
|
||||
foreach($_POST as $k => $v)
|
||||
{
|
||||
if (strpos($k,$lprefix) === 0)
|
||||
{
|
||||
$v = base64_encode(base64_encode($v));
|
||||
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}' ");
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql -> db_Insert('alt_auth', "'{$prefix}','{$k}','{$v}' ");
|
||||
}
|
||||
}
|
||||
}
|
||||
$admin_log->log_event('AUTH_03',$prefix,E_LOG_INFORMATIVE,'');
|
||||
return LAN_ALT_UPDATED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the HTML for a password type selector.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$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'>
|
||||
<tr><td colspan='2' class='forumheader2' style='text-align:center;'>".LAN_ALT_42."</td></tr>";
|
||||
|
||||
if (isset($_POST['testauth']))
|
||||
{
|
||||
// Try and connect to DB/server, and maybe validate user name
|
||||
require_once(e_PLUGIN.'alt_auth/'.$prefix.'_auth.php');
|
||||
$_login = new auth_login;
|
||||
$log_result = AUTH_UNKNOWN;
|
||||
$pass_vars = array();
|
||||
$val_name = trim(varset($_POST['nametovalidate'],''));
|
||||
|
||||
if(isset($_login->Available) && ($_login->Available === FALSE))
|
||||
{ // Relevant auth method not available (e.g. PHP extension not loaded)
|
||||
$log_result = AUTH_NOT_AVAILABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$log_result = $_login->login($val_name, $_POST['passtovalidate'], $pass_vars, ($val_name == ''));
|
||||
}
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_48;
|
||||
if ($val_name)
|
||||
{
|
||||
$text .= "<br />".LAN_ALT_49.$val_name.'<br />'.LAN_ALT_50;
|
||||
if (varset($_POST['passtovalidate'],'')) $text .= str_repeat('*',strlen($_POST['passtovalidate'])); else $text .= LAN_ALT_51;
|
||||
}
|
||||
$text .= "</td><td class='forumheader3'>";
|
||||
switch ($log_result)
|
||||
{
|
||||
case AUTH_SUCCESS :
|
||||
$text .= LAN_ALT_58;
|
||||
if (count($pass_vars))
|
||||
{
|
||||
$text .= '<br />'.LAN_ALT_59;
|
||||
foreach ($pass_vars as $k => $v)
|
||||
{
|
||||
$text .= '<br /> '.$k.'=>'.$v;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AUTH_NOUSER :
|
||||
$text .= LAN_ALT_52.LAN_ALT_55;
|
||||
break;
|
||||
case AUTH_BADPASSWORD :
|
||||
$text .= LAN_ALT_52.LAN_ALT_56;
|
||||
break;
|
||||
case AUTH_NOCONNECT :
|
||||
$text .= LAN_ALT_52.LAN_ALT_54;
|
||||
break;
|
||||
case AUTH_UNKNOWN :
|
||||
$text .= LAN_ALT_52.LAN_ALT_53;
|
||||
break;
|
||||
case AUTH_NOT_AVAILABLE :
|
||||
$text .= LAN_ALT_52.LAN_ALT_57;
|
||||
break;
|
||||
default :
|
||||
$text .= "Coding error";
|
||||
}
|
||||
if (isset($_login ->ErrorText)) $text .= '<br />'.$_login ->ErrorText;
|
||||
$text .= "</td></tr>";
|
||||
}
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_33."</td><td class='forumheader3'>";
|
||||
$text .= $frm->form_text('nametovalidate', 35, '', 120);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_34."</td><td class='forumheader3'>";
|
||||
$text .= $frm->form_password('passtovalidate', 35, '', 120);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
||||
$text .= $frm->form_button("submit", 'testauth', LAN_ALT_47);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "</table>";
|
||||
$text .= $frm->form_close();
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// VALUE COPY METHOD SELECTION
|
||||
//-----------------------------------------------
|
||||
|
||||
$procListOpts = array(
|
||||
'none' => LAN_ALT_70,
|
||||
'bool1' => LAN_ALT_71,
|
||||
'ucase' => LAN_ALT_72,
|
||||
'lcase' => LAN_ALT_73,
|
||||
'ucfirst' => LAN_ALT_74,
|
||||
'ucwords' => LAN_ALT_75
|
||||
);
|
||||
|
||||
// Return a 'select' box for available processing methods
|
||||
function alt_auth_processing($selName, $allowed='*', $curVal='')
|
||||
{
|
||||
global $procListOpts;
|
||||
if (($allowed == 'none') || ($allowed == '')) return '';
|
||||
if ($allowed == '*')
|
||||
{
|
||||
$valid = $procListOpts; // We just want all the array keys to exist!
|
||||
}
|
||||
else
|
||||
{
|
||||
$valid = array_flip(explode(',',$allowed));
|
||||
$valid['none'] = '1'; // Make sure this key exists - value doesn't matter
|
||||
}
|
||||
$ret = "<select class='tbox' name='{$selName}' id='{$selName}'>\n";
|
||||
foreach ($procListOpts as $k => $v)
|
||||
{
|
||||
if (isset($valid[$k]))
|
||||
{
|
||||
$s = ($curVal == $k) ? " selected='selected'" : '';
|
||||
$ret .= "<option value='{$k}'{$s}>{$v}</option>\n";
|
||||
}
|
||||
}
|
||||
$ret .= "</select>\n";
|
||||
// $ret .= $selName.':'.$curVal;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
function alt_auth_adminmenu()
|
||||
{
|
||||
global $authlist;
|
||||
echo " ";
|
||||
if(!is_array($authlist))
|
||||
{
|
||||
$authlist = alt_auth_get_authlist();
|
||||
}
|
||||
define("ALT_AUTH_ACTION", "main");
|
||||
|
||||
$var['main']['text'] = LAN_ALT_31;
|
||||
$var['main']['link'] = e_PLUGIN."alt_auth/alt_auth_conf.php";
|
||||
show_admin_menu("alt auth", ALT_AUTH_ACTION, $var);
|
||||
$var = array();
|
||||
foreach($authlist as $a)
|
||||
{
|
||||
if($a != 'e107')
|
||||
{
|
||||
$var[$a]['text'] = LAN_ALT_30.$a;
|
||||
$var[$a]['link'] = e_PLUGIN."alt_auth/{$a}_conf.php";
|
||||
}
|
||||
}
|
||||
show_admin_menu(LAN_ALT_29, ALT_AUTH_ACTION, $var);
|
||||
}
|
||||
?>
|
||||
|
@@ -6,14 +6,30 @@
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Alt_auth plugin - general configuration
|
||||
*
|
||||
* $URL$
|
||||
* $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;
|
||||
require_once('../../class2.php');
|
||||
if(!getperms("P") || !plugInstalled('alt_auth'))
|
||||
if(!getperms('P') || !e107::isInstalled('alt_auth'))
|
||||
{
|
||||
header('location:'.e_BASE.'index.php');
|
||||
exit();
|
||||
@@ -37,7 +53,7 @@ if(isset($_POST['updateprefs']))
|
||||
if ($admin_log->logArrayDiffs($temp, $pref, 'AUTH_01'))
|
||||
{
|
||||
save_prefs(); // Only save if changes
|
||||
header("location:".e_SELF);
|
||||
header('location:'.e_SELF);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +107,7 @@ else
|
||||
|
||||
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 = "
|
||||
@@ -125,9 +141,9 @@ $text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
|
||||
<td>".LAN_ALT_6.":<br /></td>
|
||||
<td>
|
||||
<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>";
|
||||
$sel = ($pref['auth_noconn'] ? " selected = 'selected' " : "");
|
||||
$sel = ($pref['auth_noconn'] ? " selected = 'selected' " : '');
|
||||
$text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
|
||||
</select><div class='smalltext field-help'>".LAN_ALT_7."</div>
|
||||
</td>
|
||||
@@ -149,7 +165,7 @@ $text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
|
||||
</form>
|
||||
</div>";
|
||||
|
||||
$ns -> tablerender(LAN_ALT_3, $text);
|
||||
e107::getRender()->tablerender(LAN_ALT_3, $text);
|
||||
|
||||
|
||||
if ($euf->userCount)
|
||||
@@ -190,13 +206,13 @@ if ($euf->userCount)
|
||||
|
||||
</form>
|
||||
</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()
|
||||
{
|
||||
|
@@ -13,15 +13,26 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
define('AA_DEBUG',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_NOUSER', 1);
|
||||
define('AUTH_BADPASSWORD', 2);
|
||||
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
|
||||
{
|
||||
@@ -30,7 +41,6 @@ class alt_login
|
||||
|
||||
public function __construct($method, &$username, &$userpass)
|
||||
{
|
||||
global $pref;
|
||||
$this->e107 = e107::getInstance();
|
||||
$newvals=array();
|
||||
|
||||
@@ -45,11 +55,11 @@ class alt_login
|
||||
|
||||
if(isset($_login->Available) && ($_login->Available === FALSE))
|
||||
{ // Relevant auth method not available (e.g. PHP extension not loaded)
|
||||
$this->loginResult = AUTH_NOCONNECT;
|
||||
$this->loginResult = AUTH_NOT_AVAILABLE;
|
||||
return;
|
||||
}
|
||||
|
||||
$login_result = $_login -> login($username, $userpass, $newvals, FALSE);
|
||||
$login_result = $_login->login($username, $userpass, $newvals, FALSE);
|
||||
|
||||
if($login_result === AUTH_SUCCESS )
|
||||
{
|
||||
@@ -61,7 +71,7 @@ class alt_login
|
||||
$username = mysql_real_escape_string($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');
|
||||
$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_loginname'])) $db_vals['user_loginname'] = $username;
|
||||
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_prefs'])) $db_vals['user_prefs'] = '';
|
||||
if (!isset($db_vals['user_perms'])) $db_vals['user_perms'] = '';
|
||||
@@ -193,17 +203,8 @@ class alt_login
|
||||
{ // Failure modes
|
||||
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:
|
||||
if(varset($pref['auth_noconn'], TRUE))
|
||||
if(varset(e107::getPref('auth_noconn'), TRUE))
|
||||
{
|
||||
$this->loginResult = LOGIN_TRY_OTHER;
|
||||
return;
|
||||
@@ -211,9 +212,8 @@ class alt_login
|
||||
$username=md5('xx_noconn_xx');
|
||||
$this->loginResult = LOGIN_ABORT;
|
||||
return;
|
||||
break;
|
||||
case AUTH_BADPASSWORD:
|
||||
if(varset($pref['auth_badpassword'], TRUE))
|
||||
if(varset(e107::getPref('auth_badpassword'), TRUE))
|
||||
{
|
||||
$this->loginResult = LOGIN_TRY_OTHER;
|
||||
return;
|
||||
@@ -221,7 +221,6 @@ class alt_login
|
||||
$userpass=md5('xx_badpassword_xx');
|
||||
$this->loginResult = LOGIN_ABORT; // Not going to magically be able to log in!
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->loginResult = LOGIN_ABORT; // catch-all just in case
|
||||
@@ -232,7 +231,7 @@ class alt_login
|
||||
// Function to implement copy methods
|
||||
public function translate($method, $word)
|
||||
{
|
||||
global $tp;
|
||||
$tp = e107::getParser();
|
||||
switch ($method)
|
||||
{
|
||||
case 'bool1' :
|
||||
|
@@ -1,21 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/e107db_auth.php,v $
|
||||
| $Revision$
|
||||
| $Date$
|
||||
| $Author$
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
* 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)
|
||||
*
|
||||
* e107 DB authorisation for alt_auth plugin
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -28,61 +33,77 @@
|
||||
|
||||
class auth_login
|
||||
{
|
||||
|
||||
var $Available;
|
||||
var $ErrorText;
|
||||
var $conf; // Configuration parameters
|
||||
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||
public $ErrorText; // e107 error string on exit
|
||||
private $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 = '';
|
||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'e107db' ");
|
||||
while($row = $sql -> db_Fetch())
|
||||
{
|
||||
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
||||
}
|
||||
$this->conf = altAuthGetParams('e107db');
|
||||
$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;
|
||||
global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
||||
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
|
||||
//global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
||||
//$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
|
||||
if(!$res = mysql_connect($this->conf['e107db_server'], $this->conf['e107db_username'], $this->conf['e107db_password']))
|
||||
{
|
||||
$this->makeErrorText('Cannot connect to remote server');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
//Select correct db
|
||||
if(!mysql_select_db($this->conf['e107db_database'], $res))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('Cannot connect to remote DB');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
if ($connect_only) return AUTH_SUCCESS; // Test mode may just want to connect to the DB
|
||||
|
||||
$sel_fields = array();
|
||||
// Make an array of the fields we want from the source DB
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
if ($v && (strpos($k,'e107db_xf_') === 0))
|
||||
//Attempt to open connection to sql database
|
||||
if(!$res = mysql_connect($this->conf['e107db_server'], $this->conf['e107db_username'], $this->conf['e107db_password']))
|
||||
{
|
||||
$sel_fields[] = substr($k,strlen('e107db_xf_'));
|
||||
$this->makeErrorText('Cannot connect to remote server');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
//Select correct db
|
||||
|
||||
if(!mysql_select_db($this->conf['e107db_database'], $res))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('Cannot connect to remote DB');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
if ($connect_only) return AUTH_SUCCESS; // Test mode may just want to connect to the DB
|
||||
|
||||
$sel_fields = array();
|
||||
// Make an array of the fields we want from the source DB
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
if ($v && (strpos($k,'e107db_xf_') === 0))
|
||||
{
|
||||
$sel_fields[] = substr($k,strlen('e107db_xf_'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filterClass = intval(varset($this->conf['e107db_filter_class'], e_UC_PUBLIC));
|
||||
if (($filterClass != e_UC_PUBLIC) && (!in_array('user_class',$sel_fields)))
|
||||
@@ -95,7 +116,7 @@ class auth_login
|
||||
|
||||
|
||||
//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 />";
|
||||
if(!$r1 = mysql_query($qry))
|
||||
{
|
||||
@@ -103,7 +124,7 @@ class auth_login
|
||||
$this->makeErrorText('Lookup query failed');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
if(!$row = mysql_fetch_array($r1))
|
||||
if (!$row = mysql_fetch_array($r1))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('User not found');
|
||||
@@ -143,17 +164,17 @@ class auth_login
|
||||
unset($tmp);
|
||||
}
|
||||
|
||||
// Now copy across any values we have selected
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
if ($v && (strpos($k,'e107db_xf_') === 0))
|
||||
// Now copy across any values we have selected
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
$f = substr($k,strlen('e107db_xf_'));
|
||||
if (isset($row[$f])) $newvals[$f] = $row[$f];
|
||||
if ($v && (strpos($k,'e107db_xf_') === 0))
|
||||
{
|
||||
$f = substr($k,strlen('e107db_xf_'));
|
||||
if (isset($row[$f])) $newvals[$f] = $row[$f];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->makeErrorText(''); // Success - just reconnect to E107 DB if needed
|
||||
return AUTH_SUCCESS;
|
||||
return AUTH_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,99 +1,97 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
$eplug_admin = true;
|
||||
require_once('../../class2.php');
|
||||
require_once(e_ADMIN.'auth.php');
|
||||
require_once(e_HANDLER.'form_handler.php');
|
||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_e107db_conf.php');
|
||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||
define('ALT_AUTH_ACTION', 'e107db');
|
||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||
|
||||
if($_POST['update'])
|
||||
{
|
||||
// $message = update_e107db_prefs();
|
||||
$message = alt_auth_post_options('e107db');
|
||||
}
|
||||
|
||||
if($message)
|
||||
{
|
||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
||||
}
|
||||
|
||||
|
||||
show_e107db_form();
|
||||
|
||||
function show_e107db_form()
|
||||
{
|
||||
global $sql, $tp, $ns;
|
||||
|
||||
|
||||
$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;
|
||||
$text = $frm -> form_open("post", e_SELF);
|
||||
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>";
|
||||
|
||||
$text .= "<tr><td>".LAN_ALT_26."</td><td>";
|
||||
$text .= E107DB_LAN_1;
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= alt_auth_get_db_fields('e107db', $frm, $parm, 'server|uname|pwd|db|prefix|classfilt');
|
||||
|
||||
$text .= "<tr><td>".E107DB_LAN_9."</td><td>";
|
||||
$text .= $frm -> form_select_open("e107db_password_method");
|
||||
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 .= "<tr><td colspan='2'>".E107DB_LAN_11."</td></tr>";
|
||||
|
||||
$text .= alt_auth_get_field_list('e107db',$frm, $parm, TRUE);
|
||||
|
||||
$text .= "</table><div class='buttons-bar center'>";
|
||||
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
||||
$text .= "</div>";
|
||||
$text .= $frm -> form_close();
|
||||
|
||||
$ns -> tablerender(E107DB_LAN_10, $text);
|
||||
|
||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('e107db',$frm));
|
||||
}
|
||||
|
||||
require_once(e_ADMIN."footer.php");
|
||||
|
||||
|
||||
|
||||
function e107db_conf_adminmenu()
|
||||
{
|
||||
alt_auth_adminmenu();
|
||||
}
|
||||
|
||||
?>
|
||||
<?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)
|
||||
*
|
||||
* e107 DB configuration for alt_auth plugin
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
$eplug_admin = true;
|
||||
require_once('../../class2.php');
|
||||
require_once(e_ADMIN.'auth.php');
|
||||
require_once(e_HANDLER.'form_handler.php');
|
||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_e107db_conf.php');
|
||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||
define('ALT_AUTH_ACTION', 'e107db');
|
||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||
|
||||
|
||||
if($_POST['update'])
|
||||
{
|
||||
$message = alt_auth_post_options('e107db');
|
||||
}
|
||||
|
||||
|
||||
if($message)
|
||||
{
|
||||
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
|
||||
}
|
||||
|
||||
|
||||
|
||||
show_e107db_form();
|
||||
|
||||
|
||||
function show_e107db_form()
|
||||
{
|
||||
$ns = e107::getRender();
|
||||
|
||||
$parm = altAuthGetParams('e107db');
|
||||
|
||||
$frm = new form;
|
||||
$text = $frm -> form_open('post', e_SELF);
|
||||
$text .= "<table cellpadding='0' cellspacing='0' class='fborder'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>";
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_26."</td><td class='forumheader3'>";
|
||||
$text .= E107DB_LAN_1;
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= alt_auth_get_db_fields('e107db', $frm, $parm, 'server|uname|pwd|db|prefix|classfilt');
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".E107DB_LAN_9."</td><td class='forumheader3'>";
|
||||
$text .= altAuthGetPasswordSelector('e107db_password_method', $frm, $parm['e107db_password_method'], FALSE);
|
||||
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "<tr><td colspan='2'><br />".E107DB_LAN_11."</td></tr>";
|
||||
|
||||
$text .= alt_auth_get_field_list('e107db',$frm, $parm, TRUE);
|
||||
|
||||
$text .= "</table><div class='buttons-bar center'>";
|
||||
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
||||
$text .= '</div>';
|
||||
$text .= $frm -> form_close();
|
||||
|
||||
$ns->tablerender(E107DB_LAN_10, $text);
|
||||
|
||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('e107db',$frm));
|
||||
}
|
||||
|
||||
require_once(e_ADMIN.'footer.php');
|
||||
|
||||
|
||||
|
||||
function e107db_conf_adminmenu()
|
||||
{
|
||||
alt_auth_adminmenu();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -2,11 +2,11 @@
|
||||
/*
|
||||
* 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
|
||||
* 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 $
|
||||
* $Revision$
|
||||
@@ -14,6 +14,14 @@
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
define('ALT_AUTH_PATH', e_PLUGIN.'alt_auth/');
|
||||
|
@@ -2,17 +2,25 @@
|
||||
/*
|
||||
* 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
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
* Extended password handler for alt_auth plugin
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
/**
|
||||
EXTENDED PASSWORD HANDLER CLASS
|
||||
- supports many password formats used on other systems
|
||||
- implements checking of existing passwords only
|
||||
@@ -23,97 +31,105 @@ To use:
|
||||
or, optionally:
|
||||
call CheckPassword(plaintext_password,login_name, stored_value, password_type)
|
||||
|
||||
|
||||
To do:
|
||||
|
||||
@todo:
|
||||
1. Check that public/private declarations of functions are correct
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
var $itoa64; // 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
|
||||
private $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; // Holds a string of 64 characters for base64 conversion
|
||||
var $random_state = ''; // A (hopefully) random number
|
||||
|
||||
|
||||
|
||||
|
||||
// Constructor
|
||||
function __construct()
|
||||
{
|
||||
// Lookup string ready for base64 conversions
|
||||
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
// Ancestor constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
// Return a number of random bytes as specified by $count
|
||||
function get_random_bytes($count)
|
||||
{
|
||||
$this->random_state = md5($this->random_state.microtime().mt_rand(0,10000)); // This will 'auto seed'
|
||||
|
||||
$output = '';
|
||||
for ($i = 0; $i < $count; $i += 16)
|
||||
{ // Only do this loop once unless we need more than 16 bytes
|
||||
$this->random_state = md5(microtime() . $this->random_state);
|
||||
$output .= pack('H*', md5($this->random_state)); // Becomes an array of 16 bytes
|
||||
}
|
||||
$output = substr($output, 0, $count);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
// Encode to base64 (each block of three 8-bit chars becomes 4 printable chars)
|
||||
// Use first $count characters of $input string
|
||||
function encode64($input, $count)
|
||||
{
|
||||
$output = '';
|
||||
$i = 0;
|
||||
do
|
||||
/**
|
||||
* Constructor - just call parent
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$value = ord($input[$i++]);
|
||||
$output .= $this->itoa64[$value & 0x3f];
|
||||
if ($i < $count) $value |= ord($input[$i]) << 8;
|
||||
$output .= $this->itoa64[($value >> 6) & 0x3f];
|
||||
if ($i++ >= $count) break;
|
||||
if ($i < $count) $value |= ord($input[$i]) << 16;
|
||||
$output .= $this->itoa64[($value >> 12) & 0x3f];
|
||||
if ($i++ >= $count) break;
|
||||
$output .= $this->itoa64[($value >> 18) & 0x3f];
|
||||
} while ($i < $count);
|
||||
// Ancestor constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'
|
||||
|
||||
$output = '';
|
||||
for ($i = 0; $i < $count; $i += 16)
|
||||
{ // Only do this loop once unless we need more than 16 bytes
|
||||
$this->random_state = md5(microtime() . $this->random_state);
|
||||
$output .= pack('H*', md5($this->random_state)); // Becomes an array of 16 bytes
|
||||
}
|
||||
$output = substr($output, 0, $count);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode to base64 (each block of three 8-bit chars becomes 4 printable chars)
|
||||
* 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 = '';
|
||||
$i = 0;
|
||||
do
|
||||
{
|
||||
$value = ord($input[$i++]);
|
||||
$output .= $this->itoa64[$value & 0x3f];
|
||||
if ($i < $count) $value |= ord($input[$i]) << 8;
|
||||
$output .= $this->itoa64[($value >> 6) & 0x3f];
|
||||
if ($i++ >= $count) break;
|
||||
if ($i < $count) $value |= ord($input[$i]) << 16;
|
||||
$output .= $this->itoa64[($value >> 12) & 0x3f];
|
||||
if ($i++ >= $count) break;
|
||||
$output .= $this->itoa64[($value >> 18) & 0x3f];
|
||||
} while ($i < $count);
|
||||
|
||||
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
|
||||
// Returns FALSE on error
|
||||
function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
|
||||
/**
|
||||
* 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
|
||||
* Returns FALSE on error
|
||||
*/
|
||||
private function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
|
||||
{
|
||||
$output = '*0';
|
||||
if (substr($stored_password, 0, 2) == $output)
|
||||
@@ -173,57 +189,70 @@ 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();
|
||||
if ($include_core)
|
||||
$vals = array('md5' => IMPORTDB_LAN_7,'e107_salt' => IMPORTDB_LAN_8); // Methods supported in core
|
||||
if ($includeExtended)
|
||||
{
|
||||
$vals = array('md5' => IMPORTDB_LAN_7,'e107_salt' => IMPORTDB_LAN_8); // Methods supported in core
|
||||
}
|
||||
if (is_bool($include_core))
|
||||
{
|
||||
$vals = array_merge($vals,array(
|
||||
'plaintext' => IMPORTDB_LAN_2,
|
||||
'joomla_salt' => IMPORTDB_LAN_3,
|
||||
'mambo_salt' => IMPORTDB_LAN_4,
|
||||
'smf_sha1' => IMPORTDB_LAN_5,
|
||||
'sha1' => IMPORTDB_LAN_6,
|
||||
'phpbb3_salt' => IMPORTDB_LAN_12,
|
||||
'wordpress_salt' => IMPORTDB_LAN_13,
|
||||
'wordpress_salt' => IMPORTDB_LAN_14,
|
||||
));
|
||||
$vals = array_merge($vals,array(
|
||||
'plaintext' => IMPORTDB_LAN_2,
|
||||
'joomla_salt' => IMPORTDB_LAN_3,
|
||||
'mambo_salt' => IMPORTDB_LAN_4,
|
||||
'smf_sha1' => IMPORTDB_LAN_5,
|
||||
'sha1' => IMPORTDB_LAN_6,
|
||||
'phpbb3_salt' => IMPORTDB_LAN_12,
|
||||
'wordpress_salt' => IMPORTDB_LAN_13,
|
||||
'magento_salt' => IMPORTDB_LAN_14,
|
||||
));
|
||||
}
|
||||
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(
|
||||
'plaintext' => PASSWORD_PLAINTEXT,
|
||||
'joomla_salt' => PASSWORD_JOOMLA_SALT,
|
||||
'mambo_salt' => PASSWORD_MAMBO_SALT,
|
||||
'smf_sha1' => PASSWORD_GENERAL_SHA1,
|
||||
'sha1' => PASSWORD_GENERAL_SHA1,
|
||||
'mambo' => PASSWORD_GENERAL_MD5,
|
||||
'phpbb2' => PASSWORD_GENERAL_MD5,
|
||||
'e107' => PASSWORD_GENERAL_MD5,
|
||||
'md5' => PASSWORD_GENERAL_MD5,
|
||||
'e107_salt' => PASSWORD_E107_SALT,
|
||||
'phpbb2_salt' => PASSWORD_PHPBB_SALT,
|
||||
'phpbb3_salt' => PASSWORD_PHPBB_SALT,
|
||||
'plaintext' => PASSWORD_PLAINTEXT,
|
||||
'joomla_salt' => PASSWORD_JOOMLA_SALT,
|
||||
'mambo_salt' => PASSWORD_MAMBO_SALT,
|
||||
'smf_sha1' => PASSWORD_GENERAL_SHA1,
|
||||
'sha1' => PASSWORD_GENERAL_SHA1,
|
||||
'mambo' => PASSWORD_GENERAL_MD5,
|
||||
'phpbb2' => PASSWORD_GENERAL_MD5,
|
||||
'e107' => PASSWORD_GENERAL_MD5,
|
||||
'md5' => PASSWORD_GENERAL_MD5,
|
||||
'e107_salt' => PASSWORD_E107_SALT,
|
||||
'phpbb2_salt' => PASSWORD_PHPBB_SALT,
|
||||
'phpbb3_salt' => PASSWORD_PHPBB_SALT,
|
||||
'wordpress_salt' => PASSWORD_WORDPRESS_SALT,
|
||||
'magento_salt' => PASSWORD_MAGENTO_SALT,
|
||||
'magento_salt' => PASSWORD_MAGENTO_SALT,
|
||||
);
|
||||
if (isset($maps[$ptype])) return $maps[$ptype];
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
@@ -268,11 +297,11 @@ class ExtendedPasswordHandler extends UserHandler
|
||||
|
||||
$pwHash = $salt ? md5($salt.$pword) : md5($pword);
|
||||
$stored_hash = $hash;
|
||||
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
case PASSWORD_PHPBB_SALT :
|
||||
|
@@ -1,21 +1,24 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/importdb_auth.php,v $
|
||||
| $Revision$
|
||||
| $Date$
|
||||
| $Author$
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
* 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)
|
||||
*
|
||||
* imported DB authorisation for alt_auth plugin
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
/*
|
||||
return values
|
||||
@@ -26,33 +29,47 @@
|
||||
AUTH_SUCCESS = valid login
|
||||
*/
|
||||
|
||||
|
||||
class auth_login
|
||||
{
|
||||
|
||||
var $conf;
|
||||
var $ErrorText;
|
||||
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||
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->conf = array();
|
||||
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->conf = altAuthGetParams('importdb');
|
||||
$this->Available = TRUE;
|
||||
}
|
||||
|
||||
|
||||
function makeErrorText($extra = '')
|
||||
private function makeErrorText($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!
|
||||
|
||||
|
@@ -1,126 +1,91 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
$eplug_admin = true;
|
||||
require_once('../../class2.php');
|
||||
require_once(e_ADMIN.'auth.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_alt_auth.php');
|
||||
define("ALT_AUTH_ACTION", "importdb");
|
||||
require_once(e_PLUGIN."alt_auth/alt_auth_adminmenu.php");
|
||||
require_once(e_PLUGIN."alt_auth/extended_password_handler.php");
|
||||
|
||||
|
||||
if($_POST['update'])
|
||||
{
|
||||
// $message = update_importdb_prefs();
|
||||
$message = alt_auth_post_options('importdb');
|
||||
}
|
||||
|
||||
if($message)
|
||||
{
|
||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
||||
}
|
||||
|
||||
|
||||
show_importdb_form();
|
||||
|
||||
function show_importdb_form()
|
||||
{
|
||||
global $sql, $tp, $ns;
|
||||
|
||||
$password_methods = ExtendedPasswordHandler::GetPasswordTypes(FALSE);
|
||||
|
||||
|
||||
// Get the parameters
|
||||
$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;
|
||||
$text = $frm -> form_open("post", e_SELF);
|
||||
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>";
|
||||
|
||||
|
||||
$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 .= $frm -> form_select_open("importdb_password_method");
|
||||
foreach($password_methods as $k => $v)
|
||||
{
|
||||
$sel = ($parm['importdb_password_method'] == $k) ? " Selected" : "";
|
||||
$text .= $frm -> form_option($v, $sel, $k);
|
||||
}
|
||||
$text .= $frm -> form_select_close();
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "</table><div class='buttons-bar center'>";
|
||||
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
||||
$text .= "</div>";
|
||||
$text .= $frm -> form_close();
|
||||
|
||||
$ns -> tablerender(IMPORTDB_LAN_10, $text);
|
||||
|
||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('importdb',$frm));
|
||||
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
alt_auth_adminmenu();
|
||||
}
|
||||
|
||||
?>
|
||||
<?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)
|
||||
*
|
||||
* Alt_auth plugin - 'importdb' configuration
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
$eplug_admin = true;
|
||||
require_once('../../class2.php');
|
||||
require_once(e_ADMIN.'auth.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_alt_auth.php');
|
||||
define('ALT_AUTH_ACTION', 'importdb');
|
||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||
|
||||
|
||||
if($_POST['update'])
|
||||
{
|
||||
// $message = update_importdb_prefs();
|
||||
$message = alt_auth_post_options('importdb');
|
||||
}
|
||||
|
||||
if($message)
|
||||
{
|
||||
e107::getRender()->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
||||
}
|
||||
|
||||
|
||||
show_importdb_form();
|
||||
|
||||
function show_importdb_form()
|
||||
{
|
||||
$ns = e107::getRender();
|
||||
|
||||
|
||||
$parm = altAuthGetParams('importdb');
|
||||
|
||||
$frm = new form;
|
||||
$text = $frm -> form_open('post', e_SELF);
|
||||
$text .= "<table cellpadding='0' cellspacing='0' class='adminform'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>";
|
||||
|
||||
|
||||
$text .= "<tr><td colspan='2' class='forumheader3'>".IMPORTDB_LAN_11."</td></tr>";
|
||||
$text .= "<tr><td>".IMPORTDB_LAN_9."</td><td>";
|
||||
|
||||
$text .= altAuthGetPasswordSelector('importdb_password_method', $frm, $parm['importdb_password_method'], TRUE);
|
||||
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "</table><div class='buttons-bar center'>";
|
||||
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
||||
$text .= "</div>";
|
||||
$text .= $frm -> form_close();
|
||||
|
||||
$ns -> tablerender(IMPORTDB_LAN_10, $text);
|
||||
|
||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('importdb',$frm));
|
||||
|
||||
}
|
||||
|
||||
require_once(e_ADMIN.'footer.php');
|
||||
|
||||
|
||||
function importdb_conf_adminmenu()
|
||||
{
|
||||
alt_auth_adminmenu();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -14,6 +14,14 @@
|
||||
* $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_02','Alt auth extended user classes changed');
|
||||
define('LAN_AL_AUTH_03','Alt auth method settings changed');
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* 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
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -12,6 +12,15 @@
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
define('LAN_ALT_1', 'Primary authorisation type');
|
||||
define('LAN_ALT_2', 'Update settings');
|
||||
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_21', 'Ban status 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_25', '(sometimes combined with password for added security)');
|
||||
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_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_FAIL', 'Failed login');
|
||||
|
@@ -1,17 +1,39 @@
|
||||
<?php
|
||||
|
||||
define('E107DB_LAN_1', 'E107 format database');
|
||||
define('E107DB_LAN_9', 'Password Method:');
|
||||
define('E107DB_LAN_10', 'Configure E107 db auth');
|
||||
define('E107DB_LAN_11', 'Check the box against any field you wish to be transferred to the local database:');
|
||||
|
||||
|
||||
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
|
||||
define('IMPORTDB_LAN_8', 'E107 salted (option 0.8 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
|
||||
original password is read from the local database, and validated against the storage format of the original system. If it verifies, its converted to the current E107-compatible format and
|
||||
stored in the database.');
|
||||
|
||||
?>
|
||||
<?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_9', 'Password Method:');
|
||||
define('E107DB_LAN_10', 'Configure E107 db auth');
|
||||
define('E107DB_LAN_11', 'Check the box against any field you wish to be transferred to the local database:');
|
||||
|
||||
|
||||
define('IMPORTDB_LAN_7', 'MD5 (E107 original)');
|
||||
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
|
||||
original password is read from the local database, and validated against the storage format of the original system. If it verifies, its converted to the current E107-compatible format and
|
||||
stored in the database.');
|
||||
|
||||
?>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* 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
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -12,22 +12,32 @@
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
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 0.8 on)');
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
// 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_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.
|
||||
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.');
|
||||
define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
|
||||
define('IMPORTDB_LAN_13', 'WordPress salted');
|
||||
define('IMPORTDB_LAN_14', 'Magento salted');
|
||||
//define('IMPORTDB_LAN_12', 'PHPBB2/PHPBB3 salted');
|
||||
//define('IMPORTDB_LAN_13', 'WordPress 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
|
||||
|
@@ -1,23 +1,44 @@
|
||||
<?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");
|
||||
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 />ie '(objectclass=inetOrgPerson)'");
|
||||
define("LDAPLAN_9", "Current search filter will be:");
|
||||
define("LDAPLAN_10", "Settings Updated");
|
||||
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!");
|
||||
define("LDAPLAN_12", 'Server Type');
|
||||
define("LDAPLAN_13", 'Update settings');
|
||||
define('LDAPLAN_14', 'OU for AD (e.g. ou=itdept)');
|
||||
|
||||
|
||||
define('SHOW_COPY_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.');
|
||||
|
||||
|
||||
?>
|
||||
<?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)
|
||||
*
|
||||
* LDAP authorisation for alt_auth plugin - language file
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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('SHOW_COPY_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. It requires that PHP\'s LDAP extension is loaded. Refer to the wiki for further information.');
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -1,14 +1,38 @@
|
||||
<?php
|
||||
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");
|
||||
|
||||
/*
|
||||
* 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('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
|
||||
// an asterisk (*) are mandatory.<br />Leave the field blank for it not to be transferred at all");
|
||||
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_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_CONVERSION_HELP', TRUE);
|
||||
|
@@ -1,14 +1,37 @@
|
||||
<?php
|
||||
define('LAN_RADIUS_01', 'Server address');
|
||||
define('LAN_RADIUS_02', 'Shared secret');
|
||||
define('LAN_RADIUS_03', 'Server user');
|
||||
define('LAN_RADIUS_04', 'Server password');
|
||||
define('LAN_RADIUS_06', 'Configure RADIUS auth');
|
||||
define('LAN_RADIUS_11', 'WARNING: It appears that the RADIUS module is not currently available; setting your auth method to RADIUS will probably not work!');
|
||||
|
||||
|
||||
define('LAN_AUTHENTICATE_HELP','This authentication method is used with an external RADIUS server. It requres that PHP\'s RADIUS extension is enabled. <br />
|
||||
Note that the RADIUS server may only allow access from a specific range of IP addresses');
|
||||
|
||||
|
||||
?>
|
||||
<?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_02', 'Shared secret');
|
||||
define('LAN_RADIUS_03', 'Server user');
|
||||
define('LAN_RADIUS_04', 'Server password');
|
||||
define('LAN_RADIUS_06', 'Configure RADIUS auth');
|
||||
define('LAN_RADIUS_11', 'WARNING: It appears that the RADIUS module is not currently available; setting your auth method to RADIUS will probably not work!');
|
||||
|
||||
|
||||
define('LAN_AUTHENTICATE_HELP','This authentication method is used with an external RADIUS server. It requres that PHP\'s RADIUS extension is enabled. <br />
|
||||
Note that the RADIUS server may only allow access from a specific range of IP addresses');
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -1,47 +1,56 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_auth.php,v $
|
||||
| $Revision$
|
||||
| $Date$
|
||||
| $Author$
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
* 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)
|
||||
*
|
||||
* LDAP authorisation for alt_auth plugin
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
class auth_login
|
||||
{
|
||||
var $server;
|
||||
var $dn;
|
||||
var $ou;
|
||||
var $usr;
|
||||
var $pwd;
|
||||
var $serverType;
|
||||
var $ldapErrorCode;
|
||||
var $ldapErrorText;
|
||||
var $ErrorText;
|
||||
var $connection;
|
||||
var $result;
|
||||
var $ldapVersion;
|
||||
var $Available;
|
||||
var $filter;
|
||||
var $copyAttribs; // Any attributes which are to be copied on successful login
|
||||
var $copyMethods;
|
||||
private $server; // The LDAP server (array of possible servers)
|
||||
private $dn; // LDAP domain
|
||||
private $ou; // LDAP OU
|
||||
private $usr; // User name to log on to server
|
||||
private $pwd; // Password to log on to server
|
||||
private $serverType; // Server type = LDAP/AD/eDirectory
|
||||
public $ldapErrorCode; // LDAP error code on exit
|
||||
public $ldapErrorText; // LDAP error string on exit
|
||||
public $ErrorText; // e107 error string on exit
|
||||
private $connection; // LDAP resource for connection
|
||||
private $ldapVersion; // Version of LDAP to use
|
||||
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||
private $filter; // Filter for eDirectory search
|
||||
private $copyAttribs; // Any attributes which are to be copied on successful login
|
||||
private $copyMethods; // Methods which are to be used to copy attributes
|
||||
|
||||
function auth_login()
|
||||
|
||||
|
||||
/**
|
||||
* Read configuration, initialise connection to LDAP database
|
||||
*
|
||||
* @return AUTH_xxxx result code
|
||||
*/
|
||||
public function auth_login()
|
||||
{
|
||||
$this->copyAttribs = array();
|
||||
$this->copyMethods = array();
|
||||
$sql = new db;
|
||||
$sql->db_Select("alt_auth", "*", "auth_type = 'ldap' ");
|
||||
$sql = e107::getDB('altAuth');
|
||||
$sql->db_Select('alt_auth', '*', "auth_type = 'ldap' ");
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
||||
@@ -55,7 +64,7 @@ class auth_login
|
||||
}
|
||||
unset($row['auth_parmname']);
|
||||
}
|
||||
$this->server = explode(",", $ldap['ldap_server']);
|
||||
$this->server = explode(',', $ldap['ldap_server']);
|
||||
$this->serverType = $ldap['ldap_servertype'];
|
||||
$this->dn = $ldap['ldap_basedn'];
|
||||
$this->ou = $ldap['ldap_ou'];
|
||||
@@ -66,24 +75,35 @@ class auth_login
|
||||
|
||||
if (!function_exists('ldap_connect'))
|
||||
{
|
||||
$this->Available = false;
|
||||
return false;
|
||||
return AUTH_NORESOURCE;
|
||||
}
|
||||
|
||||
if (!$this->connect())
|
||||
{
|
||||
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->ldapErrorText = ldap_error($this->connection);
|
||||
$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)
|
||||
{
|
||||
@@ -104,7 +124,11 @@ class auth_login
|
||||
return false;
|
||||
}
|
||||
|
||||
function close()
|
||||
|
||||
/**
|
||||
* Close the connection to the LDAP server
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
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)
|
||||
{
|
||||
/* Construct the full DN, eg:-
|
||||
@@ -248,8 +285,8 @@ class auth_login
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Login failed. Return false, together with the error code and text from
|
||||
** the LDAP server. The common error codes and reasons are listed below :
|
||||
/* Login failed. Return error code.
|
||||
** The common error codes and reasons are listed below :
|
||||
** (for iPlanet, other servers may differ)
|
||||
** 19 - Account locked out (too many invalid login attempts)
|
||||
** 32 - User does not exist
|
||||
|
@@ -1,37 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_conf.php,v $
|
||||
| $Revision$
|
||||
| $Date$
|
||||
| $Author$
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
* 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)
|
||||
*
|
||||
* LDAP configuration for alt_auth plugin
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
$eplug_admin = true;
|
||||
require_once("../../class2.php");
|
||||
require_once(e_ADMIN."auth.php");
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE."/admin_ldap_conf.php");
|
||||
require_once('../../class2.php');
|
||||
require_once(e_ADMIN.'auth.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_alt_auth.php');
|
||||
define('ALT_AUTH_ACTION', 'ldap');
|
||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||
|
||||
|
||||
$server_types[1]="LDAP";
|
||||
$server_types[2]="ActiveDirectory";
|
||||
$server_types[3]="eDirectory";
|
||||
$server_types[1] = 'LDAP';
|
||||
$server_types[2] = 'ActiveDirectory';
|
||||
$server_types[3] = 'eDirectory';
|
||||
|
||||
$ldap_ver[1]="2";
|
||||
$ldap_ver[2]="3";
|
||||
$ldap_ver[1]='2';
|
||||
$ldap_ver[2]='3';
|
||||
|
||||
$message = '';
|
||||
if($_POST['update'])
|
||||
@@ -48,28 +52,24 @@ if(!function_exists('ldap_connect'))
|
||||
|
||||
if($message)
|
||||
{
|
||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
||||
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
|
||||
}
|
||||
|
||||
|
||||
$ldap['ldap_edirfilter'] == "";
|
||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'ldap' ");
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval'])); // Encoding is new for 0.8
|
||||
}
|
||||
$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 = $frm -> form_open('post',e_SELF);
|
||||
$text .= "<table style='width:96%' class='fborder'>";
|
||||
$text .= "<tr><td class='forumheader3'>".LDAPLAN_12."</td><td class='forumheader3'>";
|
||||
$text .= $frm -> form_select_open("ldap_servertype");
|
||||
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_select_close();
|
||||
@@ -98,7 +98,7 @@ $text .= $frm -> form_select_open("ldap_version");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ $text .= $frm -> form_select_close();
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$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 .= "<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 .= "<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 .= "</table>";
|
||||
$text .= "</table>\n";
|
||||
$text .= $frm -> form_close();
|
||||
|
||||
$ns -> tablerender(LDAPLAN_6,$text);
|
||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('ldap',$frm));
|
||||
e107::getRender()->tablerender(LDAPLAN_6,$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");
|
||||
|
||||
function ldap_conf_adminmenu()
|
||||
{
|
||||
|
@@ -1,21 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/otherdb_auth.php,v $
|
||||
| $Revision$
|
||||
| $Date$
|
||||
| $Author$
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
* 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)
|
||||
*
|
||||
* Alt_auth plugin - 'otherdb' authorisation handler
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
|
||||
/*
|
||||
return values
|
||||
@@ -29,115 +33,133 @@
|
||||
class auth_login
|
||||
{
|
||||
|
||||
var $Available;
|
||||
var $ErrorText;
|
||||
var $conf; // Configuration parameters
|
||||
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||
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->conf = array();
|
||||
$this->ErrorText = '';
|
||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'otherdb' ");
|
||||
while($row = $sql -> db_Fetch())
|
||||
{
|
||||
$this->conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
||||
}
|
||||
$this->conf = altAuthGetParams('otherdb');
|
||||
$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;
|
||||
global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
||||
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
|
||||
//global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
|
||||
//$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
|
||||
if(!$res = mysql_connect($this->conf['otherdb_server'], $this->conf['otherdb_username'], $this->conf['otherdb_password']))
|
||||
{
|
||||
$this->makeErrorText('Cannot connect to remote server');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
//Select correct db
|
||||
if(!mysql_select_db($this->conf['otherdb_database'], $res))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('Cannot connect to remote DB');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
if ($connect_only) return AUTH_SUCCESS; // Test mode may just want to connect to the DB
|
||||
$sel_fields = array();
|
||||
// Make an array of the fields we want from the source DB
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
if ($v && (strpos($k,'otherdb_xf_') === 0))
|
||||
//Attempt to open connection to sql database
|
||||
if(!$res = mysql_connect($this->conf['otherdb_server'], $this->conf['otherdb_username'], $this->conf['otherdb_password']))
|
||||
{
|
||||
$sel_fields[] = $v;
|
||||
$this->makeErrorText('Cannot connect to remote server');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
//Select correct db
|
||||
if(!mysql_select_db($this->conf['otherdb_database'], $res))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('Cannot connect to remote DB');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
if ($connect_only) return AUTH_SUCCESS; // Test mode may just want to connect to the DB
|
||||
$sel_fields = array();
|
||||
// Make an array of the fields we want from the source DB
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
if ($v && (strpos($k,'otherdb_xf_') === 0))
|
||||
{
|
||||
$sel_fields[] = $v;
|
||||
}
|
||||
}
|
||||
$sel_fields[] = $this->conf['otherdb_password_field'];
|
||||
$user_field = $this->conf['otherdb_user_field'];
|
||||
if (isset($this->conf['otherdb_salt_field']))
|
||||
{
|
||||
$sel_fields[] = $this->conf['otherdb_salt_field'];
|
||||
}
|
||||
}
|
||||
$sel_fields[] = $this->conf['otherdb_password_field'];
|
||||
$user_field = $this->conf['otherdb_user_field'];
|
||||
if (isset($this->conf['otherdb_salt_field']))
|
||||
{
|
||||
$sel_fields[] = $this->conf['otherdb_salt_field'];
|
||||
}
|
||||
|
||||
|
||||
//Get record containing supplied login name
|
||||
$qry = "SELECT ".implode(',',$sel_fields)." FROM {$this->conf['otherdb_table']} WHERE {$user_field} = '{$uname}'";
|
||||
//Get record containing supplied login name
|
||||
$qry = "SELECT ".implode(',',$sel_fields)." FROM {$this->conf['otherdb_table']} WHERE {$user_field} = '{$uname}'";
|
||||
// echo "Query: {$qry}<br />";
|
||||
if(!$r1 = mysql_query($qry))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('Lookup query failed');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
if(!$row = mysql_fetch_array($r1))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('User not found');
|
||||
return AUTH_NOUSER;
|
||||
}
|
||||
|
||||
mysql_close($res); // Finished with 'foreign' DB now
|
||||
|
||||
// Got something from the DB - see whether password valid
|
||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php'); // This auto-loads the 'standard' password handler as well
|
||||
$pass_check = new ExtendedPasswordHandler();
|
||||
|
||||
$passMethod = $pass_check->passwordMapping($this->conf['otherdb_password_method']);
|
||||
if ($passMethod === FALSE)
|
||||
{
|
||||
$this->makeErrorText('Password error - invalid method');
|
||||
return AUTH_BADPASSWORD;
|
||||
}
|
||||
|
||||
$pwFromDB = $row[$this->conf['otherdb_password_field']]; // Password stored in DB
|
||||
if ($salt_field) $pwFromDB .= ':'.$row[$salt_field];
|
||||
|
||||
if ($pass_check->checkPassword($pword, $uname, $pwFromDB, $passMethod) !== PASSWORD_VALID)
|
||||
{
|
||||
$this->makeErrorText('Password incorrect');
|
||||
return AUTH_BADPASSWORD;
|
||||
}
|
||||
// Now copy across any values we have selected
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
if ($v && (strpos($k,'otherdb_xf_') === 0) && isset($row[$v]))
|
||||
if(!$r1 = mysql_query($qry))
|
||||
{
|
||||
$newvals[substr($k,strlen('otherdb_xf_'))] = $row[$v];
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('Lookup query failed');
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
if(!$row = mysql_fetch_array($r1))
|
||||
{
|
||||
mysql_close($res);
|
||||
$this->makeErrorText('User not found');
|
||||
return AUTH_NOUSER;
|
||||
}
|
||||
|
||||
mysql_close($res); // Finished with 'foreign' DB now
|
||||
|
||||
// Got something from the DB - see whether password valid
|
||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php'); // This auto-loads the 'standard' password handler as well
|
||||
$pass_check = new ExtendedPasswordHandler();
|
||||
|
||||
$passMethod = $pass_check->passwordMapping($this->conf['otherdb_password_method']);
|
||||
if ($passMethod === FALSE)
|
||||
{
|
||||
$this->makeErrorText('Password error - invalid method');
|
||||
return AUTH_BADPASSWORD;
|
||||
}
|
||||
|
||||
$pwFromDB = $row[$this->conf['otherdb_password_field']]; // Password stored in DB
|
||||
if ($salt_field) $pwFromDB .= ':'.$row[$salt_field];
|
||||
|
||||
if ($pass_check->checkPassword($pword, $uname, $pwFromDB, $passMethod) !== PASSWORD_VALID)
|
||||
{
|
||||
$this->makeErrorText('Password incorrect');
|
||||
return AUTH_BADPASSWORD;
|
||||
}
|
||||
// Now copy across any values we have selected
|
||||
foreach($this->conf as $k => $v)
|
||||
{
|
||||
if ($v && (strpos($k,'otherdb_xf_') === 0) && isset($row[$v]))
|
||||
{
|
||||
$newvals[substr($k,strlen('otherdb_xf_'))] = $row[$v];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->makeErrorText(''); // Success - just reconnect to E107 DB if needed
|
||||
return AUTH_SUCCESS;
|
||||
return AUTH_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,97 +1,95 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
$eplug_admin = true;
|
||||
require_once("../../class2.php");
|
||||
require_once(e_ADMIN."auth.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_alt_auth.php');
|
||||
define('ALT_AUTH_ACTION', 'otherdb');
|
||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||
|
||||
if($_POST['update'])
|
||||
{
|
||||
// $message = update_otherdb_prefs();
|
||||
$message = alt_auth_post_options('otherdb');
|
||||
}
|
||||
|
||||
if($message)
|
||||
{
|
||||
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
|
||||
}
|
||||
|
||||
|
||||
show_otherdb_form();
|
||||
|
||||
function show_otherdb_form()
|
||||
{
|
||||
global $sql, $tp, $ns;
|
||||
|
||||
|
||||
$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;
|
||||
$text = $frm -> form_open("post", e_SELF);
|
||||
$text .= "<table style='width:96%' class='fborder'>";
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_26."</td><td class='forumheader3'>";
|
||||
$text .= OTHERDB_LAN_15;
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$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 .= $frm -> form_select_open("otherdb_password_method");
|
||||
foreach($password_methods as $k => $v)
|
||||
{
|
||||
$sel = ($parm['otherdb_password_method'] == $k) ? " Selected" : "";
|
||||
$text .= $frm -> form_option($v, $sel, $k);
|
||||
}
|
||||
$text .= $frm -> form_select_close();
|
||||
$text .= "</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 .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
||||
$text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$text .= "</table>";
|
||||
$text .= $frm -> form_close();
|
||||
|
||||
$ns -> tablerender(OTHERDB_LAN_10, $text);
|
||||
|
||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('otherdb',$frm));
|
||||
}
|
||||
|
||||
require_once(e_ADMIN."footer.php");
|
||||
|
||||
|
||||
|
||||
function otherdb_conf_adminmenu()
|
||||
{
|
||||
alt_auth_adminmenu();
|
||||
}
|
||||
|
||||
?>
|
||||
<?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)
|
||||
*
|
||||
* Alt_auth plugin - 'otherdb' configuration
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* e107 Alternate authorisation plugin
|
||||
*
|
||||
* @package e107_plugins
|
||||
* @subpackage alt_auth
|
||||
* @version $Id$;
|
||||
*/
|
||||
$eplug_admin = true;
|
||||
require_once('../../class2.php');
|
||||
require_once(e_ADMIN.'auth.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_alt_auth.php');
|
||||
define('ALT_AUTH_ACTION', 'otherdb');
|
||||
require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
|
||||
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
|
||||
|
||||
|
||||
if($_POST['update'])
|
||||
{
|
||||
$message = alt_auth_post_options('otherdb');
|
||||
}
|
||||
|
||||
|
||||
if($message)
|
||||
{
|
||||
e107::getRender()->tablerender('',"<div style='text-align:center;'>".$message.'</div>');
|
||||
}
|
||||
|
||||
|
||||
|
||||
show_otherdb_form();
|
||||
|
||||
function show_otherdb_form()
|
||||
{
|
||||
$ns = e107::getRender();
|
||||
|
||||
$parm = altAuthGetParams('otherdb');
|
||||
|
||||
$frm = new form;
|
||||
$text = $frm -> form_open("post", e_SELF);
|
||||
$text .= "<table style='width:96%' class='fborder'>";
|
||||
|
||||
$text .= "<tr><td class='forumheader3'>".LAN_ALT_26."</td><td class='forumheader3'>";
|
||||
$text .= OTHERDB_LAN_15;
|
||||
$text .= "</td></tr>";
|
||||
|
||||
$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 .= altAuthGetPasswordSelector('otherdb_password_method', $frm, $parm['otherdb_password_method'], TRUE);
|
||||
|
||||
$text .= "</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 .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
|
||||
$text .= $frm -> form_button('submit', 'update', LAN_ALT_UPDATESET);
|
||||
$text .= '</td></tr>';
|
||||
|
||||
$text .= '</table>';
|
||||
$text .= $frm -> form_close();
|
||||
|
||||
$ns -> tablerender(OTHERDB_LAN_10, $text);
|
||||
|
||||
$ns->tablerender(LAN_ALT_40.LAN_ALT_41,alt_auth_test_form('otherdb',$frm));
|
||||
}
|
||||
|
||||
require_once(e_ADMIN.'footer.php');
|
||||
|
||||
|
||||
|
||||
function otherdb_conf_adminmenu()
|
||||
{
|
||||
alt_auth_adminmenu();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -31,25 +31,26 @@ define('RADIUS_DEBUG',TRUE);
|
||||
class auth_login
|
||||
{
|
||||
|
||||
var $server;
|
||||
var $secret;
|
||||
var $port;
|
||||
var $usr;
|
||||
var $pwd;
|
||||
var $ErrorText;
|
||||
var $connection; // Handle to use on successful creation
|
||||
var $result;
|
||||
var $Available;
|
||||
private $server;
|
||||
private $secret;
|
||||
private $port;
|
||||
private $usr;
|
||||
private $pwd;
|
||||
private $connection; // Handle to use on successful creation
|
||||
public $Available = FALSE; // Flag indicates whether DB connection available
|
||||
public $ErrorText; // e107 error string on exit
|
||||
|
||||
function auth_login()
|
||||
|
||||
/**
|
||||
* Read configuration, initialise connection to LDAP database
|
||||
*
|
||||
* @return AUTH_xxxx result code
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->copyAttribs = array();
|
||||
$sql = new db;
|
||||
$sql -> db_Select("alt_auth", "*", "auth_type = 'radius' ");
|
||||
while($row = $sql -> db_Fetch())
|
||||
{
|
||||
$radius[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
||||
}
|
||||
$radius = altAuthGetParams('radius');
|
||||
|
||||
$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)
|
||||
// (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 = '';
|
||||
if(!function_exists('radius_auth_open'))
|
||||
{
|
||||
$this->Available = FALSE;
|
||||
return false;
|
||||
return AUTH_NORESOURCE;
|
||||
}
|
||||
|
||||
if(!$this -> connect())
|
||||
{
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
$this->Available = TRUE;
|
||||
return AUTH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve and construct error strings
|
||||
*/
|
||||
function makeErrorText($extra = '')
|
||||
{
|
||||
$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()
|
||||
{
|
||||
// Try to connect to a radius server
|
||||
if (!($this->connection = radius_auth_open()))
|
||||
{
|
||||
$this->makeErrorText('RADIUS open failed: ') ;
|
||||
@@ -109,6 +118,9 @@ class auth_login
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Close the connection to the Radius server
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
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)
|
||||
{
|
||||
// Create authentification request
|
||||
|
Reference in New Issue
Block a user