";
- if ($v['optional'] == FALSE) $ret .= '* ';
- $ret .= $v['prompt'].':';
- if (isset($v['help']))
+ $sel = ($curval == $v ? " selected = 'selected' " : '');
+ $ret .= "\n";
+ }
+ $ret .= "\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.
+ */
+ private $alt_auth_user_fields = array(
+ 'user_email' => array('prompt' => LAN_ALT_12, 'default' => 'user_email', 'optional' => TRUE, 'otherdb' => TRUE, 'e107db' => TRUE, 'importdb' => FALSE, 'ldap' => TRUE, 'ldap_field' => 'mail'),
+ 'user_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
+ */
+ public function alt_auth_get_field_list($tableType, $frm, $parm, $asCheckboxes = FALSE)
+ {
+ $ret = '';
+ foreach ($this->alt_auth_user_fields as $f => $v)
+ {
+ if (varsettrue($v['showAll']) || varsettrue($v[$tableType]))
{
- $ret .= " ".$v['help']."";
- }
- $ret .= " | ";
-// $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} ";
- if ($asCheckboxes)
- {
- $ret .= $frm -> form_checkbox($fieldname, 1, $value);
- }
- else
- {
- $ret .= $frm -> form_text($fieldname, 35, $value, 120);
- if (isset($v['method']) && $v['method'])
+ $ret .= " |
";
+ if ($v['optional'] == FALSE) $ret .= '* ';
+ $ret .= $v['prompt'].':';
+ if (isset($v['help']))
{
- $fieldMethod = $tableType.'_pm_'.$f; // Processing method ID code
- $method = varset($parm[$fieldMethod],'');
- $ret .= ' '.alt_auth_processing($fieldMethod,$v['method'], $method);
+ $ret .= " ".$v['help']."";
+ }
+ $ret .= " | ";
+ // $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} ";
+ 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 .= ' '.$this->alt_auth_processing($fieldMethod,$v['method'], $method);
+ }
+ }
+ $ret .= " |
\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
+ */
+ public function alt_auth_get_allowed_fields($tableType)
+ {
+ $ret = array();
+ foreach ($this->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
+ */
+ public function add_extended_fields()
+ {
+ global $pref;
+
+ if (!isset($pref['auth_extended'])) return;
+ if (!$pref['auth_extended']) return;
+
+ static $fieldsAdded = FALSE;
+
+ if ($fieldsAdded) return;
+ $xFields = $this->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]))
+ {
+ $this->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.
+ */
+ private $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 ";
+ $text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
+ // $text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
+ $text .= '
';
+ $text .= $frm -> form_close();
+
+ $ns->tablerender(E107DB_LAN_10, $text);
+
+ $ns->tablerender(LAN_ALT_40.LAN_ALT_41,$this->alt_auth_test_form('e107db',$frm));
+ }
+}
+
+
+$e107dbAdmin = new alt_auth_e107db();
+
if(vartrue($_POST['update']))
{
- $message = alt_auth_post_options('e107db');
+ $message = $e107dbAdmin->alt_auth_post_options('e107db');
}
@@ -41,51 +96,9 @@ if(vartrue($message))
e107::getRender()->tablerender('',"";
- $text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
-// $text .= $frm -> form_button("submit", "update", LAN_ALT_UPDATESET);
- $text .= '
';
- $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');
diff --git a/e107_plugins/alt_auth/extended_password_handler.php b/e107_plugins/alt_auth/extended_password_handler.php
index 231078e7c..000d3b422 100644
--- a/e107_plugins/alt_auth/extended_password_handler.php
+++ b/e107_plugins/alt_auth/extended_password_handler.php
@@ -1,332 +1,332 @@
-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
- */
- private function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
- {
- $output = '*0';
- if (substr($stored_password, 0, 2) == $output)
- {
- $output = '*1';
- }
-
- $prefix = '';
- switch ($password_type)
- {
- case PASSWORD_PHPBB_SALT :
- $prefix = PASSWORD_PHPBB_ID;
- break;
- case PASSWORD_WORDPRESS_SALT :
- $prefix = PASSWORD_WORDPRESS_ID;
- break;
- default :
- $prefix = '';
- }
-
- if ($prefix != substr($stored_password, 0, 3))
- {
- return $output;
- }
-
- $count_log2 = strpos($this->itoa64, $stored_password[3]); // 4th character indicates hash depth count
- if ($count_log2 < 7 || $count_log2 > 30)
- {
- return $output;
- }
-
- $count = 1 << $count_log2;
-
- $salt = substr($stored_password, 4, 8); // Salt is characters 5..12
- if (strlen($salt) != 8)
- {
- return $output;
- }
-
- # We're kind of forced to use MD5 here since it's the only
- # cryptographic primitive available in all versions of PHP
- # currently in use. To implement our own low-level crypto
- # in PHP would result in much worse performance and
- # consequently in lower iteration counts and hashes that are
- # quicker to crack (by non-PHP code).
- // Get raw binary output (always 16 bytes) - we assume PHP5 here
- $hash = md5($salt.$password, TRUE);
- do
- {
- $hash = md5($hash.$password, TRUE);
- } while (--$count);
-
- $output = substr($setting, 0, 12); // Identifier, shift count and salt - total 12 chars
- $output .= $this->encode64($hash, 16); // Returns 22-character string
-
- return $output;
- }
-
-
- /**
- * Return array of supported password types - key is used internally, text is displayed
- */
- public function getPasswordTypes($includeExtended = TRUE)
- {
- $vals = array();
- $vals = array('md5' => IMPORTDB_LAN_7,'e107_salt' => IMPORTDB_LAN_8); // Methods supported in core
- if ($includeExtended)
- {
- $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
- */
- 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,
- 'wordpress_salt' => PASSWORD_WORDPRESS_SALT,
- 'magento_salt' => PASSWORD_MAGENTO_SALT,
- );
- if (isset($maps[$ptype])) return $maps[$ptype];
- return FALSE;
- }
-
-
- /**
- * 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)
- {
- case PASSWORD_GENERAL_MD5 :
- case PASSWORD_E107_MD5 :
- $pwHash = md5($pword);
- break;
-
- case PASSWORD_GENERAL_SHA1 :
- if (strlen($stored_hash) != 40) return PASSWORD_INVALID;
- $pwHash = sha1($pword);
- break;
-
- case PASSWORD_JOOMLA_SALT :
- case PASSWORD_MAMBO_SALT :
- if ((strpos($stored_hash, ':') === false) || (strlen($stored_hash) < 40))
- {
- return PASSWORD_INVALID;
- }
- // Mambo/Joomla salted hash - should be 32-character md5 hash, ':', 16-character salt (but could be 8-char salt, maybe)
- list($hash, $salt) = explode(':', $stored_hash);
- $pwHash = md5($pword.$salt);
- $stored_hash = $hash;
- break;
-
-
- case PASSWORD_MAGENTO_SALT :
- $hash = $salt = '';
- if ((strpos($stored_hash, ':') !== false))
- {
- list($hash, $salt) = explode(':', $stored_hash);
- }
- // Magento salted hash - should be 32-character md5 hash, ':', 2-character salt, but could be also only md5 hash
- else
- {
- $hash = $stored_hash;
- }
- if(strlen($hash) !== 32)
- {
- //return PASSWORD_INVALID;
- }
-
- $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 parent::CheckPassword($password, $login_name, $stored_hash);
- break;
-
- case PASSWORD_PHPBB_SALT :
- case PASSWORD_WORDPRESS_SALT :
- if (strlen($stored_hash) != 34) return PASSWORD_INVALID;
- $pwHash = $this->crypt_private($pword, $stored_hash, $password_type);
- if ($pwHash[0] == '*')
- {
- return PASSWORD_INVALID;
- }
- $stored_hash = substr($stored_hash,12);
- break;
-
- case PASSWORD_PLAINTEXT :
- $pwHash = $pword;
- break;
-
- default :
- return PASSWORD_INVALID;
- }
- if ($stored_hash != $pwHash) return PASSWORD_INVALID;
- return PASSWORD_VALID;
- }
-
-}
-
-
+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
+ */
+ private function crypt_private($password, $stored_password, $password_type = PASSWORD_PHPBB_SALT)
+ {
+ $output = '*0';
+ if (substr($stored_password, 0, 2) == $output)
+ {
+ $output = '*1';
+ }
+
+ $prefix = '';
+ switch ($password_type)
+ {
+ case PASSWORD_PHPBB_SALT :
+ $prefix = PASSWORD_PHPBB_ID;
+ break;
+ case PASSWORD_WORDPRESS_SALT :
+ $prefix = PASSWORD_WORDPRESS_ID;
+ break;
+ default :
+ $prefix = '';
+ }
+
+ if ($prefix != substr($stored_password, 0, 3))
+ {
+ return $output;
+ }
+
+ $count_log2 = strpos($this->itoa64, $stored_password[3]); // 4th character indicates hash depth count
+ if ($count_log2 < 7 || $count_log2 > 30)
+ {
+ return $output;
+ }
+
+ $count = 1 << $count_log2;
+
+ $salt = substr($stored_password, 4, 8); // Salt is characters 5..12
+ if (strlen($salt) != 8)
+ {
+ return $output;
+ }
+
+ # We're kind of forced to use MD5 here since it's the only
+ # cryptographic primitive available in all versions of PHP
+ # currently in use. To implement our own low-level crypto
+ # in PHP would result in much worse performance and
+ # consequently in lower iteration counts and hashes that are
+ # quicker to crack (by non-PHP code).
+ // Get raw binary output (always 16 bytes) - we assume PHP5 here
+ $hash = md5($salt.$password, TRUE);
+ do
+ {
+ $hash = md5($hash.$password, TRUE);
+ } while (--$count);
+
+ $output = substr($setting, 0, 12); // Identifier, shift count and salt - total 12 chars
+ $output .= $this->encode64($hash, 16); // Returns 22-character string
+
+ return $output;
+ }
+
+
+ /**
+ * Return array of supported password types - key is used internally, text is displayed
+ */
+ public function getPasswordTypes($includeExtended = TRUE)
+ {
+ $vals = array();
+ $vals = array('md5' => IMPORTDB_LAN_7,'e107_salt' => IMPORTDB_LAN_8); // Methods supported in core
+ if ($includeExtended)
+ {
+ $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
+ */
+ 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,
+ 'wordpress_salt' => PASSWORD_WORDPRESS_SALT,
+ 'magento_salt' => PASSWORD_MAGENTO_SALT,
+ );
+ if (isset($maps[$ptype])) return $maps[$ptype];
+ return FALSE;
+ }
+
+
+ /**
+ * 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)
+ {
+ case PASSWORD_GENERAL_MD5 :
+ case PASSWORD_E107_MD5 :
+ $pwHash = md5($pword);
+ break;
+
+ case PASSWORD_GENERAL_SHA1 :
+ if (strlen($stored_hash) != 40) return PASSWORD_INVALID;
+ $pwHash = sha1($pword);
+ break;
+
+ case PASSWORD_JOOMLA_SALT :
+ case PASSWORD_MAMBO_SALT :
+ if ((strpos($stored_hash, ':') === false) || (strlen($stored_hash) < 40))
+ {
+ return PASSWORD_INVALID;
+ }
+ // Mambo/Joomla salted hash - should be 32-character md5 hash, ':', 16-character salt (but could be 8-char salt, maybe)
+ list($hash, $salt) = explode(':', $stored_hash);
+ $pwHash = md5($pword.$salt);
+ $stored_hash = $hash;
+ break;
+
+
+ case PASSWORD_MAGENTO_SALT :
+ $hash = $salt = '';
+ if ((strpos($stored_hash, ':') !== false))
+ {
+ list($hash, $salt) = explode(':', $stored_hash);
+ }
+ // Magento salted hash - should be 32-character md5 hash, ':', 2-character salt, but could be also only md5 hash
+ else
+ {
+ $hash = $stored_hash;
+ }
+ if(strlen($hash) !== 32)
+ {
+ //return PASSWORD_INVALID;
+ }
+
+ $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 parent::CheckPassword($password, $login_name, $stored_hash);
+ break;
+
+ case PASSWORD_PHPBB_SALT :
+ case PASSWORD_WORDPRESS_SALT :
+ if (strlen($stored_hash) != 34) return PASSWORD_INVALID;
+ $pwHash = $this->crypt_private($pword, $stored_hash, $password_type);
+ if ($pwHash[0] == '*')
+ {
+ return PASSWORD_INVALID;
+ }
+ $stored_hash = substr($stored_hash,12);
+ break;
+
+ case PASSWORD_PLAINTEXT :
+ $pwHash = $pword;
+ break;
+
+ default :
+ return PASSWORD_INVALID;
+ }
+ if ($stored_hash != $pwHash) return PASSWORD_INVALID;
+ return PASSWORD_VALID;
+ }
+
+}
+
+
?>
\ No newline at end of file
diff --git a/e107_plugins/alt_auth/importdb_auth.php b/e107_plugins/alt_auth/importdb_auth.php
index f34e69ba8..9f8a7fe4c 100644
--- a/e107_plugins/alt_auth/importdb_auth.php
+++ b/e107_plugins/alt_auth/importdb_auth.php
@@ -1,113 +1,113 @@
-ErrorText = '';
- $this->conf = altAuthGetParams('importdb');
- $this->Available = TRUE;
- }
-
-
- private function makeErrorText($extra = '')
- {
- $this->ErrorText = $extra;
- }
-
-
- /**
- * 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!
-
- // See if the user's in the E107 database - otherwise they can go away
- global $sql, $tp;
- if (!$sql->db_Select('user', 'user_loginname, user_password', "user_loginname = '".$tp -> toDB($uname)."'"))
- { // Invalid user
- $this->makeErrorText('User not found');
- return AUTH_NOUSER;
- }
-
- // Now look at their password - we always need to verify it, even if its a core E107 format.
- // Higher levels will always convert an authorised password to E107 format and save it for us.
- if (!$row = $sql->db_Fetch())
- {
- $this->makeErrorText('Error reading DB');
- return AUTH_NOCONNECT; // Debateable return code - really a DB error. But consistent with other handler
- }
-
- 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['importdb_password_method']);
- if ($passMethod === FALSE)
- {
- $this->makeErrorText('Password error - invalid method');
- return AUTH_BADPASSWORD;
- }
-
- $pwFromDB = $row['user_password']; // Password stored in DB
- if ($pass_check->checkPassword($pword, $uname, $pwFromDB, $passMethod) !== PASSWORD_VALID)
- {
- $this->makeErrorText('Password incorrect');
- return LOGIN_CONTINUE; // Could have already changed password to E107 format
- }
- $this->makeErrorText('');
- return AUTH_SUCCESS;
- }
-}
-
+ErrorText = '';
+ $this->conf = $this->altAuthGetParams('importdb');
+ $this->Available = TRUE;
+ }
+
+
+ private function makeErrorText($extra = '')
+ {
+ $this->ErrorText = $extra;
+ }
+
+
+ /**
+ * 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!
+
+ // See if the user's in the E107 database - otherwise they can go away
+ global $sql, $tp;
+ if (!$sql->db_Select('user', 'user_loginname, user_password', "user_loginname = '".$tp -> toDB($uname)."'"))
+ { // Invalid user
+ $this->makeErrorText('User not found');
+ return AUTH_NOUSER;
+ }
+
+ // Now look at their password - we always need to verify it, even if its a core E107 format.
+ // Higher levels will always convert an authorised password to E107 format and save it for us.
+ if (!$row = $sql->db_Fetch())
+ {
+ $this->makeErrorText('Error reading DB');
+ return AUTH_NOCONNECT; // Debateable return code - really a DB error. But consistent with other handler
+ }
+
+ 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['importdb_password_method']);
+ if ($passMethod === FALSE)
+ {
+ $this->makeErrorText('Password error - invalid method');
+ return AUTH_BADPASSWORD;
+ }
+
+ $pwFromDB = $row['user_password']; // Password stored in DB
+ if ($pass_check->checkPassword($pword, $uname, $pwFromDB, $passMethod) !== PASSWORD_VALID)
+ {
+ $this->makeErrorText('Password incorrect');
+ return LOGIN_CONTINUE; // Could have already changed password to E107 format
+ }
+ $this->makeErrorText('');
+ return AUTH_SUCCESS;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/e107_plugins/alt_auth/importdb_conf.php b/e107_plugins/alt_auth/importdb_conf.php
index 629f64c27..c4c7a7c2e 100644
--- a/e107_plugins/alt_auth/importdb_conf.php
+++ b/e107_plugins/alt_auth/importdb_conf.php
@@ -32,10 +32,57 @@ require_once(e_PLUGIN.'alt_auth/alt_auth_adminmenu.php');
require_once(e_PLUGIN.'alt_auth/extended_password_handler.php');
+
+
+class alt_auth_otherdb extends alt_auth_admin
+{
+
+ public function __construct()
+ {
+ }
+
+
+ public function showForm()
+ {
+ $ns = e107::getRender();
+
+ $parm = $this->altAuthGetParams('importdb');
+
+ $frm = new form;
+ $text = $frm -> form_open('post', e_SELF);
+ $text .= "";
+ $text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
+ $text .= "
";
+ $text .= $frm -> form_close();
+
+ $ns -> tablerender(IMPORTDB_LAN_10, $text);
+
+ $ns->tablerender(LAN_ALT_40.LAN_ALT_41, $this->alt_auth_test_form('importdb',$frm));
+
+ }
+}
+
+
+$otherDbAdmin = new alt_auth_otherdb();
+
if(vartrue($_POST['update']))
{
// $message = update_importdb_prefs();
- $message = alt_auth_post_options('importdb');
+ $message = $otherDbAdmin->alt_auth_post_options('importdb');
}
if(vartrue($message))
@@ -44,41 +91,8 @@ if(vartrue($message))
}
-show_importdb_form();
+$otherDbAdmin->showForm();
-function show_importdb_form()
-{
- $ns = e107::getRender();
-
-
- $parm = altAuthGetParams('importdb');
-
- $frm = new form;
- $text = $frm -> form_open('post', e_SELF);
- $text .= "";
- $text .= e107::getForm()->admin_button("update", LAN_UPDATE,'update');
- $text .= "
";
- $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');
diff --git a/e107_plugins/alt_auth/ldap_auth.php b/e107_plugins/alt_auth/ldap_auth.php
index 99f92c047..8105d54ef 100755
--- a/e107_plugins/alt_auth/ldap_auth.php
+++ b/e107_plugins/alt_auth/ldap_auth.php
@@ -1,311 +1,309 @@
-copyAttribs = array();
- $this->copyMethods = array();
- $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']));
- if ((strpos($row['auth_parmname'], 'ldap_xf_') === 0) && $ldap[$row['auth_parmname']]) // Attribute to copy on successful login
- {
- $this->copyAttribs[substr($row['auth_parmname'], strlen('ldap_xf_'))] = $ldap[$row['auth_parmname']]; // Key = LDAP attribute. Value = e107 field name
- }
- 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'];
- $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'))
- {
- return AUTH_NORESOURCE;
- }
-
- if (!$this->connect())
- {
- return AUTH_NOCONNECT;
- }
- $this->Available = TRUE;
- return AUTH_SUCCESS;
- }
-
-
- /**
- * 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;
- }
-
-
- /**
- * Connect to the LDAP server
- *
- * @return boolean TRUE for success, FALSE for failure
- */
- public 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";
- $this->ErrorText = $this->ldapErrorCode . ': ' . $this->ldapErrorText;
- return false;
- }
-
-
- /**
- * Close the connection to the LDAP server
- */
- public function close()
- {
- if (!@ldap_close($this->connection))
- {
- $this->makeErrorText(); // Read the error code and explanatory string
- return false;
- }
- else
- {
- return true;
- }
- }
-
-
- /**
- * 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:-
- ** "uid=username, ou=People, dc=orgname,dc=com"
- */
- // echo "Login to server type: {$this->serverType}