PluginProbe
WebTotem Security / 2.3.30
WebTotem Security v2.3.30
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.30, at wt-security.php

195 lines 8.3 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 Security
7 Version: 2.3.30
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('admin_init', 'wtsec_admin_init');
38 add_action('wp_loaded', 'wtsec_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 function wtsec_app()
73 {
74 return new WTSEC_LIBRARY_App();
75 }
76 function wtsec_filesystem_init($form_url, $method, $context, $fields = null)
77 {
78 global $wp_filesystem;
79 if (!$creds = request_filesystem_credentials($form_url, $method, false, $context, $fields)) {
80 return false;
81 }
82 if (!WP_Filesystem($creds)) {
83 request_filesystem_credentials($form_url, $method, true, $context);
84 return false;
85 }
86 return true;
87 }
88 function wtsec_locale($lmsg, $args = [])
89 {
90 return WTSEC_LIBRARY_Localization::lmsg($lmsg, $args);
91 }
92 function wtsec_getImagePath($image)
93 {
94 return plugins_url('/htdocs/img/' . $image, __FILE__);
95 }
96 function wtsec_SIS($arr, $key, $form = null)
97 {
98 $key = explode(".", $key);
99 foreach ($key as $_key) {
100 if (!isset($arr[$_key])) {
101 $arr = "";
102 break;
103 }
104 $arr = $arr[$_key];
105 }
106 return !empty($form) ? str_replace("$" . $key, $arr, $form) : $arr;
107 }
108 }
109 }
110
111 function wtsec_admin_init()
112 {
113 $rand = '?rand='.rand();
114 if (is_admin() && stripos(wtsec_request()->page, WTSEC_PLUGIN_NAME) !== false) {
115 wp_enqueue_script('subscriber', plugins_url('/htdocs/js/wtsec_subscriber.js'.$rand, __FILE__), [], false, true);
116 wp_enqueue_script('amplitude', plugins_url( '/htdocs/js/wtsec_amplitude.js', __FILE__ ), array(),false, true );
117 wp_enqueue_script('d3-v4', plugins_url('/htdocs/js/wtsec_d3.v4.js', __FILE__), array( 'jquery' ), false, true);
118 wp_enqueue_script('jsdelivr', plugins_url('/htdocs/js/wtsec_jsdelivr_chart.js', __FILE__), array( 'jquery' ), false, true);
119 wp_enqueue_script('chart', plugins_url('/htdocs/js/wtsec_Chart.js'.$rand, __FILE__), [], false, true);
120 wp_enqueue_script('circle-progress', plugins_url('/htdocs/js/wtsec_circle-progress.js', __FILE__), [], false, true);
121 wp_enqueue_script('range-plugin', plugins_url('/htdocs/js/wtsec_rangePlugin.js', __FILE__), array( 'jquery' ), false, true);
122 wp_enqueue_script('flatpickr', plugins_url('/htdocs/js/wtsec_flatpickr.js', __FILE__), array( 'jquery' ), false, true);
123 wp_enqueue_script('filter-calendar', plugins_url('/htdocs/js/wtsec_filterCalendar.js', __FILE__), array( 'jquery' ), false, true);
124 wp_enqueue_script('line-progress', plugins_url('/htdocs/js/wtsec_line-progress.js', __FILE__), [], false, true);
125 wp_enqueue_script('main', plugins_url('/htdocs/js/wtsec_main.js'.$rand, __FILE__), [], false, true);
126 wp_enqueue_script('ajax', plugins_url( '/htdocs/js/wtsec_ajax.js'.$rand, __FILE__ ), array( 'jquery' ),false, true );
127 wp_enqueue_script('subscriber');
128 wp_enqueue_script('amplitude');
129 wp_enqueue_script('d3-v4');
130 wp_enqueue_script('jsdelivr');
131 wp_enqueue_script('chart');
132 wp_enqueue_script('circle-progress');
133 wp_enqueue_script('range-plugin');
134 wp_enqueue_script('flatpickr');
135 wp_enqueue_script('filter-calendar');
136 wp_enqueue_script('line-progress');
137 wp_enqueue_script('main');
138 wp_enqueue_script('ajax');
139
140 wp_register_style('flatpickr-css', 'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css');
141 wp_register_style('font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
142 wp_register_style('main', plugins_url('/htdocs/css/wtsec_main.css'.$rand, __FILE__));
143 wp_enqueue_style('flatpickr-css');
144 wp_enqueue_style('font');
145 wp_enqueue_style('print-css');
146 wp_enqueue_style('main');
147
148 $page = wtsec_request()->page;
149 if ($page === wtsec_getRoute("login")) {
150 if (WTSEC_LIBRARY_App::authorized()) {
151 wp_safe_redirect(wtsec_getUrl('dashboard'));
152 }
153 } elseif ($page === wtsec_getRoute("logout")) {
154 $host = WTSEC_LIBRARY_WT::getOwnSite();
155 $result = WTSEC_LIBRARY_WT::deleteAm($host['id']);
156 if($result){
157 WTSEC_LIBRARY_App::logout();
158 }
159
160 if (!WTSEC_LIBRARY_App::authorized()) {
161 wp_safe_redirect(wtsec_getUrl('login'));
162 }
163 } else {
164 if (!WTSEC_LIBRARY_App::authorized()) {
165 wp_safe_redirect(wtsec_getUrl('login'));
166 }
167 }
168 }
169 }
170
171 function wtsec_login_check($user, $username, $password) {
172 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
173 $app = new WTSEC_LIBRARY_App;
174 if($app::getOption('authorized')){
175 return $app->wtsec_login_check($user, $username, $password);
176 }
177 return $user;
178 }
179
180 // Create file generate.php after plugin update
181 function wtsec_generate_file( $upgrader_object, $options ) {
182
183 if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) {
184 foreach( $options['plugins'] as $plugin ) {
185 if( $plugin == WTSEC_PLUGIN_BASENAME ) {
186 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
187 $fileName = WTSEC_LIBRARY_App::getOption('am_installed_file');
188
189 wtsec_addCheckFile($fileName);
190 }
191 }
192 }
193 }
194
195