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