| @@ -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.9 | |
| 7 | +Version: 2.3.14 | |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | define("WTSEC_PAGE_TITLE", 'Dashboard'); |
| 11 | 11 | define("WTSEC_MENU_TITLE", 'WT Security'); |
| @@ -25,25 +25,48 @@ | ||
| 25 | 25 | } |
| 26 | 26 | define("WTSEC_PLUGIN_URL", plugins_url("", __FILE__)); |
| 27 | 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 | +function wtsec_DeactivatedPlugin(){ | |
| 39 | + define("WTSEC_DEACTIVATED", true); | |
| 40 | + require_once WTSEC_PLUGIN_PATH . 'library/App.php'; | |
| 41 | + $app = new WTSEC_LIBRARY_App; | |
| 42 | + wtsec_DeleteAm(); | |
| 43 | + | |
| 44 | + $app::_set('am_installed', false); | |
| 45 | + $app::logout(); | |
| 46 | +} | |
| 47 | + | |
| 31 | 48 | add_action('admin_init', 'wtsec_admin_init'); |
| 32 | 49 | add_action('wp_loaded', 'wtsec_init'); |
| 33 | 50 | |
| 51 | +add_action( 'authenticate', 'wtsec_login_check' ); | |
| 52 | + | |
| 34 | 53 | function wtsec_init() |
| 35 | 54 | { |
| 36 | 55 | require_once WTSEC_PLUGIN_PATH . 'library/App.php'; |
| 37 | 56 | 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 | -// } | |
| 57 | + | |
| 58 | + // WAF include (Если не админка и статус waf = "start", "uninstalled") | |
| 59 | + // && in_array(WTSEC_LIBRARY_App::getOption('waf_status'), ["start", "uninstalled"]) | |
| 60 | + if (!is_admin()) { | |
| 61 | + if ($waf = WTSEC_LIBRARY_App::getOption(("waf_installed_file"))) { | |
| 62 | + $path_to_waf = $_SERVER['DOCUMENT_ROOT'] . '/_include_' . $waf; | |
| 63 | + if (is_file($path_to_waf) && is_readable($path_to_waf)) { | |
| 64 | + include_once $path_to_waf; | |
| 65 | + } | |
| 66 | + } | |
| 67 | + } | |
| 68 | + | |
| 46 | 69 | if (is_admin()) { |
| 47 | 70 | require_once WTSEC_PLUGIN_PATH . 'library/WT.php'; |
| 48 | 71 | require_once WTSEC_PLUGIN_PATH . 'library/Localization.php'; |
| 49 | 72 | require_once WTSEC_PLUGIN_PATH . 'library/Idn.php'; |
| @@ -50,8 +73,9 @@ | ||
| 50 | 73 | require_once WTSEC_PLUGIN_PATH . 'library/Session.php'; |
| 51 | 74 | require_once WTSEC_PLUGIN_PATH . 'routes.php'; |
| 52 | 75 | require_once WTSEC_PLUGIN_PATH . 'services.php'; |
| 53 | 76 | require_once WTSEC_PLUGIN_PATH . 'helpers.php'; |
| 77 | + | |
| 54 | 78 | function wtsec_request() |
| 55 | 79 | { |
| 56 | 80 | return new WTSEC_LIBRARY_Request(); |
| 57 | 81 | } |
| @@ -95,21 +119,25 @@ | ||
| 95 | 119 | } |
| 96 | 120 | |
| 97 | 121 | function wtsec_admin_init() |
| 98 | 122 | { |
| 123 | + $rand = '?rand='.rand(); | |
| 99 | 124 | 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 ); | |
| 125 | + wp_enqueue_script('subscriber', plugins_url('/htdocs/js/wtsec_subscriber.js'.$rand, __FILE__), [], false, true); | |
| 126 | + wp_enqueue_script('d3-v4', plugins_url('/htdocs/js/wtsec_d3.v4.js', __FILE__), array( 'jquery' ), false, true); | |
| 127 | + wp_enqueue_script('jsdelivr', plugins_url('/htdocs/js/wtsec_jsdelivr_chart.js', __FILE__), array( 'jquery' ), false, true); | |
| 128 | + wp_enqueue_script('chart', plugins_url('/htdocs/js/wtsec_Chart.js'.$rand, __FILE__), [], false, true); | |
| 129 | + wp_enqueue_script('circle-progress', plugins_url('/htdocs/js/wtsec_circle-progress.js', __FILE__), [], false, true); | |
| 130 | + wp_enqueue_script('range-plugin', plugins_url('/htdocs/js/wtsec_rangePlugin.js', __FILE__), array( 'jquery' ), false, true); | |
| 131 | + wp_enqueue_script('flatpickr', plugins_url('/htdocs/js/wtsec_flatpickr.js', __FILE__), array( 'jquery' ), false, true); | |
| 132 | + wp_enqueue_script('filter-calendar', plugins_url('/htdocs/js/wtsec_filterCalendar.js', __FILE__), array( 'jquery' ), false, true); | |
| 133 | + wp_enqueue_script('line-progress', plugins_url('/htdocs/js/wtsec_line-progress.js', __FILE__), [], false, true); | |
| 134 | + wp_enqueue_script('main', plugins_url('/htdocs/js/wtsec_main.js'.$rand, __FILE__), [], false, true); | |
| 135 | + wp_enqueue_script('ajax', plugins_url( '/htdocs/js/wtsec_ajax.js'.$rand, __FILE__ ), array( 'jquery' ),false, true ); | |
| 110 | 136 | wp_enqueue_script('subscriber'); |
| 111 | - wp_enqueue_script('plug'); | |
| 137 | + wp_enqueue_script('print'); | |
| 138 | + wp_enqueue_script('d3-v4'); | |
| 139 | + wp_enqueue_script('jsdelivr'); | |
| 112 | 140 | wp_enqueue_script('chart'); |
| 113 | 141 | wp_enqueue_script('circle-progress'); |
| 114 | 142 | wp_enqueue_script('line-progress'); |
| 115 | 143 | wp_enqueue_script('range-plugin'); |
| @@ -117,17 +145,14 @@ | ||
| 117 | 145 | wp_enqueue_script('filter-calendar'); |
| 118 | 146 | wp_enqueue_script('main'); |
| 119 | 147 | wp_enqueue_script('ajax'); |
| 120 | 148 | |
| 121 | - | |
| 122 | - | |
| 123 | 149 | wp_register_style('flatpickr-css', 'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css'); |
| 124 | 150 | 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__)); | |
| 151 | + wp_register_style('main', plugins_url('/htdocs/css/wtsec_main.css'.$rand, __FILE__)); | |
| 127 | 152 | wp_enqueue_style('flatpickr-css'); |
| 128 | 153 | wp_enqueue_style('font'); |
| 129 | - wp_enqueue_style('normalize'); | |
| 154 | + wp_enqueue_style('print-css'); | |
| 130 | 155 | wp_enqueue_style('main'); |
| 131 | 156 | |
| 132 | 157 | $page = wtsec_request()->page; |
| 133 | 158 | if ($page === wtsec_getRoute("login")) { |
| @@ -150,13 +175,27 @@ | ||
| 150 | 175 | } |
| 151 | 176 | } |
| 152 | 177 | } |
| 153 | 178 | |
| 179 | +function wtsec_login_check() { | |
| 180 | + require_once WTSEC_PLUGIN_PATH . 'library/App.php'; | |
| 181 | + require_once WTSEC_PLUGIN_PATH . 'library/Localization.php'; | |
| 182 | + $app = new WTSEC_LIBRARY_App; | |
| 154 | 183 | |
| 184 | + function wtsec_locale($lmsg, $args = []) | |
| 185 | + { | |
| 186 | + return WTSEC_LIBRARY_Localization::lmsg($lmsg, $args); | |
| 187 | + } | |
| 188 | + | |
| 189 | + $app->wtsec_login_check(); | |
| 190 | +} | |
| 191 | + | |
| 192 | + | |
| 155 | 193 | add_action('init', 'wtsec_StartSession', 1); |
| 156 | 194 | add_action('wp_logout', 'wtsec_EndSession'); |
| 157 | 195 | add_action('wp_login', 'wtsec_EndSession'); |
| 158 | 196 | |
| 197 | + | |
| 159 | 198 | function wtsec_StartSession() { |
| 160 | 199 | if(!session_id()) { |
| 161 | 200 | session_start(); |
| 162 | 201 | } |
| @@ -162,6 +201,10 @@ | ||
| 162 | 201 | } |
| 163 | 202 | } |
| 164 | 203 | |
| 165 | 204 | function wtsec_EndSession() { |
| 205 | + require_once WTSEC_PLUGIN_PATH . 'library/App.php'; | |
| 166 | 206 | session_destroy (); |
| 167 | -} | |
| 207 | +} | |
| 208 | + | |
| 209 | + | |
| 210 | + | |