-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdragonip.php
More file actions
610 lines (531 loc) · 28.2 KB
/
Copy pathdragonip.php
File metadata and controls
610 lines (531 loc) · 28.2 KB
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
<?php
/**
* Plugin Name: DragonIP
* Plugin URI: https://cwmbyte.com/
* Description: Mask admin user IP addresses - both historical data and future activity
* Version: 1.0
* Author: CwmByte
* License: GPL2+
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
class DragonIP {
private $masked_ip = '127.0.0.1';
private $admin_username = ''; // Will be set to current user by default
public function __construct() {
add_action('admin_menu', array($this, 'add_admin_menu'));
add_action('admin_init', array($this, 'handle_masking'));
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
// Set default user to current user if not set
$this->set_default_user();
// Hook into future IP logging
add_action('init', array($this, 'init_ip_masking'));
}
private function set_default_user() {
$current_user_id = get_current_user_id();
if ($current_user_id && !get_option('dragon_ip_target_user', false)) {
update_option('dragon_ip_target_user', $current_user_id);
}
}
public function activate() {
// Set default user on activation
$current_user_id = get_current_user_id();
if ($current_user_id) {
update_option('dragon_ip_target_user', $current_user_id);
}
// Set default future masking to disabled
if (!get_option('dragon_ip_future_enabled', false)) {
update_option('dragon_ip_future_enabled', false);
}
}
public function add_admin_menu() {
add_management_page(
'DragonIP',
'DragonIP',
'manage_options',
'dragon-ip',
array($this, 'admin_page')
);
}
public function enqueue_admin_scripts($hook) {
// Only enqueue on our plugin page
if ('tools_page_dragon-ip' !== $hook) {
return;
}
wp_add_inline_script('jquery', '
function toggleAllAreas() {
var selectAll = document.getElementById("select_all_areas");
var checkboxes = document.querySelectorAll("input[name=\"mask_areas[]\"]");
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = selectAll.checked;
}
}
');
}
public function admin_page() {
$current_user = wp_get_current_user();
?>
<div class="wrap">
<h1>🐉 DragonIP - IP Address Masker</h1>
<div style="background: #e3f2fd; padding: 15px; margin: 20px 0; border-left: 4px solid #2196f3;">
<h3>🎭 What This Does</h3>
<p><strong>Historical:</strong> Changes existing IP addresses to 127.0.0.1</p>
<p><strong>Future:</strong> Automatically masks new IP addresses</p>
</div>
<div style="background: #fff3e0; padding: 15px; margin: 20px 0; border-left: 4px solid #ff9800;">
<h3>⚠️ Important</h3>
<p>• Permanently overwrites IP addresses - backup database first!</p>
<p>• Future masking stays active until disabled</p>
</div>
<div style="background: #fff; padding: 20px; margin: 20px 0; border: 1px solid #ccd0d4;">
<h2>⚙️ User Settings</h2>
<p>Configure which user's IP addresses should be masked</p>
<form method="post" action="">
<?php wp_nonce_field('set_default_user', 'default_user_nonce'); ?>
<input type="hidden" name="action" value="set_default_user">
<table class="form-table">
<tr>
<th scope="row">Default User</th>
<td>
<?php
$current_user = wp_get_current_user();
$current_user_id = get_current_user_id();
$saved_user_id = get_option('dragon_ip_target_user', $current_user_id);
$saved_user = get_user_by('id', $saved_user_id);
?>
<p><strong>Current User:</strong> <?php echo esc_html($current_user->user_login); ?> (ID: <?php echo esc_html($current_user_id); ?>)</p>
<p><strong>Saved Target User:</strong> <?php echo $saved_user ? esc_html($saved_user->user_login) : 'None'; ?> (ID: <?php echo esc_html($saved_user_id); ?>)</p>
<p class="description">The default user is automatically set to the current logged-in user. You can change this below.</p>
</td>
</tr>
<tr>
<th scope="row">Set Target User</th>
<td>
<?php
wp_dropdown_users(array(
'name' => 'default_target_user_id',
'show_option_none' => 'Select user to set as default...',
'option_none_value' => '',
'selected' => $saved_user_id,
'role__in' => array('administrator') // Only show admins for safety
));
?>
<p class="description">This user will be used as the default target for IP masking operations</p>
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="💾 Save User Settings" />
</p>
</form>
</div>
<div style="background: #fff; padding: 20px; margin: 20px 0; border: 1px solid #ccd0d4;">
<h2>🔍 Historical IP Masking</h2>
<p>Overwrite ALL existing IP addresses for the admin user with 127.0.0.1</p>
<form method="post" action="">
<?php wp_nonce_field('mask_historical_action', 'mask_historical_nonce'); ?>
<input type="hidden" name="action" value="mask_historical">
<table class="form-table">
<tr>
<th scope="row">Target User</th>
<td>
<?php
wp_dropdown_users(array(
'name' => 'target_user_id',
'show_option_none' => 'Select user to mask...',
'option_none_value' => '',
'selected' => get_option('dragon_ip_target_user', ''),
'role__in' => array('administrator') // Only show admins for safety
));
?>
<p class="description">Select the user whose IP history should be masked to 127.0.0.1</p>
</td>
</tr>
<tr>
<th scope="row">Areas to Mask</th>
<td>
<label><input type="checkbox" id="select_all_areas" onclick="toggleAllAreas()"> <strong>Select All</strong></label><br><br>
<label><input type="checkbox" name="mask_areas[]" value="comments" checked> Comments</label><br>
<label><input type="checkbox" name="mask_areas[]" value="usermeta" checked> User Meta Data</label><br>
<label><input type="checkbox" name="mask_areas[]" value="wordfence" checked> Wordfence Logs</label><br>
<label><input type="checkbox" name="mask_areas[]" value="ithemes" checked> iThemes Security</label><br>
<label><input type="checkbox" name="mask_areas[]" value="security_plugins" checked> Security Plugins (Sucuri, MalCare, etc.)</label><br>
<label><input type="checkbox" name="mask_areas[]" value="activity_logs" checked> Activity Logs</label><br>
<label><input type="checkbox" name="mask_areas[]" value="all_logs" checked> All Log Tables</label>
</td>
</tr>
<tr>
<th scope="row">Confirmation</th>
<td>
<label><input type="checkbox" name="confirm_historical" required>
I understand this will permanently overwrite existing IP addresses with 127.0.0.1</label>
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="🎭 Mask Historical IPs"
onclick="return confirm('This will permanently change IP addresses to 127.0.0.1. Are you sure?');" />
</p>
</form>
</div>
<div style="background: #fff; padding: 20px; margin: 20px 0; border: 1px solid #ccd0d4;">
<h2>🚀 Future IP Masking</h2>
<p>Automatically mask IP addresses for future admin activity</p>
<form method="post" action="">
<?php wp_nonce_field('toggle_future_masking', 'future_masking_nonce'); ?>
<input type="hidden" name="action" value="toggle_future_masking">
<table class="form-table">
<tr>
<th scope="row">Current Status</th>
<td>
<?php
$future_masking = get_option('dragon_ip_future_enabled', false);
$target_user = get_option('dragon_ip_target_user', '');
$user_info = $target_user ? get_user_by('id', $target_user) : null;
?>
<strong style="color: <?php echo $future_masking ? '#4caf50' : '#f44336'; ?>">
<?php echo $future_masking ? '✅ ACTIVE' : '❌ INACTIVE'; ?>
</strong>
<?php if ($user_info): ?>
<p class="description">Target User: <?php echo esc_html($user_info->user_login); ?></p>
<?php endif; ?>
</td>
</tr>
<tr>
<th scope="row">Target User</th>
<td>
<?php
wp_dropdown_users(array(
'name' => 'future_target_user_id',
'show_option_none' => 'Select user to mask...',
'option_none_value' => '',
'selected' => get_option('dragon_ip_target_user', ''),
'role__in' => array('administrator')
));
?>
<p class="description">This user's future IP addresses will be automatically masked to 127.0.0.1</p>
</td>
</tr>
</table>
<p class="submit">
<?php if ($future_masking): ?>
<input type="submit" name="disable_future" class="button-secondary" value="🛑 Disable Future Masking" />
<?php else: ?>
<input type="submit" name="enable_future" class="button-primary" value="🚀 Enable Future Masking" />
<?php endif; ?>
</p>
</form>
</div>
<?php if (isset($_GET['message'])): ?>
<div class="notice notice-success">
<p><?php echo esc_html(sanitize_text_field($_GET['message'])); ?></p>
</div>
<?php endif; ?>
<?php if (isset($_GET['error'])): ?>
<div class="notice notice-error">
<p><?php echo esc_html(sanitize_text_field($_GET['error'])); ?></p>
</div>
<?php endif; ?>
<div style="background: #f8f9fa; padding: 15px; margin: 20px 0; border: 1px solid #e9ecef; text-align: center; border-radius: 5px;">
<p style="margin: 0; color: #6c757d; font-size: 14px;">
DragonIP by <a href="https://cwmbyte.com/" target="_blank" style="color: #007cba; text-decoration: none;">CwmByte</a> |
<a href="https://cwmbyte.com/" target="_blank" style="color: #007cba; text-decoration: none;">Visit Our Website</a>
</p>
</div>
</div>
<?php
}
public function handle_masking() {
if (!isset($_POST['action'])) {
return;
}
if (sanitize_text_field($_POST['action']) === 'set_default_user') {
if (!isset($_POST['default_user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['default_user_nonce'])), 'set_default_user')) {
wp_die('Security check failed');
}
$this->set_target_user();
}
if (sanitize_text_field($_POST['action']) === 'mask_historical') {
if (!isset($_POST['mask_historical_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['mask_historical_nonce'])), 'mask_historical_action')) {
wp_die('Security check failed');
}
$this->mask_historical_ips();
}
if (sanitize_text_field($_POST['action']) === 'toggle_future_masking') {
if (!isset($_POST['future_masking_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['future_masking_nonce'])), 'toggle_future_masking')) {
wp_die('Security check failed');
}
$this->toggle_future_masking();
}
}
private function set_target_user() {
$target_user_id = intval(sanitize_text_field($_POST['default_target_user_id']));
if (empty($target_user_id)) {
wp_redirect(admin_url('tools.php?page=dragon-ip&error=' . urlencode('Please select a target user.')));
exit;
}
$user = get_user_by('id', $target_user_id);
if (!$user) {
wp_redirect(admin_url('tools.php?page=dragon-ip&error=' . urlencode('Invalid user selected.')));
exit;
}
update_option('dragon_ip_target_user', $target_user_id);
$message = "💾 Target user set to: {$user->user_login} (ID: {$target_user_id})";
wp_redirect(admin_url('tools.php?page=dragon-ip&message=' . urlencode($message)));
exit;
}
private function mask_historical_ips() {
if (empty(sanitize_text_field($_POST['target_user_id'])) || !isset($_POST['confirm_historical'])) {
wp_redirect(admin_url('tools.php?page=dragon-ip&error=' . urlencode('Please select a user and confirm the action.')));
exit;
}
$user_id = intval(sanitize_text_field($_POST['target_user_id']));
$mask_areas = isset($_POST['mask_areas']) ? array_map('sanitize_text_field', $_POST['mask_areas']) : array();
$user = get_user_by('id', $user_id);
if (!$user) {
wp_redirect(admin_url('tools.php?page=dragon-ip&error=' . urlencode('Invalid user selected.')));
exit;
}
global $wpdb;
$results = array();
$username = $user->user_login;
$user_email = $user->user_email;
// Comments
if (in_array('comments', $mask_areas)) {
$count = $wpdb->query($wpdb->prepare(
"UPDATE {$wpdb->comments} SET comment_author_IP = %s WHERE user_id = %d",
$this->masked_ip, $user_id
));
if ($user_email) {
$count += $wpdb->query($wpdb->prepare(
"UPDATE {$wpdb->comments} SET comment_author_IP = %s WHERE comment_author_email = %s",
$this->masked_ip, $user_email
));
}
$results[] = "Comments: {$count} IPs masked";
}
// User Meta
if (in_array('usermeta', $mask_areas)) {
// Find all IP-related meta keys (exclude biography and other non-IP fields)
$ip_metas = $wpdb->get_results($wpdb->prepare(
"SELECT umeta_id, meta_key FROM {$wpdb->usermeta}
WHERE user_id = %d
AND (
meta_key LIKE '%_ip%' OR
meta_key LIKE '%ip_%' OR
meta_key = 'last_login_ip' OR
meta_key = 'login_ip' OR
meta_key = 'user_ip' OR
meta_key = 'registration_ip'
)
AND meta_key NOT IN ('description', 'biography', 'user_description')
AND meta_key NOT LIKE '%bio%'
AND meta_key NOT LIKE '%description%'",
$user_id
));
if ($ip_metas && is_array($ip_metas)) {
foreach ($ip_metas as $meta) {
$wpdb->update(
$wpdb->usermeta,
array('meta_value' => $this->masked_ip),
array('umeta_id' => $meta->umeta_id)
);
}
$results[] = "User Meta: " . count($ip_metas) . " IP entries masked";
} else {
$results[] = "User Meta: 0 IP entries masked";
}
}
// Wordfence
if (in_array('wordfence', $mask_areas)) {
$wf_count = 0;
$wf_logins_table = $wpdb->prefix . 'wfLogins';
$wf_hits_table = $wpdb->prefix . 'wfHits';
if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $wf_logins_table))) {
$wf_count += $wpdb->query($wpdb->prepare(
"UPDATE %s SET IP = INET_ATON(%s) WHERE userID = %d",
$wf_logins_table, $this->masked_ip, $user_id
));
}
if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $wf_hits_table))) {
$wf_count += $wpdb->query($wpdb->prepare(
"UPDATE %s SET IP = INET_ATON(%s) WHERE userID = %d",
$wf_hits_table, $this->masked_ip, $user_id
));
}
$results[] = "Wordfence: {$wf_count} entries masked";
}
// Security Plugins (Sucuri, MalCare, All In One WP Security, Security Ninja, etc.)
if (in_array('security_plugins', $mask_areas)) {
$security_tables = $wpdb->get_results("
SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME LIKE '{$wpdb->prefix}%'
AND (COLUMN_NAME LIKE '%ip%' OR COLUMN_NAME LIKE '%IP%')
AND TABLE_NAME NOT LIKE '%wf%'
AND (
TABLE_NAME LIKE '%sucuri%' OR
TABLE_NAME LIKE '%malcare%' OR
TABLE_NAME LIKE '%aiowps%' OR
TABLE_NAME LIKE '%security_ninja%' OR
TABLE_NAME LIKE '%audit%' OR
TABLE_NAME LIKE '%login%' OR
TABLE_NAME LIKE '%firewall%' OR
TABLE_NAME LIKE '%security%'
)
", ARRAY_A);
$security_count = 0;
foreach ($security_tables as $table_info) {
$table_name = $table_info['TABLE_NAME'];
$column_name = $table_info['COLUMN_NAME'];
// Check if table has user_id column
$has_user_id = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, 'user_id'));
if ($has_user_id) {
$security_count += $wpdb->query($wpdb->prepare(
"UPDATE %s SET %s = %s WHERE user_id = %d",
$table_name, $column_name, $this->masked_ip, $user_id
));
}
// Also check for username columns
$has_username = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, '%username%'));
if ($has_username) {
$username_col = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, '%username%'));
$security_count += $wpdb->query($wpdb->prepare(
"UPDATE %s SET %s = %s WHERE %s = %s",
$table_name, $column_name, $this->masked_ip, $username_col, $username
));
}
// Check for email columns
$has_email = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, '%email%'));
if ($has_email && $user_email) {
$email_col = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, '%email%'));
$security_count += $wpdb->query($wpdb->prepare(
"UPDATE %s SET %s = %s WHERE %s = %s",
$table_name, $column_name, $this->masked_ip, $email_col, $user_email
));
}
}
$table_count = ($security_tables && is_array($security_tables)) ? count($security_tables) : 0;
$results[] = "Security Plugins: {$security_count} IP entries masked across " . $table_count . " tables";
}
// All log tables - find any table with IP columns
if (in_array('all_logs', $mask_areas)) {
$tables_with_ip = $wpdb->get_results("
SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME LIKE '{$wpdb->prefix}%'
AND (COLUMN_NAME LIKE '%ip%' OR COLUMN_NAME LIKE '%IP%')
AND TABLE_NAME NOT LIKE '%wf%'
", ARRAY_A);
$log_count = 0;
foreach ($tables_with_ip as $table_info) {
$table_name = $table_info['TABLE_NAME'];
$column_name = $table_info['COLUMN_NAME'];
// Check if table has user_id column
$has_user_id = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, 'user_id'));
if ($has_user_id) {
$log_count += $wpdb->query($wpdb->prepare(
"UPDATE %s SET %s = %s WHERE user_id = %d",
$table_name, $column_name, $this->masked_ip, $user_id
));
}
// Also check for username columns
$has_username = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, '%username%'));
if ($has_username) {
$username_col = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM %s LIKE %s", $table_name, '%username%'));
$log_count += $wpdb->query($wpdb->prepare(
"UPDATE %s SET %s = %s WHERE %s = %s",
$table_name, $column_name, $this->masked_ip, $username_col, $username
));
}
}
$table_count = ($tables_with_ip && is_array($tables_with_ip)) ? count($tables_with_ip) : 0;
$results[] = "Log Tables: {$log_count} IP entries masked across " . $table_count . " tables";
}
// Save the target user for future masking
update_option('dragon_ip_target_user', $user_id);
$message = "🎭 Historical IP masking completed for '{$username}'. " . implode(' | ', $results);
wp_redirect(admin_url('tools.php?page=dragon-ip&message=' . urlencode($message)));
exit;
}
private function toggle_future_masking() {
$target_user_id = intval(sanitize_text_field($_POST['future_target_user_id']));
if (empty($target_user_id)) {
wp_redirect(admin_url('tools.php?page=dragon-ip&error=' . urlencode('Please select a target user.')));
exit;
}
if (isset($_POST['enable_future'])) {
update_option('dragon_ip_future_enabled', true);
update_option('dragon_ip_target_user', $target_user_id);
$message = "🚀 Future IP masking ENABLED for user ID: {$target_user_id}";
} else {
update_option('dragon_ip_future_enabled', false);
$message = "🛑 Future IP masking DISABLED";
}
wp_redirect(admin_url('tools.php?page=dragon-ip&message=' . urlencode($message)));
exit;
}
public function init_ip_masking() {
if (!get_option('dragon_ip_future_enabled', false)) {
return;
}
$target_user_id = get_option('dragon_ip_target_user', 0);
if (!$target_user_id || get_current_user_id() !== intval($target_user_id)) {
return;
}
// Hook into various WordPress actions that log IPs
add_action('wp_insert_comment', array($this, 'mask_comment_ip'), 10, 2);
add_action('wp_login', array($this, 'mask_login_ip'), 10, 2);
add_filter('pre_comment_author_ip', array($this, 'filter_comment_ip'));
// Override $_SERVER variables for this user
add_action('init', array($this, 'override_server_ip'), 1);
}
public function override_server_ip() {
if (!get_option('dragon_ip_future_enabled', false)) {
return;
}
$target_user_id = get_option('dragon_ip_target_user', 0);
if (!$target_user_id || get_current_user_id() !== intval($target_user_id)) {
return;
}
// Override common IP server variables
$_SERVER['REMOTE_ADDR'] = $this->masked_ip;
$_SERVER['HTTP_X_FORWARDED_FOR'] = $this->masked_ip;
$_SERVER['HTTP_X_REAL_IP'] = $this->masked_ip;
$_SERVER['HTTP_CLIENT_IP'] = $this->masked_ip;
}
public function mask_comment_ip($comment_id, $comment_obj) {
$target_user_id = get_option('dragon_ip_target_user', 0);
if ($comment_obj && isset($comment_obj->user_id) && $comment_obj->user_id == $target_user_id) {
global $wpdb;
$wpdb->update(
$wpdb->comments,
array('comment_author_IP' => $this->masked_ip),
array('comment_ID' => $comment_id)
);
}
}
public function filter_comment_ip($ip) {
$target_user_id = get_option('dragon_ip_target_user', 0);
if ($target_user_id && get_current_user_id() === intval($target_user_id)) {
return $this->masked_ip;
}
return $ip;
}
public function mask_login_ip($user_login, $user) {
$target_user_id = get_option('dragon_ip_target_user', 0);
if ($target_user_id && $user->ID === intval($target_user_id)) {
// This will help with any login logging that happens after this hook
$_SERVER['REMOTE_ADDR'] = $this->masked_ip;
}
}
}
// Initialize DragonIP
$dragon_ip = new DragonIP();
// Register activation hook
register_activation_hook(__FILE__, array($dragon_ip, 'activate'));
?>