PluginProbe
Easy Basic Authentication – Add basic auth to site or admin area / 2.2
Easy Basic Authentication – Add basic auth to site or admin area v2.2
trunk 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.7 1.7.1 1.8 1.8.1 1.9 All 50 releases
easy-basic-authentication / class / easy-basic-authentication-emailalert-class.php

easy-basic-authentication-emailalert-class.php in Easy Basic Authentication – Add basic auth to site or admin area 2.2, at class/easy-basic-authentication-emailalert-class.php

40 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class easy_basic_authentication_emailalert_class {
4
5 public function __construct()
6 {
7
8 }
9
10 public function is_enabled() {
11 return get_option( 'basic_auth_plugin_alert_enable' )&&filter_var(get_option( 'basic_auth_plugin_alertemail' ), FILTER_VALIDATE_EMAIL);
12 }
13
14 public function sendAlert($access){
15 $to = get_option('basic_auth_plugin_alertemail');
16 $subject = __('Access Attempt', 'easy-basic-authentication');
17 $message = '<html><body>';
18 $message .= '<p>' . __('Hi', 'easy-basic-authentication') . '</p>';
19 $message .= '<p>' . __('New access attempt detected:', 'easy-basic-authentication') . '</p>';
20 $message .= '<p><ul>
21 <li>ip: '.esc_attr($access['REMOTE_ADDR']).'</li>
22 <li>browser: '.esc_attr($access['HTTP_USER_AGENT']).'</li>
23 <li>request_uri: '.esc_attr($access['REQUEST_URI']).'</li>
24 </ul></p>';
25 $message .= '<p>' . __('All text of the call:', 'easy-basic-authentication') . '</p>';
26 $message .= '<p style="font-size: 0.8em">' . wp_json_encode($access) . '</p>';
27 $message .= '<p>' . __('You are receiving this email because you have installed Easy Basic Authentication on your website and enabled the email alert option.', 'easy-basic-authentication') . '</p>';
28 $message .= '</body></html>';
29
30 $site_email = get_option('admin_email');
31
32 $headers = array(
33 'Content-Type: text/html; charset=UTF-8',
34 'From: ' . $site_email,
35 );
36
37 wp_mail($to, $subject, $message, $headers);
38 }
39
40 }