Upload folder via GUI - includes
This commit is contained in:
@@ -798,6 +798,13 @@ class MC_Gallery_Core {
|
|||||||
if (!$server_id) {
|
if (!$server_id) {
|
||||||
$server_id = $t['server_id'] ?? '';
|
$server_id = $t['server_id'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wenn ein Forum-Account mit diesem MC-Namen verknüpft ist,
|
||||||
|
// den Link bei erfolgreichem Token-Flow automatisch verifizieren.
|
||||||
|
if (class_exists('MC_Gallery_Forum_Bridge')) {
|
||||||
|
MC_Gallery_Forum_Bridge::verify_linked_user_by_mc_username($username);
|
||||||
|
}
|
||||||
|
|
||||||
$authorized = true;
|
$authorized = true;
|
||||||
} elseif (class_exists('WBF_Auth') && class_exists('MC_Gallery_Forum_Bridge')) {
|
} elseif (class_exists('WBF_Auth') && class_exists('MC_Gallery_Forum_Bridge')) {
|
||||||
// Forum-Login-Weg: eingeloggten Forum-User prüfen
|
// Forum-Login-Weg: eingeloggten Forum-User prüfen
|
||||||
|
|||||||
@@ -115,6 +115,13 @@ class MC_Gallery_Forum_Bridge {
|
|||||||
</div>
|
</div>
|
||||||
<?php if ( $is_own || $is_mod ) : ?>
|
<?php if ( $is_own || $is_mod ) : ?>
|
||||||
<div class="mc-bridge-actions">
|
<div class="mc-bridge-actions">
|
||||||
|
<?php if ( ! $verified && $is_own ) : ?>
|
||||||
|
<button type="button" class="mc-bridge-btn mc-bridge-btn--self-verify"
|
||||||
|
data-server="<?php echo esc_attr( $sv ); ?>"
|
||||||
|
data-nonce="<?php echo wp_create_nonce( self::NONCE_ACTION ); ?>">
|
||||||
|
<i class="fas fa-shield-check"></i> Jetzt verifizieren
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
<?php if ( ! $verified && $is_mod ) : ?>
|
<?php if ( ! $verified && $is_mod ) : ?>
|
||||||
<button type="button" class="mc-bridge-btn mc-bridge-btn--approve"
|
<button type="button" class="mc-bridge-btn mc-bridge-btn--approve"
|
||||||
data-uid="<?php echo (int) $profile_user->id; ?>"
|
data-uid="<?php echo (int) $profile_user->id; ?>"
|
||||||
@@ -214,6 +221,34 @@ class MC_Gallery_Forum_Bridge {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Eigene Verknüpfung verifizieren (ohne Admin-Button)
|
||||||
|
$('.mc-bridge-btn--self-verify').on('click', function(){
|
||||||
|
var $btn = $(this).prop('disabled', true);
|
||||||
|
var nonce = $btn.data('nonce');
|
||||||
|
var sv = $btn.data('server') || '';
|
||||||
|
var old = $btn.html();
|
||||||
|
|
||||||
|
$btn.html('<i class="fas fa-spinner fa-spin"></i> Prüfe...');
|
||||||
|
|
||||||
|
$.post(<?php echo json_encode( admin_url('admin-ajax.php') ); ?>, {
|
||||||
|
action: 'mc_forum_verify_upload',
|
||||||
|
nonce: nonce,
|
||||||
|
server_id: sv
|
||||||
|
})
|
||||||
|
.done(function(r){
|
||||||
|
if ( r && r.success ) {
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
|
alert((r && r.data && r.data.message) ? r.data.message : 'Verifizierung nicht möglich.');
|
||||||
|
$btn.prop('disabled', false).html(old);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail(function(){
|
||||||
|
alert('Netzwerkfehler. Bitte erneut versuchen.');
|
||||||
|
$btn.prop('disabled', false).html(old);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Admin: Bestätigen
|
// Admin: Bestätigen
|
||||||
$('.mc-bridge-btn--approve').on('click', function(){
|
$('.mc-bridge-btn--approve').on('click', function(){
|
||||||
var uid = $(this).data('uid');
|
var uid = $(this).data('uid');
|
||||||
@@ -344,6 +379,16 @@ class MC_Gallery_Forum_Bridge {
|
|||||||
$server_id = self::get_mc_server( $forum_user->id )
|
$server_id = self::get_mc_server( $forum_user->id )
|
||||||
?: sanitize_text_field( $_POST['server_id'] ?? '' );
|
?: sanitize_text_field( $_POST['server_id'] ?? '' );
|
||||||
|
|
||||||
|
if ( empty( $server_id ) ) {
|
||||||
|
$servers = self::get_server_list();
|
||||||
|
if ( ! empty( $servers ) ) {
|
||||||
|
$first = array_key_first( $servers );
|
||||||
|
if ( $first !== null ) {
|
||||||
|
$server_id = (string) $first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wp_send_json_success( [
|
wp_send_json_success( [
|
||||||
'mc_username' => $mc_user,
|
'mc_username' => $mc_user,
|
||||||
'server_id' => $server_id,
|
'server_id' => $server_id,
|
||||||
@@ -512,6 +557,10 @@ class MC_Gallery_Forum_Bridge {
|
|||||||
})
|
})
|
||||||
.done(function(r){
|
.done(function(r){
|
||||||
if ( r.success ) {
|
if ( r.success ) {
|
||||||
|
if (!r.data.server_id) {
|
||||||
|
r.data.server_id = server || '';
|
||||||
|
}
|
||||||
|
|
||||||
// Galerie-JS über erfolgreiche Verify informieren
|
// Galerie-JS über erfolgreiche Verify informieren
|
||||||
// Standard-Event — Gallery-JS kann darauf lauschen
|
// Standard-Event — Gallery-JS kann darauf lauschen
|
||||||
$(document).trigger('mc_gallery_forum_verified', [ r.data ]);
|
$(document).trigger('mc_gallery_forum_verified', [ r.data ]);
|
||||||
@@ -529,9 +578,9 @@ class MC_Gallery_Forum_Bridge {
|
|||||||
+ '</strong></div>');
|
+ '</strong></div>');
|
||||||
} else {
|
} else {
|
||||||
var msg = (r.data && r.data.message) ? r.data.message : 'Fehler bei der Verifikation.';
|
var msg = (r.data && r.data.message) ? r.data.message : 'Fehler bei der Verifikation.';
|
||||||
$btn.closest('.mc-bridge-verify-wrap').find('.mc-bridge-error').remove();
|
var $wrap = $btn.closest('.mc-bridge-verify-wrap');
|
||||||
$btn.closest('.mc-bridge-forum-linked, .mc-bridge-not-linked')
|
$wrap.find('.mc-bridge-error').remove();
|
||||||
.after('<p class="mc-bridge-error"><i class="fas fa-times-circle"></i> ' + msg + '</p>');
|
$wrap.append('<p class="mc-bridge-error"><i class="fas fa-times-circle"></i> ' + msg + '</p>');
|
||||||
$btn.prop('disabled', false).html('<i class="fas fa-sign-in-alt"></i> Mit Forum-Login verifizieren');
|
$btn.prop('disabled', false).html('<i class="fas fa-sign-in-alt"></i> Mit Forum-Login verifizieren');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -667,15 +716,46 @@ class MC_Gallery_Forum_Bridge {
|
|||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gibt true zurück wenn gerade ein gültiger Ingame-Token für diesen MC-Namen existiert
|
/**
|
||||||
|
* Markiert den verknüpften Forum-Account zu einem MC-Namen als verifiziert.
|
||||||
|
* Gibt true zurück, wenn ein Account gefunden und aktualisiert wurde.
|
||||||
|
*/
|
||||||
|
public static function verify_linked_user_by_mc_username( $mc_username ) {
|
||||||
|
$mc_username = trim( (string) $mc_username );
|
||||||
|
if ( $mc_username === '' ) return false;
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$user_id = (int) $wpdb->get_var( $wpdb->prepare(
|
||||||
|
"SELECT user_id FROM {$wpdb->prefix}forum_user_meta
|
||||||
|
WHERE meta_key = %s AND LOWER(meta_value) = LOWER(%s)
|
||||||
|
LIMIT 1",
|
||||||
|
self::META_MC_USER,
|
||||||
|
$mc_username
|
||||||
|
) );
|
||||||
|
|
||||||
|
if ( ! $user_id ) return false;
|
||||||
|
|
||||||
|
self::set_verified( $user_id, true );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gibt true zurück wenn ein gültiger und bereits verifizierter Ingame-Token für diesen MC-Namen existiert
|
||||||
private static function check_active_token_for( $mc_username ) {
|
private static function check_active_token_for( $mc_username ) {
|
||||||
if ( ! class_exists( 'MC_Gallery_Helpers' ) ) return false;
|
if ( ! class_exists( 'MC_Gallery_Helpers' ) ) return false;
|
||||||
$tokens = MC_Gallery_Helpers::get_tokens();
|
$tokens = MC_Gallery_Helpers::get_tokens();
|
||||||
$now = time();
|
$now = time();
|
||||||
|
|
||||||
|
$wanted = strtolower( trim( (string) $mc_username ) );
|
||||||
|
if ( $wanted === '' ) return false;
|
||||||
|
|
||||||
foreach ( $tokens as $token => $data ) {
|
foreach ( $tokens as $token => $data ) {
|
||||||
if ( ! is_array( $data ) ) continue;
|
if ( ! is_array( $data ) ) continue;
|
||||||
if ( ( $data['expires'] ?? 0 ) < $now ) continue;
|
if ( ( $data['expires'] ?? 0 ) < $now ) continue;
|
||||||
if ( strtolower( $data['player'] ?? '' ) === strtolower( $mc_username ) ) {
|
if ( empty( $data['claimed'] ) ) continue;
|
||||||
|
|
||||||
|
// Unterschiedliche Payload-Feldnamen aus Java/WP-Versionen tolerieren
|
||||||
|
$name = $data['claimed_by'] ?? $data['username'] ?? $data['player'] ?? '';
|
||||||
|
if ( strtolower( trim( (string) $name ) ) === $wanted ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user