Update plugin.php

Fix unsupported direct access to $ydb
This commit is contained in:
K3A 2018-01-29 21:27:23 +01:00 committed by GitHub
parent b8064a482b
commit 2560973949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@
Plugin Name: Simple LDAP Auth Plugin Name: Simple LDAP Auth
Plugin URI: Plugin URI:
Description: This plugin enables use of LDAP provider for authentication Description: This plugin enables use of LDAP provider for authentication
Version: 1.0 Version: 1.1
Author: k3a Author: k3a
Author URI: http://k3a.me Author URI: http://k3a.me
*/ */
@ -118,7 +118,6 @@ function ldapauth_get_ldap_connection() {
// returns true/false // returns true/false
function ldapauth_is_valid_user( $value ) { function ldapauth_is_valid_user( $value ) {
global $yourls_user_passwords; global $yourls_user_passwords;
global $ydb;
// Always check & set early // Always check & set early
if ( !ldapauth_environment_check() ) { if ( !ldapauth_environment_check() ) {
@ -126,7 +125,7 @@ function ldapauth_is_valid_user( $value ) {
} }
if( LDAPAUTH_USERCACHE_TYPE == 1) { if( LDAPAUTH_USERCACHE_TYPE == 1) {
$ldapauth_usercache = $ydb->option['ldapauth_usercache']; $ldapauth_usercache = yourls_get_option('ldapauth_usercache');
} }
// no point in continuing if the user has already been validated by core // no point in continuing if the user has already been validated by core
@ -277,14 +276,13 @@ function ldapauth_logout_hook( $args ) {
yourls_add_action ('plugins_loaded', 'ldapauth_merge_users'); yourls_add_action ('plugins_loaded', 'ldapauth_merge_users');
function ldapauth_merge_users() { function ldapauth_merge_users() {
global $ydb;
global $yourls_user_passwords; global $yourls_user_passwords;
if ( !ldapauth_environment_check() ) { if ( !ldapauth_environment_check() ) {
die( 'Invalid configuration for YOURLS LDAP plugin. Check PHP error log.' ); die( 'Invalid configuration for YOURLS LDAP plugin. Check PHP error log.' );
} }
if(LDAPAUTH_USERCACHE_TYPE==1 && isset($ydb->option['ldapauth_usercache'])) { if(LDAPAUTH_USERCACHE_TYPE==1 && isset(yourls_get_option('ldapauth_usercache'))) {
ldapauth_debug("Merging text file users and cached LDAP users"); ldapauth_debug("Merging text file users and cached LDAP users");
$yourls_user_passwords = array_merge($yourls_user_passwords, $ydb->option['ldapauth_usercache']); $yourls_user_passwords = array_merge($yourls_user_passwords, yourls_get_option('ldapauth_usercache'));
} }
} }
/** /**