PluginProbe
WebTotem Security / 2.4.11
WebTotem Security v2.4.11
3.0.2 3.0.1 3.0.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 2.0 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.1 2.2.2 2.2.3 All 110 releases
← All changes | src/Common.php +84 -215 trunk2.4.11 View file →
@@ -1,243 +1,112 @@
1 1 <?php
2 2
3 3 if (!defined('WEBTOTEM_INIT') || WEBTOTEM_INIT !== true) {
4 - if (!headers_sent()) {
5 - header('HTTP/1.1 403 Forbidden');
6 - }
7 - die("Protected By WebTotem!");
8 -}
9 -
10 -add_action('upgrader_process_complete', 'wt_security_upgrade_complete', 10, 2);
11 -function wt_security_upgrade_complete($upgrader, $options)
12 -{
13 - /**
14 - * Creating a marker file after updating the plugin.
15 - */
16 - if ($options['type'] === 'plugin' && $options['action'] === 'update' && $upgrader->result['destination_name'] == 'wt-security') {
17 - WebTotemAgentManager::generateMarkerFile();
4 + if (!headers_sent()) {
5 + header('HTTP/1.1 403 Forbidden');
18 6 }
7 + die("Protected By WebTotem!");
19 8 }
20 9
21 -// WAF Include.
22 -WebTotemAgentManager::wafInclude();
23 -
24 10 if (defined('WEBTOTEM')) {
25 11
26 - /**
27 - * Define which javascript and css files will be loaded in the header of the plugin pages.
28 - */
29 - $_page = WebTotemRequest::get('page');
30 - if (strpos($_page, 'wtotem') === 0) {
31 - add_action('admin_enqueue_scripts', 'WebTotemInterface::enqueueScripts', 1);
32 - }
12 + /**
13 + * Remove the WordPress generator meta-tag from the source code.
14 + */
15 + remove_action('wp_head', 'wp_generator');
33 16
34 - add_filter('pre_current_active_plugins', 'WebTotemInterface::registerDeletePrompt');
17 + /**
18 + * Define which javascript and css files will be loaded in the header of the
19 + * plugin pages.
20 + */
21 + add_action('admin_enqueue_scripts', 'WebTotemInterface::enqueueScripts', 1);
35 22
36 - /** Define role of current user */
37 - add_action('init', 'WebTotem::getUserRole');
23 + /** Execute pre-checks before every page */
24 + add_action('wp_loaded', 'WebTotemInterface::startupChecks');
38 25
39 - /** Execute pre-checks before every page */
40 - add_action('init', 'WebTotemInterface::startupChecks');
26 + /** Add site or new sites if it is multisite */
27 + add_action( 'wp_insert_site', 'WebTotemInterface::addNewSite' );
41 28
42 - /** Attach HTTP request handlers for the AJAX requests */
43 - add_action('wp_ajax_nopriv_wtotem_ajax', 'wtotem_public_ajax_callback');
44 - add_action('wp_ajax_wtotem_ajax', 'wtotem_ajax_callback');
29 + /** Attach HTTP request handlers for the AJAX requests */
30 + add_action('wp_ajax_wtotem_ajax', 'wtotem_ajax_callback');
45 31
46 - if (WebTotemOption::isActivated()) {
47 - if (WebTotemCaptcha::isEnabled() or WebTotemLogin::anyTwoFactorActivated()) {
48 - /** Login Page */
49 - add_action('login_enqueue_scripts', 'WebTotemInterface::loginEnqueueScripts');
50 - }
32 + /** Define role of current user */
33 + //add_action('init', 'WebTotem::getUserRole');
51 34
52 - /** Add authenticate filter */
53 - add_filter('authenticate', 'WebTotemInterface::wt_authenticate', 25, 3);
54 35
55 - /** Add lostpassword filter */
56 - add_action('lostpassword_errors', 'WebTotemInterface::wt_lost_password', 1, 2);
36 + /**
37 + * List an associative array with the sub-pages of this plugin.
38 + *
39 + * @return array List of sub-pages of this plugin.
40 + */
41 + function wtotemPages() {
42 + if( WebTotem::isMultiSite() ) {
43 + $pages['wtotem_all_sites'] = [ 'title' => __('All sites', 'wtotem'), 'slug' => 'wtotem'];
44 + }
45 + $slug = WebTotem::isMultiSite() ? 'wtotem_' : 'wtotem';
57 46
58 - /** Add site or new sites if it is multisite */
59 -// add_action('wp_insert_site', 'WebTotemInterface::addNewSite');
60 - }
47 + $pages['wtotem_dashboard'] = [ 'title' => __('Dashboard', 'wtotem'), 'slug' => $slug];
48 + $pages['wtotem_firewall'] = [ 'title' => __('Firewall', 'wtotem'), 'slug' => $slug];
49 + if(!WebTotem::isMultiSite() or is_super_admin()) {
50 + $pages['wtotem_antivirus'] = [ 'title' => __('Antivirus', 'wtotem'), 'slug' => $slug];
51 + $pages['wtotem_settings'] = [ 'title' => __('Settings', 'wtotem'), 'slug' => $slug];
52 + }
53 + $pages['wtotem_reports'] = [ 'title' => __('Reports', 'wtotem'), 'slug' => $slug];
54 + $pages['wtotem_documentation'] = [ 'title' => __('Documentation', 'wtotem'), 'slug' => 'wtotem'];
61 55
62 - if (WebTotemOption::getPluginSettings('hide_wp_version')) {
63 - /** Restore readme file before WP update, then after update hide readme file */
64 - add_filter('update_feedback', 'WebTotemInterface::restoreReadmeWhenUpdating');
56 + return $pages;
57 + }
65 58
66 - /** Remove the WordPress generator meta-tag from the source code. */
67 - remove_action('wp_head', 'wp_generator');
68 - }
59 + if (function_exists('add_action')) {
60 + /**
61 + * Display extension menu and submenu items in the correct interface.
62 + *
63 + * @return void
64 + */
65 + function wtotemAddMenu() {
69 66
70 - /** User Profile */
71 - global $pagenow;
72 - if ('profile.php' === $pagenow or 'user-edit.php' === $pagenow) {
73 - add_action('admin_enqueue_scripts', 'WebTotemInterface::enqueueScripts', 1);
74 - add_action('show_user_profile', 'WebTotemInterface::add2faProfileForm');
75 - add_action('edit_user_profile', 'WebTotemInterface::add2faProfileForm');
76 - }
67 + $page = ! WebTotemOption::isActivated() ? 'activation' : ( WebTotem::isMultiSite() ? 'all_sites' : 'dashboard' );
77 68
78 - /** Launch of the daily cron. */
79 - add_action('wp', 'webtotem_add_cron_');
80 - function webtotem_add_cron_()
81 - {
82 - if (!wp_next_scheduled('webtotem_daily_cron')) {
83 - wp_schedule_event(time(), 'daily', 'webtotem_daily_cron');
84 - }
85 - }
69 + add_menu_page(
70 + __('WebTotem Security', 'wtotem'),
71 + __('WebTotem Security', 'wtotem'),
72 + 'manage_options',
73 + 'wtotem',
74 + 'wtotem_' . $page . '_page',
75 + WebTotem::getImagePath('logo_17x17_w.png')
76 + );
86 77
87 - add_action('webtotem_daily_cron', 'WtotemDailyCron');
78 + if(WebTotemOption::isActivated()){
79 + $pages = wtotemPages();
80 + foreach ($pages as $sub_page_function => $sub_page) {
81 + add_submenu_page(
82 + $sub_page['slug'],
83 + $sub_page['title'],
84 + $sub_page['title'],
85 + 'manage_options',
86 + $sub_page_function,
87 + $sub_page_function . '_page'
88 + );
89 + }
88 90
89 - function WtotemDailyCron()
90 - {
91 - WebTotemOption::setOptions(['scan_init' => 1]);
92 - }
93 -
94 - /** Launch of the minute cron. */
95 - if (WebTotemOption::getOption('scan_init')) {
96 -
97 - // Register the n minute interval
98 - add_filter('cron_schedules', 'cron_add_some_min');
99 - function cron_add_some_min($schedules)
100 - {
101 - $schedules['some_min'] = array(
102 - 'interval' => 60,
103 - 'display' => __('Every few minutes', 'wtotem'),
104 - );
105 - return $schedules;
91 + } else {
92 + add_submenu_page(
93 + 'wtotem',
94 + __('Activation', 'wtotem'),
95 + __('Activation', 'wtotem'),
96 + 'manage_options',
97 + 'wtotem_activation',
98 + 'wtotem_activation_page'
99 + );
106 100 }
101 + }
107 102
108 - // Registering an event
109 - add_action('wp', 'wtotem_step_cron');
110 - function wtotem_step_cron()
111 - {
112 - if (!wp_next_scheduled('wtotem_step_init_cron')) {
113 - wp_schedule_event(time(), 'some_min', 'wtotem_step_init_cron');
114 - }
115 - }
103 + /* Attach HTTP request handlers for the internal plugin pages */
104 + if(WebTotem::isMultiSite()){
105 + add_action('network_admin_menu', 'wtotemAddMenu');
106 + }
107 + add_action('admin_menu', 'wtotemAddMenu');
116 108
117 - // Linking the function to the cron event/task
118 - add_action('wtotem_step_init_cron', 'WebTotemScan::initialize');
119 - }
120 109
121 - /**
122 - * List an associative array with the sub-pages of this plugin.
123 - *
124 - * @return array List of sub-pages of this plugin.
125 - */
126 - function wtotemPages()
127 - {
128 -
129 - $slug = 'wtotem';
130 -
131 - $pages['wtotem_dashboard'] = ['title' => __('Dashboard', 'wtotem'), 'slug' => $slug];
132 - $pages['wtotem_open_paths'] = ['title' => __('Open paths', 'wtotem'), 'slug' => $slug];
133 - $pages['wtotem_firewall'] = ['title' => __('Firewall', 'wtotem'), 'slug' => $slug];
134 - $pages['wtotem_antivirus'] = ['title' => __('Antivirus', 'wtotem'), 'slug' => $slug];
135 - $pages['wtotem_settings'] = ['title' => __('Settings', 'wtotem'), 'slug' => $slug];
136 - $pages['wtotem_documentation'] = ['title' => __('Documentation', 'wtotem'), 'slug' => 'wtotem'];
137 - $pages['wtotem_wpscan'] = ['title' => __('WP scan', 'wtotem'), 'slug' => 'wtotem'];
138 -
139 - return $pages;
140 - }
141 -
142 - if (function_exists('add_action')) {
143 - /**
144 - * Display extension menu and submenu items in the correct interface.
145 - *
146 - * @return void
147 - */
148 - function wtotemAddMenu()
149 - {
150 -
151 -// $page = !WebTotemOption::isActivated() ? 'activation' : (WebTotem::isMultiSite() ? 'all_sites' : 'dashboard');
152 - $page = !WebTotemOption::isActivated() ? 'activation' : 'dashboard';
153 -
154 -
155 - add_menu_page(
156 - __('WebTotem', 'wtotem'),
157 - __('WebTotem', 'wtotem'),
158 - 'manage_options',
159 - 'wtotem',
160 - 'wtotem_' . $page . '_page',
161 - WebTotem::getImagePath('logo_17x17_w.png')
162 - );
163 -
164 - if (WebTotemOption::isActivated()) {
165 - $pages = wtotemPages();
166 - foreach ($pages as $sub_page_function => $sub_page) {
167 - add_submenu_page(
168 - $sub_page['slug'],
169 - $sub_page['title'],
170 - $sub_page['title'],
171 - 'manage_options',
172 - $sub_page_function,
173 - $sub_page_function . '_page'
174 - );
175 - }
176 -
177 - } else {
178 - add_submenu_page(
179 - 'wtotem',
180 - __('Activation', 'wtotem'),
181 - __('Activation', 'wtotem'),
182 - 'manage_options',
183 - 'wtotem_activation',
184 - 'wtotem_activation_page'
185 - );
186 - }
187 - }
188 -
189 - /* Attach HTTP request handlers for the internal plugin pages */
190 - if (WebTotem::isMultiSite()) {
191 - add_action('network_admin_menu', 'wtotemAddMenu');
192 - }
193 - add_action('admin_menu', 'wtotemAddMenu');
194 - }
195 -
196 - /**
197 - * Event hooks.
198 - *
199 - */
200 - if (class_exists('WebTotemEventListener')) {
201 -
202 - add_action('add_user_to_blog', 'WebTotemEventListener::hookAddUserToBlog', 50, 4);
203 -
204 - add_action('add_user_to_blog', 'WebTotemEventListener::hookAddUserToBlog', 50, 4);
205 - add_action('remove_user_from_blog', 'WebTotemEventListener::hookRemoveUserFromBlog', 50, 2);
206 - add_action('login_form_resetpass', 'WebTotemEventListener::hookLoginFormResetpass', 50, 5);
207 - add_action('profile_update', 'WebTotemEventListener::hookProfileUpdate', 50, 5);
208 - add_action('retrieve_password', 'WebTotemEventListener::hookRetrievePassword', 50, 5);
209 - add_action('user_register', 'WebTotemEventListener::hookUserRegister', 50, 5);
210 - add_action('deleted_user', 'WebTotemEventListener::hookUserDelete', 50, 3);
211 - add_action('wp_login', 'WebTotemEventListener::hookLoginSuccess', 50, 5);
212 - add_action('wp_login_failed', 'WebTotemEventListener::hookLoginFailure', 50, 5);
213 - add_action('add_link', 'WebTotemEventListener::hookLinkAdd', 50, 5);
214 - add_action('edit_link', 'WebTotemEventListener::hookLinkEdit', 50, 5);
215 - add_action('create_category', 'WebTotemEventListener::hookCategoryCreate', 50, 5);
216 - add_action('publish_post', 'WebTotemEventListener::hookPublishPost', 50, 5);
217 - add_action('transition_post_status', 'WebTotemEventListener::hookPostStatus', 50, 3);
218 - add_action('xmlrpc_publish_post', 'WebTotemEventListener::hookPublishPostXMLRPC', 50, 5);
219 - add_action('before_delete_post', 'WebTotemEventListener::hookPostBeforeDelete', 50, 5);
220 - add_action('delete_post', 'WebTotemEventListener::hookPostDelete', 50, 5);
221 - add_action('wp_trash_post', 'WebTotemEventListener::hookPostTrash', 50, 5);
222 - add_action('publish_page', 'WebTotemEventListener::hookPublishPage', 50, 5);
223 - add_action('add_attachment', 'WebTotemEventListener::hookAttachmentAdd', 50, 5);
224 - add_action('activated_plugin', 'WebTotemEventListener::hookPluginActivate', 50, 2);
225 - add_action('deactivated_plugin', 'WebTotemEventListener::hookPluginDeactivate', 50, 2);
226 - add_action('switch_theme', 'WebTotemEventListener::hookThemeSwitch', 50, 5);
227 -
228 - add_action('admin_init', 'WebTotemEventListener::hookCoreUpdate');
229 - add_action('admin_init', 'WebTotemEventListener::hookOptionsManagement');
230 - add_action('admin_init', 'WebTotemEventListener::hookPluginDelete');
231 - add_action('admin_init', 'WebTotemEventListener::hookPluginEditor');
232 - add_action('admin_init', 'WebTotemEventListener::hookPluginInstall');
233 - add_action('admin_init', 'WebTotemEventListener::hookPluginUpdate');
234 - add_action('admin_init', 'WebTotemEventListener::hookThemeDelete');
235 - add_action('admin_init', 'WebTotemEventListener::hookThemeEditor');
236 - add_action('admin_init', 'WebTotemEventListener::hookThemeInstall');
237 - add_action('admin_init', 'WebTotemEventListener::hookThemeUpdate');
238 - add_action('admin_init', 'WebTotemEventListener::hookWidgetAdd');
239 - add_action('admin_init', 'WebTotemEventListener::hookWidgetDelete');
240 -
241 - }
110 + }
242 111
243 112 }