PluginProbe
WebTotem Security / 2.4.19
WebTotem Security v2.4.19
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.19, at src/Common.php

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