PluginProbe
Easy Basic Authentication – Add basic auth to site or admin area / 3.2
Easy Basic Authentication – Add basic auth to site or admin area v3.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 3.2, at class/easy-basic-authentication-emailalert-class.php

43 lines 2.0 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
18 $message = '<html><body>';
19 $message .= '<p>' . __('Hi', 'easy-basic-authentication') . ',</p>';
20 $message .= '<p>' . __('New access attempt detected:', 'easy-basic-authentication') . '</p>';
21 $message .= '<ul style="list-style-type: none; padding-left: 0;">';
22 $message .= '<li><strong>' . __('IP:', 'easy-basic-authentication') . '</strong> ' . esc_attr($access['REMOTE_ADDR']) . '</li>';
23 $message .= '<li><strong>' . __('Browser:', 'easy-basic-authentication') . '</strong> ' . esc_attr($access['HTTP_USER_AGENT']) . '</li>';
24 $message .= '<li><strong>' . __('Request URI:', 'easy-basic-authentication') . '</strong> ' . esc_attr($access['REQUEST_URI']) . '</li>';
25 $message .= '</ul>';
26 $message .= '<p>' . __('All text of the call:', 'easy-basic-authentication') . '</p>';
27 $message .= '<pre style="font-size: 0.8em; background-color: #f8f8f8; padding: 10px;">' . esc_html(wp_json_encode($access, JSON_PRETTY_PRINT)) . '</pre>';
28 $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>';
29 $message .= '</body></html>';
30
31 $site_email = get_option('admin_email');
32
33 $headers = array(
34 'Content-Type: text/html; charset=UTF-8',
35 'From: ' . $site_email,
36 );
37
38 // Invio dell'email
39 wp_mail($to, $subject, $message, $headers);
40 }
41
42
43 }