| 1 |
<?php |
| 2 |
if( ! defined('WP_UNINSTALL_PLUGIN') ) |
| 3 |
exit; |
| 4 |
|
| 5 |
if( ! defined('WTSEC_PLUGIN_PREFIX') ) |
| 6 |
define("WTSEC_PLUGIN_PREFIX", 'wtsec_'); |
| 7 |
|
| 8 |
wtsec_deleteAllAgentsFiles(); |
| 9 |
deleteOptions(); |
| 10 |
|
| 11 |
function wtsec_deleteAllAgentsFiles(){ |
| 12 |
global $wp_filesystem; |
| 13 |
|
| 14 |
if (empty($wp_filesystem)) { |
| 15 |
require_once(ABSPATH . '/wp-admin/includes/file.php'); |
| 16 |
WP_Filesystem(); |
| 17 |
} |
| 18 |
$target_dir = $wp_filesystem->find_folder($wp_filesystem->abspath()); |
| 19 |
$list = $wp_filesystem->dirlist($target_dir); |
| 20 |
|
| 21 |
foreach ($list as $item){ |
| 22 |
$target_item = trailingslashit($target_dir) . $item['name']; |
| 23 |
$recursive = ($item['type'] == 'd') ? true : false; |
| 24 |
if( wtsec_multineedle_stripos( $item['name'], ['.am.php','.waf.php','.av.php','.wtotem_'] ) ){ |
| 25 |
$wp_filesystem->delete($target_item, $recursive, $item['type']); |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
function wtsec_multineedle_stripos($haystack, $needles, $offset = 0) { |
| 32 |
foreach($needles as $needle) { |
| 33 |
if(stripos($haystack, $needle, $offset)){ |
| 34 |
return true; |
| 35 |
} |
| 36 |
} |
| 37 |
return false; |
| 38 |
} |
| 39 |
|
| 40 |
function deleteOptions(){ |
| 41 |
$options = [ |
| 42 |
'api_key', 'api_key_safe', 'api_key_activated', 'authorized', 'authToken', |
| 43 |
'waf_installed_file','am_installed_file','am_installed', 'logout', |
| 44 |
'av_installed', 'waf_installed', 'agents_installed', 'api_url', |
| 45 |
'color_scheme' ,'time_zone', |
| 46 |
'token_expired','deactivated', 'antivirus_event','antivirus_permissions_changed', |
| 47 |
'antivirus_endCursor', 'antivirus_hasNextPage', |
| 48 |
'firewall_endCursor', 'firewall_hasNextPage', |
| 49 |
'reports_endCursor', 'reports_hasNextPage']; |
| 50 |
|
| 51 |
foreach ($options as $option) { |
| 52 |
delete_option(WTSEC_PLUGIN_PREFIX.$option); |
| 53 |
delete_site_option(WTSEC_PLUGIN_PREFIX.$option); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|