From 743837d6fa63a6ff7c7d562e51dedc3b99dced5a Mon Sep 17 00:00:00 2001 From: M_Viper Date: Sat, 21 Mar 2026 18:47:36 +0100 Subject: [PATCH] Upload file uninstall.php via GUI --- uninstall.php | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 uninstall.php diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000..e0a667a --- /dev/null +++ b/uninstall.php @@ -0,0 +1,108 @@ +query( "DROP TABLE IF EXISTS `{$wpdb->prefix}{$table}`" ); +} + +// ── 2. Alle wp_options löschen ─────────────────────────────────────────────── +$options = [ + 'wbf_settings', + 'wbf_custom_roles', + 'wbf_level_config', + 'wbf_levels_enabled', + 'wbf_profile_fields', + 'wbf_reactions', + 'wbf_forum_page_id', + 'wbf_superadmin_email', + 'wbf_db_version', +]; + +foreach ( $options as $option ) { + delete_option( $option ); +} + +// Multisite: Netzwerk-Optionen ebenfalls entfernen +if ( is_multisite() ) { + foreach ( $options as $option ) { + delete_site_option( $option ); + } +} + +// ── 3. Transients löschen ──────────────────────────────────────────────────── +delete_transient( 'wbf_activation_redirect' ); +delete_transient( 'wbf_stats_cache' ); + +// Alle wbf_* Transients per LIKE-Query entfernen +$wpdb->query( + "DELETE FROM `{$wpdb->options}` + WHERE `option_name` LIKE '_transient_wbf_%' + OR `option_name` LIKE '_transient_timeout_wbf_%'" +); + +// ── 4. Geplante Cron-Jobs entfernen ────────────────────────────────────────── +wp_clear_scheduled_hook( 'wbf_check_expired_bans' ); + +// ── 5. Forum-Seite löschen (vom Setup-Wizard erstellt) ─────────────────────── +$forum_page_id = get_option( 'wbf_forum_page_id' ); +if ( $forum_page_id ) { + wp_delete_post( (int) $forum_page_id, true ); // true = dauerhaft löschen +} + +// ── 6. Upload-Unterverzeichnis entfernen ───────────────────────────────────── +$upload_dir = wp_upload_dir(); +$wbf_dir = trailingslashit( $upload_dir['basedir'] ) . 'wbf-avatars'; +if ( is_dir( $wbf_dir ) ) { + wbf_uninstall_rmdir( $wbf_dir ); +} + +/** + * Hilfsfunktion: Verzeichnis rekursiv löschen. + * Nur innerhalb des WP-Upload-Verzeichnisses erlaubt. + */ +function wbf_uninstall_rmdir( $dir ) { + $upload_base = wp_upload_dir()['basedir']; + // Sicherheitscheck: nur Unterverzeichnisse von uploads/ löschen + if ( strpos( realpath( $dir ), realpath( $upload_base ) ) !== 0 ) { + return; + } + $files = array_diff( scandir( $dir ), [ '.', '..' ] ); + foreach ( $files as $file ) { + $path = $dir . DIRECTORY_SEPARATOR . $file; + is_dir( $path ) ? wbf_uninstall_rmdir( $path ) : unlink( $path ); + } + rmdir( $dir ); +} \ No newline at end of file