From 2b128c54dba39c0661a2ec8f14151c5a0e186f60 Mon Sep 17 00:00:00 2001 From: Gioxx Date: Thu, 28 Nov 2024 16:44:47 +0100 Subject: [PATCH 1/3] Ricerca (e pulizia) possibili duplicati MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Il codice è stato parzialmente rivisto e ottimizzato. Ora, nel plugin, si naviga per schede. È stata aggiunta la ricerca dei possibili utenti duplicati. --- email-user-cleaner.css | 3 +- email-user-cleaner.php | 336 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 306 insertions(+), 33 deletions(-) diff --git a/email-user-cleaner.css b/email-user-cleaner.css index 2a48c5b..018dad5 100644 --- a/email-user-cleaner.css +++ b/email-user-cleaner.css @@ -73,7 +73,8 @@ GSolone, 2024 margin-top: 10px; } -.wrap h2 span.dashicons.dashicons-email-alt { +.wrap h2 span.dashicons.dashicons-email-alt, +.wrap h2 span.dashicons.dashicons-groups { font-size: 35px; padding-right: 10px; margin-right: 10px; diff --git a/email-user-cleaner.php b/email-user-cleaner.php index 2399781..92d06ad 100644 --- a/email-user-cleaner.php +++ b/email-user-cleaner.php @@ -2,44 +2,130 @@ /* Plugin Name: E-mail User Cleaner Plugin URI: https://go.gioxx.org/emailusercleaner -Description: Delete users corresponding to the specified email addresses. -Version: 1.5 +Description: Delete users corresponding to the specified email addresses, but also search for duplicate users. +Version: 1.6 Author: Gioxx Author URI: https://gioxx.org License: GPL v2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html */ -// WordPress admin menu item -add_action('admin_menu', 'euc_admin_menu'); - +/** + * Add the plugin to the WordPress admin menu. + * + * This function adds an item in the WordPress admin menu, which + * will lead to the plugin's main page, containing navigation tabs. + * + * @since 1.5 + */ function euc_admin_menu() { add_menu_page( 'E-mail User Cleaner', 'E-mail User Cleaner', 'manage_options', 'email-user-cleaner', - 'euc_admin_page', + 'euc_admin_page', // Show the main page with navigation tabs 'dashicons-superhero' ); } +add_action('admin_menu', 'euc_admin_menu'); -// Enqueue styles +/** + * Enqueue the plugin's CSS file. + * + * This function is triggered by the 'admin_enqueue_scripts' action hook. + * + * @since 1.5 + */ function euc_enqueue_styles() { wp_enqueue_style( 'euc-styles', plugins_url('email-user-cleaner.css', __FILE__), array(), - '1.5' + '1.6' ); } add_action('admin_enqueue_scripts', 'euc_enqueue_styles'); -// Show the plugin page -function euc_admin_page() { +/** + * Renders the footer section for the E-mail User Cleaner plugin admin page. + * + * This footer includes styled dashicons, the current year, and links to Gioxx.org + * and the plugin's GitHub repository. + */ +function euc_render_footer() { + ?> + + +
+ + + +
+

- - + + user_login), - sanitize_email($user->user_email), - sanitize_text_field($user->display_name), - sanitize_text_field(implode(', ', $user->roles)), - sanitize_text_field(get_user_meta($user->ID, 'first_name', true)), - sanitize_text_field(get_user_meta($user->ID, 'last_name', true)) + sanitize_user($user->user_login), // user_login + sanitize_email($user->user_email), // user_email + sanitize_text_field($user->display_name), // display_name + sanitize_text_field(implode(', ', $user->roles)), // roles + sanitize_text_field(get_user_meta($user->ID, 'first_name', true)), // first_name + sanitize_text_field(get_user_meta($user->ID, 'last_name', true)) // last_name ); $csv_content .= '"' . implode('","', array_map('esc_html', $user_info)) . '"' . "\n"; } @@ -173,16 +265,20 @@ function euc_delete_users() { } // Verify that the user has the necessary permissions - if (!current_user_can('manage_options')) { - wp_die(esc_html__('Access denied', 'email-user-cleaner')); - } + euc_verify_permissions(); // Get email addresses specified $emails = isset($_POST['emails']) ? sanitize_textarea_field($_POST['emails']) : ''; // Split email addresses into an array $emails_array = array_map('trim', explode("\n", $emails)); - $emails_array = array_filter($emails_array, 'is_email'); + $emails_array = array_filter($emails_array, function ($email) { + $sanitized_email = sanitize_email($email); + return is_email($sanitized_email) ? $sanitized_email : false; + }); + + // Avoid duplicates + $emails_array = array_unique($emails_array); // Get current user's email $current_user = wp_get_current_user(); @@ -200,6 +296,7 @@ function euc_delete_users() { continue; } + // Checks that the email is valid and belongs to a user $user = get_user_by('email', $email); if ($user) { $deleted = wp_delete_user($user->ID); @@ -213,24 +310,199 @@ function euc_delete_users() { } } + // Messages output if (!empty($success_messages)) { - echo '
'; + echo '
'; foreach ($success_messages as $message) { - echo '' . esc_html($message) . '
'; + echo '

' . esc_html($message) . '

'; } echo '
'; } if (!empty($error_messages)) { - echo '
'; + echo '
'; foreach ($error_messages as $message) { - echo '' . esc_html($message) . '
'; + echo '

' . esc_html($message) . '

'; } echo '
'; } } } +/** + * Hook to capture user login and save the time to user meta. + * + * Capture the WordPress hook "wp_login" to save the last login time to user meta. + * + * @param string $user_login The user login. + * @param WP_User $user WP_User object. + */ +function euc_save_last_login($user_login, $user) { + update_user_meta($user->ID, 'last_login', current_time('mysql')); +} +add_action('wp_login', 'euc_save_last_login', 10, 2); + +// Function to identify duplicated users +function euc_show_duplicates_page() { + // Verify if the current user has permission to view this page + euc_verify_permissions(); + + // Retrieve duplicate users + $duplicates = euc_find_duplicate_users(); // This function should be defined elsewhere to find duplicates + + ?> +
+

+ +
+ + + +
+
!
+
+ +
. +
+
+ + + + + + + + + + + + + + + + ID, 'last_login', true); + + // Format the last login date if available + $last_login_display = !empty($last_login) ? date('Y-m-d H:i:s', strtotime($last_login)) : __('Never logged in', 'email-user-cleaner'); + ?> + + + + + + + + + + + + +
+ + user_login); ?>user_email); ?>first_name . ' ' . $user->last_name); ?>

+
+ +
+ +

+ +
+
+ + + + ' . esc_html(sprintf(__('User with ID %d successfully deleted.', 'email-user-cleaner'), $user_id)) . '
'; + } else { + echo '
' . esc_html(sprintf(__('Error deleting user with ID %d.', 'email-user-cleaner'), $user_id)) . '
'; + } + } + } +} + +// Helper function to add duplicates to the duplicates list +function add_duplicates_to_list($map, $criteria, &$duplicates) { + foreach ($map as $key => $users_with_same_key) { + // Check if there are multiple users with the same key (e.g., email or full name) + if (count($users_with_same_key) > 1) { + // Add these users to the duplicates list with the appropriate criteria + $duplicates[] = [ + 'criteria' => $criteria, + 'users' => $users_with_same_key + ]; + } + } +} + +// Main function to find duplicate users based on different criteria +function euc_find_duplicate_users() { + $users = get_users(); + $duplicates = []; + $email_map = []; + $name_map = []; + + // Find duplicates based on email and full names in a single loop + foreach ($users as $user) { + // Check for duplicates by email + $user_email = $user->user_email; + if (isset($email_map[$user_email])) { + // If email already exists in the map, add this user to the existing array + $email_map[$user_email][] = $user; + } else { + // Otherwise, create a new array with this user + $email_map[$user_email] = [$user]; + } + + // Check for duplicates by full name + $full_name = strtolower(trim($user->first_name . ' ' . $user->last_name)); + if (isset($name_map[$full_name])) { + // If full name already exists in the map, add this user to the existing array + $name_map[$full_name][] = $user; + } else { + // Otherwise, create a new array with this user + $name_map[$full_name] = [$user]; + } + } + + // Use the helper function to add duplicate users to the final duplicates list + add_duplicates_to_list($email_map, 'Email', $duplicates); + add_duplicates_to_list($name_map, 'Full Name', $duplicates); + + return $duplicates; +} + // Add user deletion function to admin_init hook add_action('admin_action_euc_export_users_csv', 'euc_export_users_csv'); \ No newline at end of file From 4c5b7419c096e315a2ac26f86d5c484094c5f21b Mon Sep 17 00:00:00 2001 From: Gioxx Date: Thu, 28 Nov 2024 16:45:38 +0100 Subject: [PATCH 2/3] generateRandomCSV with parameters Il generatore ora accetta parametri da riga di comando per generare file CSV completi di nome e cognome, con un numero di righe variabile e un nome a scelta dell'utente (default: output.csv da 120 righe). --- tools/example_include-names.csv | 122 ++++++++++++++++++++++++++++++++ tools/example_simple.csv | 121 +++++++++++++++++++++++++++++++ tools/generateRandomCSV.py | 55 +++++++++++--- 3 files changed, 287 insertions(+), 11 deletions(-) create mode 100644 tools/example_include-names.csv create mode 100644 tools/example_simple.csv diff --git a/tools/example_include-names.csv b/tools/example_include-names.csv new file mode 100644 index 0000000..a91988b --- /dev/null +++ b/tools/example_include-names.csv @@ -0,0 +1,122 @@ +username,email,first_name,last_name +R4ddSbPyA8Nd,R4ddSbPyA8Nd@autluc.de,Giulia,Conti +R4dd5ayA8Nd,R4ddSbPyA8Nd@autluc.de,Milon,Fusk +vUp7apI5mOYw,vUp7apI5mOYw@autluc.de,Giorgio,Ricci +UB2LlsBJ60p5,UB2LlsBJ60p5@yau.com,Giorgio,Verdi +z745Z72uvacr,z745Z72uvacr@gnails.from,Anna,Conti +wZmTHNm5PfXk,wZmTHNm5PfXk@yau.com,Elena,Marini +oHZ1SQoye6lp,oHZ1SQoye6lp@gnails.from,Luigi,Ferrari +CuFQIrsPEoeP,CuFQIrsPEoeP@hotmeil.con,Luigi,Verdi +jYDP4qZmMrSA,jYDP4qZmMrSA@hotmeil.con,Luigi,Rossi +bZ2iU8MtwQu3,bZ2iU8MtwQu3@yau.com,Luca,Ferrari +shKLYnCwrIxM,shKLYnCwrIxM@hotmeil.con,Elena,Ricci +r9Z5ABh8Jov9,r9Z5ABh8Jov9@gnails.from,Mario,Esposito +eVqum5dRsMHj,eVqum5dRsMHj@yau.com,Marco,Neri +JAKD0ztv6aeP,JAKD0ztv6aeP@gnails.from,Marco,Rossi +jFOQFzSttjlX,jFOQFzSttjlX@hotmeil.con,Giorgio,Verdi +fbeq8ODkkvWL,fbeq8ODkkvWL@gnails.from,Mario,Esposito +ZucBNo1XGNZS,ZucBNo1XGNZS@hotmeil.con,Anna,Neri +aG38DFEDFmdx,aG38DFEDFmdx@autluc.de,Anna,Esposito +bKFSvD6qDJC0,bKFSvD6qDJC0@autluc.de,Elena,Verdi +btskuqlIypur,btskuqlIypur@autluc.de,Marco,Conti +sHzrfvE2JSjH,sHzrfvE2JSjH@yau.com,Elena,Neri +POXcPryNo5aC,POXcPryNo5aC@autluc.de,Luca,Bianchi +RDOzaGnT5H3f,RDOzaGnT5H3f@autluc.de,Elena,Conti +VMHgbYTKmmVV,VMHgbYTKmmVV@hotmeil.con,Luca,Neri +cfxErhCb008r,cfxErhCb008r@gnails.from,Giorgio,Marini +D3YfY6fi2ASo,D3YfY6fi2ASo@autluc.de,Francesca,Ricci +lm5RiNcopQ0J,lm5RiNcopQ0J@hotmeil.con,Mario,Esposito +89EKISBc7Q92,89EKISBc7Q92@gnails.from,Marco,Neri +cSCQZk2GzZSS,cSCQZk2GzZSS@gnails.from,Luca,Esposito +0L0wJ8wS7954,0L0wJ8wS7954@autluc.de,Mario,Conti +JqguJykTgPMN,JqguJykTgPMN@gnails.from,Anna,Ricci +x5Do6WJIGPDa,x5Do6WJIGPDa@yau.com,Marco,Conti +14BFGBeWyLZs,14BFGBeWyLZs@gnails.from,Giorgio,Neri +JDSGSA3uxjNX,JDSGSA3uxjNX@yau.com,Francesca,Rossi +dAAO0snPltLS,dAAO0snPltLS@yau.com,Giulia,Ricci +qSv3NJibEjx2,qSv3NJibEjx2@autluc.de,Marco,Verdi +pM982NRmzAYu,pM982NRmzAYu@gnails.from,Mario,Ricci +ZxUHJuugcEJt,ZxUHJuugcEJt@yau.com,Mario,Esposito +fZ1QGTFb89bu,fZ1QGTFb89bu@autluc.de,Sofia,Verdi +ELfXZYLFe4dg,ELfXZYLFe4dg@yau.com,Francesca,Bianchi +kjrWY069UkrB,kjrWY069UkrB@yau.com,Marco,Gallo +vbNCWQy6aJAj,vbNCWQy6aJAj@hotmeil.con,Francesca,Rossi +0dMQUGCNt5HZ,0dMQUGCNt5HZ@gnails.from,Elena,Esposito +HkB0br095Dvh,HkB0br095Dvh@gnails.from,Anna,Ricci +4NvCmirCtWPy,4NvCmirCtWPy@autluc.de,Giulia,Conti +M0dzWpJPLW5w,M0dzWpJPLW5w@autluc.de,Giorgio,Gallo +1nzeLFdScW9i,1nzeLFdScW9i@autluc.de,Mario,Rossi +4n7c0fdzBUGz,4n7c0fdzBUGz@hotmeil.con,Marco,Marini +8r3iOYOfRRPz,8r3iOYOfRRPz@hotmeil.con,Mario,Ferrari +Wsj8Sv9ldW3h,Wsj8Sv9ldW3h@autluc.de,Mario,Marini +BPhJWkCDbWQR,BPhJWkCDbWQR@autluc.de,Elena,Marini +wMh6u3fymLKZ,wMh6u3fymLKZ@hotmeil.con,Anna,Neri +EuXOo9PI9KYG,EuXOo9PI9KYG@gnails.from,Luca,Rossi +2dZZT8fGEIcQ,2dZZT8fGEIcQ@gnails.from,Mario,Gallo +M5ORVxI4lVdU,M5ORVxI4lVdU@gnails.from,Marco,Ricci +7wUF35G0bpYj,7wUF35G0bpYj@yau.com,Giorgio,Gallo +HkRHcFcYo7Ms,HkRHcFcYo7Ms@hotmeil.con,Giulia,Gallo +h9o2IWqBU7TX,h9o2IWqBU7TX@gnails.from,Giorgio,Gallo +yalCC3HGNki5,yalCC3HGNki5@gnails.from,Sofia,Ferrari +0i7DLpLprO77,0i7DLpLprO77@gnails.from,Luca,Ferrari +bWs4LADDdR8F,bWs4LADDdR8F@yau.com,Giulia,Verdi +ddFWuz0xPCX0,ddFWuz0xPCX0@yau.com,Elena,Verdi +duBQlnnLPbyb,duBQlnnLPbyb@autluc.de,Francesca,Rossi +jIiWmPwktyil,jIiWmPwktyil@autluc.de,Elena,Marini +rKMNHhpA9CpV,rKMNHhpA9CpV@yau.com,Giorgio,Gallo +8R991OqtiZJV,8R991OqtiZJV@gnails.from,Marco,Rossi +hWxPwcA52B3c,hWxPwcA52B3c@hotmeil.con,Elena,Bianchi +26S2Jwe96lnm,26S2Jwe96lnm@hotmeil.con,Giulia,Conti +GAX75WeqTmsC,GAX75WeqTmsC@autluc.de,Giulia,Esposito +9Ci4Y5r2J6xw,9Ci4Y5r2J6xw@gnails.from,Marco,Ricci +NvwTFH4D3NJ7,NvwTFH4D3NJ7@gnails.from,Anna,Conti +jna9RBYkD1zF,jna9RBYkD1zF@gnails.from,Elena,Rossi +N0TLHHSwgey7,N0TLHHSwgey7@autluc.de,Luca,Neri +rJxXwJPIwqNN,rJxXwJPIwqNN@gnails.from,Giulia,Gallo +03F0KhV3rIFP,03F0KhV3rIFP@yau.com,Marco,Bianchi +Aze6JdsKWpv9,Aze6JdsKWpv9@hotmeil.con,Mario,Ricci +vmLcZlBa4tzj,vmLcZlBa4tzj@hotmeil.con,Elena,Neri +XdXiLy5OyTIW,XdXiLy5OyTIW@autluc.de,Luigi,Ferrari +kx3F8RLl9E04,kx3F8RLl9E04@hotmeil.con,Giorgio,Neri +SILg4atinvNP,SILg4atinvNP@autluc.de,Giulia,Esposito +5f5XKCTtwzGS,5f5XKCTtwzGS@hotmeil.con,Francesca,Verdi +beAcIsws6amh,beAcIsws6amh@yau.com,Mario,Esposito +2QXHndo6hqQ3,2QXHndo6hqQ3@autluc.de,Luca,Esposito +hAJsBFOhZYYp,hAJsBFOhZYYp@yau.com,Luca,Esposito +vgrtRZ1kwH2O,vgrtRZ1kwH2O@gnails.from,Elena,Ferrari +Tk06AnjXkewR,Tk06AnjXkewR@hotmeil.con,Luigi,Rossi +hxehWCkA88dE,hxehWCkA88dE@yau.com,Giorgio,Rossi +EeYgm5jfWy2g,EeYgm5jfWy2g@gnails.from,Elena,Marini +QAsitaDTHS34,QAsitaDTHS34@autluc.de,Luigi,Conti +VZfVFLwBIiPM,VZfVFLwBIiPM@autluc.de,Giulia,Ferrari +0NCiz7vBnxCl,0NCiz7vBnxCl@hotmeil.con,Sofia,Bianchi +IClbkvHzf2zk,IClbkvHzf2zk@yau.com,Francesca,Rossi +A4O8thQlBV99,A4O8thQlBV99@hotmeil.con,Giulia,Marini +7NRjbdiZk12E,7NRjbdiZk12E@gnails.from,Sofia,Ricci +YOQeMZct87kj,YOQeMZct87kj@hotmeil.con,Giulia,Ferrari +LlDMWSQVAkdd,LlDMWSQVAkdd@hotmeil.con,Luigi,Ferrari +v5bYMf11WGRF,v5bYMf11WGRF@hotmeil.con,Mario,Ferrari +Ek17Uk3wvcp0,Ek17Uk3wvcp0@yau.com,Mario,Neri +463IR3cOYa4G,463IR3cOYa4G@gnails.from,Mario,Esposito +xOUasKi3tRzd,xOUasKi3tRzd@hotmeil.con,Mario,Marini +Se5PqYhsdoIu,Se5PqYhsdoIu@gnails.from,Luca,Ferrari +VXbTviADOUYP,VXbTviADOUYP@yau.com,Sofia,Gallo +cg81yRbicKCv,cg81yRbicKCv@gnails.from,Luigi,Neri +IOjbkPRlaCNv,IOjbkPRlaCNv@yau.com,Giulia,Neri +fsZUXYAHOddP,fsZUXYAHOddP@autluc.de,Luigi,Bianchi +NCrnBZb9tPBe,NCrnBZb9tPBe@yau.com,Elena,Marini +kcWmmXz2ttbt,kcWmmXz2ttbt@gnails.from,Giorgio,Verdi +hd09pdy2kDlj,hd09pdy2kDlj@gnails.from,Mario,Neri +uhqFoXZ5eomg,uhqFoXZ5eomg@yau.com,Anna,Neri +iQXg6zl2WkqA,iQXg6zl2WkqA@hotmeil.con,Luigi,Verdi +jRCQO2YGshsy,jRCQO2YGshsy@yau.com,Giulia,Ricci +fmCQrL7jj1aH,fmCQrL7jj1aH@autluc.de,Mario,Marini +tniIy2USig1t,tniIy2USig1t@autluc.de,Sofia,Marini +7xxxVOw1D4ps,7xxxVOw1D4ps@autluc.de,Sofia,Gallo +FRlXbXmUuXvd,FRlXbXmUuXvd@yau.com,Giulia,Esposito +VeV4mXHoDI1s,VeV4mXHoDI1s@gnails.from,Elena,Marini +VAcmsLPqIzdd,VAcmsLPqIzdd@autluc.de,Francesca,Verdi +4ZRhFy3TJJyG,4ZRhFy3TJJyG@yau.com,Anna,Marini +1jQjdv1hcFnU,1jQjdv1hcFnU@hotmeil.con,Luigi,Gallo +bf4WcbqPz5sR,bf4WcbqPz5sR@yau.com,Mario,Rossi +4pPH3Cb8SfVS,4pPH3Cb8SfVS@gnails.from,Anna,Marini diff --git a/tools/example_simple.csv b/tools/example_simple.csv new file mode 100644 index 0000000..9cb9763 --- /dev/null +++ b/tools/example_simple.csv @@ -0,0 +1,121 @@ +username,email +YKobHZ7jEcAr,YKobHZ7jEcAr@hotmeil.con +KAYdNcyZGVuD,KAYdNcyZGVuD@autluc.de +0KEnZeRuuZF5,0KEnZeRuuZF5@gnails.from +ahBW0ihUThbM,ahBW0ihUThbM@yau.com +xk6ylvfhgKRP,xk6ylvfhgKRP@autluc.de +e5yLTUct3lyT,e5yLTUct3lyT@autluc.de +OGOM3FKleCk7,OGOM3FKleCk7@gnails.from +Ndc73IWfxDbR,Ndc73IWfxDbR@yau.com +4zAKFa6F0dqT,4zAKFa6F0dqT@hotmeil.con +wH2ebC1HdOc9,wH2ebC1HdOc9@gnails.from +kfXXHsTOUCDm,kfXXHsTOUCDm@autluc.de +GxXAFqKeZaPJ,GxXAFqKeZaPJ@gnails.from +wP8l7Q6ydexF,wP8l7Q6ydexF@autluc.de +15mLmv3q7KCm,15mLmv3q7KCm@yau.com +lfqQZFlQYJXg,lfqQZFlQYJXg@yau.com +ATkAeiBoJTFD,ATkAeiBoJTFD@autluc.de +xebnfc60Dxru,xebnfc60Dxru@yau.com +7jhvT095wFtN,7jhvT095wFtN@gnails.from +ikTUl3xDqsbM,ikTUl3xDqsbM@hotmeil.con +JU0AVInY2moB,JU0AVInY2moB@yau.com +W4QvrnqcHf6y,W4QvrnqcHf6y@autluc.de +dWm7VY62B5zw,dWm7VY62B5zw@yau.com +ZMdTvGZWCnUO,ZMdTvGZWCnUO@gnails.from +x0D2XjThSjcL,x0D2XjThSjcL@yau.com +sTw0OXX9dCsn,sTw0OXX9dCsn@yau.com +FmmqFFkvtDfq,FmmqFFkvtDfq@gnails.from +xDhJXwOFQxfa,xDhJXwOFQxfa@hotmeil.con +FUJcucFSB2Sl,FUJcucFSB2Sl@gnails.from +0MkJapna01Mt,0MkJapna01Mt@autluc.de +JXSysj94OrpJ,JXSysj94OrpJ@hotmeil.con +cT8G2m0P2YHL,cT8G2m0P2YHL@yau.com +8rcYBkbfffbA,8rcYBkbfffbA@hotmeil.con +3opNm1psgHx5,3opNm1psgHx5@yau.com +kI0IPUgOtwqO,kI0IPUgOtwqO@yau.com +NQsp4jddUZYG,NQsp4jddUZYG@hotmeil.con +MSh08aMZiSXZ,MSh08aMZiSXZ@hotmeil.con +XizTJtLzv5yS,XizTJtLzv5yS@autluc.de +Y6l6GEjwKLSM,Y6l6GEjwKLSM@gnails.from +tgoK7B4u0tj8,tgoK7B4u0tj8@yau.com +a9sHZ3crRico,a9sHZ3crRico@hotmeil.con +xBLa6r9VIqFC,xBLa6r9VIqFC@yau.com +uRBxrRTqVQdP,uRBxrRTqVQdP@autluc.de +rRFXkmgRNYkg,rRFXkmgRNYkg@gnails.from +dGEUJ0JN7qSi,dGEUJ0JN7qSi@autluc.de +Gb88uCQO5O0t,Gb88uCQO5O0t@hotmeil.con +CUZFW4O8Pv4C,CUZFW4O8Pv4C@gnails.from +zJmSyFekBSko,zJmSyFekBSko@autluc.de +wPfajTBBgnjs,wPfajTBBgnjs@hotmeil.con +NYIsbG859PN8,NYIsbG859PN8@autluc.de +DbQGDmDhIpS4,DbQGDmDhIpS4@gnails.from +3fBBrGjpcgBx,3fBBrGjpcgBx@gnails.from +Phh1H4Iv8RAL,Phh1H4Iv8RAL@autluc.de +JxXqOznocLlk,JxXqOznocLlk@autluc.de +5ppt6FAA40fQ,5ppt6FAA40fQ@yau.com +NoRgRYxDUAtV,NoRgRYxDUAtV@autluc.de +qxqWRFedovts,qxqWRFedovts@gnails.from +h69SvU8KMQtz,h69SvU8KMQtz@yau.com +0zGf4JiWknA1,0zGf4JiWknA1@autluc.de +t14bf8JSzkUR,t14bf8JSzkUR@autluc.de +utCF2ocNuNyf,utCF2ocNuNyf@hotmeil.con +mfmc67KACvWj,mfmc67KACvWj@yau.com +OAwiRrss0OsA,OAwiRrss0OsA@autluc.de +nj2hyGCOOxva,nj2hyGCOOxva@hotmeil.con +jZG2ABx4OIjt,jZG2ABx4OIjt@autluc.de +suRo2B4N69XI,suRo2B4N69XI@autluc.de +5qW3JrZn3C7b,5qW3JrZn3C7b@hotmeil.con +RYp6CKeP9yFE,RYp6CKeP9yFE@hotmeil.con +Sl6TUn4jZn6D,Sl6TUn4jZn6D@hotmeil.con +TMbigDcWXIeB,TMbigDcWXIeB@gnails.from +svEgF4q2LoLO,svEgF4q2LoLO@autluc.de +a96kzGTJFwtX,a96kzGTJFwtX@autluc.de +cU92GOi40slk,cU92GOi40slk@hotmeil.con +txmMTrwCJfpk,txmMTrwCJfpk@gnails.from +9FVd3gKIXn9O,9FVd3gKIXn9O@yau.com +qWNzeLCP34Wm,qWNzeLCP34Wm@yau.com +fqcHIJoSAhNP,fqcHIJoSAhNP@autluc.de +KBYcLPBcb48O,KBYcLPBcb48O@autluc.de +ii0FJzo2UtkM,ii0FJzo2UtkM@gnails.from +ksPQJxhngvLP,ksPQJxhngvLP@gnails.from +wD7keIY5nup4,wD7keIY5nup4@hotmeil.con +q97PRUiU0W9e,q97PRUiU0W9e@hotmeil.con +n99kNNohMX5A,n99kNNohMX5A@yau.com +uaaDL347NvbC,uaaDL347NvbC@gnails.from +F5CejCGdMwAA,F5CejCGdMwAA@gnails.from +CkLveZ7hmKLl,CkLveZ7hmKLl@autluc.de +a5aMeRsmhJOQ,a5aMeRsmhJOQ@yau.com +DTmCQXe75YvY,DTmCQXe75YvY@gnails.from +Kl90VpUxmT9N,Kl90VpUxmT9N@hotmeil.con +gVXGdCLcdeTz,gVXGdCLcdeTz@autluc.de +HssiwRMuN6VZ,HssiwRMuN6VZ@hotmeil.con +a6WjYi95Fbk9,a6WjYi95Fbk9@yau.com +SLHdAQZ23p0c,SLHdAQZ23p0c@autluc.de +7O78wVZbztjw,7O78wVZbztjw@autluc.de +uqAMvc1Ofvn6,uqAMvc1Ofvn6@yau.com +pabQsPo2Lyce,pabQsPo2Lyce@hotmeil.con +IdfT8XRyzJfP,IdfT8XRyzJfP@yau.com +BQLUKfGVYx4H,BQLUKfGVYx4H@yau.com +2wfchtW8Gmq3,2wfchtW8Gmq3@gnails.from +4slv12rwLtqj,4slv12rwLtqj@gnails.from +zMZ2CtdHycPD,zMZ2CtdHycPD@autluc.de +UXRvcUPRsr2q,UXRvcUPRsr2q@yau.com +svsTiVBngHht,svsTiVBngHht@yau.com +QOXHkvJ29W0l,QOXHkvJ29W0l@autluc.de +jkwJoacjKSYb,jkwJoacjKSYb@yau.com +xiOxWZGIkaPp,xiOxWZGIkaPp@yau.com +GCWhLyjSGurC,GCWhLyjSGurC@gnails.from +Iy4SpGPay9Sq,Iy4SpGPay9Sq@gnails.from +zZbTQntH4TVH,zZbTQntH4TVH@yau.com +FcG9QtfcXLqX,FcG9QtfcXLqX@yau.com +xFW0LaZ3W3ub,xFW0LaZ3W3ub@autluc.de +WCgtkDWWhuWJ,WCgtkDWWhuWJ@autluc.de +TArUOWStIR7O,TArUOWStIR7O@gnails.from +8Gjo7CL2gGwn,8Gjo7CL2gGwn@autluc.de +EPpqxVR0a4oi,EPpqxVR0a4oi@yau.com +Qw1jJe8Tsjlf,Qw1jJe8Tsjlf@autluc.de +7iqSJO6d66PO,7iqSJO6d66PO@yau.com +awXEH0Vn8cUa,awXEH0Vn8cUa@autluc.de +2DkF2RO1p5r4,2DkF2RO1p5r4@autluc.de +PhBKRWD5xES4,PhBKRWD5xES4@autluc.de +BjvEeLyfd66q,BjvEeLyfd66q@hotmeil.con diff --git a/tools/generateRandomCSV.py b/tools/generateRandomCSV.py index b9d4360..dabaa19 100644 --- a/tools/generateRandomCSV.py +++ b/tools/generateRandomCSV.py @@ -1,6 +1,7 @@ import csv import random import string +import argparse # Funzione per generare un username casuale def generate_username(length=12): @@ -12,17 +13,49 @@ def generate_email(username, domain_list=['gnails.from', 'yau.com', 'hotmeil.con domain = random.choice(domain_list) return f"{username}@{domain}" -# Numero di righe da generare -num_rows = 120 +# Funzione per generare un nome casuale +def generate_first_name(): + first_names = ['Mario', 'Luigi', 'Giulia', 'Marco', 'Anna', 'Sofia', 'Giorgio', 'Elena', 'Luca', 'Francesca'] + return random.choice(first_names) -# Creazione del file CSV -with open('output.csv', 'w', newline='') as csvfile: - writer = csv.writer(csvfile) - writer.writerow(['username', 'email']) +# Funzione per generare un cognome casuale +def generate_last_name(): + last_names = ['Rossi', 'Bianchi', 'Verdi', 'Neri', 'Gallo', 'Ferrari', 'Conti', 'Esposito', 'Ricci', 'Marini'] + return random.choice(last_names) - for _ in range(num_rows): - username = generate_username() - email = generate_email(username) - writer.writerow([username, email]) +# Funzione per generare il file CSV +def generate_csv(include_names, num_rows=120, output_file='output.csv'): + with open(output_file, 'w', newline='') as csvfile: + writer = csv.writer(csvfile) -print(f"File CSV generato: output.csv") + # Intestazione del CSV + if include_names: + writer.writerow(['username', 'email', 'first_name', 'last_name']) + else: + writer.writerow(['username', 'email']) + + # Scrittura dei dati + for _ in range(num_rows): + username = generate_username() + email = generate_email(username) + + if include_names: + first_name = generate_first_name() + last_name = generate_last_name() + writer.writerow([username, email, first_name, last_name]) + else: + writer.writerow([username, email]) + + print(f"CSV file generated: {output_file}") + +# Parser degli argomenti da riga di comando +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Generate a CSV file with random user data.') + parser.add_argument('--include-names', action='store_true', help='Include first and last names in the generated CSV') + parser.add_argument('--num-rows', type=int, default=120, help='Number of rows to generate (default: 120)') + parser.add_argument('--output-file', type=str, default='output.csv', help='Output CSV file name (default: output.csv)') + + args = parser.parse_args() + + # Generazione del file CSV + generate_csv(args.include_names, args.num_rows, args.output_file) From e535c1ed359f9d81669c5ae14fc89a1b7e2eca69 Mon Sep 17 00:00:00 2001 From: Gioxx Date: Thu, 28 Nov 2024 17:14:57 +0100 Subject: [PATCH 3/3] Update readme.txt --- readme.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 533fead..f87f10a 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: gioxx Tags: maintenance, email, user, cleaning, csv Donate link: https://ko-fi.com/gioxx Requires at least: 6.0 -Tested up to: 6.6.1 +Tested up to: 6.7.1 Requires PHP: 7.4 -Stable tag: 1.5 +Stable tag: 1.6 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -16,6 +16,7 @@ The plugin provides the administrator with a convenient maintenance page, called From the E-mail User Cleaner page you will be able to: - generate and download a CSV file containing a complete list of registered users on the WordPress instance. - Specify one or more e-mail addresses (one address per line), corresponding to registered users on the WordPress instance, to be deleted from the system. + - Identify duplicated users (based on criteria that checks first name, last name and e-mail address) and decide to select and delete them, also referring to the last login date to the WordPress installation. == Installation == Install the plugin and activate it. You will find the E-mail User Cleaner entry in the sidebar of your WordPress Administrative Dashboard. @@ -27,5 +28,9 @@ Install the plugin and activate it. You will find the E-mail User Cleaner entry 4. The plugin reports that the user corresponding to the administrator's e-mail address has not been deleted for security reasons. == Changelog == += 1.6= +* You can now identify duplicated users (based on criteria that checks first name, last name and e-mail address) and decide to select and delete them, also referring to the last login date to the WordPress installation. +* You can use, for your tests, the Python script generateRandomCSV.py (found in the tools folder of the plugin's GitHub repository) which is able to generate CSVs of fake users complete with first name, last name, email address, which you can import into WordPress (test environment) to play around with this plugin and verify that everything is working properly (you can find two ready-made files already, example_include-names.csv and example_simple.csv). + = 1.5 = * Initial release published in the WordPress plugin directory. \ No newline at end of file