Plugin Directory

Changeset 1946417


Ignore:
Timestamp:
09/24/2018 11:05:33 PM (7 years ago)
Author:
edir
Message:

UI improvements

Location:
vulnerability-alerts
Files:
21 added
9 edited

Legend:

Unmodified
Added
Removed
  • vulnerability-alerts/trunk/languages/vulnerability-alerts-en_US.po

    r1787624 r1946417  
    22msgstr ""
    33"Project-Id-Version: Vulnerability Alerts\n"
    4 "POT-Creation-Date: 2017-12-15 10:55-0300\n"
    5 "PO-Revision-Date: 2017-12-15 10:55-0300\n"
     4"POT-Creation-Date: 2018-09-24 19:57-0300\n"
     5"PO-Revision-Date: 2018-09-24 19:57-0300\n"
    66"Last-Translator: Edir Pedro <[email protected]>\n"
    77"Language-Team: \n"
    8 "Language: English\n"
     8"Language: en\n"
    99"MIME-Version: 1.0\n"
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.5.7\n"
     12"X-Generator: Poedit 2.1.1\n"
    1313"X-Poedit-KeywordsList: _;__;_e;_n:1,2\n"
    1414"X-Poedit-Basepath: .\n"
     
    1616"X-Poedit-SearchPath-0: ..\n"
    1717
    18 #: ../report.php:3 ../vulnerability-alerts.php:175
    19 msgid "Vulnerability Alerts"
     18#: ../class-notification.php:29
     19msgid "E-mail"
    2020msgstr ""
    2121
    22 #: ../report.php:9
     22#: ../class-notification.php:36
     23msgid "Send Alerts"
     24msgstr ""
     25
     26#: ../class-notification.php:44
     27msgid "Vulnerabilities to Ignore"
     28msgstr ""
     29
     30#: ../class-notification.php:59
     31msgid "Notification"
     32msgstr ""
     33
     34#: ../class-notification.php:86
     35msgid ""
     36"Fill the options below if you want to be notified by mail about new "
     37"vulnerabilities. Add multiple e-mail addresses separating them by comma."
     38msgstr ""
     39
     40#: ../class-notification.php:108
     41msgid "Daily"
     42msgstr ""
     43
     44#: ../class-notification.php:109
     45msgid "Every Monday"
     46msgstr ""
     47
     48#: ../class-notification.php:110
     49msgid "Every Tuesday"
     50msgstr ""
     51
     52#: ../class-notification.php:111
     53msgid "Every Wednesday"
     54msgstr ""
     55
     56#: ../class-notification.php:112
     57msgid "Every Thursday"
     58msgstr ""
     59
     60#: ../class-notification.php:113
     61msgid "Every Friday"
     62msgstr ""
     63
     64#: ../class-notification.php:114
     65msgid "Every Saturday"
     66msgstr ""
     67
     68#: ../class-notification.php:115
     69msgid "Every Sunday"
     70msgstr ""
     71
     72#: ../class-notification.php:116
     73msgid "Every Month"
     74msgstr ""
     75
     76#: ../class-notification.php:182
     77msgid "You have entered an invalid e-mail address."
     78msgstr ""
     79
     80#: ../class-notification.php:232
     81msgid "Hello Friend,"
     82msgstr ""
     83
     84#: ../class-notification.php:233
     85#, php-format
     86msgid "Some vulnerabilities were found in %s, visit the site for more details."
     87msgstr ""
     88
     89#: ../class-notification.php:251 ../report.php:34
     90msgid "Plugins"
     91msgstr ""
     92
     93#: ../class-notification.php:263 ../report.php:57
     94msgid "Themes"
     95msgstr ""
     96
     97#: ../class-notification.php:269
     98msgid "Hope this help!"
     99msgstr ""
     100
     101#: ../class-notification.php:273
     102#, php-format
     103msgid "Some vulnerabilities were found in %s"
     104msgstr ""
     105
     106#: ../class-vulnerability-alerts.php:107
     107msgid "Summary"
     108msgstr ""
     109
     110#: ../class-vulnerability-alerts.php:125
     111msgid "Last request to"
     112msgstr ""
     113
     114#: ../class-vulnerability-alerts.php:131
     115msgid "Your website is secure"
     116msgstr ""
     117
     118#: ../class-vulnerability-alerts.php:133
     119msgid "Requires your attention"
     120msgstr ""
     121
     122#: ../class-vulnerability-alerts.php:136
     123msgid ""
     124"Some paid plugins and themes, or developed exclusively for this website and "
     125"not shared for the public, may not be reported by WPScan."
     126msgstr ""
     127
     128#: ../class-vulnerability-alerts.php:140
    23129msgid "Check Now"
    24130msgstr ""
    25131
    26 #: ../report.php:10
    27 #, php-format
    28 msgid "Last request to %s on %s"
    29 msgstr ""
    30 
    31 #: ../report.php:11
    32 msgid ""
    33 "Some paid plugins and themes, or developed exclusively for this website and "
    34 "not shared for the public, may not be reported on WPScan."
    35 msgstr ""
    36 
    37 #: ../report.php:21 ../report.php:40 ../report.php:61
    38 msgid "Name"
    39 msgstr ""
    40 
    41 #: ../report.php:22 ../report.php:41 ../report.php:62
    42 msgid "Vulnerabilities"
    43 msgstr ""
    44 
    45 #: ../report.php:28 ../report.php:48 ../report.php:69
    46 #, php-format
    47 msgid "Version %s"
    48 msgstr ""
    49 
    50 #: ../report.php:34 ../vulnerability-alerts.php:564
    51 msgid "Plugins"
    52 msgstr ""
    53 
    54 #: ../report.php:55 ../vulnerability-alerts.php:576
    55 msgid "Themes"
    56 msgstr ""
    57 
    58 #: ../vulnerability-alerts.php:114
     132#: ../class-vulnerability-alerts.php:165
    59133#, php-format
    60134msgid "%d vulnerability found"
     
    63137msgstr[1] ""
    64138
    65 #: ../vulnerability-alerts.php:187
     139#: ../class-vulnerability-alerts.php:232 ../class-vulnerability-alerts.php:233
     140#: ../report.php:3
     141msgid "Vulnerability Alerts"
     142msgstr ""
     143
     144#: ../class-vulnerability-alerts.php:249
    66145msgid "View"
    67146msgstr ""
    68147
    69 #: ../vulnerability-alerts.php:259
    70 msgid "Report updated."
     148#: ../class-vulnerability-alerts.php:323
     149msgid "Task is running and in few minutes your report will be updated."
    71150msgstr ""
    72151
    73 #: ../vulnerability-alerts.php:307
     152#: ../class-vulnerability-alerts.php:379
    74153msgid "Report not available"
    75154msgstr ""
    76155
    77 #: ../vulnerability-alerts.php:332
     156#: ../class-vulnerability-alerts.php:405
    78157msgid "Not fixed"
    79158msgstr ""
    80159
    81 #: ../vulnerability-alerts.php:332
     160#: ../class-vulnerability-alerts.php:405
    82161#, php-format
    83162msgid "Fixed in version %s"
    84163msgstr ""
    85164
    86 #: ../vulnerability-alerts.php:382
    87 msgid "Notification"
     165#: ../report.php:19 ../report.php:40 ../report.php:63
     166msgid "Name"
    88167msgstr ""
    89168
    90 #: ../vulnerability-alerts.php:388
    91 msgid "E-mail Address"
     169#: ../report.php:20 ../report.php:41 ../report.php:64
     170msgid "Vulnerabilities"
    92171msgstr ""
    93172
    94 #: ../vulnerability-alerts.php:395
    95 msgid "Send E-mail Alerts"
     173#: ../report.php:27 ../report.php:49 ../report.php:72
     174#, php-format
     175msgid "Version %s"
    96176msgstr ""
    97 
    98 #: ../vulnerability-alerts.php:403
    99 msgid "Vulnerabilities to Ignore"
    100 msgstr ""
    101 
    102 #: ../vulnerability-alerts.php:416
    103 msgid ""
    104 "Fill the options below if you want to be notified by mail about new "
    105 "vulnerabilities."
    106 msgstr ""
    107 
    108 #: ../vulnerability-alerts.php:438
    109 msgid "Daily"
    110 msgstr ""
    111 
    112 #: ../vulnerability-alerts.php:439
    113 msgid "Every Monday"
    114 msgstr ""
    115 
    116 #: ../vulnerability-alerts.php:440
    117 msgid "Every Tuesday"
    118 msgstr ""
    119 
    120 #: ../vulnerability-alerts.php:441
    121 msgid "Every Wednesday"
    122 msgstr ""
    123 
    124 #: ../vulnerability-alerts.php:442
    125 msgid "Every Thursday"
    126 msgstr ""
    127 
    128 #: ../vulnerability-alerts.php:443
    129 msgid "Every Friday"
    130 msgstr ""
    131 
    132 #: ../vulnerability-alerts.php:444
    133 msgid "Every Saturday"
    134 msgstr ""
    135 
    136 #: ../vulnerability-alerts.php:445
    137 msgid "Every Sunday"
    138 msgstr ""
    139 
    140 #: ../vulnerability-alerts.php:446
    141 msgid "Every Month"
    142 msgstr ""
    143 
    144 #: ../vulnerability-alerts.php:504
    145 msgid "You have entered an invalid e-mail address."
    146 msgstr ""
    147 
    148 #: ../vulnerability-alerts.php:545
    149 msgid "Hello Friend,"
    150 msgstr ""
    151 
    152 #: ../vulnerability-alerts.php:546
    153 #, php-format
    154 msgid "Some vulnerabilities were found in %s, visit the site for more details."
    155 msgstr ""
    156 
    157 #: ../vulnerability-alerts.php:582
    158 msgid "Hope this help!"
    159 msgstr ""
    160 
    161 #: ../vulnerability-alerts.php:586
    162 #, php-format
    163 msgid "Some vulnerabilities were found in %s"
    164 msgstr ""
  • vulnerability-alerts/trunk/languages/vulnerability-alerts-pt_BR.po

    r1939555 r1946417  
    22msgstr ""
    33"Project-Id-Version: Vulnerability Alerts\n"
    4 "POT-Creation-Date: 2018-09-11 19:48-0300\n"
    5 "PO-Revision-Date: 2018-09-11 19:49-0300\n"
     4"POT-Creation-Date: 2018-09-24 19:57-0300\n"
     5"PO-Revision-Date: 2018-09-24 19:57-0300\n"
    66"Last-Translator: Edir Pedro <[email protected]>\n"
    77"Language-Team: \n"
     
    1616"X-Poedit-SearchPath-0: ..\n"
    1717
    18 #: ../report.php:3 ../vulnerability-alerts.php:184
    19 #: ../vulnerability-alerts.php:185
    20 msgid "Vulnerability Alerts"
    21 msgstr "Alertas de Vulnerabilidade"
    22 
    23 #: ../report.php:9
     18#: ../class-notification.php:29
     19msgid "E-mail"
     20msgstr "E-mail"
     21
     22#: ../class-notification.php:36
     23msgid "Send Alerts"
     24msgstr "Enviar Alertas"
     25
     26#: ../class-notification.php:44
     27msgid "Vulnerabilities to Ignore"
     28msgstr "Vulnerabilidades Ignoradas"
     29
     30#: ../class-notification.php:59
     31msgid "Notification"
     32msgstr "Notificação"
     33
     34#: ../class-notification.php:86
     35msgid ""
     36"Fill the options below if you want to be notified by mail about new "
     37"vulnerabilities. Add multiple e-mail addresses separating them by comma."
     38msgstr ""
     39"Preencha as opções abaixo se desejar ser notificado por e-mail sobre novas "
     40"vulnerabilidades. Adicione múltiplos endereços de e-mail separando-os por "
     41"vírgula."
     42
     43#: ../class-notification.php:108
     44msgid "Daily"
     45msgstr "Diariamente"
     46
     47#: ../class-notification.php:109
     48msgid "Every Monday"
     49msgstr "Toda Segunda"
     50
     51#: ../class-notification.php:110
     52msgid "Every Tuesday"
     53msgstr "Toda Terça"
     54
     55#: ../class-notification.php:111
     56msgid "Every Wednesday"
     57msgstr "Toda Quarta"
     58
     59#: ../class-notification.php:112
     60msgid "Every Thursday"
     61msgstr "Toda Quinta"
     62
     63#: ../class-notification.php:113
     64msgid "Every Friday"
     65msgstr "Toda Sexta"
     66
     67#: ../class-notification.php:114
     68msgid "Every Saturday"
     69msgstr "Todo Sábado"
     70
     71#: ../class-notification.php:115
     72msgid "Every Sunday"
     73msgstr "Todo Domingo"
     74
     75#: ../class-notification.php:116
     76msgid "Every Month"
     77msgstr "Todo Mês"
     78
     79#: ../class-notification.php:182
     80msgid "You have entered an invalid e-mail address."
     81msgstr "Você informou um endereço de e-mail inválido."
     82
     83#: ../class-notification.php:232
     84msgid "Hello Friend,"
     85msgstr "Olá Amigo(a),"
     86
     87#: ../class-notification.php:233
     88#, php-format
     89msgid "Some vulnerabilities were found in %s, visit the site for more details."
     90msgstr ""
     91"Algumas vulnerabilidades foram encontradas em %s, visite o site para mais "
     92"detalhes."
     93
     94#: ../class-notification.php:251 ../report.php:34
     95msgid "Plugins"
     96msgstr "Plugins"
     97
     98#: ../class-notification.php:263 ../report.php:57
     99msgid "Themes"
     100msgstr "Temas"
     101
     102#: ../class-notification.php:269
     103msgid "Hope this help!"
     104msgstr "Espero que isso ajude!"
     105
     106#: ../class-notification.php:273
     107#, php-format
     108msgid "Some vulnerabilities were found in %s"
     109msgstr "Algumas vulnerabilidades foram encontradas em %s"
     110
     111#: ../class-vulnerability-alerts.php:107
     112msgid "Summary"
     113msgstr "Resumo"
     114
     115#: ../class-vulnerability-alerts.php:125
     116msgid "Last request to"
     117msgstr "Última verificação no"
     118
     119#: ../class-vulnerability-alerts.php:131
     120msgid "Your website is secure"
     121msgstr "Seu site esta seguro"
     122
     123#: ../class-vulnerability-alerts.php:133
     124#, fuzzy
     125#| msgid "Require your attention"
     126msgid "Requires your attention"
     127msgstr "Requer sua atenção"
     128
     129#: ../class-vulnerability-alerts.php:136
     130msgid ""
     131"Some paid plugins and themes, or developed exclusively for this website and "
     132"not shared for the public, may not be reported by WPScan."
     133msgstr ""
     134"Alguns plugins e temas pagos, ou desenvolvidos exclusivamente para este site "
     135"e não compartilhados com o público, podem não ser reportados pelo WPScan."
     136
     137#: ../class-vulnerability-alerts.php:140
    24138msgid "Check Now"
    25139msgstr "Verificar Agora"
    26140
    27 #: ../report.php:10
    28 #, php-format
    29 msgid "Last request to %s on %s"
    30 msgstr "Última verificação no %s em %s"
    31 
    32 #: ../report.php:12
    33 msgid ""
    34 "Some paid plugins and themes, or developed exclusively for this website and "
    35 "not shared for the public, may not be reported on WPScan."
    36 msgstr ""
    37 "Alguns plugins e temas pagos, ou desenvolvidos exclusivamente para este site "
    38 "e não compartilhados com o público, podem não ser reportados pelo WPScan."
    39 
    40 #: ../report.php:22 ../report.php:43 ../report.php:66
    41 msgid "Name"
    42 msgstr "Nome"
    43 
    44 #: ../report.php:23 ../report.php:44 ../report.php:67
    45 msgid "Vulnerabilities"
    46 msgstr "Vulnerabilidades"
    47 
    48 #: ../report.php:30 ../report.php:52 ../report.php:75
    49 #, php-format
    50 msgid "Version %s"
    51 msgstr "Versão %s"
    52 
    53 #: ../report.php:37 ../vulnerability-alerts.php:610
    54 msgid "Plugins"
    55 msgstr "Plugins"
    56 
    57 #: ../report.php:60 ../vulnerability-alerts.php:622
    58 msgid "Themes"
    59 msgstr "Temas"
    60 
    61 #: ../vulnerability-alerts.php:117
     141#: ../class-vulnerability-alerts.php:165
    62142#, php-format
    63143msgid "%d vulnerability found"
     
    66146msgstr[1] "%d vulnerabilidades encontradas"
    67147
    68 #: ../vulnerability-alerts.php:201
     148#: ../class-vulnerability-alerts.php:232 ../class-vulnerability-alerts.php:233
     149#: ../report.php:3
     150msgid "Vulnerability Alerts"
     151msgstr "Alertas de Vulnerabilidade"
     152
     153#: ../class-vulnerability-alerts.php:249
    69154msgid "View"
    70155msgstr "Ver"
    71156
    72 #: ../vulnerability-alerts.php:275
    73 msgid "Report updated."
    74 msgstr "Relatório atualizado."
    75 
    76 #: ../vulnerability-alerts.php:329
     157#: ../class-vulnerability-alerts.php:323
     158msgid "Task is running and in few minutes your report will be updated."
     159msgstr "Tarefa em andamento e em poucos minutos seu relatório será atualizado."
     160
     161#: ../class-vulnerability-alerts.php:379
    77162msgid "Report not available"
    78163msgstr "Relatório não disponível"
    79164
    80 #: ../vulnerability-alerts.php:355
     165#: ../class-vulnerability-alerts.php:405
    81166msgid "Not fixed"
    82167msgstr "Sem correção"
    83168
    84 #: ../vulnerability-alerts.php:355
     169#: ../class-vulnerability-alerts.php:405
    85170#, php-format
    86171msgid "Fixed in version %s"
    87172msgstr "Corrigido na versão %s"
    88173
    89 #: ../vulnerability-alerts.php:410
    90 msgid "Notification"
    91 msgstr "Notificação"
    92 
    93 #: ../vulnerability-alerts.php:416
    94 msgid "E-mail Address"
    95 msgstr "Endereço de E-mail"
    96 
    97 #: ../vulnerability-alerts.php:423
    98 msgid "Send E-mail Alerts"
    99 msgstr "Enviar Alertas no E-mail"
    100 
    101 #: ../vulnerability-alerts.php:431
    102 msgid "Vulnerabilities to Ignore"
    103 msgstr "Vulnerabilidades Ignoradas"
    104 
    105 #: ../vulnerability-alerts.php:444
    106 msgid ""
    107 "Fill the options below if you want to be notified by mail about new "
    108 "vulnerabilities."
    109 msgstr ""
    110 "Preencha as opções abaixo se desejar ser notificado por e-mail sobre novas "
    111 "vulnerabilidades."
    112 
    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
    118 msgid "Daily"
    119 msgstr "Diariamente"
    120 
    121 #: ../vulnerability-alerts.php:468
    122 msgid "Every Monday"
    123 msgstr "Toda Segunda"
    124 
    125 #: ../vulnerability-alerts.php:469
    126 msgid "Every Tuesday"
    127 msgstr "Toda Terça"
    128 
    129 #: ../vulnerability-alerts.php:470
    130 msgid "Every Wednesday"
    131 msgstr "Toda Quarta"
    132 
    133 #: ../vulnerability-alerts.php:471
    134 msgid "Every Thursday"
    135 msgstr "Toda Quinta"
    136 
    137 #: ../vulnerability-alerts.php:472
    138 msgid "Every Friday"
    139 msgstr "Toda Sexta"
    140 
    141 #: ../vulnerability-alerts.php:473
    142 msgid "Every Saturday"
    143 msgstr "Todo Sábado"
    144 
    145 #: ../vulnerability-alerts.php:474
    146 msgid "Every Sunday"
    147 msgstr "Todo Domingo"
    148 
    149 #: ../vulnerability-alerts.php:475
    150 msgid "Every Month"
    151 msgstr "Todo Mês"
    152 
    153 #: ../vulnerability-alerts.php:541
    154 msgid "You have entered an invalid e-mail address."
    155 msgstr "Você informou um endereço de e-mail inválido."
    156 
    157 #: ../vulnerability-alerts.php:591
    158 msgid "Hello Friend,"
    159 msgstr "Olá Amigo(a),"
    160 
    161 #: ../vulnerability-alerts.php:592
    162 #, php-format
    163 msgid "Some vulnerabilities were found in %s, visit the site for more details."
    164 msgstr ""
    165 "Algumas vulnerabilidades foram encontradas em %s, visite o site para mais "
    166 "detalhes."
    167 
    168 #: ../vulnerability-alerts.php:628
    169 msgid "Hope this help!"
    170 msgstr "Espero que isso ajude!"
    171 
    172 #: ../vulnerability-alerts.php:632
    173 #, php-format
    174 msgid "Some vulnerabilities were found in %s"
    175 msgstr "Algumas vulnerabilidades foram encontradas em %s"
     174#: ../report.php:19 ../report.php:40 ../report.php:63
     175msgid "Name"
     176msgstr "Nome"
     177
     178#: ../report.php:20 ../report.php:41 ../report.php:64
     179msgid "Vulnerabilities"
     180msgstr "Vulnerabilidades"
     181
     182#: ../report.php:27 ../report.php:49 ../report.php:72
     183#, php-format
     184msgid "Version %s"
     185msgstr "Versão %s"
     186
     187#~ msgid "Information"
     188#~ msgstr "Informações"
     189
     190#~ msgid "Report updated."
     191#~ msgstr "Relatório atualizado."
     192
     193#~ msgid "Add multiple e-mail addresses separating them by comma."
     194#~ msgstr "Adicione múltiplos endereços de e-mail separando-os por vírgula."
    176195
    177196#~ msgid "Plugin"
  • vulnerability-alerts/trunk/readme.txt

    r1939555 r1946417  
    44Requires at least: 3.4
    55Tested up to: 4.9.8
    6 Stable tag: 1.3.6
     6Stable tag: 1.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3232
    3333== Changelog ==
     34
     35= 1.4 =
     36* [Added] Some UI improvements
     37* [Fixed] Check Now button now runs the scheduled task to avoid timeout error
    3438
    3539= 1.3.6 =
  • vulnerability-alerts/trunk/report.php

    r1939555 r1946417  
    55    <?php settings_errors(); ?>
    66
    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>
     7    <div id="poststuff">
     8           
     9        <div id="post-body" class="metabox-holder columns-2">
     10           
     11            <div id="postbox-body" class="postbox-container">
    1512
    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">&nbsp;</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">&nbsp;</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">&nbsp;</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' );
    87         submit_button();
    88     ?>
    89     </form>
     13                <h3>WordPress</h3>
     14           
     15                <table class="wp-list-table widefat striped plugins">
     16                    <thead>
     17                    <tr>
     18                        <td scope="col" class="manage-column check-column">&nbsp;</td>
     19                        <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th>
     20                        <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th>
     21                    </tr>
     22                    </thead>
     23                    <tbody id="report-wordpress">
     24                    <tr>
     25                        <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'wordpress' ) ?></span></th>
     26                        <td class="plugin-title column-primary">
     27                            <strong>WordPress</strong> <?php echo sprintf( __( 'Version %s', self::$id ), get_bloginfo( 'version' ) ) ?>
     28                        </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">&nbsp;</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">
     49                                <strong><?php echo $details['Name'] ?></strong> <?php echo sprintf( __( 'Version %s', self::$id ), $details['Version'] ) ?>
     50                            </td>
     51                            <td><?php self::list_vulnerabilities( 'plugins', $name ) ?></td>
     52                        </tr>
     53                    <?php endforeach; ?>
     54                    </tbody>
     55                </table>
     56           
     57                <h3><?php _e( 'Themes', self::$id ) ?></h3>
     58           
     59                <table class="wp-list-table widefat striped plugins">
     60                    <thead>
     61                    <tr>
     62                        <td scope="col" class="manage-column check-column">&nbsp;</td>
     63                        <th scope="col" class="manage-column column-name column-primary" width="250"><?php _e( 'Name', self::$id ) ?></th>
     64                        <th scope="col" class="manage-column column-description"><?php _e( 'Vulnerabilities', self::$id ) ?></th>
     65                    </tr>
     66                    </thead>
     67                    <tbody id="report-themes">
     68                    <?php foreach ( wp_get_themes() as $name => $details ) : ?>
     69                        <tr>
     70                            <th scope="row" class="check-column" align="center"><?php echo self::get_status( 'themes', $name ) ?></span></th>
     71                            <td class="plugin-title column-primary">
     72                                <strong><?php echo $details['Name'] ?></strong> <?php echo sprintf( __( 'Version %s', self::$id ), $details['Version'] ) ?>
     73                            </td>
     74                            <td><?php self::list_vulnerabilities( 'themes', $name ) ?></td>
     75                        </tr>
     76                    <?php endforeach; ?>
     77                    </tbody>
     78                </table>
     79               
     80            </div>
     81           
     82            <div id="postbox-container-1" class="postbox-container">
     83                                   
     84                <?php do_meta_boxes( self::$id, 'side', null ); ?>
     85               
     86            </div>
     87       
     88        </div>
     89       
     90        <br class="clear">
     91   
     92    </div>
    9093
    9194</div>
  • vulnerability-alerts/trunk/vulnerability-alerts.php

    r1939555 r1946417  
    55 * Description: Scans your system to find vulnerabilities listed in WPScan Vulnerability Database.
    66 * Plugin URI: http://wordpress.org/plugins/vulnerability-alerts/
    7  * Version: 1.3.6
     7 * Version: 1.4
    88 * Author: Edir Pedro
    99 * Author URI: http://edirpedro.com.br
     
    1616defined( 'ABSPATH' ) or die( "No script kiddies please!" );
    1717
    18 
    19 class Vulnerabilty_Alerts {
    20 
    21     // Plugin name
    22     static public $id = 'vulnerability-alerts';
    23 
    24     // Report shortcut
    25     static public $report = array();
    26 
    27     // Arguments to WP Remote Get
    28     static public $remote = array(
    29         'user-agent' => 'WordPress Plugin Vulnerability Alerts'
    30     );
    31 
    32     /*
    33     * Initialize actions
    34     */
    35     static public function init() {
    36 
    37         // Languages
    38         load_plugin_textdomain( self::$id, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    39 
    40         // Arguments to wp remote get
    41         self::$remote['user-agent'] .= '; ' . get_bloginfo( 'url' );
    42 
    43         // Report
    44         self::$report = get_option( self::$id );
    45 
    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 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 
    56     /*
    57     * Plugins Loaded
    58     */
    59     static public function loaded() {
    60 
    61         // Languages
    62         load_plugin_textdomain( self::$id, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    63 
    64     }
    65 
    66     /*
    67     * Activate actions
    68     */
    69     static public function activate() {
    70 
    71         wp_clear_scheduled_hook( self::$id . '_schedule' ); // Prevent duplication
    72         wp_schedule_event( time(), 'daily', self::$id . '_schedule' );
    73 
    74         self::verify();
    75 
    76     }
    77 
    78     /*
    79     * Deactivate actions
    80     */
    81     static public function deactivate() {
    82 
    83         wp_clear_scheduled_hook( self::$id . '_schedule' );
    84 
    85     }
    86 
    87     /*
    88     * Schedule and event to run verify() function
    89     */
    90     static public function schedule() {
    91 
    92         self::verify();
    93 
    94         // Notify by mail when solicited
    95         Vulnerabilty_Alerts_Notification::notify();
    96 
    97     }
    98 
    99     /*
    100     * Create a shortcut on Admin Bar to show the total of vulnerabilities found
    101     */
    102     static public function admin_bar( $wp_admin_bar ) {
    103 
    104         if ( ! current_user_can( 'manage_options' ) ) {
    105             return;
    106         }
    107 
    108         $report = self::$report;
    109         $total = self::get_total();
    110 
    111         if ( ! empty( $report ) and $total > 0 ) {
    112             $args = array(
    113                 'id' => 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 ),
    116                 'meta' => array(
    117                     'title' => sprintf( _n( '%d vulnerability found', '%d vulnerabilities found', $total, self::$id ), $total )
    118                 )
    119             );
    120             $wp_admin_bar->add_node( $args );
    121         }
    122 
    123     }
    124 
    125     /*
    126     * Return the total of vulnerabilities found
    127     */
    128     static public function get_total() {
    129         $report = self::$report;
    130         $options = get_option( self::$id . '_notification' );
    131         $ignored = empty( $options['ignored'] ) ? array() : $options['ignored'];
    132 
    133         $total = 0;
    134         $total += $report['wordpress']['total'];
    135         $total += $report['plugins']['total'];
    136         $total += $report['themes']['total'];
    137 
    138         // WordPress ignored
    139         if ( $report['wordpress']['total'] > 0 ) {
    140             foreach ( $report['wordpress']['vulnerabilities'] as $item ) {
    141                 if ( in_array( $item->id, $ignored ) ) {
    142                     $total -= 1;
    143                 }
    144             }
    145         }
    146 
    147         // Plugins ignored
    148         if ( $report['plugins']['total'] > 0 ) {
    149             foreach ( $report['plugins'] as $plugin ) {
    150                 if ( empty( $plugin['vulnerabilities'] ) ) {
    151                     continue;
    152                 }
    153                 foreach ( $plugin['vulnerabilities'] as $item ) {
    154                     if ( in_array( $item->id, $ignored ) ) {
    155                         $total -= 1;
    156                     }
    157                 }
    158             }
    159         }
    160 
    161         // Themes ignored
    162         if ( $report['themes']['total'] > 0 ) {
    163             foreach ( $report['themes'] as $theme ) {
    164                 if ( empty( $theme['vulnerabilities'] ) ) {
    165                     continue;
    166                 }
    167                 foreach ( $theme['vulnerabilities'] as $item ) {
    168                     if ( in_array( $item->id, $ignored ) ) {
    169                         $total -= 1;
    170                     }
    171                 }
    172             }
    173         }
    174 
    175         return $total;
    176     }
    177 
    178     /*
    179     * Create a menu on Tools section
    180     */
    181     static public function menu() {
    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 
    193     /*
    194     * Include a shortcut on Plugins Page
    195     *
    196     * @param array $links - Array of links provided by the filter
    197     * @return array
    198     */
    199     static public function add_action_links( $links ) {
    200 
    201         $links[] = '<a href="' . admin_url( 'tools.php?page=' . self::$id ) . '">' . __( 'View' ) . '</a>';
    202 
    203         return $links;
    204 
    205     }
    206 
    207     /*
    208     * Function to verify on WpScan Database for vulnerabilities
    209     */
    210     static public function verify() {
    211 
    212         // Suppports during WP Cron
    213         if ( ! function_exists( 'get_plugins' ) ) {
    214             require_once ABSPATH . 'wp-admin/includes/plugin.php';
    215         }
    216 
    217         $report = array();
    218 
    219         // WordPress
    220         $report['wordpress'] = array();
    221         $report['wordpress']['total'] = 0;
    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'] );
    229             }
    230         }
    231 
    232         // Plugins
    233         $report['plugins'] = array();
    234         $report['plugins']['total'] = 0;
    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 
    247         // Themes
    248         $report['themes'] = array();
    249         $report['themes']['total'] = 0;
    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 
    261         // Caching
    262         $report['cache'] = strtotime( current_time( 'mysql' ) );
    263         update_option( self::$id, $report, true );
    264         self::$report = $report;
    265 
    266     }
    267 
    268     /*
    269     * Report Page
    270     */
    271     static public function report() {
    272 
    273         // Button Check Now
    274         if ( isset( $_POST['verify'] ) ) {
    275             add_settings_error( self::$id, 'update', __( 'Report updated.', self::$id ), 'updated' );
    276             self::verify();
    277         }
    278 
    279         $report = self::$report;
    280         include 'report.php';
    281 
    282     }
    283 
    284     /*
    285     * Filter vulnerability list from WPScan
    286     *
    287     * @param array $data - Report data for the element to check
    288     * @param string $version - Installed version
    289     * @return string
    290     */
    291     static public function get_vulnerabilities( $data, $version ) {
    292 
    293         $list = array();
    294         $key = key( $data );
    295 
    296         if ( empty( $data[ $key ]->vulnerabilities ) ) {
    297             return $list;
    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                 }
    305             } else {
    306                 $list[] = $item;
    307             }
    308         }
    309 
    310         return $list;
    311 
    312     }
    313 
    314     /*
    315     * List vulnerabilities on screen
    316     *
    317     * @param string $type - Type of report: wordpress, plugins, themes
    318     * @param string $name - key name of the element
    319     * @return string
    320     */
    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 
    331             return;
    332         }
    333 
    334         $list = array();
    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 );
    339             $html .= '</a>';
    340             $list[] = $html;
    341         }
    342 
    343         echo empty( $list ) ? '- -' : join( '<br>', $list );
    344 
    345     }
    346 
    347     /*
    348     * Get vulnerability title
    349     *
    350     * @param string $vulnerability - element array
    351     * @return string
    352     */
    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 
    357         return $title;
    358     }
    359 
    360     /*
    361     * Show status icons: checked, attention and error
    362     *
    363     * @param string $type - Type of report: wordpress, plugins, themes
    364     * @param string $name - key name of the element
    365     * @return string
    366     */
    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'] ) ) {
    375             return '&nbsp; <span class="dashicons dashicons-no-alt" style="color:gray"></span>';
    376         }
    377 
    378         if ( empty( $report['vulnerabilities'] ) ) {
    379             return '&nbsp; <span class="dashicons dashicons-yes" style="color:green"></span>';
    380         } else {
    381             return '&nbsp; <span class="dashicons dashicons-warning" style="color:Crimson"></span>';
    382         }
    383 
    384     }
    385 
    386 }
    387 
    388 /*
    389 * Notification System
    390 */
    391 
    392 class Vulnerabilty_Alerts_Notification extends Vulnerabilty_Alerts {
    393 
    394     /*
    395     * Notification Options
    396     */
    397     static public function init() {
    398 
    399         $report = self::$report;
    400 
    401         $total = 0;
    402         $total += $report['wordpress']['total'];
    403         $total += $report['plugins']['total'];
    404         $total += $report['themes']['total'];
    405 
    406         register_setting( self::$id . '_notification', self::$id . '_notification', array( __CLASS__, 'validate' ) );
    407 
    408         add_settings_section(
    409             self::$id . '_notification_section',
    410             __( 'Notification', self::$id ),
    411             array( __CLASS__, 'introduction' ),
    412             self::$id . '_notification' );
    413 
    414         add_settings_field(
    415             'email',
    416             __( 'E-mail Address', self::$id ),
    417             array( __CLASS__, 'field_email' ),
    418             self::$id . '_notification',
    419             self::$id . '_notification_section' );
    420 
    421         add_settings_field(
    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 ) {
    429             add_settings_field(
    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 
    439     /*
    440     * Introduction
    441     */
    442     static public function introduction() {
    443 
    444         echo '<p>' . __( 'Fill the options below if you want to be notified by mail about new vulnerabilities.', self::$id ) . '</p>';
    445 
    446     }
    447 
    448     /*
    449     * Field E-mail
    450     */
    451     static public function field_email() {
    452 
    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 
    459     /*
    460     * Field Interval
    461     */
    462     static public function field_interval() {
    463 
    464         $options = get_option( self::$id . '_notification' );
    465         $interval = empty( $options['interval'] ) ? 'd' : $options['interval'];
    466         echo '<select name="' . self::$id . '_notification[interval]">';
    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>';
    476         echo '</selected>';
    477 
    478     }
    479 
    480     /*
    481     * Field Ignore
    482     */
    483     static public function field_ignored() {
    484 
    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 
    500     /*
    501     * List of vulnerabilities
    502     *
    503     * @param string $type - Type of report: wordpress, plugins, themes
    504     * @param string $name - key name of the element
    505     * @return string
    506     */
    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'] ) ) {
    515             return null;
    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'] );
    538    
    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             }
    544    
    545         }
    546 
    547         return $input;
    548 
    549     }
    550 
    551     /*
    552     * Sending notification
    553     */
    554     static public function notify() {
    555 
    556         // Suppports during WP Cron
    557         if ( ! function_exists( 'get_plugins' ) ) {
    558             require_once ABSPATH . 'wp-admin/includes/plugin.php';
    559         }
    560 
    561         $report = self::$report;
    562         $total = self::get_total();
    563 
    564         if ( $total == 0 ) {
    565             return;
    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 
    573         // Check email             
    574         if ( empty( $email ) ) {
    575             return;
    576         }
    577 
    578         // Check weekly interval
    579         if ( is_numeric( $interval ) && date( 'N' ) != $interval ) {
    580             return;
    581         }
    582 
    583         // Check monthly interval
    584         if ( $interval == 'm' && date( 'j' ) != 1 ) {
    585             return;
    586         }
    587 
    588         // Send email
    589         $has_vulnerabilities = false;
    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 
    594         // WordPress
    595         if ( $report['wordpress']['total'] > 0 ) {
    596             $list = self::email_vulnerabilities( 'wordpress' );
    597             if ( ! empty( $list ) ) {
    598                 $has_vulnerabilities = true;
    599                 $msg .= '<p><b>WordPress</b><br>';
    600                 $msg .= join( '<br>', $list ) . '</p>';
    601             }
    602         }
    603 
    604         // Plugins
    605         if ( $report['plugins']['total'] > 0 ) {
    606             foreach ( get_plugins() as $name => $details ) {
    607                 $list = self::email_vulnerabilities( 'plugins', $name );
    608                 if ( ! empty( $list ) ) {
    609                     $has_vulnerabilities = true;
    610                     $msg .= '<p><b>' . __( 'Plugins', self::$id ) . ' ' . $details['Name'] . '</b><br>';
    611                     $msg .= join( '<br>', $list ) . '</p>';
    612                 }
    613             }
    614         }
    615 
    616         // Themes
    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 ) ) {
    621                     $has_vulnerabilities = true;
    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>';
    629         $msg .= '</body></html>';
    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 
    639     /*
    640     * List of vulnerabilities to send by mail
    641     */
    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'] ) ) {
    650             return null;
    651         }
    652 
    653         $options = get_option( self::$id . '_notification' );
    654         $ignored = empty( $options['ignored'] ) ? array() : $options['ignored'];
    655 
    656         $list = array();
    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 );
    662                 $html .= '</a>';
    663                 $list[] = $html;
    664             }
    665         }
    666 
    667         return $list;
    668 
    669     }
    670 
    671 }
    672 
     18//Includes
     19require_once 'class-vulnerability-alerts.php';
     20require_once 'class-notification.php';
    67321
    67422// Activating
     
    68028// Initialize
    68129add_action( 'init', array( 'Vulnerabilty_Alerts', 'init' ) );
    682 
Note: See TracChangeset for help on using the changeset viewer.