PluginProbe
WebTotem Security / 2.4.16
WebTotem Security v2.4.16
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.16, at src/Common.php

149 lines 5.0 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 /** Execute pre-checks before every page */
21 add_action('init', 'WebTotemInterface::startupChecks'); //wp_loaded
22
23 /** Attach HTTP request handlers for the AJAX requests */
24 add_action('wp_ajax_nopriv_wtotem_ajax', 'wtotem_public_ajax_callback');
25 add_action('wp_ajax_wtotem_ajax', 'wtotem_ajax_callback');
26
27 if(WebTotemOption::isActivated()){
28 if(WebTotemCaptcha::isEnabled() or WebTotemLogin::anyTwoFactorActivated()){
29 /** Login Page */
30 add_action('login_enqueue_scripts', 'WebTotemInterface::loginEnqueueScripts');
31 }
32
33 /** Add authenticate filter */
34 add_filter('authenticate', 'WebTotemInterface::wt_authenticate', 25, 3);
35
36 /** Add lostpassword filter */
37 add_action('lostpassword_errors', 'WebTotemInterface::wt_lost_password', 1, 2);
38
39 /** Add site or new sites if it is multisite */
40 add_action( 'wp_insert_site', 'WebTotemInterface::addNewSite' );
41 }
42
43 if (WebTotemOption::getPluginSettings('hide_wp_version')) {
44 /** Restore readme file before WP update, then after update hide readme file */
45 add_filter('update_feedback', 'WebTotemInterface::restoreReadmeWhenUpdating');
46
47 /** Remove the WordPress generator meta-tag from the source code. */
48 remove_action('wp_head', 'wp_generator');
49 }
50
51 /** User Profile */
52 global $pagenow;
53 if ( 'profile.php' === $pagenow or 'user-edit.php' === $pagenow ) {
54 add_action( 'admin_enqueue_scripts', 'WebTotemInterface::enqueueScripts', 1);
55 add_action( 'show_user_profile', 'WebTotemInterface::add2faProfileForm');
56 add_action( 'edit_user_profile', 'WebTotemInterface::add2faProfileForm' );
57 }
58
59 /** Define role of current user */
60 //add_action('init', 'WebTotem::getUserRole');
61
62 /** */
63 add_action( 'wp', 'webtotem_add_cron' );
64 add_action( 'webtotem_daily_cron', 'dailyCron' );
65
66 function webtotem_add_cron() {
67 if( ! wp_next_scheduled( 'webtotem_daily_cron' ) ) {
68 wp_schedule_event( time(), 'daily', 'webtotem_daily_cron' );
69 }
70 }
71
72 /**
73 * List an associative array with the sub-pages of this plugin.
74 *
75 * @return array List of sub-pages of this plugin.
76 */
77 function wtotemPages() {
78 if( WebTotem::isMultiSite() ) {
79 $pages['wtotem_all_sites'] = [ 'title' => __('All sites', 'wtotem'), 'slug' => 'wtotem'];
80 }
81 $slug = WebTotem::isMultiSite() ? 'wtotem_' : 'wtotem';
82
83 $pages['wtotem_dashboard'] = [ 'title' => __('Dashboard', 'wtotem'), 'slug' => $slug];
84 $pages['wtotem_firewall'] = [ 'title' => __('Firewall', 'wtotem'), 'slug' => $slug];
85 if(!WebTotem::isMultiSite() or is_super_admin()) {
86 $pages['wtotem_antivirus'] = [ 'title' => __('Antivirus', 'wtotem'), 'slug' => $slug];
87 $pages['wtotem_settings'] = [ 'title' => __('Settings', 'wtotem'), 'slug' => $slug];
88 }
89 $pages['wtotem_reports'] = [ 'title' => __('Reports', 'wtotem'), 'slug' => $slug];
90 $pages['wtotem_documentation'] = [ 'title' => __('Documentation', 'wtotem'), 'slug' => 'wtotem'];
91
92 return $pages;
93 }
94
95 if (function_exists('add_action')) {
96 /**
97 * Display extension menu and submenu items in the correct interface.
98 *
99 * @return void
100 */
101 function wtotemAddMenu() {
102
103 $page = ! WebTotemOption::isActivated() ? 'activation' : ( WebTotem::isMultiSite() ? 'all_sites' : 'dashboard' );
104
105 add_menu_page(
106 __('WebTotem', 'wtotem'),
107 __('WebTotem', 'wtotem'),
108 'manage_options',
109 'wtotem',
110 'wtotem_' . $page . '_page',
111 WebTotem::getImagePath('logo_17x17_w.png')
112 );
113
114 if(WebTotemOption::isActivated()){
115 $pages = wtotemPages();
116 foreach ($pages as $sub_page_function => $sub_page) {
117 add_submenu_page(
118 $sub_page['slug'],
119 $sub_page['title'],
120 $sub_page['title'],
121 'manage_options',
122 $sub_page_function,
123 $sub_page_function . '_page'
124 );
125 }
126
127 } else {
128 add_submenu_page(
129 'wtotem',
130 __('Activation', 'wtotem'),
131 __('Activation', 'wtotem'),
132 'manage_options',
133 'wtotem_activation',
134 'wtotem_activation_page'
135 );
136 }
137 }
138
139 /* Attach HTTP request handlers for the internal plugin pages */
140 if(WebTotem::isMultiSite()){
141 add_action('network_admin_menu', 'wtotemAddMenu');
142 }
143 add_action('admin_menu', 'wtotemAddMenu');
144
145
146 }
147
148 }
149