PluginProbe
WebTotem Security / 2.4.25
WebTotem Security v2.4.25
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 2.2.4 All 109 releases
wt-security / src / Common.php

Common.php in WebTotem Security 2.4.25, at src/Common.php

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