PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.2.0
Defender Security – Malware Scanner, Login Security & Firewall v6.2.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / traits / pro-database-tables.php

pro-database-tables.php in Defender Security – Malware Scanner, Login Security & Firewall 6.2.0, at src/traits/pro-database-tables.php

46 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Pro-only database table creation methods.
4 *
5 * @package WP_Defender\Traits
6 */
7
8 namespace WP_Defender\Traits;
9
10 /**
11 * Provides database table creation for Pro-only features (Audit Logging).
12 */
13 trait Pro_Database_Tables {
14
15 /**
16 * Creates the audit log table used for caching audit events.
17 */
18 protected function create_table_audit_log(): void {
19 global $wpdb;
20
21 $charset_collate = $wpdb->get_charset_collate();
22 // Audit log table. Though our data mainly store on API side, we will need a table for caching.
23 $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->base_prefix}defender_audit_log (
24 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
25 `timestamp` int NOT NULL,
26 `event_type` varchar(255) NOT NULL,
27 `action_type` varchar(255) NOT NULL,
28 `site_url` varchar(255) NOT NULL,
29 `user_id` int NOT NULL,
30 `context` varchar(255) NOT NULL,
31 `ip` varchar(45) NOT NULL,
32 `msg` varchar(255) NOT NULL,
33 `blog_id` int NOT NULL,
34 `synced` int NOT NULL,
35 `ttl` int NOT NULL,
36 PRIMARY KEY (`id`),
37 KEY `event_type` (`event_type`),
38 KEY `action_type` (`action_type`),
39 KEY `user_id` (`user_id`),
40 KEY `context` (`context`),
41 KEY `ip` (`ip`)
42 ) $charset_collate;";
43 $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
44 }
45 }
46