| @@ -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.2.3 | |
| 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,13 +25,32 @@ | ||
| 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.2"); | |
| 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'; |
| @@ -100,21 +119,23 @@ | ||
| 100 | 119 | } |
| 101 | 120 | |
| 102 | 121 | function wtsec_admin_init() |
| 103 | 122 | { |
| 123 | + $rand = '?rand='.rand(); | |
| 104 | 124 | if (is_admin() && stripos(wtsec_request()->page, WTSEC_PLUGIN_NAME) !== false) { |
| 105 | - wp_enqueue_script('subscriber', plugins_url('/htdocs/js/subscriber.js', __FILE__), [], false, true); | |
| 106 | - wp_enqueue_script('d3-v4', plugins_url('/htdocs/js/d3.v4.js', __FILE__), array( 'jquery' ), false, true); | |
| 107 | - wp_enqueue_script('jsdelivr', plugins_url('/htdocs/js/jsdelivr_chart.js', __FILE__), array( 'jquery' ), false, true); | |
| 108 | - wp_enqueue_script('chart', plugins_url('/htdocs/js/Chart.js', __FILE__), [], false, true); | |
| 109 | - wp_enqueue_script('circle-progress', plugins_url('/htdocs/js/circle-progress.js', __FILE__), [], false, true); | |
| 110 | - wp_enqueue_script('range-plugin', plugins_url('/htdocs/js/rangePlugin.js', __FILE__), array( 'jquery' ), false, true); | |
| 111 | - wp_enqueue_script('flatpickr', plugins_url('/htdocs/js/flatpickr.js', __FILE__), array( 'jquery' ), false, true); | |
| 112 | - wp_enqueue_script('filter-calendar', plugins_url('/htdocs/js/filterCalendar.js', __FILE__), array( 'jquery' ), false, true); | |
| 113 | - wp_enqueue_script('line-progress', plugins_url('/htdocs/js/line-progress.js', __FILE__), [], false, true); | |
| 114 | - wp_enqueue_script('main', plugins_url('/htdocs/js/main.js', __FILE__), [], false, true); | |
| 115 | - 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 ); | |
| 116 | 136 | wp_enqueue_script('subscriber'); |
| 137 | + wp_enqueue_script('print'); | |
| 117 | 138 | wp_enqueue_script('d3-v4'); |
| 118 | 139 | wp_enqueue_script('jsdelivr'); |
| 119 | 140 | wp_enqueue_script('chart'); |
| 120 | 141 | wp_enqueue_script('circle-progress'); |
| @@ -126,13 +147,12 @@ | ||
| 126 | 147 | wp_enqueue_script('ajax'); |
| 127 | 148 | |
| 128 | 149 | wp_register_style('flatpickr-css', 'https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css'); |
| 129 | 150 | wp_register_style('font', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap'); |
| 130 | - wp_register_style('normalize', plugins_url('/htdocs/css/normalize.css', __FILE__)); | |
| 131 | - 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__)); | |
| 132 | 152 | wp_enqueue_style('flatpickr-css'); |
| 133 | 153 | wp_enqueue_style('font'); |
| 134 | - wp_enqueue_style('normalize'); | |
| 154 | + wp_enqueue_style('print-css'); | |
| 135 | 155 | wp_enqueue_style('main'); |
| 136 | 156 | |
| 137 | 157 | $page = wtsec_request()->page; |
| 138 | 158 | if ($page === wtsec_getRoute("login")) { |
| @@ -155,13 +175,27 @@ | ||
| 155 | 175 | } |
| 156 | 176 | } |
| 157 | 177 | } |
| 158 | 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; | |
| 159 | 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 | + | |
| 160 | 193 | add_action('init', 'wtsec_StartSession', 1); |
| 161 | 194 | add_action('wp_logout', 'wtsec_EndSession'); |
| 162 | 195 | add_action('wp_login', 'wtsec_EndSession'); |
| 163 | 196 | |
| 197 | + | |
| 164 | 198 | function wtsec_StartSession() { |
| 165 | 199 | if(!session_id()) { |
| 166 | 200 | session_start(); |
| 167 | 201 | } |
| @@ -167,6 +201,10 @@ | ||
| 167 | 201 | } |
| 168 | 202 | } |
| 169 | 203 | |
| 170 | 204 | function wtsec_EndSession() { |
| 205 | + require_once WTSEC_PLUGIN_PATH . 'library/App.php'; | |
| 171 | 206 | session_destroy (); |
| 172 | -} | |
| 207 | +} | |
| 208 | + | |
| 209 | + | |
| 210 | + | |