| @@ -63,15 +63,8 @@ | ||
| 63 | 63 | |
| 64 | 64 | public const KEY = 'defender_last_settings', INDEXER = 'defender_config_indexer'; |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | - * Indicates whether the current installation is a pro version. | |
| 68 | - * | |
| 69 | - * @var bool | |
| 70 | - */ | |
| 71 | - private $is_pro; | |
| 72 | - | |
| 73 | - /** | |
| 74 | 67 | * Indicates whether the site has a HUB API key (true for both free and pro with Hub connected). |
| 75 | 68 | * |
| 76 | 69 | * @var bool |
| 77 | 70 | */ |
| @@ -81,11 +74,10 @@ | ||
| 81 | 74 | * Constructor for the Backup_Settings class. |
| 82 | 75 | * It initializes the class and sets whether the current installation is a pro version. |
| 83 | 76 | */ |
| 84 | 77 | public function __construct() { |
| 85 | - $wpmudev = new WPMUDEV(); | |
| 86 | - $this->is_pro = $wpmudev->is_pro(); | |
| 87 | - $this->has_hub_api_key = false !== $wpmudev->get_apikey(); | |
| 78 | + $wpmudev = wd_di()->get( WPMUDEV::class ); | |
| 79 | + $this->has_hub_api_key = $wpmudev->is_apikey_available(); | |
| 88 | 80 | } |
| 89 | 81 | |
| 90 | 82 | /** |
| 91 | 83 | * Changes the format of subscribers in a notification object to an array format. |
| @@ -170,9 +162,26 @@ | ||
| 170 | 162 | 'email_content_issue_not_found' => $scan_notification->configs['template']['not_found']['body'], |
| 171 | 163 | 'email_content_issue_found' => $scan_notification->configs['template']['found']['body'], |
| 172 | 164 | 'email_content_error' => $scan_notification->configs['template']['error']['body'], |
| 173 | 165 | ); |
| 166 | + if ( class_exists( Model_Audit_Logging::class ) ) { | |
| 167 | + $settings = new Model_Audit_Logging(); | |
| 168 | + $audit_report = new Audit_Report(); | |
| 169 | + $audit = array( | |
| 170 | + 'enabled' => $settings->is_active(), | |
| 171 | + 'report' => 'disabled', | |
| 172 | + 'subscribers' => $this->change_subscriber_format( $audit_report ), | |
| 173 | + 'frequency' => $audit_report->frequency, | |
| 174 | + 'day' => $audit_report->day, | |
| 175 | + 'day_n' => $audit_report->day_n, | |
| 176 | + 'time' => $audit_report->time, | |
| 177 | + // @since 2.7.0 We can remove it in the next version. | |
| 178 | + 'dry_run' => false, | |
| 179 | + 'storage_days' => $settings->storage_days, | |
| 180 | + ); | |
| 181 | + } else { | |
| 174 | 182 | $audit['enabled'] = false; |
| 183 | + } | |
| 175 | 184 | |
| 176 | 185 | $settings_firewall = new Model_Firewall(); |
| 177 | 186 | $settings_ll = new Model_Login_Lockout(); |
| 178 | 187 | $settings_nl = new Model_Notfound_Lockout(); |
| @@ -419,10 +428,11 @@ | ||
| 419 | 428 | $default_ua_lockout_values = ( new Model_Ua_Lockout() )->get_default_values(); |
| 420 | 429 | $default_password_protection_values = ( new Model_Password_Protection() )->get_default_values(); |
| 421 | 430 | $default_2fa_values = ( new Model_Two_Fa() )->get_default_values(); |
| 422 | 431 | $default_scan_settings = wd_di()->get( Model_Scan::class ); |
| 432 | + | |
| 423 | 433 | // Total data. |
| 424 | - $data = array( | |
| 434 | + $data = array( | |
| 425 | 435 | 'scan' => array( |
| 426 | 436 | 'integrity_check' => true, |
| 427 | 437 | 'check_core' => true, |
| 428 | 438 | 'check_plugins' => true, |
| @@ -575,9 +585,20 @@ | ||
| 575 | 585 | 'user_roles' => $user_roles, |
| 576 | 586 | 'lock_properties' => array(), |
| 577 | 587 | ), |
| 578 | 588 | ); |
| 579 | - $data['audit']['enabled'] = false; | |
| 589 | + $data['audit'] = array( | |
| 590 | + 'enabled' => true, | |
| 591 | + 'report' => 'disabled', | |
| 592 | + 'subscribers' => $default_recipients, | |
| 593 | + 'frequency' => 'weekly', | |
| 594 | + 'day' => 'sunday', | |
| 595 | + 'day_n' => 1, | |
| 596 | + 'time' => '4:00', | |
| 597 | + // @since 2.7.0 We can remove it in the next version. | |
| 598 | + 'dry_run' => false, | |
| 599 | + 'storage_days' => '6 months', | |
| 600 | + ); | |
| 580 | 601 | if ( $this->has_hub_api_key ) { |
| 581 | 602 | $data['blocklist_monitor'] = array( |
| 582 | 603 | // @since 2.7.0 Enable. |
| 583 | 604 | 'enabled' => true, |
| @@ -749,9 +770,13 @@ | ||
| 749 | 770 | // Reset all recipients before. |
| 750 | 771 | $scan_notification->in_house_recipients = array(); |
| 751 | 772 | $scan_notification->out_house_recipients = array(); |
| 752 | 773 | foreach ( $module_data['notification_subscribers'] as $key => $subscribers ) { |
| 753 | - $scan_notification->$key = $subscribers; | |
| 774 | + if ( 'in_house_recipients' === $key ) { | |
| 775 | + $scan_notification->in_house_recipients = $subscribers; | |
| 776 | + } elseif ( 'out_house_recipients' === $key ) { | |
| 777 | + $scan_notification->out_house_recipients = $subscribers; | |
| 778 | + } | |
| 754 | 779 | } |
| 755 | 780 | } |
| 756 | 781 | $scan_notification->save(); |
| 757 | 782 | } |
| @@ -762,9 +787,13 @@ | ||
| 762 | 787 | // Reset all recipients before. |
| 763 | 788 | $scan_report->in_house_recipients = array(); |
| 764 | 789 | $scan_report->out_house_recipients = array(); |
| 765 | 790 | foreach ( $module_data['report_subscribers'] as $key => $subscribers ) { |
| 766 | - $scan_report->$key = $subscribers; | |
| 791 | + if ( 'in_house_recipients' === $key ) { | |
| 792 | + $scan_report->in_house_recipients = $subscribers; | |
| 793 | + } elseif ( 'out_house_recipients' === $key ) { | |
| 794 | + $scan_report->out_house_recipients = $subscribers; | |
| 795 | + } | |
| 767 | 796 | } |
| 768 | 797 | } |
| 769 | 798 | // Step#2 if 'scheduled_scanning'-key exists. |
| 770 | 799 | if ( isset( $module_data['scheduled_scanning'] ) ) { |
| @@ -833,9 +862,13 @@ | ||
| 833 | 862 | // Reset all recipients before. |
| 834 | 863 | $lockout_notification->in_house_recipients = array(); |
| 835 | 864 | $lockout_notification->out_house_recipients = array(); |
| 836 | 865 | foreach ( $module_data['notification_subscribers'] as $key => $subscribers ) { |
| 837 | - $lockout_notification->$key = $subscribers; | |
| 866 | + if ( 'in_house_recipients' === $key ) { | |
| 867 | + $lockout_notification->in_house_recipients = $subscribers; | |
| 868 | + } elseif ( 'out_house_recipients' === $key ) { | |
| 869 | + $lockout_notification->out_house_recipients = $subscribers; | |
| 870 | + } | |
| 838 | 871 | } |
| 839 | 872 | } |
| 840 | 873 | |
| 841 | 874 | $lockout_notification->save(); |
| @@ -887,9 +920,13 @@ | ||
| 887 | 920 | // Reset all recipients before. |
| 888 | 921 | $audit_report->in_house_recipients = array(); |
| 889 | 922 | $audit_report->out_house_recipients = array(); |
| 890 | 923 | foreach ( $module_data['subscribers'] as $key => $subscribers ) { |
| 891 | - $audit_report->$key = $subscribers; | |
| 924 | + if ( 'in_house_recipients' === $key ) { | |
| 925 | + $audit_report->in_house_recipients = $subscribers; | |
| 926 | + } elseif ( 'out_house_recipients' === $key ) { | |
| 927 | + $audit_report->out_house_recipients = $subscribers; | |
| 928 | + } | |
| 892 | 929 | } |
| 893 | 930 | } |
| 894 | 931 | if ( isset( $module_data['last_sent'] ) ) { |
| 895 | 932 | $audit_report->last_sent = $module_data['last_sent']; |