PluginProbe ʕ •ᴥ•ʔ
NinjaFirewall (WP Edition) – Advanced Security Plugin and Firewall / trunk
NinjaFirewall (WP Edition) – Advanced Security Plugin and Firewall vtrunk
4.8.8 4.8.7 4.8.6 trunk 4.5 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6 4.6.1 4.7 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.8 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5
ninjafirewall / uninstall.php
ninjafirewall Last commit date
images 3 weeks ago languages 9 months ago lib 1 week ago static 1 week ago .htaccess 7 years ago .htninja.sample 2 years ago LICENSE.TXT 13 years ago index.html 12 years ago ninjafirewall.php 1 week ago readme.txt 1 week ago uninstall.php 1 year ago
uninstall.php
134 lines
1 <?php
2 /*
3 +---------------------------------------------------------------------+
4 | NinjaFirewall (WP Edition) |
5 | |
6 | (c) NinTechNet - https://nintechnet.com/ |
7 +---------------------------------------------------------------------+
8 | This program is free software: you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License as |
10 | published by the Free Software Foundation, either version 3 of |
11 | the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 +---------------------------------------------------------------------+ sa / 2
18 */
19
20 if (! defined('WP_UNINSTALL_PLUGIN') ) {
21 exit;
22 }
23
24 nfw_uninstall();
25
26 // ---------------------------------------------------------------------
27
28 function nfw_uninstall() {
29
30 if (! defined( 'NFW_ENGINE_VERSION' ) ) { define( 'NFW_ENGINE_VERSION', true ); }
31
32 if (! defined('NINJAFIREWALL_MU_PLUGIN') ) {
33 define('NINJAFIREWALL_MU_PLUGIN', '0-ninjafirewall.php');
34 }
35
36 if (! function_exists( 'get_home_path' ) ) {
37 include_once ABSPATH .'wp-admin/includes/file.php';
38 }
39 $NFW_ABSPATH = get_home_path();
40
41 define( 'HTACCESS_BEGIN', '# BEGIN NinjaFirewall' );
42 define( 'HTACCESS_END', '# END NinjaFirewall' );
43 define( 'PHPINI_BEGIN', '; BEGIN NinjaFirewall' );
44 define( 'PHPINI_END', '; END NinjaFirewall' );
45 define( 'WP_CONFIG_BEGIN', '// BEGIN NinjaFirewall' );
46 define( 'WP_CONFIG_END', '// END NinjaFirewall' );
47
48 // Retrieve installation info :
49 if ( is_multisite() ) {
50 $nfw_install = get_site_option('nfw_install');
51 } else {
52 $nfw_install = get_option('nfw_install');
53 }
54
55 // Clean-up wp-config.php:
56 if (! empty( $nfw_install['wp_config'] ) && file_exists( $nfw_install['wp_config'] ) && is_writable( $nfw_install['wp_config'] ) ) {
57 $wp_config_content = @file_get_contents( $nfw_install['wp_config'] );
58 $wp_config_content = preg_replace( '`\s?'. WP_CONFIG_BEGIN .'.+?'. WP_CONFIG_END .'[^\r\n]*\s?`s' , "\n", $wp_config_content);
59 @file_put_contents( $nfw_install['wp_config'], $wp_config_content, LOCK_EX );
60 }
61
62 // Clean-up .htaccess :
63 if (! empty($nfw_install['htaccess']) && file_exists($nfw_install['htaccess']) ) {
64 $htaccess_file = $nfw_install['htaccess'];
65 } elseif ( file_exists( $NFW_ABSPATH . '.htaccess' ) ) {
66 $htaccess_file = $NFW_ABSPATH . '.htaccess';
67 } else {
68 $htaccess_file = '';
69 }
70
71 // Ensure it is writable :
72 if (! empty($htaccess_file) && is_writable( $htaccess_file ) ) {
73 $data = file_get_contents( $htaccess_file );
74 // Find / delete instructions :
75 $data = preg_replace( '`\s?'. HTACCESS_BEGIN .'.+?'. HTACCESS_END .'[^\r\n]*\s?`s' , "\n", $data);
76 @file_put_contents( $htaccess_file, $data, LOCK_EX );
77 }
78
79 // Clean up PHP INI file :
80 $phpini = array();
81 if (! empty($nfw_install['phpini']) && file_exists($nfw_install['phpini']) ) {
82 if ( is_writable( $nfw_install['phpini'] ) ) {
83 $phpini[] = $nfw_install['phpini'];
84 }
85 }
86 if ( file_exists( $NFW_ABSPATH . 'php.ini' ) ) {
87 if ( is_writable( $NFW_ABSPATH . 'php.ini' ) ) {
88 $phpini[] = $NFW_ABSPATH . 'php.ini';
89 }
90 }
91 if ( file_exists( $NFW_ABSPATH . 'php5.ini' ) ) {
92 if ( is_writable( $NFW_ABSPATH . 'php5.ini' ) ) {
93 $phpini[] = $NFW_ABSPATH . 'php5.ini';
94 }
95 }
96 if ( file_exists( $NFW_ABSPATH . '.user.ini' ) ) {
97 if ( is_writable( $NFW_ABSPATH . '.user.ini' ) ) {
98 $phpini[] = $NFW_ABSPATH . '.user.ini';
99 }
100 }
101 foreach( $phpini as $ini ) {
102 $data = file_get_contents( $ini );
103 $data = preg_replace( '`\s?'. PHPINI_BEGIN .'.+?'. PHPINI_END .'[^\r\n]*\s?`s' , "\n", $data);
104 @file_put_contents( $ini, $data, LOCK_EX );
105 }
106
107 // Remove any scheduled cron job
108 include_once 'lib/scheduled_tasks.php';
109 nfw_delete_scheduled_tasks();
110
111 // Delete DB rows :
112 delete_option('nfw_options');
113 delete_option('nfw_rules');
114 delete_option('nfw_install');
115 delete_option('nfw_tmp');
116 delete_option('nfw_checked');
117 if ( is_multisite() ) {
118 // Delete those ones too :
119 delete_site_option('nfw_options');
120 delete_site_option('nfw_rules');
121 delete_site_option('nfw_install');
122 delete_site_option('nfw_tmp');
123 delete_site_option('nfw_checked');
124 }
125
126 // Remove fallback loader
127 if ( file_exists( WPMU_PLUGIN_DIR .'/'. NINJAFIREWALL_MU_PLUGIN ) ) {
128 unlink( WPMU_PLUGIN_DIR .'/'. NINJAFIREWALL_MU_PLUGIN );
129 }
130 }
131
132 // ---------------------------------------------------------------------
133 // EOF
134