PluginProbe
WebTotem Security / 2.3.4
WebTotem Security v2.3.4
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.4, at wt-security.php

193 lines 7.8 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: WT Security
5 Description: WT is a SaaS which provides powerful tools for securing and monitoring your website in one place in easy and flexible way.
6 Author: WT Security
7 Version: 2.3.4
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_ROOT", WP_PLUGIN_DIR . '/');
18 define("WTSEC_MODULES_DIR", WTSEC_PLUGIN_PATH . 'uploads/');
19 if (is_dir(WTSEC_MODULES_DIR) && is_writable(WTSEC_MODULES_DIR)) {
20 define("WTSEC_INSTALLATION_DIR", WTSEC_MODULES_DIR);
21 define("WTOTEMSEC_INSTALLATION_DIR", WTSEC_MODULES_DIR);
22 } else {
23 define("WTSEC_INSTALLATION_DIR", wp_upload_dir()['basedir'] . '/');
24 define("WTOTEMSEC_INSTALLATION_DIR", wp_upload_dir()['basedir'] . '/');
25 }
26 define("WTSEC_PLUGIN_URL", plugins_url("", __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 add_action('admin_init', 'wtsec_admin_init');
32 add_action('wp_loaded', 'wtsec_init');
33
34 add_action( 'authenticate', 'wtsec_login_check' );
35
36 function wtsec_init()
37 {
38 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
39 require_once WTSEC_PLUGIN_PATH . 'library/Request.php';
40
41 // WAF include (Если не админка и статус waf = "start", "uninstalled")
42 // && in_array(WTSEC_LIBRARY_App::getOption('waf_status'), ["start", "uninstalled"])
43 if (!is_admin()) {
44 if ($waf = WTSEC_LIBRARY_App::getOption(("waf_installed_file"))) {
45 $path_to_waf = $_SERVER['DOCUMENT_ROOT'] . '/_include_' . $waf;
46 if (is_file($path_to_waf) && is_readable($path_to_waf)) {
47 include_once $path_to_waf;
48 }
49 }
50 }
51
52 if (is_admin()) {
53 require_once WTSEC_PLUGIN_PATH . 'library/WT.php';
54 require_once WTSEC_PLUGIN_PATH . 'library/Localization.php';
55 require_once WTSEC_PLUGIN_PATH . 'library/Idn.php';
56 require_once WTSEC_PLUGIN_PATH . 'library/Session.php';
57 require_once WTSEC_PLUGIN_PATH . 'routes.php';
58 require_once WTSEC_PLUGIN_PATH . 'services.php';
59 require_once WTSEC_PLUGIN_PATH . 'helpers.php';
60
61 function wtsec_request()
62 {
63 return new WTSEC_LIBRARY_Request();
64 }
65 function wtsec_app()
66 {
67 return new WTSEC_LIBRARY_App();
68 }
69 function wtsec_filesystem_init($form_url, $method, $context, $fields = null)
70 {
71 global $wp_filesystem;
72 if (!$creds = request_filesystem_credentials($form_url, $method, false, $context, $fields)) {
73 return false;
74 }
75 if (!WP_Filesystem($creds)) {
76 request_filesystem_credentials($form_url, $method, true, $context);
77 return false;
78 }
79 return true;
80 }
81 function wtsec_locale($lmsg, $args = [])
82 {
83 return WTSEC_LIBRARY_Localization::lmsg($lmsg, $args);
84 }
85 function wtsec_getImagePath($image)
86 {
87 return plugins_url('/htdocs/img/' . $image, __FILE__);
88 }
89 function wtsec_SIS($arr, $key, $form = null)
90 {
91 $key = explode(".", $key);
92 foreach ($key as $_key) {
93 if (!isset($arr[$_key])) {
94 $arr = "";
95 break;
96 }
97 $arr = $arr[$_key];
98 }
99 return !empty($form) ? str_replace("$" . $key, $arr, $form) : $arr;
100 }
101 }
102 }
103
104 function wtsec_admin_init()
105 {
106 $rand = '?rand='.rand();
107 if (is_admin() && stripos(wtsec_request()->page, WTSEC_PLUGIN_NAME) !== false) {
108 wp_enqueue_script('subscriber', plugins_url('/htdocs/js/subscriber.js'.$rand, __FILE__), [], false, true);
109 wp_enqueue_script('d3-v4', plugins_url('/htdocs/js/d3.v4.js', __FILE__), array( 'jquery' ), false, true);
110 wp_enqueue_script('jsdelivr', plugins_url('/htdocs/js/jsdelivr_chart.js', __FILE__), array( 'jquery' ), false, true);
111 wp_enqueue_script('chart', plugins_url('/htdocs/js/Chart.js'.$rand, __FILE__), [], false, true);
112 wp_enqueue_script('circle-progress', plugins_url('/htdocs/js/circle-progress.js', __FILE__), [], false, true);
113 wp_enqueue_script('range-plugin', plugins_url('/htdocs/js/rangePlugin.js', __FILE__), array( 'jquery' ), false, true);
114 wp_enqueue_script('flatpickr', plugins_url('/htdocs/js/flatpickr.js', __FILE__), array( 'jquery' ), false, true);
115 wp_enqueue_script('filter-calendar', plugins_url('/htdocs/js/filterCalendar.js', __FILE__), array( 'jquery' ), false, true);
116 wp_enqueue_script('line-progress', plugins_url('/htdocs/js/line-progress.js', __FILE__), [], false, true);
117 wp_enqueue_script('main', plugins_url('/htdocs/js/main.js'.$rand, __FILE__), [], false, true);
118 wp_enqueue_script('ajax', plugins_url( '/htdocs/js/ajax.js'.$rand, __FILE__ ), array( 'jquery' ),false, true );
119 wp_enqueue_script('subscriber');
120 wp_enqueue_script('print');
121 wp_enqueue_script('d3-v4');
122 wp_enqueue_script('jsdelivr');
123 wp_enqueue_script('chart');
124 wp_enqueue_script('circle-progress');
125 wp_enqueue_script('line-progress');
126 wp_enqueue_script('range-plugin');
127 wp_enqueue_script('flatpickr');
128 wp_enqueue_script('filter-calendar');
129 wp_enqueue_script('main');
130 wp_enqueue_script('ajax');
131
132 wp_register_style('flatpickr-css', 'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css');
133 wp_register_style('font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
134 wp_register_style('main', plugins_url('/htdocs/css/main.css'.$rand, __FILE__));
135 wp_enqueue_style('flatpickr-css');
136 wp_enqueue_style('font');
137 wp_enqueue_style('print-css');
138 wp_enqueue_style('main');
139
140 $page = wtsec_request()->page;
141 if ($page === wtsec_getRoute("login")) {
142 if (WTSEC_LIBRARY_App::authorized()) {
143 wp_safe_redirect(wtsec_getUrl('dashboard'));
144 }
145 } elseif ($page === wtsec_getRoute("logout")) {
146 WTSEC_LIBRARY_App::logout();
147 if (!WTSEC_LIBRARY_App::authorized()) {
148 wp_safe_redirect(wtsec_getUrl('login'));
149 }
150 } elseif ($page === wtsec_getRoute("activate")) {
151 if (WTSEC_LIBRARY_App::authorized()) {
152 wp_safe_redirect(wtsec_getUrl('sites'));
153 }
154 } else {
155 if (!WTSEC_LIBRARY_App::authorized()) {
156 wp_safe_redirect(wtsec_getUrl('login'));
157 }
158 }
159 }
160 }
161
162 function wtsec_login_check() {
163 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
164 require_once WTSEC_PLUGIN_PATH . 'library/Localization.php';
165 $app = new WTSEC_LIBRARY_App;
166
167 function wtsec_locale($lmsg, $args = [])
168 {
169 return WTSEC_LIBRARY_Localization::lmsg($lmsg, $args);
170 }
171
172 $app->wtsec_login_check();
173 }
174
175
176 add_action('init', 'wtsec_StartSession', 1);
177 add_action('wp_logout', 'wtsec_EndSession');
178 add_action('wp_login', 'wtsec_EndSession');
179
180 function wtsec_StartSession() {
181 if(!session_id()) {
182 session_start();
183 }
184 }
185
186 function wtsec_EndSession() {
187 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
188 session_destroy ();
189 }
190
191
192
193