1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-21 05:41:58 +02:00

new module creation

This commit is contained in:
mcfly
2006-12-02 04:36:16 +00:00
commit e149b35fcc
2196 changed files with 182987 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
function alt_auth_get_authlist()
{
$authlist = array("e107");
$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_adminmenu()
{
global $authlist;
echo " ";
if(!is_array($authlist))
{
$authlist = alt_auth_get_authlist();
}
define("ALT_AUTH_ACTION", "main");
$var['main']['text'] = "Main config";
$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'] = "Config {$a}";
$var[$a]['link'] = e_PLUGIN."alt_auth/{$a}_conf.php";
}
}
show_admin_menu("Auth methods", ALT_AUTH_ACTION, $var);
}
?>

View File

@@ -0,0 +1,115 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@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/alt_auth_conf.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:34:43 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
$eplug_admin = true;
require_once("../../class2.php");
if(!getperms("P")){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."/lan_alt_auth_conf.php");
define("ALT_AUTH_ACTION", "main");
require_once(e_PLUGIN."alt_auth/alt_auth_adminmenu.php");
if(isset($_POST['updateprefs']))
{
$pref['auth_method'] = $_POST['auth_method'];
$pref['auth_noconn'] = intval($_POST['auth_noconn']);
$pref['auth_nouser'] = intval($_POST['auth_nouser']);
save_prefs();
header("location:".e_SELF);
exit;
}
$authlist = alt_auth_get_authlist();
$auth_dropdown = "<select class='tbox' name='auth_method'>\n";
foreach($authlist as $a)
{
$s = ($pref['auth_method'] == $a) ? "selected='selected'" : "";
$auth_dropdown .= "<option value='{$a}' {$s}>".$a."</option>\n";
}
$auth_dropdown .= "</select>\n";
if(isset($message))
{
$ns -> tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
}
$text = "
<div style='text-align:center'>
<form method='post' action='".e_SELF."'>
<table style='width:95%' class='fborder' cellspacing='1' cellpadding='0'>
<tr>
<td style='width:70%' class='forumheader3'>".LAN_ALT_1.": </td>
<td style='width:30%; text-align:right;' class='forumheader3'>".
$auth_dropdown."
</td>
</tr>
<tr>
<td style='width:70%' class='forumheader3'>".LAN_ALT_6.":<br />
<div class='smalltext'>".LAN_ALT_7."</div>
</td>
<td style='width:30%; text-align:right;' class='forumheader3'>
<select class='tbox' name='auth_noconn'>";
$sel = (isset($pref['auth_noconn']) && $pref['auth_noconn'] ? "" : " selected = 'selected' ");
$text .= "<option value='0' {$sel} >".LAN_ALT_FAIL."</option>";
$sel = (isset($pref['auth_noconn']) && $pref['auth_noconn'] ? " selected = 'selected' " : "");
$text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
</select>
</td>
</tr>
<tr>
<td style='width:70%' class='forumheader3'>".LAN_ALT_8.":<br />
<div class='smalltext'>".LAN_ALT_9."</div>
</td>
<td style='width:30%; text-align:right;' class='forumheader3'>
<select class='tbox' name='auth_nouser'>";
$sel = (isset($pref['auth_nouser']) && $pref['auth_nouser'] ? "" : " selected = 'selected' ");
$text .= "<option value='0' {$sel} >".LAN_ALT_FAIL."</option>";
$sel = (isset($pref['auth_nouser']) && $pref['auth_nouser'] ? " selected = 'selected' " : "");
$text .= "<option value='1' {$sel} >".LAN_ALT_FALLBACK."</option>
</select>
</td>
</tr>
<tr style='vertical-align:top'>
<td colspan='2' style='text-align:center' class='forumheader3'>
<br />
<input class='button' type='submit' name='updateprefs' value='".LAN_ALT_2."' />
</td>
</tr>
</table>
</form>
</div>";
$ns -> tablerender("<div style='text-align:center'>".LAN_ALT_3."</div>", $text);
require_once(e_ADMIN."footer.php");
function alt_auth_conf_adminmenu()
{
alt_auth_adminmenu();
}
?>

View File

@@ -0,0 +1,80 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@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/alt_auth_login_class.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:34:43 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
class alt_login
{
function alt_login($method, &$username, &$userpass)
{
global $pref;
$newvals=array();
define("AUTH_SUCCESS", -1);
define("AUTH_NOUSER", 1);
define("AUTH_BADPASSWORD", 2);
define("AUTH_NOCONNECT", 3);
require_once(e_PLUGIN."alt_auth/".$method."_auth.php");
$_login = new auth_login;
if($_login->Available === FALSE)
{
return false;
}
$login_result = $_login -> login($username, $userpass, $newvals);
if($login_result === AUTH_SUCCESS )
{
$sql = new db;
if(!$sql -> db_Select("user","*","user_loginname='{$username}' "))
{
// User not found in e107 database - add it now.
$qry = "INSERT INTO #user (user_id, user_loginname, user_name, user_join) VALUES ('0','{$username}','{$username}',".time().")";
$sql -> db_Select_gen($qry);
}
// Set password and any other applicable fields
$qry="user_password='".md5($userpass)."'";
foreach($newvals as $key => $val)
{
$qry .= " ,user_{$key}='{$val}' ";
}
$qry.=" WHERE user_loginname='{$username}' ";
$sql -> db_Update("user", $qry);
}
else
{
switch($login_result)
{
case AUTH_NOUSER:
if(!isset($pref['auth_nouser']) || !$pref['auth_nouser'])
{
$username=md5("xx_nouser_xx");
}
break;
case AUTH_NOCONNECT:
if(!isset($pref['auth_noconn']) || !$pref['auth_noconn'])
{
$username=md5("xx_noconn_xx");
}
break;
case AUTH_BADPASSWORD:
$userpass=md5("xx_badpassword_xx");
break;
}
}
}
}
?>

View File

@@ -0,0 +1,52 @@
/*
| Copyright (C) 2003 Thom Michelbrink
|
| Author: Thom Michelbrink mcfly@e107.org
|
*/
Purpose:
This is a plugin for the E107 CMS system (e107.org).
This plugin will enable Alternate authorization functionality to your site.
Requirements:
This plugin requires e107 Verion 0.600+
############## INSTALLATION #######################
1) Upload all files to your e107_plugins directory on your server, retaining directory structure.
2) Go to the admin section of the website, go the to plugin manager and install the Alt auth.
3) Go to the admin section of the website and configure the Alternate Authorization setting.
Until this is integrated into the e107 core. the following lines need to be added to the e107_handlers\login.php file. They need to be inserted into the userlogin() function, just after the 'global $pref;' line:
if($pref['auth_method'] && $pref['auth_method'] != "e107"){
$auth_file=e_PLUGIN."alt_auth/".$pref['auth_method']."_auth.php";
if(file_exists($auth_file)){
require_once(e_PLUGIN."alt_auth/alt_auth_login_class.php");
$result = new alt_login($pref['auth_method'],$username, $userpass);
}
}
--- AUTHORIZATION TYPES --
This version currently supports Active Directory and LDAP authorization types. Others could easily
be added though.
The requirements to add a new auth type are:
xxx_auth.php - Actual file the performs the authorization based on user input of uname / passwd.
xxx_conf.php - The file used to edit any configuration option for your auth type.
The xxx_auth.php must contain a class named auth_login(), the class must contain a function named login($uname,$passwd). The login() function must return values of:
AUTH_SUCCESS - valid login
AUTH_NOUSER - User not found
AUTH_BADPASSWORD - Password is incorrect
-----------------------------------------------------------------------------
Version history:
11/11/2003 - Initial beta release

View File

@@ -0,0 +1,56 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@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/alt_login_class.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:34:43 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
class alt_login{
function alt_login($method,&$username,&$userpass){
$newvals=array();
define("AUTH_SUCCESS",-1);
define("AUTH_NOUSER",1);
define("AUTH_BADPASSWORD",2);
require_once(e_PLUGIN."auth_".$method."/auth_".$method.".php");
$xx = new auth_login;
$login_result = $xx -> login($username,$userpass,$newvals);
if($login_result === AUTH_SUCCESS ){
$sql = new db;
if(!$sql -> db_Select("user","*","user_loginname='{$username}' ")){
// User not found in e107 database - add it now.
$qry = "INSERT INTO ".MPREFIX."user (user_id, user_loginname, user_name, user_join) VALUES ('0', '{$username}', '{$username}', ".time().")";
$sql -> db_Select_gen($qry);
}
// Set password and any other applicable fields
$qry="user_password='".md5($userpass)."'";
foreach($newvals as $key => $val){
$qry .= " ,user_{$key}='{$val}' ";
}
$qry.=" WHERE user_loginname='{$username}' ";
$sql -> db_Update("user",$qry);
} else {
switch($login_result){
case AUTH_NOUSER:
$username=md5("xx_nouser_xx");
break;
case AUTH_BADPASSWORD:
$userpass=md5("xx_badpassword_xx");
break;
}
}
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,15 @@
<?php
define("LAN_ALT_1", "Current authorization type");
define("LAN_ALT_2", "Update settings");
define("LAN_ALT_3", "Choose Alternate Authorization Type");
define("LAN_ALT_4", "Configure parameters for");
define("LAN_ALT_5", "Configure authorization parameters");
define("LAN_ALT_6", "Failed connection action");
define("LAN_ALT_7", "If connection to the alternate method fails, how should that be handled?");
define("LAN_ALT_8", "User not found action");
define("LAN_ALT_9", "If username is not found using alternate method, how should that be handled?");
define("LAN_ALT_FALLBACK", "Use e107 user table");
define("LAN_ALT_FAIL", "Failed login");
?>

View File

@@ -0,0 +1,15 @@
<?php
define("LDAPLAN_1", "Server address");
define("LDAPLAN_2", "Base DN or Domain<br />If LDAP - Enter BaseDN<br />If AD - Enter domain");
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");
?>

View File

@@ -0,0 +1,14 @@
<?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");
define("OTHERDB_LAN_11", "** The following fields are not required if using an e107 database");
?>

View File

@@ -0,0 +1,186 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Steve Dunstan 2001-2002
| http://e107.org
| jalist@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: 1.1.1.1 $
| $Date: 2006-12-02 04:34:43 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
class auth_login
{
var $server;
var $dn;
var $usr;
var $pwd;
var $serverType;
var $ldapErrorCode;
var $ldapErrorText;
var $connection;
var $result;
var $ldapVersion;
var $Available;
var $filter;
function auth_login()
{
$sql = new db;
$sql -> db_Select("alt_auth", "*", "auth_type = 'ldap' ");
while($row = $sql -> db_Fetch())
{
$ldap[$row['auth_parmname']]=$row['auth_parmval'];
}
$this->server = explode(",", $ldap['ldap_server']);
$this->serverType = $ldap['ldap_servertype'];
$this->dn = $ldap['ldap_basedn'];
$this->usr = $ldap['ldap_user'];
$this->pwd = $ldap['ldap_passwd'];
$this->ldapVersion = $ldap['ldap_version'];
$this->filter = (isset($ldap['ldap_edirfilter']) ? $ldap['ldap_edirfilter'] : "");
if(!function_exists('ldap_connect'))
{
$this->Available = FALSE;
return false;
}
if(!$this -> connect())
{
return AUTH_NOCONNECT;
}
}
function connect()
{
foreach ($this->server as $key => $host)
{
$this->connection = ldap_connect($host);
if ( $this->connection) {
if($this -> ldapVersion == 3 || $this->serverType == "ActiveDirectory")
{
@ldap_set_option( $this -> connection, LDAP_OPT_PROTOCOL_VERSION, 3 );
}
return true;
}
}
$this->ldapErrorCode = -1;
$this->ldapErrorText = "Unable to connect to any server";
return false;
}
function close()
{
if ( !@ldap_close( $this->connection))
{
$this->ldapErrorCode = ldap_errno( $this->connection);
$this->ldapErrorText = ldap_error( $this->connection);
return false;
}
else
{
return true;
}
}
function login($uname, $pass)
{
/* Construct the full DN, eg:-
** "uid=username, ou=People, dc=orgname,dc=com"
*/
if ($this->serverType == "ActiveDirectory")
{
$checkDn = "$uname@$this->dn";
}
else
{
if ($this -> usr != '' && $this -> pwd != '')
{
$this -> result = ldap_bind($this -> connection, $this -> usr, $this -> pwd);
}
else
{
$this -> result = ldap_bind($this -> connection);
}
// In ldap_auth.php, should look like this instead for eDirectory
// $query = ldap_search($this -> connection, $this -> dn, "cn=".$uname);
if($this->serverType == "eDirectory")
{
$_filter = (isset($ldap['ldap_edirfilter']) ? $ldap['ldap_edirfilter'] : "");
$current_filter = "(&(cn={$uname})".$this->filter.")";
$query = ldap_search($this->connection, $this->dn, $current_filter);
}
else
{
$query = ldap_search($this->connection, $this->dn, "uid=".$uname);
}
if ($query == false)
{
// Could not perform query to LDAP directory
return AUTH_NOCONNECT;
}
else
{
$query_result = ldap_get_entries($this -> connection, $query);
if ($query_result["count"] != 1)
{
return AUTH_NOUSER;
}
else
{
$checkDn = $query_result[0]["dn"];
$this -> close();
$this -> connect();
}
}
}
// Try and connect...
$this->result = ldap_bind($this -> connection, $checkDn, $pass);
if ( $this->result)
{
// Connected OK - login credentials are fine!
return AUTH_SUCCESS;
}
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 :
** (for iPlanet, other servers may differ)
** 19 - Account locked out (too many invalid login attempts)
** 32 - User does not exist
** 49 - Wrong password
** 53 - Account inactive (manually locked out by administrator)
*/
$this->ldapErrorCode = ldap_errno( $this->connection);
$this->ldapErrorText = ldap_error( $this->connection);
if($this -> ldapErrorCode == 32)
{
return AUTH_NOUSER;
}
if($this -> ldapErrorCode == 49)
{
return AUTH_BADPASSWORD;
}
// return error code as if it never connected, maybe change that in the future
return AUTH_NOCONNECT;
}
}
}
?>

View File

@@ -0,0 +1,133 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Steve Dunstan 2001-2002
| http://e107.org
| jalist@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: 1.1.1.1 $
| $Date: 2006-12-02 04:34:43 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
$eplug_admin = true;
require_once("../../class2.php");
require_once(e_ADMIN."auth.php");
require_once(e_HANDLER."form_handler.php");
include_lan("languages/".e_LANGUAGE."/lan_ldap_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";
$ldap_ver[1]="2";
$ldap_ver[2]="3";
if($_POST['update'])
{
foreach($_POST as $k => $v)
{
if(preg_match("/ldap_/", $k))
{
if($sql -> db_Select("alt_auth", "*", "auth_type='ldap' AND auth_parmname='{$k}' "))
{
$sql -> db_Update("alt_auth", "auth_parmval='{$v}' WHERE auth_type='ldap' AND auth_parmname='{$k}' ");
}
else
{
$sql -> db_Insert("alt_auth", "'ldap','{$k}','{$v}' ");
}
}
}
$message = LDAPLAN_10;
}
if(!function_exists('ldap_connect'))
{
$message = "<div style='color:#f00; font-weight:bold'>".LDAPLAN_11."</div>";
}
if($message)
{
$ns->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']] = $row['auth_parmval'];
}
$current_filter = "(&(cn=[USERNAME]){$ldap['ldap_edirfilter']})";
$frm = new form;
$text = $frm -> form_open("POST",e_SELF);
$text .= "<table style='width:96%'>";
$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" : "";
$text .= $frm -> form_option($v, $sel, $v);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".LDAPLAN_1."</td><td class='forumheader3'>";
$text .= $frm -> form_text("ldap_server", 35, $ldap['ldap_server'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".LDAPLAN_2."</td><td class='forumheader3'>";
$text .= $frm -> form_text("ldap_basedn", 35, $ldap['ldap_basedn'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".LDAPLAN_3."</td><td class='forumheader3'>";
$text .= $frm -> form_text("ldap_user", 35, $ldap['ldap_user'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".LDAPLAN_4."</td><td class='forumheader3'>";
$text .= $frm -> form_text("ldap_passwd", 35, $ldap['ldap_passwd'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".LDAPLAN_5."</td><td class='forumheader3'>";
$text .= $frm -> form_select_open("ldap_version");
foreach($ldap_ver as $v)
{
$sel = ($ldap['ldap_version'] == $v) ? " Selected" : "";
$text .= $frm -> form_option($v, $sel, $v);
}
$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 .= "<br /><span class='smalltext'>".LDAPLAN_9."<br />{$current_filter}</span></td></tr>";
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
$text .= $frm -> form_button("submit", "update", LDAPLAN_13);
$text .= "</td></tr>";
$text .= "</table>";
$text .= $frm -> form_close();
$ns -> tablerender(LDAPLAN_6,$text);
require_once(e_ADMIN."footer.php");
function ldap_conf_adminmenu()
{
alt_auth_adminmenu();
}
?>

View File

@@ -0,0 +1,147 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Steve Dunstan 2001-2002
| http://e107.org
| jalist@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: 1.1.1.1 $
| $Date: 2006-12-02 04:34:43 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
/*
return values
AUTH_NOCONNECT = unable to connect to db
AUTH_NOUSER = user not found
AUTH_BADPASSWORD = supplied password incorrect
AUTH_SUCCESS = valid login
*/
class auth_login
{
var $od;
function auth_login()
{
global $otherdb_conf, $sql;
$sql -> db_Select("alt_auth", "*", "auth_type = 'otherdb' ");
while($row = $sql -> db_Fetch())
{
$otherdb_conf[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval']));
}
$class_name = "otherdb_".$otherdb_conf['otherdb_dbtype']."_class";
if($otherdb_conf['otherdb_dbtype'] == 'e107')
{
$class_name = "otherdb_mysql_class";
}
if(class_exists($class_name))
{
$this->od = new $class_name;
}
else
{
return AUTH_NOCONNECT;
}
}
function login($uname, $pword, &$newvals)
{
global $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $sql;
$ret = $this->od->login($uname, $pword, $newvals);
$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
return $ret;
}
}
class otherdb_mysql_class
{
var $conf;
function otherdb_mysql_class()
{
global $otherdb_conf;
$this->conf = $otherdb_conf;
}
function login($uname, $pword, &$newvals)
{
//Attempt to open connection to sql database
if(!$res = mysql_connect($this->conf['otherdb_server'], $this->conf['otherdb_username'], $this->conf['otherdb_password']))
{
return AUTH_NOCONNECT;
}
//Select correct db
if(!mysql_select_db($this->conf['otherdb_database'], $res))
{
mysql_close($res);
return AUTH_NOCONNECT;
}
if($this->conf['otherdb_dbtype'] == 'mysql')
{
$sel_fields = $this->conf['otherdb_password_field'];
$user_field = $this->conf['otherdb_user_field'];
}
else
{
$sel_fields = 'user_password, user_email, user_join';
$user_field = "user_loginname";
}
//Get record containing supplied login name
$qry = "SELECT {$sel_fields} FROM {$this->conf['otherdb_table']} WHERE {$user_field} = '{$uname}'";
if(!$r1 = mysql_query($qry))
{
mysql_close($res);
return AUTH_NOCONNECT;
}
if(!$row = mysql_fetch_array($r1))
{
mysql_close($res);
return AUTH_NOUSER;
}
//Compare password in db to supplied password
if($this->conf['otherdb_password_method'] == 'md5' || $this->conf['otherdb_dbtype'] == 'e107')
{
$goodpw = md5($pword) == $row[0];
}
else
{
$goodpw = $pword == $row[0];
}
if($goodpw)
{
//Close newly opened mysql connection
mysql_close($res);
if($this->conf['otherdb_dbtype'] == 'e107')
{
$newvals['email'] = $row[1];
$newvals['join'] = $row[2];
}
return AUTH_SUCCESS;
}
mysql_close($res);
return AUTH_BADPASSWORD;
}
}
?>

View File

@@ -0,0 +1,143 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Steve Dunstan 2001-2002
| http://e107.org
| jalist@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("languages/".e_LANGUAGE."/lan_otherdb_auth.php");
define("ALT_AUTH_ACTION", "otherdb");
require_once(e_PLUGIN."alt_auth/alt_auth_adminmenu.php");
if($_POST['update'])
{
$message = update_otherdb_prefs();
}
if($message)
{
$ns->tablerender("","<div style='text-align:center;'>".$message."</div>");
}
show_otherdb_form();
function show_otherdb_form()
{
global $sql, $tp, $ns;
$password_methods = array("md5", "plaintext");
$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%'>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_1."</td><td class='forumheader3'>";
$text .= $frm -> form_select_open("otherdb_dbtype");
foreach($db_types as $k => $v)
{
$sel = ($parm['otherdb_dbtype'] == $k) ? " Selected" : "";
$text .= $frm -> form_option($v, $sel, $k);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_2."</td><td class='forumheader3'>";
$text .= $frm -> form_text("otherdb_server", 35, $parm['otherdb_server'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_3."</td><td class='forumheader3'>";
$text .= $frm -> form_text("otherdb_username", 35, $parm['otherdb_username'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_4."</td><td class='forumheader3'>";
$text .= $frm -> form_text("otherdb_password", 35, $parm['otherdb_password'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_5."</td><td class='forumheader3'>";
$text .= $frm -> form_text("otherdb_database", 35, $parm['otherdb_database'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_6."</td><td class='forumheader3'>";
$text .= $frm -> form_text("otherdb_table", 35, $parm['otherdb_table'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader2' colspan='2'>".OTHERDB_LAN_11."</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_7."</td><td class='forumheader3'>";
$text .= $frm -> form_text("otherdb_user_field", 35, $parm['otherdb_user_field'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_8."</td><td class='forumheader3'>";
$text .= $frm -> form_text("otherdb_password_field", 35, $parm['otherdb_password_field'], 120);
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader3'>".OTHERDB_LAN_9."</td><td class='forumheader3'>";
$text .= $frm -> form_select_open("otherdb_password_method");
foreach($password_methods as $v)
{
$sel = ($parm['otherdb_password_method'] == $v) ? " Selected" : "";
$text .= $frm -> form_option($v, $sel, $v);
}
$text .= $frm -> form_select_close();
$text .= "</td></tr>";
$text .= "<tr><td class='forumheader' colspan='2' style='text-align:center;'>";
$text .= $frm -> form_button("submit", "update", "Update settings");
$text .= "</td></tr>";
$text .= "</table>";
$text .= $frm -> form_close();
$ns -> tablerender(OTHERDB_LAN_10, $text);
}
require_once(e_ADMIN."footer.php");
function update_otherdb_prefs()
{
global $sql;
foreach($_POST as $k => $v)
{
$v = base64_encode(base64_encode($v));
if(preg_match("/otherdb_/", $k))
{
if($sql -> db_Select("alt_auth", "*", "auth_type='otherdb' AND auth_parmname='{$k}' "))
{
$sql -> db_Update("alt_auth", "auth_parmval='{$v}' WHERE auth_type='otherdb' AND auth_parmname='{$k}' ");
}
else
{
$sql -> db_Insert("alt_auth", "'otherdb','{$k}','{$v}' ");
}
}
}
return "Settings Updated";
}
function otherdb_conf_adminmenu()
{
alt_auth_adminmenu();
}
?>

View File

@@ -0,0 +1,74 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@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/plugin.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:34:44 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
// Plugin info -------------------------------------------------------------------------------------------------------
$eplug_name = "Alternate Authentication";
$eplug_version = "0.3";
$eplug_author = "McFly";
$eplug_logo = "/images/icon_ldap.png";
$eplug_url = "";
$eplug_email = "mcfly@e107.org";
$eplug_description = "This plugin allows for alternate authentication methods.";
$eplug_compatible = "e107v7+";
$eplug_readme = ""; // leave blank if no readme file
// Name of the plugin's folder -------------------------------------------------------------------------------------
$eplug_folder = "alt_auth";
// Mane of menu item for plugin ----------------------------------------------------------------------------------
$eplug_menu_name = "alt_auth";
// Name of the admin configuration file --------------------------------------------------------------------------
$eplug_conffile = "alt_auth_conf.php";
// Icon image and caption text ------------------------------------------------------------------------------------
$eplug_icon = $eplug_folder."/images/icon_ldap.png";
$eplug_caption = "Configure Alt auth";
// List of preferences -----------------------------------------------------------------------------------------------
$eplug_prefs = "";
// List of table names -----------------------------------------------------------------------------------------------
$eplug_table_names = array(
"alt_auth"
);
// List of sql requests to create tables -----------------------------------------------------------------------------
$eplug_tables = array(
"CREATE TABLE ".MPREFIX."alt_auth (
auth_type varchar(20) NOT NULL default '',
auth_parmname varchar(30) NOT NULL default '',
auth_parmval varchar(120) NOT NULL default ''
) TYPE=MyISAM;");
// Create a link in main menu (yes=TRUE, no=FALSE) -------------------------------------------------------------
$eplug_link = FALSE;
$eplug_link_name = "";
$eplug_link_url = "";
// Text to display after plugin successfully installed ------------------------------------------------------------------
$eplug_done = "Alt auth service is now set up. You will now need to configure your preferred method.";
?>