C:\xampp\htdocs\landing\wp-content\plugins\better-wp-security\core\notify.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?php

/**
 * Handles sending notifications to users
 *
 * @package iThemes-Security
 * @since   4.5
 */
class ITSEC_Notify {

    public function 
__construct() {
        
add_filter'itsec_notifications', array( $this'register_notification' ) );
        
add_filter'itsec_digest_notification_strings', array( $this'notification_strings' ) );
        
add_filter'itsec_send_notification_digest', array( $this'send_daily_digest' ), 10);
    }

    
/**
     * Register the digest notification.
     *
     * @param array $notifications
     *
     * @return array
     */
    
public function register_notification$notifications ) {
        
$notifications['digest'] = array(
            
'slug'             => 'digest',
            
'recipient'        => ITSEC_Notification_Center::R_USER_LIST_ADMIN_UPGRADE,
            
'schedule'         => array(
                
'min' => ITSEC_Notification_Center::S_DAILY,
                
'max' => ITSEC_Notification_Center::S_WEEKLY,
            ),
            
'subject_editable' => true,
            
'optional'         => true,
        );

        return 
$notifications;
    }

    
/**
     * Get the digest notification strings.
     *
     * @return array
     */
    
public function notification_strings() {
        
$description esc_html__'During periods of heavy attack, iThemes Security can generate a LOT of email.''better-wp-security' );

        if ( 
ITSEC_Core::is_pro() ) {
            
$features esc_html__'The Security Digest reduces the number of emails sent so you can receive a summary of lockouts, file change detection scans, and privilege escalations.' );
        } else {
            
$features esc_html__'The Security Digest reduces the number of emails sent so you can receive a summary of lockouts and file change detection scans.' );
        }

        return array(
            
'label'       => esc_html__'Security Digest''better-wp-security' ),
            
'description' => $description ' ' $features,
            
'subject'     => esc_html__'Daily Security Digest''better-wp-security' ), // Default schedule is Daily
        
);
    }

    
/**
     * Send the daily digest email.
     *
     * @since 2.6.0
     *
     * @param bool  $sent
     * @param int   $last_sent
     * @param array $data
     *
     * @return bool
     */
    
public function send_daily_digest$sent$last_sent$data ) {

        
/** @var ITSEC_Lockout $itsec_lockout */
        
global $itsec_lockout;

        
$send_email false;

        
$df get_option'date_format' );
        
$nc ITSEC_Core::get_notification_center();

        switch ( 
$nc->get_schedule'digest' ) ) {
            case 
ITSEC_Notification_Center::S_DAILY:
                
$title esc_html__'Daily Security Digest''better-wp-security' );
                
$banner_title sprintfesc_html__'Your Daily Security Digest for %s''better-wp-security' ), '<b>' date_i18n$df ) . '</b>' );
                break;
            case 
ITSEC_Notification_Center::S_WEEKLY:
                
$period sprintf(
                    
'%s - %s',
                    
ITSEC_Lib::date_format_i18n_and_local_timezone$last_sent$df ),
                    
ITSEC_Lib::date_format_i18n_and_local_timezoneITSEC_Core::get_current_time_gmt(), $df )
                );

                
$title esc_html__'Weekly Security Digest''better-wp-security' );
                
$banner_title sprintfesc_html__'Your Weekly Security Digest for %s''better-wp-security' ), '<b>' $period '</b>' );
                break;
            case 
ITSEC_Notification_Center::S_MONTHLY:

                
$this_day = (int) date'j'ITSEC_Core::get_current_time_gmt() );

                if ( 
$this_day <= ) {
                    
$period date_i18n('F Y'$last_sent );
                } else {
                    
$period sprintf(
                        
'%s - %s',
                        
ITSEC_Lib::date_format_i18n_and_local_timezone$last_sent$df ),
                        
ITSEC_Lib::date_format_i18n_and_local_timezoneITSEC_Core::get_current_time_gmt(), $df )
                    );
                }

                
$title esc_html__'Monthly Security Digest''better-wp-security' );
                
$banner_title sprintfesc_html__'Your Monthly Security Digest for %s''better-wp-security' ), '<b>' $period '</b>' );
                break;
            default:
                
$period sprintf(
                    
'%s - %s',
                    
ITSEC_Lib::date_format_i18n_and_local_timezone$last_sent$df ),
                    
ITSEC_Lib::date_format_i18n_and_local_timezoneITSEC_Core::get_current_time_gmt(), $df )
                );

                
$title esc_html__'Security Digest''better-wp-security' );
                
$banner_title sprintfesc_html__'Your Security Digest for %s''better-wp-security' ), '<b>' $period '</b>' );
                break;
        }

        
$data_proxy = new ITSEC_Notify_Data_Proxy$data );

        
$mail $nc->mail'digest' );
        
$mail->add_header$title$banner_title );
        
$mail->start_group'intro' );
        
$mail->add_info_boxsprintfesc_html__'The following is a summary of security related activity on your site: %s''better-wp-security' ), '<b>' $mail->get_display_url() . '</b>' ) );
        
$mail->end_group();

        
$content $mail->get_content();

        
/**
         * Fires before the main content of the Security Digest is added.
         *
         * @param ITSEC_Mail              $mail
         * @param ITSEC_Notify_Data_Proxy $data_proxy
         * @param int                     $last_sent
         */
        
do_action'itsec_security_digest_before'$mail$data_proxy$last_sent );

        if ( 
$content !== $mail->get_content() ) {
            
$send_email true;
        }

        
$mail->add_section_headingesc_html__'Lockouts''better-wp-security' ), 'lock' );

        
$user_count $itsec_lockout->get_lockouts'user', array( 'after' => $last_sent'current' => false'return' => 'count' ) );
        
$host_count $itsec_lockout->get_lockouts'host', array( 'after' => $last_sent'current' => false'return' => 'count' ) );

        if ( 
$host_count || $user_count ) {
            
$mail->add_lockouts_summary$user_count$host_count );
            
$send_email true;
        } else {
            
$mail->add_textesc_html__'No lockouts since the last email check.''better-wp-security' ) );
        }

        if ( 
$data_proxy->has_message'file-change' ) ) {
            
$mail->add_section_headingesc_html__'File Changes''better-wp-security' ), 'folder' );
            
$mail->add_textesc_html__'File changes detected on the site.''better-wp-security' ) );
            
$send_email true;
        }

        if ( ! 
$send_email ) {
            
$content $mail->get_content();
        }

        
/**
         * Fires when additional info should be attached to the Security Digest.
         *
         * @since 3.9.0
         *
         * @param ITSEC_Mail              $mail
         * @param ITSEC_Notify_Data_Proxy $data_proxy
         * @param int                     $last_sent
         */
        
do_action'itsec_security_digest_attach_additional_info'$mail$data_proxy$last_sent );

        if ( ! 
$send_email && $content !== $mail->get_content() ) {
            
$send_email true;
        }

        
$messages $this->get_general_messages$data );

        if ( 
$messages ) {
            
$mail->add_section_headingesc_html__'Messages''better-wp-security' ), 'message' );

            foreach ( 
$messages as $message ) {
                
$mail->add_text$message );
            }

            
$send_email true;
        }


        if ( ! 
$send_email ) {
            return 
true;
        }


        
$mail->add_details_boxsprintf(
            
esc_html__'For more details, %1$svisit your security logs%2$s''better-wp-security' ),
            
'<a href="' ITSEC_Mail::filter_admin_page_urlITSEC_Core::get_logs_page_url() ) . '"><b>',
            
'</b></a>'
        
) );

        if ( 
apply_filters'itsec_security_digest_include_security_check'true ) ) {
            
$mail->add_divider();
            
$mail->add_large_textesc_html__'Is your site as secure as it could be?''better-wp-security' ) );
            
$mail->add_textesc_html__'Ensure your site is using recommended settings and features with a security check.''better-wp-security' ) );
            
$mail->add_buttonesc_html__'Run a Security Check ✓''better-wp-security' ), ITSEC_Mail::filter_admin_page_urlITSEC_Core::get_security_check_page_url() ) );
        }

        
$mail->add_footer();

        return 
$nc->send'digest'$mail );
    }

    
/**
     * Get general digest messages.
     *
     * @param array $data
     *
     * @return string[]
     */
    
private function get_general_messages$data ) {

        
$messages = array();

        foreach ( 
$data as $datum ) {

            if ( ! 
is_array$datum ) || ! isset( $datum['message'] ) ) {
                continue;
            }

            if ( isset( 
$datum['type'] ) && 'general' !== $datum['type'] ) {
                continue;
            }

            
$messages[] = $datum['message'];
        }

        return 
$messages;
    }

    
/**
     * Used by the File Change Detection module to tell the notification system about found file changes.
     *
     * @since 2.6.0
     *
     * @return null
     */
    
public function register_file_change() {
        
_deprecated_function__METHOD__'3.9.0''ITSEC_Notification_Center::enqueue_data' );
        
ITSEC_Core::get_notification_center()->enqueue_data'digest', array( 'type' => 'file-change' ) );
    }

    
/**
     * Set HTML content type for email
     *
     * @since 4.5
     *
     * @return string html content type
     */
    
public function wp_mail_content_type() {

        return 
'text/html';

    }
}

class 
ITSEC_Notify_Data_Proxy {

    
/** @var array */
    
private $data;

    
/**
     * ITSEC_Notify_Data_Proxy constructor.
     *
     * @param array $data
     */
    
public function __construct$data ) { $this->data $data; }

    
/**
     * Check for a queued message.
     *
     * @param string $type
     *
     * @return array|null
     */
    
public function has_message$type ) {

        foreach ( 
$this->data as $datum ) {

            if ( ! 
is_array$datum ) ) {
                continue;
            }

            if ( isset( 
$datum['type'] ) && $type === $datum['type'] ) {
                return 
$datum;
            }
        }

        return 
null;
    }

    
/**
     * Get all messages of a given type.
     *
     * @param string $type
     *
     * @return array
     */
    
public function get_messages_of_type$type ) {

        
$of_type = array();

        foreach ( 
$this->data as $datum ) {
            if ( ! 
is_array$datum ) ) {
                continue;
            }

            if ( isset( 
$datum['type'] ) && $type === $datum['type'] ) {
                
$of_type[] = $datum;
            }
        }

        return 
$of_type;
    }

}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586