PluginProbe
WebTotem Security / 2.3.24
WebTotem Security v2.3.24
3.0.2 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 All 110 releases
← All changes | wt-security.php +81 -40 2.1.82.3.24 View file →
@@ -3,9 +3,9 @@
3 3 /*
4 4 Plugin Name: WT Security
5 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 6 Author: WT Security
7 -Version: 2.1.8
7 +Version: 2.3.24
8 8 */
9 9
10 10 define("WTSEC_PAGE_TITLE", 'Dashboard');
11 11 define("WTSEC_MENU_TITLE", 'WT Security');
@@ -13,9 +13,8 @@
13 13 define("WTSEC_PLUGIN_NAME", 'wt-security');
14 14 define("WTSEC_PLUGIN_PREFIX", 'wtsec_');
15 15 define("WTSEC_PAGE_PREFIX", WTSEC_PLUGIN_NAME . '-');
16 16 define("WTSEC_FILE_URL", "https://api.wtotem.com/agent");
17 -define("WTSEC_ROOT", WP_PLUGIN_DIR . '/');
18 17 define("WTSEC_MODULES_DIR", WTSEC_PLUGIN_PATH . 'uploads/');
19 18 if (is_dir(WTSEC_MODULES_DIR) && is_writable(WTSEC_MODULES_DIR)) {
20 19 define("WTSEC_INSTALLATION_DIR", WTSEC_MODULES_DIR);
21 20 define("WTOTEMSEC_INSTALLATION_DIR", WTSEC_MODULES_DIR);
@@ -23,27 +22,73 @@
23 22 define("WTSEC_INSTALLATION_DIR", wp_upload_dir()['basedir'] . '/');
24 23 define("WTOTEMSEC_INSTALLATION_DIR", wp_upload_dir()['basedir'] . '/');
25 24 }
26 25 define("WTSEC_PLUGIN_URL", plugins_url("", __FILE__));
27 -define("WTSEC_SITE_URL", str_replace(['http://', 'https://', 'www.', '//', '://'], '', get_site_url()));
26 +define("WTSEC_PLUGIN_BASENAME", plugin_basename( __FILE__));
27 +define("WTSEC_SITE_URL", str_replace(['http://', 'https://', '//', '://', 'www.'], '', get_site_url()));
28 28
29 -define("WTSEC_PLUGIN_INFORMATION_VERSION", "2.1");
29 +define("WTSEC_PLUGIN_INFORMATION_VERSION", "2.3");
30 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 +add_action( 'deactivated_plugin', 'wtsec_DeactivatedPlugin', 1 );
37 +
38 +// Clear database, delete am(agents) after plugin deactivate
39 +function wtsec_DeactivatedPlugin($plugin){
40 +
41 + if($plugin == WTSEC_PLUGIN_BASENAME) {
42 +
43 + define("WTSEC_DEACTIVATED", true);
44 + require_once WTSEC_PLUGIN_PATH . 'library/App.php';
45 + $app = new WTSEC_LIBRARY_App;
46 + if(wtsec_DeleteAm()){
47 + $app::clearDB();
48 + }
49 +
50 + }
51 +}
52 +
53 +add_action( 'upgrader_process_complete', 'wtsec_generate_file', 10, 2 );
54 +
55 +// Create file generate.php after plugin update
56 +function wtsec_generate_file( $upgrader_object, $options ) {
57 +
58 + if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ) {
59 + foreach( $options['plugins'] as $plugin ) {
60 + if( $plugin == WTSEC_PLUGIN_BASENAME ) {
61 + require_once WTSEC_PLUGIN_PATH . 'library/App.php';
62 + $fileName = WTSEC_LIBRARY_App::getOption('am_installed_file');
63 +
64 + wtsec_addCheckFile($fileName);
65 + }
66 + }
67 + }
68 +}
69 +
31 70 add_action('admin_init', 'wtsec_admin_init');
32 71 add_action('wp_loaded', 'wtsec_init');
33 72
73 +add_filter( 'authenticate', 'wtsec_login_check', 30, 3 );
74 +
34 75 function wtsec_init()
35 76 {
36 77 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
37 78 require_once WTSEC_PLUGIN_PATH . 'library/Request.php';
38 -// if (!is_admin() && in_array(WTSEC_LIBRARY_App::getOption('waf_status'), ["start", "uninstalled"])) {
39 -// if ($waf = WTSEC_LIBRARY_App::getOption(("waf_installed_file"))) {
40 -// $path_to_waf = WTSEC_INSTALLATION_DIR . '/' . $waf;
41 -// if (is_file($path_to_waf) && is_readable($path_to_waf)) {
42 -// include $path_to_waf;
43 -// }
44 -// }
45 -// }
79 +
80 + // WAF include (Если не админка и статус waf = "start", "uninstalled")
81 + // && in_array(WTSEC_LIBRARY_App::getOption('waf_status'), ["start", "uninstalled"])
82 + if (!is_admin()) {
83 + if ($waf = WTSEC_LIBRARY_App::getOption(("waf_installed_file"))) {
84 + $path_to_waf = $_SERVER['DOCUMENT_ROOT'] . '/_include_' . $waf;
85 + if (is_file($path_to_waf) && is_readable($path_to_waf)) {
86 + include_once $path_to_waf;
87 + }
88 + }
89 + }
90 +
46 91 if (is_admin()) {
47 92 require_once WTSEC_PLUGIN_PATH . 'library/WT.php';
48 93 require_once WTSEC_PLUGIN_PATH . 'library/Localization.php';
49 94 require_once WTSEC_PLUGIN_PATH . 'library/Idn.php';
@@ -50,8 +95,9 @@
50 95 require_once WTSEC_PLUGIN_PATH . 'library/Session.php';
51 96 require_once WTSEC_PLUGIN_PATH . 'routes.php';
52 97 require_once WTSEC_PLUGIN_PATH . 'services.php';
53 98 require_once WTSEC_PLUGIN_PATH . 'helpers.php';
99 +
54 100 function wtsec_request()
55 101 {
56 102 return new WTSEC_LIBRARY_Request();
57 103 }
@@ -95,21 +141,25 @@
95 141 }
96 142
97 143 function wtsec_admin_init()
98 144 {
145 + $rand = '?rand='.rand();
99 146 if (is_admin() && stripos(wtsec_request()->page, WTSEC_PLUGIN_NAME) !== false) {
100 - wp_enqueue_script('subscriber', plugins_url('/htdocs/js/subscriber.js', __FILE__), [], false, true);
101 - wp_enqueue_script('plug', 'https://d3js.org/d3.v5.min.js', [], false, true);
102 - wp_enqueue_script('chart', plugins_url('/htdocs/js/Chart.js', __FILE__), [], false, true);
103 - wp_enqueue_script('circle-progress', plugins_url('/htdocs/js/circle-progress.js', __FILE__), [], false, true);
104 - wp_enqueue_script('range-plugin', plugins_url('/htdocs/js/rangePlugin.js', __FILE__), array( 'jquery' ), false, true);
105 - wp_enqueue_script('flatpickr', plugins_url('/htdocs/js/flatpickr.js', __FILE__), array( 'jquery' ), false, true);
106 - wp_enqueue_script('filter-calendar', plugins_url('/htdocs/js/filterCalendar.js', __FILE__), array( 'jquery' ), false, true);
107 - wp_enqueue_script('line-progress', plugins_url('/htdocs/js/line-progress.js', __FILE__), [], false, true);
108 - wp_enqueue_script('main', plugins_url('/htdocs/js/main.js', __FILE__), [], false, true);
109 - wp_enqueue_script( 'ajax', plugins_url( '/htdocs/js/ajax.js', __FILE__ ), array( 'jquery' ),false, true );
147 + wp_enqueue_script('subscriber', plugins_url('/htdocs/js/wtsec_subscriber.js'.$rand, __FILE__), [], false, true);
148 + wp_enqueue_script('d3-v4', plugins_url('/htdocs/js/wtsec_d3.v4.js', __FILE__), array( 'jquery' ), false, true);
149 + wp_enqueue_script('jsdelivr', plugins_url('/htdocs/js/wtsec_jsdelivr_chart.js', __FILE__), array( 'jquery' ), false, true);
150 + wp_enqueue_script('chart', plugins_url('/htdocs/js/wtsec_Chart.js'.$rand, __FILE__), [], false, true);
151 + wp_enqueue_script('circle-progress', plugins_url('/htdocs/js/wtsec_circle-progress.js', __FILE__), [], false, true);
152 + wp_enqueue_script('range-plugin', plugins_url('/htdocs/js/wtsec_rangePlugin.js', __FILE__), array( 'jquery' ), false, true);
153 + wp_enqueue_script('flatpickr', plugins_url('/htdocs/js/wtsec_flatpickr.js', __FILE__), array( 'jquery' ), false, true);
154 + wp_enqueue_script('filter-calendar', plugins_url('/htdocs/js/wtsec_filterCalendar.js', __FILE__), array( 'jquery' ), false, true);
155 + wp_enqueue_script('line-progress', plugins_url('/htdocs/js/wtsec_line-progress.js', __FILE__), [], false, true);
156 + wp_enqueue_script('main', plugins_url('/htdocs/js/wtsec_main.js'.$rand, __FILE__), [], false, true);
157 + wp_enqueue_script('ajax', plugins_url( '/htdocs/js/wtsec_ajax.js'.$rand, __FILE__ ), array( 'jquery' ),false, true );
110 158 wp_enqueue_script('subscriber');
111 - wp_enqueue_script('plug');
159 + wp_enqueue_script('print');
160 + wp_enqueue_script('d3-v4');
161 + wp_enqueue_script('jsdelivr');
112 162 wp_enqueue_script('chart');
113 163 wp_enqueue_script('circle-progress');
114 164 wp_enqueue_script('line-progress');
115 165 wp_enqueue_script('range-plugin');
@@ -117,17 +167,14 @@
117 167 wp_enqueue_script('filter-calendar');
118 168 wp_enqueue_script('main');
119 169 wp_enqueue_script('ajax');
120 170
121 -
122 -
123 171 wp_register_style('flatpickr-css', 'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css');
124 172 wp_register_style('font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
125 - wp_register_style('normalize', plugins_url('/htdocs/css/normalize.css', __FILE__));
126 - wp_register_style('main', plugins_url('/htdocs/css/main.css', __FILE__));
173 + wp_register_style('main', plugins_url('/htdocs/css/wtsec_main.css'.$rand, __FILE__));
127 174 wp_enqueue_style('flatpickr-css');
128 175 wp_enqueue_style('font');
129 - wp_enqueue_style('normalize');
176 + wp_enqueue_style('print-css');
130 177 wp_enqueue_style('main');
131 178
132 179 $page = wtsec_request()->page;
133 180 if ($page === wtsec_getRoute("login")) {
@@ -150,18 +197,12 @@
150 197 }
151 198 }
152 199 }
153 200
154 -
155 -add_action('init', 'wtsec_StartSession', 1);
156 -add_action('wp_logout', 'wtsec_EndSession');
157 -add_action('wp_login', 'wtsec_EndSession');
158 -
159 -function wtsec_StartSession() {
160 - if(!session_id()) {
161 - session_start();
201 +function wtsec_login_check($user, $username, $password) {
202 + require_once WTSEC_PLUGIN_PATH . 'library/App.php';
203 + $app = new WTSEC_LIBRARY_App;
204 + if($app::getOption('authorized')){
205 + return $app->wtsec_login_check($user, $username, $password);
162 206 }
163 -}
164 -
165 -function wtsec_EndSession() {
166 - session_destroy ();
207 + return $user;
167 208 }