mirror of
https://github.com/e107inc/e107.git
synced 2025-01-18 05:09:05 +01:00
alt_auth update - feature complete
This commit is contained in:
parent
7c70ee283a
commit
61eb377350
@ -1,5 +1,15 @@
|
||||
<?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');
|
||||
@ -30,11 +40,11 @@ function alt_auth_get_authlist()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// All user fields which might, just possibly, be transferred. The option name must be the corresponding field in the E107 user database, prefixed with 'xf_'
|
||||
$alt_auth_user_fields = array(
|
||||
'user_email' => array('prompt' => LAN_ALT_12, 'optname' => 'xf_user_email', 'default' => 'user_email', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'mail'),
|
||||
'user_hideemail' => array('prompt' => LAN_ALT_13, 'optname' => 'xf_user_hideemail', 'default' => 'user_hideemail', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
|
||||
'user_hideemail' => array('prompt' => LAN_ALT_13, 'optname' => 'xf_user_hideemail', 'default' => 'user_hideemail', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => '', method => 'bool1'),
|
||||
'user_name' => array('prompt' => LAN_ALT_14, 'optname' => 'xf_user_name', 'default' => 'user_name', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => ''),
|
||||
'user_login' => array('prompt' => LAN_ALT_15, 'optname' => 'xf_user_login', 'default' => 'user_login', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'sn'),
|
||||
'user_customtitle'=> array('prompt' => LAN_ALT_16, 'optname' => 'xf_user_customtitle', 'default' => 'user_customtitle', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE),
|
||||
@ -47,62 +57,95 @@ $alt_auth_user_fields = array(
|
||||
'user_xup' => array('prompt' => LAN_ALT_23, 'optname' => 'xf_user_xup', 'default' => 'user_xup', 'optional' => TRUE, 'otherdb' => FALSE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => FALSE)
|
||||
);
|
||||
|
||||
*/
|
||||
// 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]))
|
||||
global $alt_auth_user_fields;
|
||||
$ret = '';
|
||||
foreach ($alt_auth_user_fields as $f => $v)
|
||||
{
|
||||
$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'];
|
||||
$value = varset($v['default'],'');
|
||||
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);
|
||||
}
|
||||
$ret .= "</td></tr>\n";
|
||||
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;
|
||||
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]))
|
||||
global $alt_auth_user_fields;
|
||||
$ret = array();
|
||||
foreach ($alt_auth_user_fields as $f => $v)
|
||||
{
|
||||
$fieldname = $tableType.'_'.$v['optname'];
|
||||
$ret[$fieldname] = '1';
|
||||
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;
|
||||
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;
|
||||
@ -118,10 +161,11 @@ function add_extended_fields()
|
||||
if (isset($xFields[$f]))
|
||||
{
|
||||
$alt_auth_user_fields['x_'.$f] = array('prompt' => varset($xFields[$f]['user_extended_struct_text'],'').' ('.$f.')',
|
||||
'optname' => 'xf_x_'.$f,
|
||||
'default' => varset($xFields[$f]['default'],''),
|
||||
'optional' => TRUE,
|
||||
'showAll' => 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;
|
||||
@ -140,6 +184,7 @@ $common_fields = array(
|
||||
'salt' => array('fieldname' => 'password_salt','size' => 35, 'max_size' => 120, 'prompt' => LAN_ALT_24, 'help' => LAN_ALT_25)
|
||||
);
|
||||
|
||||
|
||||
function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pwd|db|table|ufield|pwfield')
|
||||
{
|
||||
global $common_fields;
|
||||
@ -164,37 +209,37 @@ function alt_auth_get_db_fields($prefix, $frm, $parm, $fields = 'server|uname|pw
|
||||
// Write all the options to the DB. $prefix must NOT have trailing underscore
|
||||
function alt_auth_post_options($prefix)
|
||||
{
|
||||
global $common_fields, $sql, $admin_log;
|
||||
$lprefix = $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]))
|
||||
$user_fields = alt_auth_get_allowed_fields($prefix); // Need this list in case checkboxes for parameters
|
||||
foreach ($user_fields as $k => $v)
|
||||
{
|
||||
$_POST[$k] = '0';
|
||||
if (!isset($_POST[$k]))
|
||||
{
|
||||
$_POST[$k] = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we can post everything
|
||||
foreach($_POST as $k => $v)
|
||||
{
|
||||
if (strpos($k,$lprefix) === 0)
|
||||
// Now we can post everything
|
||||
foreach($_POST as $k => $v)
|
||||
{
|
||||
$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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -286,6 +331,48 @@ function alt_auth_test_form($prefix,$frm)
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// 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;
|
||||
|
@ -11,14 +11,18 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/alt_auth_conf.php,v $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2008-12-09 20:40:54 $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2008-12-23 20:31:30 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
$eplug_admin = true;
|
||||
require_once('../../class2.php');
|
||||
if(!getperms("P")){header('location:'.e_BASE.'index.php'); exit; }
|
||||
if(!getperms("P") || !plugInstalled('alt_auth'))
|
||||
{
|
||||
header('location:'.e_BASE.'index.php');
|
||||
exit();
|
||||
}
|
||||
require_once(e_HANDLER.'form_handler.php');
|
||||
require_once(e_ADMIN.'auth.php');
|
||||
include_lan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||
|
@ -11,12 +11,13 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/alt_auth_login_class.php,v $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2008-12-09 20:40:54 $
|
||||
| $Revision: 1.6 $
|
||||
| $Date: 2008-12-23 20:31:30 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
define('AA_DEBUG',FALSE);
|
||||
define('AA_DEBUG1',FALSE);
|
||||
|
||||
class alt_login
|
||||
{
|
||||
@ -51,6 +52,19 @@ class alt_login
|
||||
$uh = new UserHandler;
|
||||
$db_vals = array('user_password' => $aa_sql->escape($uh->HashPassword($userpass,$username)));
|
||||
$xFields = array(); // Possible extended user fields
|
||||
|
||||
// See if any of the fields need processing before save
|
||||
if (isset($_login->copyMethods) && count($_login->copyMethods))
|
||||
{
|
||||
foreach ($newvals as $k => $v)
|
||||
{
|
||||
if (isset($_login->copyMethods[$k]))
|
||||
{
|
||||
$newvals[$k] = $this->translate($_login->copyMethods[$k], $v);
|
||||
if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth convert",$k.': '.$v.'=>'.$newvals[$k],FALSE,LOG_TO_ROLLING);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($newvals as $k => $v)
|
||||
{
|
||||
if (strpos($k,'x_') === 0)
|
||||
@ -66,8 +80,7 @@ class alt_login
|
||||
}
|
||||
if (count($xFields))
|
||||
{
|
||||
// $qry = "SELECT u.*, ue.* FROM `#user` AS u
|
||||
$qry = "SELECT u.user_id,u.".implode(',u.',array_keys($db_vals)).", ue.".implode(',ue.',array_keys($xFields))." FROM `#user` AS u
|
||||
$qry = "SELECT u.user_id,u.".implode(',u.',array_keys($db_vals)).", ue.user_extended_id, ue.".implode(',ue.',array_keys($xFields))." FROM `#user` AS u
|
||||
LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = u.user_id
|
||||
WHERE u.user_loginname='{$username}' ";
|
||||
if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","Query: {$qry}[!br!]".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
@ -76,8 +89,6 @@ class alt_login
|
||||
{
|
||||
$qry = "SELECT * FROM `#user` WHERE `user_loginname`='{$username}'";
|
||||
}
|
||||
// echo "Query: {$qry}<br />";
|
||||
// if($aa_sql -> db_Select("user","*","user_loginname='{$username}' "))
|
||||
if($aa_sql -> db_Select_gen($qry))
|
||||
{ // Existing user - get current data, see if any changes
|
||||
$row = $aa_sql->db_Fetch(MYSQL_ASSOC);
|
||||
@ -88,17 +99,19 @@ class alt_login
|
||||
if (count($db_vals))
|
||||
{
|
||||
$aa_sql->db_UpdateArray('user',$db_vals," WHERE `user_id`=".$row['user_id']);
|
||||
if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User data update: ".print_r($db_vals,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
}
|
||||
foreach ($xFields as $k => $v)
|
||||
{
|
||||
if ($row[$k] == $v) unset($xFields[$k]);
|
||||
}
|
||||
if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User data read: ".print_r($row,TRUE)."[!br!]".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User xtnd read: ".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
if (count($xFields))
|
||||
{
|
||||
if ($row['user_extended_id'])
|
||||
{
|
||||
if (AA_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","Update existing extended record",FALSE,LOG_TO_ROLLING);
|
||||
if (AA_DEBUG1) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User xtnd update: ".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
$aa_sql->db_UpdateArray('user_extended',$xFields," WHERE `user_extended_id`=".intval($row['user_id']));
|
||||
}
|
||||
else
|
||||
@ -154,5 +167,33 @@ class alt_login
|
||||
}
|
||||
return LOGIN_ABORT; // catch-all just in case
|
||||
}
|
||||
|
||||
|
||||
// Function to implement copy methods
|
||||
function translate($method, $word)
|
||||
{
|
||||
global $tp;
|
||||
switch ($method)
|
||||
{
|
||||
case 'bool1' :
|
||||
switch ($tp->uStrToUpper($word))
|
||||
{
|
||||
case 'TRUE' : return TRUE;
|
||||
case 'FALSE' : return FALSE;
|
||||
}
|
||||
return $word;
|
||||
case 'ucase' :
|
||||
return $tp->uStrToUpper($word);
|
||||
case 'lcase' :
|
||||
return $tp->uStrToLower($word);
|
||||
case 'ucfirst' :
|
||||
return ucfirst($word); // TODO: Needs changing to utf-8 function
|
||||
case 'ucwords' :
|
||||
return ucwords($word); // TODO: Needs changing to utf-8 function
|
||||
case 'none' :
|
||||
return $word;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/e_help.php,v $
|
||||
| $Revision: 1.1 $
|
||||
| $Date: 2008-09-02 19:39:12 $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2008-12-23 20:31:30 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -20,16 +20,17 @@
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
define('ALT_AUTH_PATH', e_PLUGIN.'alt_auth/');
|
||||
if (!include_lan(ALT_AUTH_PATH.'languages/'.e_LANGUAGE.'/lan_'.e_PAGE)) return 'No help!';
|
||||
|
||||
if (e_PAGE == 'alt_auth_conf.php')
|
||||
{
|
||||
include_lan(ALT_AUTH_PATH.'languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||
$ns -> tablerender('help',LAN_ALT_AUTH_HELP);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!defined('LAN_ALT_VALIDATE_HELP')) include_lan(ALT_AUTH_PATH.'languages/'.e_LANGUAGE.'/lan_alt_auth_conf.php');
|
||||
$ns -> tablerender('help',LAN_AUTHENTICATE_HELP.'<br /><br />'.LAN_ALT_VALIDATE_HELP);
|
||||
include_lan(ALT_AUTH_PATH.'languages/'.e_LANGUAGE.'/admin_'.e_PAGE);
|
||||
if (!defined('LAN_ALT_VALIDATE_HELP')) include_lan(ALT_AUTH_PATH.'languages/'.e_LANGUAGE.'/admin_alt_auth.php');
|
||||
$ns -> tablerender('help',LAN_AUTHENTICATE_HELP.'<br /><br />'.(defined('SHOW_COPY_HELP') ? LAN_ALT_COPY_HELP : '').(defined('SHOW_CONVERSION_HELP') ? LAN_ALT_CONVERSION_HELP : '').LAN_ALT_VALIDATE_HELP);
|
||||
}
|
||||
|
||||
?>
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/languages/English/admin_alt_auth.php,v $
|
||||
| $Revision: 1.1 $
|
||||
| $Date: 2008-12-09 20:40:54 $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2008-12-23 20:31:30 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -88,7 +88,13 @@ define('LAN_ALT_66', 'This plugin allows for alternate authentication methods.')
|
||||
define('LAN_ALT_67', 'Configure Alt auth');
|
||||
define('LAN_ALT_68', 'Alt auth service is now set up. You will now need to configure your preferred method.');
|
||||
define('LAN_ALT_69', '');
|
||||
define('LAN_ALT_70', '');
|
||||
define('LAN_ALT_70', 'None');
|
||||
define('LAN_ALT_71', 'TRUE/FALSE');
|
||||
define('LAN_ALT_72', 'Upper case');
|
||||
define('LAN_ALT_73', 'Lower case');
|
||||
define('LAN_ALT_74', 'Upper first');
|
||||
define('LAN_ALT_75', 'Upper words');
|
||||
|
||||
|
||||
define('LAN_ALT_FALLBACK', 'Use e107 user table');
|
||||
define('LAN_ALT_FAIL', 'Failed login');
|
||||
@ -99,8 +105,19 @@ define('LAN_ALT_AUTH_HELP', 'These are the settings common to all authentication
|
||||
The Extended User Field selection determines which <i>may</i> be added/updated when a user logs in - further configuration is required
|
||||
for the specific authentication method.');
|
||||
define('LAN_ALT_VALIDATE_HELP', 'You can check the settings by using the \'Test Database Access\' section to try and validate a user - this uses exactly
|
||||
the same process as when a user tries to log in, and confirms whether your settings are correct
|
||||
the same process as when a user tries to log in, and confirms whether your settings are correct.<br />
|
||||
If you have configured some parameters to be copied to the user table on successful login, these are also listed.
|
||||
');
|
||||
|
||||
define('LAN_ALT_COPY_HELP', 'You can select fields to copy from the remote database into the user database by entering the appropriate names.<br /><br />
|
||||
');
|
||||
define('LAN_ALT_CONVERSION_HELP', 'For some fields, the drop-down box to the right of the field entry box selects a conversion which may be applied to the value
|
||||
read from the remote database; if \'none\' is selected, the value is copied as received. Conversions are:<br />
|
||||
<b>TRUE/FALSE</b> - the words \'TRUE\' and \'FALSE\' (and their lower/mixed case equivalents) are converted to the Booleans 1 and zero.<br />
|
||||
<b>Upper case</b> - All letters are converted to upper case<br />
|
||||
<b>Lower case</b> - All letters are converted to lower case<br />
|
||||
<b>Upper first</b> - the first character is converted to upper case<br />
|
||||
<b>Upper words</b> - the first letter of each word is converted to upper case<br />
|
||||
<br />
|
||||
<br />');
|
||||
|
||||
?>
|
||||
|
@ -15,6 +15,8 @@ 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.');
|
||||
|
||||
|
||||
|
@ -26,6 +26,8 @@ define("IMPORTDB_LAN_8", 'E107 salted (option 0.8 on)');
|
||||
define("IMPORTDB_LAN_12", 'PHPBB2/PHPBB3 salted');
|
||||
|
||||
|
||||
define('SHOW_COPY_HELP', TRUE);
|
||||
define('SHOW_CONVERSION_HELP', TRUE);
|
||||
define('LAN_AUTHENTICATE_HELP','This authentication method is used to validate against a non-E107 database. The password must be stored in one of the supported formats.');
|
||||
|
||||
|
||||
|
@ -11,12 +11,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_auth.php,v $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2008-12-09 20:40:54 $
|
||||
| $Revision: 1.6 $
|
||||
| $Date: 2008-12-23 20:31:30 $
|
||||
| $Author: e107steved $
|
||||
|
||||
To do:
|
||||
1. Sort out a method of just checking the connection on login (needed for test)
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@ -37,10 +34,12 @@ class auth_login
|
||||
var $Available;
|
||||
var $filter;
|
||||
var $copyAttribs; // Any attributes which are to be copied on successful login
|
||||
var $copyMethods;
|
||||
|
||||
function auth_login()
|
||||
{
|
||||
$this->copyAttribs = array();
|
||||
$this->copyMethods = array();
|
||||
$sql = new db;
|
||||
$sql->db_Select("alt_auth", "*", "auth_type = 'ldap' ");
|
||||
while ($row = $sql->db_Fetch())
|
||||
@ -48,15 +47,18 @@ class auth_login
|
||||
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
|
||||
if ((strpos($row['auth_parmname'], 'ldap_xf_') === 0) && $ldap[$row['auth_parmname']]) // Attribute to copy on successful login
|
||||
{
|
||||
// $this->copyAttribs[$ldap[$row['auth_parmname']]] = substr($row['auth_parmname'], strlen('ldap_xf_')); // Key = LDAP attribute. Value = e107 field name
|
||||
$this->copyAttribs[substr($row['auth_parmname'], strlen('ldap_xf_'))] = $ldap[$row['auth_parmname']]; // Key = LDAP attribute. Value = e107 field name
|
||||
unset($row['auth_parmname']);
|
||||
}
|
||||
elseif ((strpos($row['auth_parmname'], 'ldap_pm_') === 0) && $ldap[$row['auth_parmname']] && ($ldap[$row['auth_parmname']] != 'none')) // Method to use to copy parameter
|
||||
{ // Any fields with non-null 'copy' methods
|
||||
$this->copyMethods[substr($row['auth_parmname'], strlen('ldap_pm_'))] = $ldap[$row['auth_parmname']]; // Key = e107 field name. Value = copy method
|
||||
}
|
||||
unset($row['auth_parmname']);
|
||||
}
|
||||
$this->server = explode(",", $ldap['ldap_server']);
|
||||
$this->serverType = $ldap['ldap_servertype'];
|
||||
$this->dn = $ldap['ldap_basedn'];
|
||||
$this->ou = $ldap['ldap_ou']; // added by Father Barry Keal
|
||||
$this->ou = $ldap['ldap_ou'];
|
||||
$this->usr = $ldap['ldap_user'];
|
||||
$this->pwd = $ldap['ldap_passwd'];
|
||||
$this->ldapVersion = $ldap['ldap_version'];
|
||||
@ -218,11 +220,9 @@ class auth_login
|
||||
{
|
||||
foreach ($tempKeys as $tk) // Single LDAP attribute may be mapped to several fields
|
||||
{
|
||||
$newvals[$tk] = $this->translate($tlv[0]); // Just grab the first value
|
||||
// $newvals[$tk] = $this->translate($tlv[0]); // Just grab the first value
|
||||
$newvals[$tk] = $tlv[0]; // Just grab the first value
|
||||
}
|
||||
// echo $j.":Key: {$k} (Values: {$tlv['count']})";
|
||||
// for ($i = 0; $i < $tlv['count']; $i++) { echo ' '.$tlv[$i]; }
|
||||
// echo "<br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -269,18 +269,6 @@ class auth_login
|
||||
return AUTH_NOCONNECT;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to decode some special values
|
||||
function translate($word)
|
||||
{
|
||||
global $tp;
|
||||
switch ($tp->uStrToUpper($word))
|
||||
{
|
||||
case 'TRUE' : return TRUE;
|
||||
case 'FALSE' : return FALSE;
|
||||
}
|
||||
return $word;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/alt_auth/ldap_conf.php,v $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2008-12-09 20:40:54 $
|
||||
| $Revision: 1.6 $
|
||||
| $Date: 2008-12-23 20:31:30 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -58,6 +58,7 @@ while($row = $sql->db_Fetch())
|
||||
{
|
||||
$ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval'])); // Encoding is new for 0.8
|
||||
}
|
||||
//print_a($ldap);
|
||||
|
||||
$current_filter = "(&(cn=[USERNAME]){$ldap['ldap_edirfilter']})";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user