Changeset 1939555
- Timestamp:
- 09/11/2018 10:59:30 PM (7 years ago)
- Location:
- vulnerability-alerts
- Files:
-
- 16 added
- 6 edited
-
tags/1.3.6 (added)
-
tags/1.3.6/languages (added)
-
tags/1.3.6/languages/vulnerability-alerts-en_US.mo (added)
-
tags/1.3.6/languages/vulnerability-alerts-en_US.po (added)
-
tags/1.3.6/languages/vulnerability-alerts-fr_FR.mo (added)
-
tags/1.3.6/languages/vulnerability-alerts-fr_FR.po (added)
-
tags/1.3.6/languages/vulnerability-alerts-pt_BR.mo (added)
-
tags/1.3.6/languages/vulnerability-alerts-pt_BR.po (added)
-
tags/1.3.6/license.txt (added)
-
tags/1.3.6/readme.md (added)
-
tags/1.3.6/readme.txt (added)
-
tags/1.3.6/report.php (added)
-
tags/1.3.6/screenshot-1.png (added)
-
tags/1.3.6/screenshot-2.png (added)
-
tags/1.3.6/uninstall.php (added)
-
tags/1.3.6/vulnerability-alerts.php (added)
-
trunk/languages/vulnerability-alerts-pt_BR.mo (modified) (previous)
-
trunk/languages/vulnerability-alerts-pt_BR.po (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/report.php (modified) (1 diff)
-
trunk/uninstall.php (modified) (1 diff)
-
trunk/vulnerability-alerts.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vulnerability-alerts/trunk/languages/vulnerability-alerts-pt_BR.po
r1787624 r1939555 2 2 msgstr "" 3 3 "Project-Id-Version: Vulnerability Alerts\n" 4 "POT-Creation-Date: 201 7-12-15 10:55-0300\n"5 "PO-Revision-Date: 201 7-12-15 10:55-0300\n"4 "POT-Creation-Date: 2018-09-11 19:48-0300\n" 5 "PO-Revision-Date: 2018-09-11 19:49-0300\n" 6 6 "Last-Translator: Edir Pedro <[email protected]>\n" 7 7 "Language-Team: \n" 8 "Language: Português Brasileiro\n"8 "Language: pt_BR\n" 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 1.5.7\n"12 "X-Generator: Poedit 2.1.1\n" 13 13 "X-Poedit-KeywordsList: _;__;_e;_n:1,2\n" 14 14 "X-Poedit-Basepath: .\n" … … 16 16 "X-Poedit-SearchPath-0: ..\n" 17 17 18 #: ../report.php:3 ../vulnerability-alerts.php:175 18 #: ../report.php:3 ../vulnerability-alerts.php:184 19 #: ../vulnerability-alerts.php:185 19 20 msgid "Vulnerability Alerts" 20 21 msgstr "Alertas de Vulnerabilidade" … … 29 30 msgstr "Última verificação no %s em %s" 30 31 31 #: ../report.php:1 132 #: ../report.php:12 32 33 msgid "" 33 34 "Some paid plugins and themes, or developed exclusively for this website and " … … 37 38 "e não compartilhados com o público, podem não ser reportados pelo WPScan." 38 39 39 #: ../report.php:2 1 ../report.php:40 ../report.php:6140 #: ../report.php:22 ../report.php:43 ../report.php:66 40 41 msgid "Name" 41 42 msgstr "Nome" 42 43 43 #: ../report.php:2 2 ../report.php:41 ../report.php:6244 #: ../report.php:23 ../report.php:44 ../report.php:67 44 45 msgid "Vulnerabilities" 45 46 msgstr "Vulnerabilidades" 46 47 47 #: ../report.php: 28 ../report.php:48 ../report.php:6948 #: ../report.php:30 ../report.php:52 ../report.php:75 48 49 #, php-format 49 50 msgid "Version %s" 50 51 msgstr "Versão %s" 51 52 52 #: ../report.php:3 4 ../vulnerability-alerts.php:56453 #: ../report.php:37 ../vulnerability-alerts.php:610 53 54 msgid "Plugins" 54 55 msgstr "Plugins" 55 56 56 #: ../report.php: 55 ../vulnerability-alerts.php:57657 #: ../report.php:60 ../vulnerability-alerts.php:622 57 58 msgid "Themes" 58 59 msgstr "Temas" 59 60 60 #: ../vulnerability-alerts.php:11 461 #: ../vulnerability-alerts.php:117 61 62 #, php-format 62 63 msgid "%d vulnerability found" … … 65 66 msgstr[1] "%d vulnerabilidades encontradas" 66 67 67 #: ../vulnerability-alerts.php: 18768 #: ../vulnerability-alerts.php:201 68 69 msgid "View" 69 70 msgstr "Ver" 70 71 71 #: ../vulnerability-alerts.php:2 5972 #: ../vulnerability-alerts.php:275 72 73 msgid "Report updated." 73 74 msgstr "Relatório atualizado." 74 75 75 #: ../vulnerability-alerts.php:3 0776 #: ../vulnerability-alerts.php:329 76 77 msgid "Report not available" 77 78 msgstr "Relatório não disponível" 78 79 79 #: ../vulnerability-alerts.php:3 3280 #: ../vulnerability-alerts.php:355 80 81 msgid "Not fixed" 81 82 msgstr "Sem correção" 82 83 83 #: ../vulnerability-alerts.php:3 3284 #: ../vulnerability-alerts.php:355 84 85 #, php-format 85 86 msgid "Fixed in version %s" 86 87 msgstr "Corrigido na versão %s" 87 88 88 #: ../vulnerability-alerts.php: 38289 #: ../vulnerability-alerts.php:410 89 90 msgid "Notification" 90 91 msgstr "Notificação" 91 92 92 #: ../vulnerability-alerts.php: 38893 #: ../vulnerability-alerts.php:416 93 94 msgid "E-mail Address" 94 95 msgstr "Endereço de E-mail" 95 96 96 #: ../vulnerability-alerts.php: 39597 #: ../vulnerability-alerts.php:423 97 98 msgid "Send E-mail Alerts" 98 99 msgstr "Enviar Alertas no E-mail" 99 100 100 #: ../vulnerability-alerts.php:4 03101 #: ../vulnerability-alerts.php:431 101 102 msgid "Vulnerabilities to Ignore" 102 103 msgstr "Vulnerabilidades Ignoradas" 103 104 104 #: ../vulnerability-alerts.php:4 16105 #: ../vulnerability-alerts.php:444 105 106 msgid "" 106 107 "Fill the options below if you want to be notified by mail about new " … … 110 111 "vulnerabilidades." 111 112 112 #: ../vulnerability-alerts.php:438 113 #: ../vulnerability-alerts.php:455 114 msgid "Add multiple e-mail addresses separating them by comma." 115 msgstr "Adicione múltiplos endereços de e-mail separando-os por vírgula." 116 117 #: ../vulnerability-alerts.php:467 113 118 msgid "Daily" 114 119 msgstr "Diariamente" 115 120 116 #: ../vulnerability-alerts.php:4 39121 #: ../vulnerability-alerts.php:468 117 122 msgid "Every Monday" 118 123 msgstr "Toda Segunda" 119 124 120 #: ../vulnerability-alerts.php:4 40125 #: ../vulnerability-alerts.php:469 121 126 msgid "Every Tuesday" 122 127 msgstr "Toda Terça" 123 128 124 #: ../vulnerability-alerts.php:4 41129 #: ../vulnerability-alerts.php:470 125 130 msgid "Every Wednesday" 126 131 msgstr "Toda Quarta" 127 132 128 #: ../vulnerability-alerts.php:4 42133 #: ../vulnerability-alerts.php:471 129 134 msgid "Every Thursday" 130 135 msgstr "Toda Quinta" 131 136 132 #: ../vulnerability-alerts.php:4 43137 #: ../vulnerability-alerts.php:472 133 138 msgid "Every Friday" 134 139 msgstr "Toda Sexta" 135 140 136 #: ../vulnerability-alerts.php:4 44141 #: ../vulnerability-alerts.php:473 137 142 msgid "Every Saturday" 138 143 msgstr "Todo Sábado" 139 144 140 #: ../vulnerability-alerts.php:4 45145 #: ../vulnerability-alerts.php:474 141 146 msgid "Every Sunday" 142 147 msgstr "Todo Domingo" 143 148 144 #: ../vulnerability-alerts.php:4 46149 #: ../vulnerability-alerts.php:475 145 150 msgid "Every Month" 146 151 msgstr "Todo Mês" 147 152 148 #: ../vulnerability-alerts.php:5 04153 #: ../vulnerability-alerts.php:541 149 154 msgid "You have entered an invalid e-mail address." 150 155 msgstr "Você informou um endereço de e-mail inválido." 151 156 152 #: ../vulnerability-alerts.php:5 45157 #: ../vulnerability-alerts.php:591 153 158 msgid "Hello Friend," 154 159 msgstr "Olá Amigo(a)," 155 160 156 #: ../vulnerability-alerts.php:5 46161 #: ../vulnerability-alerts.php:592 157 162 #, php-format 158 163 msgid "Some vulnerabilities were found in %s, visit the site for more details." … … 161 166 "detalhes." 162 167 163 #: ../vulnerability-alerts.php: 582168 #: ../vulnerability-alerts.php:628 164 169 msgid "Hope this help!" 165 170 msgstr "Espero que isso ajude!" 166 171 167 #: ../vulnerability-alerts.php: 586172 #: ../vulnerability-alerts.php:632 168 173 #, php-format 169 174 msgid "Some vulnerabilities were found in %s" -
vulnerability-alerts/trunk/readme.txt
r1845067 r1939555 3 3 Tags: security, vulnerability, wpscan, hack, scan, exploit, secure 4 4 Requires at least: 3.4 5 Tested up to: 4.9. 46 Stable tag: 1.3. 55 Tested up to: 4.9.8 6 Stable tag: 1.3.6 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 == Changelog == 34 34 35 = 1.3.6 = 36 * [Added] Support to send to multiple e-mails 37 35 38 = 1.3.5 = 36 39 * [Fixed] Prevent cron jobs duplication. -
vulnerability-alerts/trunk/report.php
r1393065 r1939555 1 1 <div class="wrap"> 2 2 3 <h1><?php _e('Vulnerability Alerts', self::$id) ?></h1>4 3 <h1><?php _e( 'Vulnerability Alerts', self::$id ) ?></h1> 4 5 5 <?php settings_errors(); ?> 6 6 7 <form method='post'> 8 <input type="hidden" name="verify" value="1"> 9 <p class="alignright"><?php submit_button(__('Check Now', self::$id), 'primary', 'submit', false) ?></p> 10 <p><?php printf(__('Last request to %s on %s', self::$id), '<a href="https://wpvulndb.com/" target="_blank">WPScan Vulnerability Database</a>', date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $report['cache'])) ?><br> 11 <?php _e('Some paid plugins and themes, or developed exclusively for this website and not shared for the public, may not be reported on WPScan.', self::$id) ?> 12 </p> 13 </form> 14 15 <h3>WordPress</h3> 16 17 <table class="wp-list-table widefat striped plugins"> 18 <thead> 19 <tr> 20 <td scope="col" class="manage-column check-column"> </td> 21 <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e('Name', self::$id) ?></th> 22 <th scope="col" class="manage-column column-description"><?php _e('Vulnerabilities', self::$id) ?></th> 23 </tr> 24 </thead> 25 <tbody id="report-wordpress"> 26 <tr> 27 <th scope="row" class="check-column" align="center"><?php echo self::get_status('wordpress') ?></span></th> 28 <td class="plugin-title column-primary"><strong>WordPress</strong> <?php echo sprintf(__('Version %s', self::$id), get_bloginfo('version')) ?></td> 29 <td><?php self::list_vulnerabilities('wordpress') ?></td> 30 </tr> 31 </tbody> 32 </table> 33 34 <h3><?php _e('Plugins', self::$id) ?></h3> 35 36 <table class="wp-list-table widefat striped plugins"> 37 <thead> 38 <tr> 39 <td scope="col" class="manage-column check-column"> </td> 40 <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e('Name', self::$id) ?></th> 41 <th scope="col" class="manage-column column-description"><?php _e('Vulnerabilities', self::$id) ?></th> 42 </tr> 43 </thead> 44 <tbody id="report-plugins"> 45 <?php foreach(get_plugins() as $name => $details) : ?> 46 <tr> 47 <th scope="row" class="check-column" align="center"><?php echo self::get_status('plugins', $name) ?></span></th> 48 <td class="plugin-title column-primary"><strong><?php echo $details['Name'] ?></strong> <?php echo sprintf(__('Version %s', self::$id), $details['Version']) ?></td> 49 <td><?php self::list_vulnerabilities('plugins', $name) ?></td> 50 </tr> 51 <?php endforeach; ?> 52 </tbody> 53 </table> 54 55 <h3><?php _e('Themes', self::$id) ?></h3> 56 57 <table class="wp-list-table widefat striped plugins"> 58 <thead> 59 <tr> 60 <td scope="col" class="manage-column check-column"> </td> 61 <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e('Name', self::$id) ?></th> 62 <th scope="col" class="manage-column column-description"><?php _e('Vulnerabilities', self::$id) ?></th> 63 </tr> 64 </thead> 65 <tbody id="report-themes"> 66 <?php foreach(wp_get_themes() as $name => $details) : ?> 67 <tr> 68 <th scope="row" class="check-column" align="center"><?php echo self::get_status('themes', $name) ?></span></th> 69 <td class="plugin-title column-primary"><strong><?php echo $details['Name'] ?></strong> <?php echo sprintf(__('Version %s', self::$id), $details['Version']) ?></td> 70 <td><?php self::list_vulnerabilities('themes', $name) ?></td> 71 </tr> 72 <?php endforeach; ?> 73 </tbody> 74 </table> 75 76 <form action='options.php' method='post'> 77 <?php 78 settings_fields(self::$id . '_notification'); 79 do_settings_sections(self::$id . '_notification'); 7 <form method='post'> 8 <input type="hidden" name="verify" value="1"> 9 <p class="alignright"><?php submit_button( __( 'Check Now', self::$id ), 'primary', 'submit', false ) ?></p> 10 <p><?php printf( __( 'Last request to %s on %s', self::$id ), '<a href="https://wpvulndb.com/" target="_blank">WPScan Vulnerability Database</a>', date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $report['cache'] ) ) ?> 11 <br> 12 <?php _e( 'Some paid plugins and themes, or developed exclusively for this website and not shared for the public, may not be reported on WPScan.', self::$id ) ?> 13 </p> 14 </form> 15 16 <h3>WordPress</h3> 17 18 <table class="wp-list-table widefat striped plugins"> 19 <thead> 20 <tr> 21 <td scope="col" class="manage-column check-column"> </td> 22 <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th> 23 <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th> 24 </tr> 25 </thead> 26 <tbody id="report-wordpress"> 27 <tr> 28 <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'wordpress' ) ?></span></th> 29 <td class="plugin-title column-primary"> 30 <strong>WordPress</strong> <?php echo sprintf( __( 'Version %s', self::$id ), get_bloginfo( 'version' ) ) ?> 31 </td> 32 <td><?php self::list_vulnerabilities( 'wordpress' ) ?></td> 33 </tr> 34 </tbody> 35 </table> 36 37 <h3><?php _e( 'Plugins', self::$id ) ?></h3> 38 39 <table class="wp-list-table widefat striped plugins"> 40 <thead> 41 <tr> 42 <td scope="col" class="manage-column check-column"> </td> 43 <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th> 44 <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th> 45 </tr> 46 </thead> 47 <tbody id="report-plugins"> 48 <?php foreach ( get_plugins() as $name => $details ) : ?> 49 <tr> 50 <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'plugins', $name ) ?></span></th> 51 <td class="plugin-title column-primary"> 52 <strong><?php echo $details['Name'] ?></strong> <?php echo sprintf( __( 'Version %s', self::$id ), $details['Version'] ) ?> 53 </td> 54 <td><?php self::list_vulnerabilities( 'plugins', $name ) ?></td> 55 </tr> 56 <?php endforeach; ?> 57 </tbody> 58 </table> 59 60 <h3><?php _e( 'Themes', self::$id ) ?></h3> 61 62 <table class="wp-list-table widefat striped plugins"> 63 <thead> 64 <tr> 65 <td scope="col" class="manage-column check-column"> </td> 66 <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th> 67 <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th> 68 </tr> 69 </thead> 70 <tbody id="report-themes"> 71 <?php foreach ( wp_get_themes() as $name => $details ) : ?> 72 <tr> 73 <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'themes', $name ) ?></span></th> 74 <td class="plugin-title column-primary"> 75 <strong><?php echo $details['Name'] ?></strong> <?php echo sprintf( __( 'Version %s', self::$id ), $details['Version'] ) ?> 76 </td> 77 <td><?php self::list_vulnerabilities( 'themes', $name ) ?></td> 78 </tr> 79 <?php endforeach; ?> 80 </tbody> 81 </table> 82 83 <form action='options.php' method='post'> 84 <?php 85 settings_fields( self::$id . '_notification' ); 86 do_settings_sections( self::$id . '_notification' ); 80 87 submit_button(); 81 ?>82 </form>88 ?> 89 </form> 83 90 84 91 </div> -
vulnerability-alerts/trunk/uninstall.php
r1498915 r1939555 2 2 3 3 // If uninstall is not called from WordPress, exit 4 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {5 exit();4 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { 5 exit(); 6 6 } 7 7 8 8 $option_name = 'vulnerability-alerts'; 9 9 10 if (is_multisite()) {10 if ( is_multisite() ) { 11 11 global $wpdb; 12 13 $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A);14 if ($blogs) {15 foreach ($blogs as $blog) {16 switch_to_blog( $blog['blog_id']);17 delete_option( $option_name);18 delete_option( $option_name . '_notification');12 13 $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A ); 14 if ( $blogs ) { 15 foreach ( $blogs as $blog ) { 16 switch_to_blog( $blog['blog_id'] ); 17 delete_option( $option_name ); 18 delete_option( $option_name . '_notification' ); 19 19 } 20 20 restore_current_blog(); 21 21 } 22 22 } else { 23 delete_option( $option_name);24 delete_option( $option_name . '_notification');23 delete_option( $option_name ); 24 delete_option( $option_name . '_notification' ); 25 25 } 26 27 ?> -
vulnerability-alerts/trunk/vulnerability-alerts.php
r1845067 r1939555 1 1 <?php 2 2 3 3 /** 4 4 * Plugin Name: Vulnerability Alerts 5 5 * Description: Scans your system to find vulnerabilities listed in WPScan Vulnerability Database. 6 6 * Plugin URI: http://wordpress.org/plugins/vulnerability-alerts/ 7 * Version: 1.3. 57 * Version: 1.3.6 8 8 * Author: Edir Pedro 9 9 * Author URI: http://edirpedro.com.br … … 14 14 15 15 // File Security Check 16 defined( 'ABSPATH') or die("No script kiddies please!");17 18 19 class Vulnerabilty Alerts {20 16 defined( 'ABSPATH' ) or die( "No script kiddies please!" ); 17 18 19 class Vulnerabilty_Alerts { 20 21 21 // Plugin name 22 22 static public $id = 'vulnerability-alerts'; 23 23 24 24 // Report shortcut 25 25 static public $report = array(); 26 26 27 27 // Arguments to WP Remote Get 28 28 static public $remote = array( 29 29 'user-agent' => 'WordPress Plugin Vulnerability Alerts' 30 );31 30 ); 31 32 32 /* 33 33 * Initialize actions … … 36 36 37 37 // Languages 38 load_plugin_textdomain( self::$id, false, dirname(plugin_basename(__FILE__)) . '/languages');39 38 load_plugin_textdomain( self::$id, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 39 40 40 // Arguments to wp remote get 41 self::$remote['user-agent'] .= '; ' . get_bloginfo('url');42 41 self::$remote['user-agent'] .= '; ' . get_bloginfo( 'url' ); 42 43 43 // Report 44 self::$report = get_option( self::$id);45 44 self::$report = get_option( self::$id ); 45 46 46 // Hooks 47 add_action( 'admin_menu', array(__CLASS__, 'menu'));48 add_action( 'admin_bar_menu', array(__CLASS__, 'admin_bar'), 65); // Between Updates, Comments and New Content menu49 add_action( 'admin_init', array('VulnerabiltyAlerts_Notification', 'init'));50 add_action( self::$id . '_schedule', array(__CLASS__, 'schedule'), 999);51 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'add_action_links'));52 53 } 54 47 add_action( 'admin_menu', array( __CLASS__, 'menu' ) ); 48 add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar' ), 65 ); // Between Updates, Comments and New Content menu 49 add_action( 'admin_init', array( 'Vulnerabilty_Alerts_Notification', 'init' ) ); 50 add_action( self::$id . '_schedule', array( __CLASS__, 'schedule' ), 999 ); 51 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( __CLASS__, 'add_action_links' ) ); 52 53 } 54 55 55 56 56 /* … … 60 60 61 61 // Languages 62 load_plugin_textdomain( self::$id, false, dirname(plugin_basename(__FILE__)) . '/languages');63 64 } 65 62 load_plugin_textdomain( self::$id, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 63 64 } 65 66 66 /* 67 67 * Activate actions 68 68 */ 69 69 static public function activate() { 70 71 wp_clear_scheduled_hook( self::$id . '_schedule'); // Prevent duplication72 wp_schedule_event( time(), 'daily', self::$id . '_schedule');73 70 71 wp_clear_scheduled_hook( self::$id . '_schedule' ); // Prevent duplication 72 wp_schedule_event( time(), 'daily', self::$id . '_schedule' ); 73 74 74 self::verify(); 75 76 } 77 75 76 } 77 78 78 /* 79 79 * Deactivate actions 80 80 */ 81 81 static public function deactivate() { 82 83 wp_clear_scheduled_hook( self::$id . '_schedule');84 85 } 86 82 83 wp_clear_scheduled_hook( self::$id . '_schedule' ); 84 85 } 86 87 87 /* 88 88 * Schedule and event to run verify() function 89 89 */ 90 90 static public function schedule() { 91 91 92 92 self::verify(); 93 93 94 94 // Notify by mail when solicited 95 Vulnerabilty Alerts_Notification::notify();96 97 } 98 95 Vulnerabilty_Alerts_Notification::notify(); 96 97 } 98 99 99 /* 100 100 * Create a shortcut on Admin Bar to show the total of vulnerabilities found 101 101 */ 102 static public function admin_bar( $wp_admin_bar) {103 104 if (!current_user_can('manage_options'))102 static public function admin_bar( $wp_admin_bar ) { 103 104 if ( ! current_user_can( 'manage_options' ) ) { 105 105 return; 106 106 } 107 107 108 $report = self::$report; 108 109 $total = self::get_total(); 109 110 if (!empty($report) and $total > 0) {110 111 if ( ! empty( $report ) and $total > 0 ) { 111 112 $args = array( 112 113 'id' => self::$id, 113 'title' => '<span class="ab-icon dashicons-shield"></span><span class="ab-label">' . $total . '</span>',114 'href' => admin_url( 'tools.php?page=' . self::$id),114 'title' => '<span class="ab-icon dashicons-shield"></span><span class="ab-label">' . $total . '</span>', 115 'href' => admin_url( 'tools.php?page=' . self::$id ), 115 116 'meta' => array( 116 'title' => sprintf( _n('%d vulnerability found', '%d vulnerabilities found', $total, self::$id), $total)117 'title' => sprintf( _n( '%d vulnerability found', '%d vulnerabilities found', $total, self::$id ), $total ) 117 118 ) 118 119 ); 119 $wp_admin_bar->add_node( $args);120 } 121 122 } 123 120 $wp_admin_bar->add_node( $args ); 121 } 122 123 } 124 124 125 /* 125 126 * Return the total of vulnerabilities found … … 127 128 static public function get_total() { 128 129 $report = self::$report; 129 $options = get_option( self::$id . '_notification');130 $ignored = empty( $options['ignored']) ? array() : $options['ignored'];131 130 $options = get_option( self::$id . '_notification' ); 131 $ignored = empty( $options['ignored'] ) ? array() : $options['ignored']; 132 132 133 $total = 0; 133 134 $total += $report['wordpress']['total']; 134 135 $total += $report['plugins']['total']; 135 136 $total += $report['themes']['total']; 136 137 137 138 // WordPress ignored 138 if ($report['wordpress']['total'] > 0) {139 foreach ($report['wordpress']['vulnerabilities'] as $item) {140 if (in_array($item->id, $ignored))139 if ( $report['wordpress']['total'] > 0 ) { 140 foreach ( $report['wordpress']['vulnerabilities'] as $item ) { 141 if ( in_array( $item->id, $ignored ) ) { 141 142 $total -= 1; 142 } 143 } 144 143 } 144 } 145 } 146 145 147 // Plugins ignored 146 if ($report['plugins']['total'] > 0) {147 foreach ($report['plugins'] as $plugin) {148 if (empty($plugin['vulnerabilities']))148 if ( $report['plugins']['total'] > 0 ) { 149 foreach ( $report['plugins'] as $plugin ) { 150 if ( empty( $plugin['vulnerabilities'] ) ) { 149 151 continue; 150 foreach($plugin['vulnerabilities'] as $item) { 151 if(in_array($item->id, $ignored)) 152 } 153 foreach ( $plugin['vulnerabilities'] as $item ) { 154 if ( in_array( $item->id, $ignored ) ) { 152 155 $total -= 1; 153 } 154 } 155 } 156 156 } 157 } 158 } 159 } 160 157 161 // Themes ignored 158 if ($report['themes']['total'] > 0) {159 foreach ($report['themes'] as $theme) {160 if (empty($theme['vulnerabilities']))162 if ( $report['themes']['total'] > 0 ) { 163 foreach ( $report['themes'] as $theme ) { 164 if ( empty( $theme['vulnerabilities'] ) ) { 161 165 continue; 162 foreach($theme['vulnerabilities'] as $item) { 163 if(in_array($item->id, $ignored)) 166 } 167 foreach ( $theme['vulnerabilities'] as $item ) { 168 if ( in_array( $item->id, $ignored ) ) { 164 169 $total -= 1; 165 } 166 } 167 } 168 170 } 171 } 172 } 173 } 174 169 175 return $total; 170 176 } 171 177 172 178 /* 173 179 * Create a menu on Tools section 174 180 */ 175 181 static public function menu() { 176 177 add_management_page(__('Vulnerability Alerts', self::$id), __('Vulnerability Alerts', self::$id), 'manage_options', self::$id, array(__CLASS__, 'report')); 178 179 } 180 182 183 add_management_page( 184 __( 'Vulnerability Alerts', self::$id ), 185 __( 'Vulnerability Alerts', self::$id ), 186 'manage_options', 187 self::$id, 188 array( __CLASS__, 'report' ) 189 ); 190 191 } 192 181 193 /* 182 194 * Include a shortcut on Plugins Page … … 185 197 * @return array 186 198 */ 187 static public function add_action_links($links) { 188 189 $links[] = '<a href="' . admin_url('tools.php?page=' . self::$id) . '">' . __('View') . '</a>'; 199 static public function add_action_links( $links ) { 200 201 $links[] = '<a href="' . admin_url( 'tools.php?page=' . self::$id ) . '">' . __( 'View' ) . '</a>'; 202 190 203 return $links; 191 204 192 205 } 193 206 … … 196 209 */ 197 210 static public function verify() { 198 211 199 212 // Suppports during WP Cron 200 if (!function_exists('get_plugins'))213 if ( ! function_exists( 'get_plugins' ) ) { 201 214 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 202 215 } 216 203 217 $report = array(); 204 218 205 219 // WordPress 206 220 $report['wordpress'] = array(); 207 221 $report['wordpress']['total'] = 0; 208 $version = get_bloginfo( 'version');209 $response = wp_remote_get( 'https://wpvulndb.com/api/v2/wordpresses/' . str_replace('.', '', $version), self::$remote);210 if (is_array($response)) {211 $result = (array) json_decode( $response['body']);212 if (!empty($result)) {213 $report['wordpress']['vulnerabilities'] = self::get_vulnerabilities( $result, $version);214 $report['wordpress']['total'] = count( $report['wordpress']['vulnerabilities']);222 $version = get_bloginfo( 'version' ); 223 $response = wp_remote_get( 'https://wpvulndb.com/api/v2/wordpresses/' . str_replace( '.', '', $version ), self::$remote ); 224 if ( is_array( $response ) ) { 225 $result = (array) json_decode( $response['body'] ); 226 if ( ! empty( $result ) ) { 227 $report['wordpress']['vulnerabilities'] = self::get_vulnerabilities( $result, $version ); 228 $report['wordpress']['total'] = count( $report['wordpress']['vulnerabilities'] ); 215 229 } 216 230 } … … 219 233 $report['plugins'] = array(); 220 234 $report['plugins']['total'] = 0; 221 foreach (get_plugins() as $name => $details) {222 $parts = pathinfo( $name);223 $response = wp_remote_get( 'https://wpvulndb.com/api/v2/plugins/' . $parts['dirname'], self::$remote);224 if (is_array($response)) {225 $result = (array) json_decode( $response['body']);226 if (!empty($result)) {227 $report['plugins'][ $name]['vulnerabilities'] = self::get_vulnerabilities($result, $details['Version']);228 $report['plugins']['total'] += count( $report['plugins'][$name]['vulnerabilities']);229 } 230 } 231 } 232 235 foreach ( get_plugins() as $name => $details ) { 236 $parts = pathinfo( $name ); 237 $response = wp_remote_get( 'https://wpvulndb.com/api/v2/plugins/' . $parts['dirname'], self::$remote ); 238 if ( is_array( $response ) ) { 239 $result = (array) json_decode( $response['body'] ); 240 if ( ! empty( $result ) ) { 241 $report['plugins'][ $name ]['vulnerabilities'] = self::get_vulnerabilities( $result, $details['Version'] ); 242 $report['plugins']['total'] += count( $report['plugins'][ $name ]['vulnerabilities'] ); 243 } 244 } 245 } 246 233 247 // Themes 234 248 $report['themes'] = array(); 235 249 $report['themes']['total'] = 0; 236 foreach (wp_get_themes() as $name => $details) {237 $response = wp_remote_get( 'https://wpvulndb.com/api/v2/themes/' . $name, self::$remote);238 if (is_array($response)) {239 $result = (array) json_decode( $response['body']);240 if (!empty($result)) {241 $report['themes'][ $name]['vulnerabilities'] = self::get_vulnerabilities($result, $details['Version']);242 $report['themes']['total'] += count( $report['themes'][$name]['vulnerabilities']);243 } 244 } 245 } 246 250 foreach ( wp_get_themes() as $name => $details ) { 251 $response = wp_remote_get( 'https://wpvulndb.com/api/v2/themes/' . $name, self::$remote ); 252 if ( is_array( $response ) ) { 253 $result = (array) json_decode( $response['body'] ); 254 if ( ! empty( $result ) ) { 255 $report['themes'][ $name ]['vulnerabilities'] = self::get_vulnerabilities( $result, $details['Version'] ); 256 $report['themes']['total'] += count( $report['themes'][ $name ]['vulnerabilities'] ); 257 } 258 } 259 } 260 247 261 // Caching 248 $report['cache'] = strtotime( current_time('mysql'));249 update_option( self::$id, $report, true);262 $report['cache'] = strtotime( current_time( 'mysql' ) ); 263 update_option( self::$id, $report, true ); 250 264 self::$report = $report; 251 252 } 253 265 266 } 267 254 268 /* 255 269 * Report Page 256 270 */ 257 271 static public function report() { 258 272 259 273 // Button Check Now 260 if (isset($_POST['verify'])) {261 add_settings_error( self::$id, 'update', __('Report updated.', self::$id), 'updated');274 if ( isset( $_POST['verify'] ) ) { 275 add_settings_error( self::$id, 'update', __( 'Report updated.', self::$id ), 'updated' ); 262 276 self::verify(); 263 277 } 264 278 265 279 $report = self::$report; 266 280 include 'report.php'; 267 268 } 269 281 282 } 283 270 284 /* 271 285 * Filter vulnerability list from WPScan … … 275 289 * @return string 276 290 */ 277 static public function get_vulnerabilities( $data, $version) {278 291 static public function get_vulnerabilities( $data, $version ) { 292 279 293 $list = array(); 280 $key = key( $data);281 282 if (empty($data[$key]->vulnerabilities))294 $key = key( $data ); 295 296 if ( empty( $data[ $key ]->vulnerabilities ) ) { 283 297 return $list; 284 285 foreach($data[$key]->vulnerabilities as $item) { 286 if($item->fixed_in) { 287 if(version_compare($version, $item->fixed_in, '<')) 288 $list[] = $item; 298 } 299 300 foreach ( $data[ $key ]->vulnerabilities as $item ) { 301 if ( $item->fixed_in ) { 302 if ( version_compare( $version, $item->fixed_in, '<' ) ) { 303 $list[] = $item; 304 } 289 305 } else { 290 $list[] = $item;291 }292 } 293 306 $list[] = $item; 307 } 308 } 309 294 310 return $list; 295 296 } 297 311 312 } 313 298 314 /* 299 315 * List vulnerabilities on screen … … 303 319 * @return string 304 320 */ 305 static public function list_vulnerabilities($type, $name = null) { 306 307 $report = self::$report[$type]; 308 if(array_key_exists($name, $report)) 309 $report = $report[$name]; 310 311 if(!isset($report['vulnerabilities'])) { 312 _e('Report not available', self::$id); 321 static public function list_vulnerabilities( $type, $name = null ) { 322 323 $report = self::$report[ $type ]; 324 if ( array_key_exists( $name, $report ) ) { 325 $report = $report[ $name ]; 326 } 327 328 if ( ! isset( $report['vulnerabilities'] ) ) { 329 _e( 'Report not available', self::$id ); 330 313 331 return; 314 332 } 315 333 316 334 $list = array(); 317 318 foreach ($report['vulnerabilities'] as $item) {319 $html = '<a href="' . esc_url('https://wpvulndb.com/vulnerabilities/' . $item->id) . '" target="_blank">';320 $html .= self::get_vulnerability_title( $item);335 336 foreach ( $report['vulnerabilities'] as $item ) { 337 $html = '<a href="' . esc_url( 'https://wpvulndb.com/vulnerabilities/' . $item->id ) . '" target="_blank">'; 338 $html .= self::get_vulnerability_title( $item ); 321 339 $html .= '</a>'; 322 340 $list[] = $html; 323 341 } 324 325 echo empty( $list) ? '- -' : join('<br>', $list);326 327 } 328 342 343 echo empty( $list ) ? '- -' : join( '<br>', $list ); 344 345 } 346 329 347 /* 330 348 * Get vulnerability title … … 333 351 * @return string 334 352 */ 335 static public function get_vulnerability_title($vulnerability) { 336 $title = esc_html($vulnerability->title) . ' - '; 337 $title .= empty($vulnerability->fixed_in) ? __('Not fixed', self::$id) : sprintf(__('Fixed in version %s', self::$id), $vulnerability->fixed_in); 353 static public function get_vulnerability_title( $vulnerability ) { 354 $title = esc_html( $vulnerability->title ) . ' - '; 355 $title .= empty( $vulnerability->fixed_in ) ? __( 'Not fixed', self::$id ) : sprintf( __( 'Fixed in version %s', self::$id ), $vulnerability->fixed_in ); 356 338 357 return $title; 339 358 } 340 359 341 360 /* 342 361 * Show status icons: checked, attention and error … … 346 365 * @return string 347 366 */ 348 static public function get_status($type, $name = null) { 349 350 $report = self::$report[$type]; 351 if(array_key_exists($name, $report)) 352 $report = $report[$name]; 353 354 if(!isset($report['vulnerabilities'])) 367 static public function get_status( $type, $name = null ) { 368 369 $report = self::$report[ $type ]; 370 if ( array_key_exists( $name, $report ) ) { 371 $report = $report[ $name ]; 372 } 373 374 if ( ! isset( $report['vulnerabilities'] ) ) { 355 375 return ' <span class="dashicons dashicons-no-alt" style="color:gray"></span>'; 356 357 if(empty($report['vulnerabilities'])) 376 } 377 378 if ( empty( $report['vulnerabilities'] ) ) { 358 379 return ' <span class="dashicons dashicons-yes" style="color:green"></span>'; 359 else380 } else { 360 381 return ' <span class="dashicons dashicons-warning" style="color:Crimson"></span>'; 361 362 } 363 382 } 383 384 } 385 364 386 } 365 387 … … 367 389 * Notification System 368 390 */ 369 class VulnerabiltyAlerts_Notification extends VulnerabiltyAlerts { 370 391 392 class Vulnerabilty_Alerts_Notification extends Vulnerabilty_Alerts { 393 371 394 /* 372 395 * Notification Options 373 396 */ 374 397 static public function init() { 375 398 376 399 $report = self::$report; 377 400 378 401 $total = 0; 379 402 $total += $report['wordpress']['total']; 380 403 $total += $report['plugins']['total']; 381 404 $total += $report['themes']['total']; 382 383 register_setting( self::$id . '_notification', self::$id . '_notification', array(__CLASS__, 'validate'));384 405 406 register_setting( self::$id . '_notification', self::$id . '_notification', array( __CLASS__, 'validate' ) ); 407 385 408 add_settings_section( 386 self::$id . '_notification_section',387 __('Notification', self::$id),388 array(__CLASS__, 'introduction'),389 self::$id . '_notification');409 self::$id . '_notification_section', 410 __( 'Notification', self::$id ), 411 array( __CLASS__, 'introduction' ), 412 self::$id . '_notification' ); 390 413 391 414 add_settings_field( 392 'email',393 __('E-mail Address', self::$id),394 array(__CLASS__, 'field_email'),395 self::$id . '_notification',396 self::$id . '_notification_section');397 415 'email', 416 __( 'E-mail Address', self::$id ), 417 array( __CLASS__, 'field_email' ), 418 self::$id . '_notification', 419 self::$id . '_notification_section' ); 420 398 421 add_settings_field( 399 'interval',400 __('Send E-mail Alerts', self::$id),401 array(__CLASS__, 'field_interval'),402 self::$id . '_notification',403 self::$id . '_notification_section');404 405 if ($total > 0) {422 'interval', 423 __( 'Send E-mail Alerts', self::$id ), 424 array( __CLASS__, 'field_interval' ), 425 self::$id . '_notification', 426 self::$id . '_notification_section' ); 427 428 if ( $total > 0 ) { 406 429 add_settings_field( 407 'ignored',408 __('Vulnerabilities to Ignore', self::$id),409 array(__CLASS__, 'field_ignored'),410 self::$id . '_notification',411 self::$id . '_notification_section');412 } 413 414 } 415 430 'ignored', 431 __( 'Vulnerabilities to Ignore', self::$id ), 432 array( __CLASS__, 'field_ignored' ), 433 self::$id . '_notification', 434 self::$id . '_notification_section' ); 435 } 436 437 } 438 416 439 /* 417 440 * Introduction … … 419 442 static public function introduction() { 420 443 421 echo '<p>' . __( 'Fill the options below if you want to be notified by mail about new vulnerabilities.', self::$id) . '</p>';422 423 } 424 444 echo '<p>' . __( 'Fill the options below if you want to be notified by mail about new vulnerabilities.', self::$id ) . '</p>'; 445 446 } 447 425 448 /* 426 449 * Field E-mail … … 428 451 static public function field_email() { 429 452 430 $options = get_option(self::$id . '_notification'); 431 echo '<input type="text" name="' . self::$id . '_notification[email]" value="' . $options['email'] . '" class="regular-text">'; 432 433 } 434 453 $options = get_option( self::$id . '_notification' ); 454 echo '<input type="text" name="' . self::$id . '_notification[email]" value="' . $options['email'] . '" class="regular-text" placeholder="[email protected], [email protected]">'; 455 echo '<p class="description">' . __( 'Add multiple e-mail addresses separating them by comma.', self::$id ) . '</p>'; 456 457 } 458 435 459 /* 436 460 * Field Interval … … 438 462 static public function field_interval() { 439 463 440 $options = get_option( self::$id . '_notification');441 $interval = empty( $options['interval']) ? 'd' : $options['interval'];464 $options = get_option( self::$id . '_notification' ); 465 $interval = empty( $options['interval'] ) ? 'd' : $options['interval']; 442 466 echo '<select name="' . self::$id . '_notification[interval]">'; 443 echo '<option value="d" ' . selected( 'd', $interval, false) . '>' . __('Daily', self::$id) . '</option>';444 echo '<option value="1" ' . selected( 1, $interval, false) . '>' . __('Every Monday', self::$id) . '</option>';445 echo '<option value="2" ' . selected( 2, $interval, false) . '>' . __('Every Tuesday', self::$id) . '</option>';446 echo '<option value="3" ' . selected( 3, $interval, false) . '>' . __('Every Wednesday', self::$id) . '</option>';447 echo '<option value="4" ' . selected( 4, $interval, false) . '>' . __('Every Thursday', self::$id) . '</option>';448 echo '<option value="5" ' . selected( 5, $interval, false) . '>' . __('Every Friday', self::$id) . '</option>';449 echo '<option value="6" ' . selected( 6, $interval, false) . '>' . __('Every Saturday', self::$id) . '</option>';450 echo '<option value="7" ' . selected( 7, $interval, false) . '>' . __('Every Sunday', self::$id) . '</option>';451 echo '<option value="m" ' . selected( 'm', $interval, false) . '>' . __('Every Month', self::$id) . '</option>';467 echo '<option value="d" ' . selected( 'd', $interval, false ) . '>' . __( 'Daily', self::$id ) . '</option>'; 468 echo '<option value="1" ' . selected( 1, $interval, false ) . '>' . __( 'Every Monday', self::$id ) . '</option>'; 469 echo '<option value="2" ' . selected( 2, $interval, false ) . '>' . __( 'Every Tuesday', self::$id ) . '</option>'; 470 echo '<option value="3" ' . selected( 3, $interval, false ) . '>' . __( 'Every Wednesday', self::$id ) . '</option>'; 471 echo '<option value="4" ' . selected( 4, $interval, false ) . '>' . __( 'Every Thursday', self::$id ) . '</option>'; 472 echo '<option value="5" ' . selected( 5, $interval, false ) . '>' . __( 'Every Friday', self::$id ) . '</option>'; 473 echo '<option value="6" ' . selected( 6, $interval, false ) . '>' . __( 'Every Saturday', self::$id ) . '</option>'; 474 echo '<option value="7" ' . selected( 7, $interval, false ) . '>' . __( 'Every Sunday', self::$id ) . '</option>'; 475 echo '<option value="m" ' . selected( 'm', $interval, false ) . '>' . __( 'Every Month', self::$id ) . '</option>'; 452 476 echo '</selected>'; 453 477 454 478 } 455 479 456 480 /* 457 481 * Field Ignore … … 459 483 static public function field_ignored() { 460 484 461 $options = get_option(self::$id . '_notification'); 462 $ignored = empty($options['ignored']) ? array() : $options['ignored']; 463 464 self::list_vulnerabilities_to_ignore('wordpress'); 465 466 foreach(get_plugins() as $name => $details) 467 self::list_vulnerabilities_to_ignore('plugins', $name); 468 469 foreach(wp_get_themes() as $name => $details) 470 self::list_vulnerabilities_to_ignore('themes', $name); 471 472 } 473 485 $options = get_option( self::$id . '_notification' ); 486 $ignored = empty( $options['ignored'] ) ? array() : $options['ignored']; 487 488 self::list_vulnerabilities_to_ignore( 'wordpress' ); 489 490 foreach ( get_plugins() as $name => $details ) { 491 self::list_vulnerabilities_to_ignore( 'plugins', $name ); 492 } 493 494 foreach ( wp_get_themes() as $name => $details ) { 495 self::list_vulnerabilities_to_ignore( 'themes', $name ); 496 } 497 498 } 499 474 500 /* 475 501 * List of vulnerabilities … … 479 505 * @return string 480 506 */ 481 static public function list_vulnerabilities_to_ignore($type, $name = null) { 482 483 $report = self::$report[$type]; 484 if(array_key_exists($name, $report)) 485 $report = $report[$name]; 486 487 if(!isset($report['vulnerabilities'])) { 507 static public function list_vulnerabilities_to_ignore( $type, $name = null ) { 508 509 $report = self::$report[ $type ]; 510 if ( array_key_exists( $name, $report ) ) { 511 $report = $report[ $name ]; 512 } 513 514 if ( ! isset( $report['vulnerabilities'] ) ) { 488 515 return null; 489 516 } 517 518 $options = get_option( self::$id . '_notification' ); 519 $ignored = empty( $options['ignored'] ) ? array() : $options['ignored']; 520 521 foreach ( $report['vulnerabilities'] as $item ) { 522 echo '<label><input type="checkbox" name="' . self::$id . '_notification[ignored][]" value="' . $item->id . '" ' . ( in_array( $item->id, $ignored ) ? 'checked="checked"' : null ) . '> '; 523 echo self::get_vulnerability_title( $item ); 524 echo '</label><br>'; 525 } 526 527 } 528 529 /* 530 * Validating fields 531 */ 532 static public function validate( $input ) { 533 534 // Email 535 if ( ! empty( $input['email'] ) ) { 536 537 $emails = explode( ',', $input['email'] ); 490 538 491 $options = get_option(self::$id . '_notification'); 492 $ignored = empty($options['ignored']) ? array() : $options['ignored']; 493 494 foreach($report['vulnerabilities'] as $item) { 495 echo '<label><input type="checkbox" name="' . self::$id . '_notification[ignored][]" value="' . $item->id . '" ' . (in_array($item->id, $ignored) ? 'checked="checked"' : null) . '> '; 496 echo self::get_vulnerability_title($item); 497 echo '</label><br>'; 498 } 499 500 } 539 foreach ( $emails as $email ) { 540 if ( ! is_email( trim( $email ) ) ) { 541 add_settings_error( self::$id . '_notification', 'invalid-email', __( 'You have entered an invalid e-mail address.', self::$id ) ); 542 } 543 } 501 544 502 /* 503 * Validating fields 504 */ 505 static public function validate($input) { 506 507 // Email 508 if(!empty($input['email']) && !is_email($input['email'])) 509 add_settings_error(self::$id . '_notification', 'invalid-email', __('You have entered an invalid e-mail address.', self::$id)); 545 } 510 546 511 547 return $input; 512 513 } 514 548 549 } 550 515 551 /* 516 552 * Sending notification 517 553 */ 518 554 static public function notify() { 519 555 520 556 // Suppports during WP Cron 521 if (!function_exists('get_plugins'))557 if ( ! function_exists( 'get_plugins' ) ) { 522 558 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 559 } 523 560 524 561 $report = self::$report; 525 562 $total = self::get_total(); 526 527 if ($total == 0)563 564 if ( $total == 0 ) { 528 565 return; 529 530 $options = get_option(self::$id . '_notification'); 531 $email = empty($options['email']) ? null : $options['email']; 532 $interval = empty($options['interval']) ? 'd' : $options['interval']; 533 $ignored = empty($options['ignored']) ? array() : $options['ignored']; 534 566 } 567 568 $options = get_option( self::$id . '_notification' ); 569 $email = empty( $options['email'] ) ? null : $options['email']; 570 $interval = empty( $options['interval'] ) ? 'd' : $options['interval']; 571 $ignored = empty( $options['ignored'] ) ? array() : $options['ignored']; 572 535 573 // Check email 536 if (empty($email))574 if ( empty( $email ) ) { 537 575 return; 576 } 538 577 539 578 // Check weekly interval 540 if (is_numeric($interval) && date('N') != $interval)579 if ( is_numeric( $interval ) && date( 'N' ) != $interval ) { 541 580 return; 542 581 } 582 543 583 // Check monthly interval 544 if ($interval == 'm' && date('j') != 1)584 if ( $interval == 'm' && date( 'j' ) != 1 ) { 545 585 return; 546 586 } 587 547 588 // Send email 548 589 $has_vulnerabilities = false; 549 $msg = '<doctype html><html><head><meta charset="utf-8"></head><body>';550 $msg .= '<p>' . __( 'Hello Friend,', self::$id) . '</p>';551 $msg .= '<p>' . sprintf( __('Some vulnerabilities were found in %s, visit the site for more details.', self::$id), '<a href="' . get_bloginfo('url') . '">' . get_bloginfo('name') . '</a>') . '</p>';552 590 $msg = '<doctype html><html><head><meta charset="utf-8"></head><body>'; 591 $msg .= '<p>' . __( 'Hello Friend,', self::$id ) . '</p>'; 592 $msg .= '<p>' . sprintf( __( 'Some vulnerabilities were found in %s, visit the site for more details.', self::$id ), '<a href="' . get_bloginfo( 'url' ) . '">' . get_bloginfo( 'name' ) . '</a>' ) . '</p>'; 593 553 594 // WordPress 554 if ($report['wordpress']['total'] > 0) {555 $list = self::email_vulnerabilities( 'wordpress');556 if (!empty($list)) {595 if ( $report['wordpress']['total'] > 0 ) { 596 $list = self::email_vulnerabilities( 'wordpress' ); 597 if ( ! empty( $list ) ) { 557 598 $has_vulnerabilities = true; 558 599 $msg .= '<p><b>WordPress</b><br>'; 559 $msg .= join( '<br>', $list) . '</p>';560 } 561 } 562 600 $msg .= join( '<br>', $list ) . '</p>'; 601 } 602 } 603 563 604 // Plugins 564 if ($report['plugins']['total'] > 0) {565 foreach (get_plugins() as $name => $details) {566 $list = self::email_vulnerabilities( 'plugins', $name);567 if (!empty($list)) {605 if ( $report['plugins']['total'] > 0 ) { 606 foreach ( get_plugins() as $name => $details ) { 607 $list = self::email_vulnerabilities( 'plugins', $name ); 608 if ( ! empty( $list ) ) { 568 609 $has_vulnerabilities = true; 569 $msg .= '<p><b>' . __( 'Plugins', self::$id) . ' ' . $details['Name']. '</b><br>';570 $msg .= join( '<br>', $list) . '</p>';571 } 572 } 573 } 574 610 $msg .= '<p><b>' . __( 'Plugins', self::$id ) . ' ' . $details['Name'] . '</b><br>'; 611 $msg .= join( '<br>', $list ) . '</p>'; 612 } 613 } 614 } 615 575 616 // Themes 576 if ($report['themes']['total'] > 0) {577 foreach (wp_get_themes() as $name => $details) {578 $list = self::email_vulnerabilities( 'themes', $name);579 if (!empty($list)) {617 if ( $report['themes']['total'] > 0 ) { 618 foreach ( wp_get_themes() as $name => $details ) { 619 $list = self::email_vulnerabilities( 'themes', $name ); 620 if ( ! empty( $list ) ) { 580 621 $has_vulnerabilities = true; 581 $msg .= '<p><b>' . __( 'Themes', self::$id) . ' ' . $details['Name']. '</b><br>';582 $msg .= join( '<br>', $list) . '</p>';583 } 584 } 585 } 586 587 $msg .= '<p>' . __( 'Hope this help!', self::$id) . '</p>';622 $msg .= '<p><b>' . __( 'Themes', self::$id ) . ' ' . $details['Name'] . '</b><br>'; 623 $msg .= join( '<br>', $list ) . '</p>'; 624 } 625 } 626 } 627 628 $msg .= '<p>' . __( 'Hope this help!', self::$id ) . '</p>'; 588 629 $msg .= '</body></html>'; 589 590 if ($has_vulnerabilities) {591 $subject = sprintf( __('Some vulnerabilities were found in %s', self::$id), get_bloginfo('name'));592 $headers = array( 'Content-Type: text/html; charset=UTF-8');593 wp_mail( $options['email'], $subject, $msg, $headers);594 } 595 596 } 597 630 631 if ( $has_vulnerabilities ) { 632 $subject = sprintf( __( 'Some vulnerabilities were found in %s', self::$id ), get_bloginfo( 'name' ) ); 633 $headers = array( 'Content-Type: text/html; charset=UTF-8' ); 634 wp_mail( $options['email'], $subject, $msg, $headers ); 635 } 636 637 } 638 598 639 /* 599 640 * List of vulnerabilities to send by mail 600 641 */ 601 static public function email_vulnerabilities($type, $name = null) { 602 603 $report = self::$report[$type]; 604 if(array_key_exists($name, $report)) 605 $report = $report[$name]; 606 607 if(!isset($report['vulnerabilities'])) { 642 static public function email_vulnerabilities( $type, $name = null ) { 643 644 $report = self::$report[ $type ]; 645 if ( array_key_exists( $name, $report ) ) { 646 $report = $report[ $name ]; 647 } 648 649 if ( ! isset( $report['vulnerabilities'] ) ) { 608 650 return null; 609 651 } 610 611 $options = get_option( self::$id . '_notification');612 $ignored = empty( $options['ignored']) ? array() : $options['ignored'];652 653 $options = get_option( self::$id . '_notification' ); 654 $ignored = empty( $options['ignored'] ) ? array() : $options['ignored']; 613 655 614 656 $list = array(); 615 616 foreach ($report['vulnerabilities'] as $item) {617 if (!in_array($item->id, $ignored)) {618 $html = '<a href="' . esc_url('https://wpvulndb.com/vulnerabilities/' . $item->id) . '" target="_blank">';619 $html .= self::get_vulnerability_title( $item);657 658 foreach ( $report['vulnerabilities'] as $item ) { 659 if ( ! in_array( $item->id, $ignored ) ) { 660 $html = '<a href="' . esc_url( 'https://wpvulndb.com/vulnerabilities/' . $item->id ) . '" target="_blank">'; 661 $html .= self::get_vulnerability_title( $item ); 620 662 $html .= '</a>'; 621 663 $list[] = $html; 622 664 } 623 665 } 624 666 625 667 return $list; 626 627 } 628 668 669 } 670 629 671 } 630 672 631 673 632 674 // Activating 633 register_activation_hook( __FILE__, array('VulnerabiltyAlerts', 'activate'));675 register_activation_hook( __FILE__, array( 'Vulnerabilty_Alerts', 'activate' ) ); 634 676 635 677 // Deactivating 636 register_deactivation_hook( __FILE__, array('VulnerabiltyAlerts', 'deactivate'));678 register_deactivation_hook( __FILE__, array( 'Vulnerabilty_Alerts', 'deactivate' ) ); 637 679 638 680 // Initialize 639 add_action('init', array('VulnerabiltyAlerts', 'init')); 640 641 ?> 681 add_action( 'init', array( 'Vulnerabilty_Alerts', 'init' ) ); 682
Note: See TracChangeset
for help on using the changeset viewer.