diff --git a/addon/README b/addon/README
index 8d5088f78..18843ceab 100644
--- a/addon/README
+++ b/addon/README
@@ -52,6 +52,8 @@ Current hooks:
'username' => the supplied username
'password' => the supplied password
'authenticated' => set this to non-zero to authenticate the user.
+ 'user_record' => successful authentication must also return a valid user record from the database
+
'logged_in' - called after a user has successfully logged in.
$b contains the $a->user array
diff --git a/addon/ldapauth/ldapauth.php b/addon/ldapauth/ldapauth.php
new file mode 100644
index 000000000..2ec30caad
--- /dev/null
+++ b/addon/ldapauth/ldapauth.php
@@ -0,0 +1,124 @@
+config['ldapauth']['ldap_server'] = 'host.example.com';
+ * ...etc.
+ *
+ */
+
+
+
+function ldapauth_install() {
+ register_hook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
+}
+
+
+function ldapauth_uninstall() {
+ unregister_hook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
+}
+
+
+function ldapauth_hook_authenticate($a,&$b) {
+ if(ldapauth_authenticate($b['username'],$b['password'])) {
+ $results = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
+ dbesc($b['username'])
+ );
+ if(count($results)) {
+ $b['user_record'] = $results[0];
+ $b['authenticated'] = 1;
+ }
+ }
+ return;
+}
+
+
+function ldapauth_authenticate($username,$password) {
+
+ $ldap_server = get_config('ldapauth','ldap_server');
+ $ldap_binddn = get_config('ldapauth','ldap_binddn');
+ $ldap_bindpw = get_config('ldapauth','ldap_bindpw');
+ $ldap_searchdn = get_config('ldapauth','ldap_searchdn');
+ $ldap_userattr = get_config('ldapauth','ldap_userattr');
+ $ldap_group = get_config('ldapauth','ldap_group');
+
+ if(! ((strlen($password))
+ && (function_exists('ldap_connect'))
+ && (strlen($ldap_server))))
+ return false;
+
+ $connect = @ldap_connect($ldap_server);
+
+ if(! $connect)
+ return false;
+
+ @ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION,3);
+ @ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
+ if((@ldap_bind($connect,$ldap_binddn,$ldap_bindpw)) === false) {
+ return false;
+ }
+
+ $res = @ldap_search($connect,$ldap_searchdn, $ldap_userattr . '=' . $username);
+
+ if(! $res) {
+ return false;
+ }
+
+ $id = @ldap_first_entry($connect,$res);
+
+ if(! $id) {
+ return false;
+ }
+
+ $dn = @ldap_get_dn($connect,$id);
+
+ if(! @ldap_bind($connect,$dn,$password))
+ return false;
+
+ if(! strlen($ldap_group))
+ return true;
+
+ $r = @ldap_compare($connect,$ldap_group,'member',$dn);
+ if ($r === -1) {
+ $err = @ldap_error($connect);
+ $eno = @ldap_errno($connect);
+ @ldap_close($connect);
+
+ if ($eno === 32) {
+ logger("ldapauth: access control group Does Not Exist");
+ return false;
+ }
+ elseif ($eno === 16) {
+ logger('ldapauth: membership attribute does not exist in access control group');
+ return false;
+ }
+ else {
+ logger('ldapauth: error: ' . $err);
+ return false;
+ }
+ }
+ elseif ($r === false) {
+ @ldap_close($connect);
+ return false;
+ }
+
+ return true;
+}
diff --git a/addon/randplace/randplace.php b/addon/randplace/randplace.php
index 2e1bd33ac..2f0ff038b 100644
--- a/addon/randplace/randplace.php
+++ b/addon/randplace/randplace.php
@@ -110,7 +110,7 @@ function randplace_post_hook($a, &$item) {
$cities = array();
$zones = timezone_identifiers_list();
foreach($zones as $zone) {
- if(strpos($zone,'/'))
+ if((strpos($zone,'/')) && (! stristr($zone,'US/')) && (! stristr($zone,'Etc/')))
$cities[] = str_replace('_', ' ',substr($zone,strpos($zone,'/') + 1));
}
diff --git a/include/auth.php b/include/auth.php
index bc77e5dbc..d2bcb68dc 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -132,16 +132,18 @@ else {
}
if((x($_POST,'auth-params')) && $_POST['auth-params'] === 'login') {
+ $record = null;
$addon_auth = array(
- 'name' => trim($_POST['openid_url']),
+ 'username' => trim($_POST['openid_url']),
'password' => trim($_POST['password']),
- 'authenticated' => 0
+ 'authenticated' => 0,
+ 'user_record' => null
);
/**
*
- * A plugin indicates successful login by setting 'authenticated' to non-zero value
+ * A plugin indicates successful login by setting 'authenticated' to non-zero value and returning a user record
* Plugins should never set 'authenticated' except to indicate success - as hooks may be chained
* and later plugins should not interfere with an earlier one that succeeded.
*
@@ -149,8 +151,12 @@ else {
call_hooks('authenticate', $addon_auth);
- if(! $addon_auth['authenticated']) {
- // process login request
+ if(($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
+ $record = $addon_auth['user_record'];
+ }
+ else {
+
+ // process normal login request
$r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
@@ -158,21 +164,25 @@ else {
dbesc(trim($_POST['openid_url'])),
dbesc($encrypted)
);
- if(($r === false) || (! count($r))) {
- notice( t('Login failed.') . EOL );
- goaway($a->get_baseurl());
- }
+ if(count($r))
+ $record = $r[0];
}
- $_SESSION['uid'] = $r[0]['uid'];
- $_SESSION['theme'] = $r[0]['theme'];
+ if((! $record) || (! count($record))) {
+ logger('authenticate: failed login attempt: ' . trim($_POST['openid_url']));
+ notice( t('Login failed.') . EOL );
+ goaway($a->get_baseurl());
+ }
+
+ $_SESSION['uid'] = $record['uid'];
+ $_SESSION['theme'] = $record['theme'];
$_SESSION['authenticated'] = 1;
- $_SESSION['page_flags'] = $r[0]['page-flags'];
- $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname'];
+ $_SESSION['page_flags'] = $record['page-flags'];
+ $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname'];
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
- notice( t("Welcome back ") . $r[0]['username'] . EOL);
- $a->user = $r[0];
+ notice( t("Welcome back ") . $record['username'] . EOL);
+ $a->user = $record;
if(strlen($a->user['timezone']))
date_default_timezone_set($a->user['timezone']);
diff --git a/view/it/strings.php b/view/it/strings.php
index ca6ec3e92..217f04410 100644
--- a/view/it/strings.php
+++ b/view/it/strings.php
@@ -303,9 +303,9 @@ $a->strings['Your registration can not be processed.'] = 'La tua registrazione n
$a->strings['Registration request at '] = 'Registrazione richiesta il ';
$a->strings['Your registration is pending approval by the site owner.'] = 'La tua richiesta è in attesa di approvazione da parte del prorietario del sito.';
$a->strings["You may \x28optionally\x29 fill in this form via OpenID by supplying your OpenID and clicking 'Register'."] = "Puoi \x28opzionalmento\x29 riempire questa maschera via OpenID inserendo il tuo OpenID e cliccando 'Registra'.";
-$a->strings['If you are not familiar with OpenID, please leave that field blank and fill in the rest of the items.'] = 'Se non hai famigliarità con OpenID, lascia quel campo in bianco e riempi il resto della maschera.';
+$a->strings['If you are not familiar with OpenID, please leave that field blank and fill in the rest of the items.'] = 'Se non hai familiarità con OpenID, lascia quel campo in bianco e riempi il resto della maschera.';
$a->strings["Your OpenID \x28optional\x29: "] = "Il tuo OpenID \x28opzionale\x29: ";
-$a->strings['Shared content is covered by the Creative Commons Attribution 3.0 license.'] = 'Contenuto in comune h coperto da licenza Creative Commons Attribution 3.0.';
+$a->strings['Shared content is covered by the Creative Commons Attribution 3.0 license.'] = 'Il contenuto in comune è coperto dalla licenza Creative Commons Attribuzione 3.0.';
$a->strings['Registration'] = 'Registrazione';
$a->strings['Your Full Name ' . "\x28" . 'e.g. Joe Smith' . "\x29" . ': '] = 'Il tuo Nome Completo ' . "\x28" . 'p.e. Mario Rossi' . "\x29" . ': ';
$a->strings['Your Email Address: '] = 'Il tuo Indirizzo Email: ';
@@ -319,14 +319,14 @@ $a->strings['View in context'] = 'Vedi nel contesto';
$a->strings['Passwords do not match. Password unchanged.'] = 'Le password non corrispondono. Passoword non cambiata.';
$a->strings['Empty passwords are not allowed. Password unchanged.'] = 'Password vuote non sono consentite. Password non cambiata.';
$a->strings['Password changed.'] = 'Password cambiata.';
-$a->strings['Password update failed. Please try again.'] = 'Aggiornamento password fallito. Prova ancora.';
+$a->strings['Password update failed. Please try again.'] = 'Aggiornamento password fallito. Prova ancora.';
$a->strings[' Please use a shorter name.'] = ' Usa un nome più corto.';
$a->strings[' Name too short.'] = ' Nome troppo corto.';
$a->strings[' Not valid email.'] = ' Email non valida.';
$a->strings['Settings updated.'] = 'Impostazioni aggiornate.';
$a->strings['Plugin Settings'] = 'Impostazioni Plugin';
-$a->strings['Account Settings'= = 'Impostazioni Account';
-$a->strings['No Plugin settings configured'] = 'Nessuna impostazione Plugin configurato';
+$a->strings['Account Settings'] = 'Impostazioni Account';
+$a->strings['No Plugin settings configured'] = 'Nessuna impostazione Plugin configurata';
$a->strings['OpenID: '] = 'OpenID: ';
$a->strings[" \x28Optional\x29 Allow this OpenID to login to this account."] = " \x28Opzionale\x29 Permetti a questo OpenID di accedere a questo account.";
$a->strings['Profile is not published.'] = 'Il profilo non è pubblicato.';