PluginProbe
WebTotem Security / 2.1.8
WebTotem Security v2.1.8
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.1.8, at wt-security.php

167 lines 6.9 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.1.8
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.1");
30
31 add_action('admin_init', 'wtsec_admin_init');
32 add_action('wp_loaded', 'wtsec_init');
33
34 function wtsec_init()
35 {
36 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
37 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 // }
46 if (is_admin()) {
47 require_once WTSEC_PLUGIN_PATH . 'library/WT.php';
48 require_once WTSEC_PLUGIN_PATH . 'library/Localization.php';
49 require_once WTSEC_PLUGIN_PATH . 'library/Idn.php';
50 require_once WTSEC_PLUGIN_PATH . 'library/Session.php';
51 require_once WTSEC_PLUGIN_PATH . 'routes.php';
52 require_once WTSEC_PLUGIN_PATH . 'services.php';
53 require_once WTSEC_PLUGIN_PATH . 'helpers.php';
54 function wtsec_request()
55 {
56 return new WTSEC_LIBRARY_Request();
57 }
58 function wtsec_app()
59 {
60 return new WTSEC_LIBRARY_App();
61 }
62 function wtsec_filesystem_init($form_url, $method, $context, $fields = null)
63 {
64 global $wp_filesystem;
65 if (!$creds = request_filesystem_credentials($form_url, $method, false, $context, $fields)) {
66 return false;
67 }
68 if (!WP_Filesystem($creds)) {
69 request_filesystem_credentials($form_url, $method, true, $context);
70 return false;
71 }
72 return true;
73 }
74 function wtsec_locale($lmsg, $args = [])
75 {
76 return WTSEC_LIBRARY_Localization::lmsg($lmsg, $args);
77 }
78 function wtsec_getImagePath($image)
79 {
80 return plugins_url('/htdocs/img/' . $image, __FILE__);
81 }
82 function wtsec_SIS($arr, $key, $form = null)
83 {
84 $key = explode(".", $key);
85 foreach ($key as $_key) {
86 if (!isset($arr[$_key])) {
87 $arr = "";
88 break;
89 }
90 $arr = $arr[$_key];
91 }
92 return !empty($form) ? str_replace("$" . $key, $arr, $form) : $arr;
93 }
94 }
95 }
96
97 function wtsec_admin_init()
98 {
99 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 );
110 wp_enqueue_script('subscriber');
111 wp_enqueue_script('plug');
112 wp_enqueue_script('chart');
113 wp_enqueue_script('circle-progress');
114 wp_enqueue_script('line-progress');
115 wp_enqueue_script('range-plugin');
116 wp_enqueue_script('flatpickr');
117 wp_enqueue_script('filter-calendar');
118 wp_enqueue_script('main');
119 wp_enqueue_script('ajax');
120
121
122
123 wp_register_style('flatpickr-css', 'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css');
124 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__));
127 wp_enqueue_style('flatpickr-css');
128 wp_enqueue_style('font');
129 wp_enqueue_style('normalize');
130 wp_enqueue_style('main');
131
132 $page = wtsec_request()->page;
133 if ($page === wtsec_getRoute("login")) {
134 if (WTSEC_LIBRARY_App::authorized()) {
135 wp_safe_redirect(wtsec_getUrl('dashboard'));
136 }
137 } elseif ($page === wtsec_getRoute("logout")) {
138 WTSEC_LIBRARY_App::logout();
139 if (!WTSEC_LIBRARY_App::authorized()) {
140 wp_safe_redirect(wtsec_getUrl('login'));
141 }
142 } elseif ($page === wtsec_getRoute("activate")) {
143 if (WTSEC_LIBRARY_App::authorized()) {
144 wp_safe_redirect(wtsec_getUrl('sites'));
145 }
146 } else {
147 if (!WTSEC_LIBRARY_App::authorized()) {
148 wp_safe_redirect(wtsec_getUrl('login'));
149 }
150 }
151 }
152 }
153
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();
162 }
163 }
164
165 function wtsec_EndSession() {
166 session_destroy ();
167 }