PluginProbe
WebTotem Security / 2.3.31
WebTotem Security v2.3.31
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 / wt-security.php

wt-security.php in WebTotem Security 2.3.31, at wt-security.php

194 lines 8.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php defined('ABSPATH') or die("Protected By WT!");
2
3 /*
4 Plugin Name: WebTotem Security
5 Description: WebTotem is a SaaS which provides powerful tools for securing and monitoring your website in one place in easy and flexible way.
6 Author: WebTotem
7 Version: 2.3.31
8 */
9
10 define("WTSEC_PAGE_TITLE", 'Dashboard');
11 define("WTSEC_MENU_TITLE", 'WT Security');
12 define("WTSEC_PLUGIN_PATH", plugin_dir_path(__FILE__));
13 define("WTSEC_PLUGIN_NAME", 'wt-security');
14 define("WTSEC_PLUGIN_PREFIX", 'wtsec_');
15 define("WTSEC_PAGE_PREFIX", WTSEC_PLUGIN_NAME . '-');
16 define("WTSEC_FILE_URL", "https://api.wtotem.com/agent");
17 define("WTSEC_MODULES_DIR", WTSEC_PLUGIN_PATH . 'uploads/');
18
19 if (is_dir(WTSEC_MODULES_DIR) && is_writable(WTSEC_MODULES_DIR)) {
20 define("WTSEC_INSTALLATION_DIR", WTSEC_MODULES_DIR);
21 } else {
22 define("WTSEC_INSTALLATION_DIR", wp_upload_dir()['basedir'] . '/');
23 }
24
25 define("WTSEC_PLUGIN_URL", plugins_url("", __FILE__));
26 define("WTSEC_PLUGIN_BASENAME", plugin_basename( __FILE__));
27 define("WTSEC_SITE_URL", str_replace(['http://', 'https://', '//', '://', 'www.'], '', get_site_url()));
28
29 define("WTSEC_PLUGIN_INFORMATION_VERSION", "2.3");
30
31 $curLang = substr(get_bloginfo('language'), 0,2);
32 $language = (in_array($curLang,['ru','en','pl'])) ? $curLang : 'en' ;
33 define("WTSEC_LANGUAGE", $language);
34
35
36
37 add_action('wp_loaded', 'wtsec_init');
38 add_action('admin_init', 'wtsec_admin_init');
39 add_filter( 'authenticate', 'wtsec_login_check', 30, 3 );
40
41 add_action( 'upgrader_process_complete', 'wtsec_generate_file', 10, 2 );
42
43 function wtsec_init()
44 {
45 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
46 require_once WTSEC_PLUGIN_PATH . 'library/Request.php';
47
48 // WAF include (Если не админка и статус waf = "start", "uninstalled")
49 // && in_array(WTSEC_LIBRARY_App::getOption('waf_status'), ["start", "uninstalled"])
50 if (!is_admin()) {
51 if (!function_exists('wt_logs') && $waf = WTSEC_LIBRARY_App::getOption(("waf_installed_file"))) {
52 $path_to_waf = $_SERVER['DOCUMENT_ROOT'] . '/_include_' . $waf;
53 if (is_file($path_to_waf) && is_readable($path_to_waf)) {
54 include_once $path_to_waf;
55 }
56 }
57 }
58
59 if (is_admin()) {
60 require_once WTSEC_PLUGIN_PATH . 'library/WT.php';
61 require_once WTSEC_PLUGIN_PATH . 'library/Localization.php';
62 require_once WTSEC_PLUGIN_PATH . 'library/Idn.php';
63 require_once WTSEC_PLUGIN_PATH . 'library/Session.php';
64 require_once WTSEC_PLUGIN_PATH . 'routes.php';
65 require_once WTSEC_PLUGIN_PATH . 'services.php';
66 require_once WTSEC_PLUGIN_PATH . 'helpers.php';
67
68 function wtsec_request()
69 {
70 return new WTSEC_LIBRARY_Request();
71 }
72
73 function wtsec_app()
74 {
75 return new WTSEC_LIBRARY_App();
76 }
77
78 function wtsec_filesystem_init($form_url, $method, $context, $fields = null)
79 {
80 global $wp_filesystem;
81 if (!$creds = request_filesystem_credentials($form_url, $method, false, $context, $fields)) {
82 return false;
83 }
84 if (!WP_Filesystem($creds)) {
85 request_filesystem_credentials($form_url, $method, true, $context);
86 return false;
87 }
88 return true;
89 }
90
91 function wtsec_locale($lmsg, $args = [])
92 {
93 return WTSEC_LIBRARY_Localization::lmsg($lmsg, $args);
94 }
95
96 function wtsec_getImagePath($image)
97 {
98 return plugins_url('/htdocs/img/' . $image, __FILE__);
99 }
100
101 }
102 }
103
104 function wtsec_admin_init()
105 {
106 if(!function_exists('wtsec_request')){
107 function wtsec_request(){
108 return new WTSEC_LIBRARY_Request();
109 }
110 }
111
112 $rand = '?rand='.rand();
113 if (is_admin() && stripos(wtsec_request()->page, WTSEC_PLUGIN_NAME) !== false) {
114 wp_enqueue_script('subscriber', plugins_url('/htdocs/js/wtsec_subscriber.js'.$rand, __FILE__), [], false, true);
115 wp_enqueue_script('amplitude', plugins_url( '/htdocs/js/wtsec_amplitude.js', __FILE__ ), array(),false, true );
116 wp_enqueue_script('d3-v4', plugins_url('/htdocs/js/wtsec_d3.v4.js', __FILE__), array( 'jquery' ), false, true);
117 wp_enqueue_script('jsdelivr', plugins_url('/htdocs/js/wtsec_jsdelivr_chart.js', __FILE__), array( 'jquery' ), false, true);
118 wp_enqueue_script('chart', plugins_url('/htdocs/js/wtsec_Chart.js'.$rand, __FILE__), [], false, true);
119 wp_enqueue_script('circle-progress', plugins_url('/htdocs/js/wtsec_circle-progress.js', __FILE__), [], false, true);
120 wp_enqueue_script('range-plugin', plugins_url('/htdocs/js/wtsec_rangePlugin.js', __FILE__), array( 'jquery' ), false, true);
121 wp_enqueue_script('flatpickr', plugins_url('/htdocs/js/wtsec_flatpickr.js', __FILE__), array( 'jquery' ), false, true);
122 wp_enqueue_script('filter-calendar', plugins_url('/htdocs/js/wtsec_filterCalendar.js', __FILE__), array( 'jquery' ), false, true);
123 wp_enqueue_script('line-progress', plugins_url('/htdocs/js/wtsec_line-progress.js', __FILE__), [], false, true);
124 wp_enqueue_script('main', plugins_url('/htdocs/js/wtsec_main.js'.$rand, __FILE__), [], false, true);
125 wp_enqueue_script('ajax', plugins_url( '/htdocs/js/wtsec_ajax.js'.$rand, __FILE__ ), array( 'jquery' ),false, true );
126 wp_enqueue_script('subscriber');
127 wp_enqueue_script('amplitude');
128 wp_enqueue_script('d3-v4');
129 wp_enqueue_script('jsdelivr');
130 wp_enqueue_script('chart');
131 wp_enqueue_script('circle-progress');
132 wp_enqueue_script('range-plugin');
133 wp_enqueue_script('flatpickr');
134 wp_enqueue_script('filter-calendar');
135 wp_enqueue_script('line-progress');
136 wp_enqueue_script('main');
137 wp_enqueue_script('ajax');
138
139 wp_register_style('flatpickr-css', 'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css');
140 wp_register_style('font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
141 wp_register_style('main', plugins_url('/htdocs/css/wtsec_main.css'.$rand, __FILE__));
142 wp_enqueue_style('flatpickr-css');
143 wp_enqueue_style('font');
144 wp_enqueue_style('print-css');
145 wp_enqueue_style('main');
146
147 $page = wtsec_request()->page;
148 if ($page === wtsec_getRoute("login")) {
149 if (WTSEC_LIBRARY_App::authorized()) {
150 wp_safe_redirect(wtsec_getUrl('dashboard'));
151 }
152 } elseif ($page === wtsec_getRoute("logout")) {
153 $host = WTSEC_LIBRARY_WT::getOwnSite();
154 $result = WTSEC_LIBRARY_WT::deleteAm($host['id']);
155 if($result){
156 WTSEC_LIBRARY_App::logout();
157 }
158
159 if (!WTSEC_LIBRARY_App::authorized()) {
160 wp_safe_redirect(wtsec_getUrl('login'));
161 }
162 } else {
163 if (!WTSEC_LIBRARY_App::authorized()) {
164 wp_safe_redirect(wtsec_getUrl('login'));
165 }
166 }
167 }
168 }
169
170 function wtsec_login_check($user, $username, $password) {
171 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
172 $app = new WTSEC_LIBRARY_App;
173 if($app::getOption('authorized')){
174 return $app->wtsec_login_check($user, $username, $password);
175 }
176 return $user;
177 }
178
179 // Create file generate.php after plugin update
180 function wtsec_generate_file( $upgrader_object, $options ) {
181
182 if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) {
183 foreach( $options['plugins'] as $plugin ) {
184 if( $plugin == WTSEC_PLUGIN_BASENAME ) {
185 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
186 $fileName = WTSEC_LIBRARY_App::getOption('am_installed_file');
187
188 wtsec_addCheckFile($fileName);
189 }
190 }
191 }
192 }
193
194