PluginProbe
WebTotem Security / 1.3
WebTotem Security v1.3
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 1.3, at wt-security.php

125 lines 4.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: Webtotem Wordpress Security
5 Description: Webtotem Wordpress Security is a SaaS which provides powerful tools for securing and monitoring your website in one place in easy and flexible way.
6 Author: TSARKA
7 Version: 1.3
8 */
9 define("WTSEC_PAGE_TITLE", 'Dashboard');
10 define("WTSEC_MENU_TITLE", 'Webtotem Security');
11 define("WTSEC_PLUGIN_PATH", plugin_dir_path(__FILE__));
12 define("WTSEC_PLUGIN_NAME", 'wt-security');
13 define("WTSEC_PLUGIN_PREFIX", 'wtsec_');
14 define("WTSEC_PAGE_PREFIX", WTSEC_PLUGIN_NAME . '-');
15 define("WTSEC_FILE_URL", "https://api.wtotem.com");
16 define("WTSEC_ROOT", WP_PLUGIN_DIR . '/');
17 define("WTSEC_MODULES_DIR", WTSEC_PLUGIN_PATH . 'uploads/');
18 if (is_dir(WTSEC_MODULES_DIR) && is_writable(WTSEC_MODULES_DIR)) {
19 define("WTSEC_INSTALLATION_DIR", WTSEC_MODULES_DIR);
20 define("WTOTEMSEC_INSTALLATION_DIR", WTSEC_MODULES_DIR);
21 } else {
22 define("WTSEC_INSTALLATION_DIR", wp_upload_dir()['basedir'] . '/');
23 define("WTOTEMSEC_INSTALLATION_DIR", wp_upload_dir()['basedir'] . '/');
24 }
25 define("WTSEC_PLUGIN_URL", plugins_url("", __FILE__));
26 define("WTSEC_SITE_URL", str_replace(['http://', 'https://', 'www.', '//', '://'], '', get_site_url()));
27
28 define("WTSEC_PLUGIN_INFORMATION_VERSION", "1.2");
29
30 add_action('admin_init', 'wtsec_admin_init');
31 add_action('wp_loaded', 'wtsec_init');
32
33 function wtsec_init()
34 {
35 require_once WTSEC_PLUGIN_PATH . 'library/App.php';
36 require_once WTSEC_PLUGIN_PATH . 'library/Request.php';
37 if (!is_admin() && in_array(WTSEC_LIBRARY_App::getOption('waf_status'), ["start", "uninstalled"])) {
38 if ($waf = WTSEC_LIBRARY_App::getOption(("waf_installed_file"))) {
39 $path_to_waf = WTSEC_INSTALLATION_DIR . '/' . $waf;
40 if (is_file($path_to_waf) && is_readable($path_to_waf)) {
41 include $path_to_waf;
42 }
43 }
44 }
45 if (is_admin()) {
46 require_once WTSEC_PLUGIN_PATH . 'library/WT.php';
47 require_once WTSEC_PLUGIN_PATH . 'library/Localization.php';
48 require_once WTSEC_PLUGIN_PATH . 'library/Idn.php';
49 require_once WTSEC_PLUGIN_PATH . 'library/Session.php';
50 require_once WTSEC_PLUGIN_PATH . 'routes.php';
51 require_once WTSEC_PLUGIN_PATH . 'services.php';
52 function wtsec_request()
53 {
54 return new WTSEC_LIBRARY_Request();
55 }
56 function wtsec_app()
57 {
58 return new WTSEC_LIBRARY_App();
59 }
60 function wtsec_filesystem_init($form_url, $method, $context, $fields = null)
61 {
62 global $wp_filesystem;
63 if (!$creds = request_filesystem_credentials($form_url, $method, false, $context, $fields)) {
64 return false;
65 }
66 if (!WP_Filesystem($creds)) {
67 request_filesystem_credentials($form_url, $method, true, $context);
68 return false;
69 }
70 return true;
71 }
72 function wtsec_locale($lmsg, $args = [])
73 {
74 return WTSEC_LIBRARY_Localization::lmsg($lmsg, $args);
75 }
76 function wtsec_getImagePath($image)
77 {
78 return plugins_url('/htdocs/images/' . $image, __FILE__);
79 }
80 function wtsec_SIS($arr, $key, $form = null)
81 {
82 $key = explode(".", $key);
83 foreach ($key as $_key) {
84 if (!isset($arr[$_key])) {
85 $arr = "";
86 break;
87 }
88 $arr = $arr[$_key];
89 }
90 return !empty($form) ? str_replace("$" . $key, $arr, $form) : $arr;
91 }
92 }
93 }
94
95 function wtsec_admin_init()
96 {
97 if (is_admin() && stripos(wtsec_request()->page, WTSEC_PLUGIN_NAME) !== false) {
98 wp_register_style("css", plugins_url('/htdocs/css/src.c37ba8ac.css', __FILE__));
99 wp_enqueue_style('css');
100 wp_enqueue_script('chart', plugins_url('/htdocs/js/Chart.min.js', __FILE__), [], false, true);
101 wp_enqueue_script('chart');
102 wp_enqueue_script('app', plugins_url('/htdocs/js/src.e31bb0bc.js', __FILE__), [], false, true);
103 wp_enqueue_script('app');
104 $page = wtsec_request()->page;
105 if ($page === wtsec_getRoute("login")) {
106 if (WTSEC_LIBRARY_App::authorized()) {
107 wp_safe_redirect(wtsec_getUrl('dashboard'));
108 }
109 } elseif ($page === wtsec_getRoute("logout")) {
110 WTSEC_LIBRARY_App::logout();
111 if (!WTSEC_LIBRARY_App::authorized()) {
112 wp_safe_redirect(wtsec_getUrl('login'));
113 }
114 } elseif ($page === wtsec_getRoute("activate")) {
115 if (WTSEC_LIBRARY_App::authorized()) {
116 wp_safe_redirect(wtsec_getUrl('sites'));
117 }
118 } else {
119 if (!WTSEC_LIBRARY_App::authorized()) {
120 wp_safe_redirect(wtsec_getUrl('login'));
121 }
122 }
123 }
124 }
125