PluginProbe
WebTotem Security / 2.1.7
WebTotem Security v2.1.7
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 / routes.php

routes.php in WebTotem Security 2.1.7, at routes.php

633 lines 25.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 add_action('admin_menu', 'wtsec_add_menu_link');
4 add_action('wp_ajax_change_status', 'wtsec_ajax_changeStatus');
5 add_action('admin_post_change_status', 'wtsec_changeStatus');
6 add_action('wp_ajax_cmd', 'wtsec_cmd_ajax');
7 add_action('admin_post_login_form', 'wtsec_login_form');
8 add_action('admin_post_ajax_cmd', 'wtsec_cmd_ajax');
9
10 function wtsec_add_menu_link()
11 {
12 add_menu_page(
13 WTSEC_PAGE_TITLE,
14 WTSEC_MENU_TITLE,
15 'manage_options',
16 wtsec_getRoute('dashboard'),
17 'wtsec_index_page',
18 '',
19 '1'
20 );
21 $parent = wtsec_getRoute('dashboard');
22 if (WTSEC_LIBRARY_App::authorized()) {
23 $capability = 'manage_options';
24 foreach (wtsec_pages() as $page => $arguments) {
25 add_submenu_page($parent, $arguments['page_title'], $arguments['menu_title'], $capability, wtsec_getRoute($page), $arguments['function']);
26 }
27 add_submenu_page(null, WTSEC_LIBRARY_Localization::lmsg('sign_in'), WTSEC_LIBRARY_Localization::lmsg('sign_in'), 'manage_options', wtsec_getRoute('login'), 'wtsec_login');
28 add_submenu_page($parent, WTSEC_LIBRARY_Localization::lmsg('logout'), WTSEC_LIBRARY_Localization::lmsg('logout'), 'manage_options', wtsec_getRoute('logout'), 'wtsec_logout');
29 } else {
30 $capability = 'manage_options';
31 foreach (wtsec_pages() as $page => $arguments) {
32 add_submenu_page(null, $arguments['page_title'], $arguments['menu_title'], $capability, wtsec_getRoute($page), function () {
33 wp_safe_redirect(wtsec_getUrl('login'));
34 });
35 }
36 add_submenu_page($parent, WTSEC_LIBRARY_Localization::lmsg('sign_in'), WTSEC_LIBRARY_Localization::lmsg('sign_in'), 'manage_options', wtsec_getRoute('login'), 'wtsec_login');
37 add_submenu_page(null, WTSEC_LIBRARY_Localization::lmsg('logout'), WTSEC_LIBRARY_Localization::lmsg('logout'), 'manage_options', wtsec_getRoute('logout'), 'wtsec_logout');
38 }
39 }
40
41 function dd($vl)
42 {
43 echo '<pre>';
44 print_r($vl);
45 echo '</pre>';
46 die();
47 }
48
49 function myGrading($score)
50 {
51 if ($score < 0 || $score > 100) return ['grade' => '','color' => ''];
52 if ($score == 100) return ['grade' => 'A+','color' => 'green'];
53 $decimal = $score % 10;
54 $score = $score / 10;
55 $scores = ['F', 'F', 'F', 'F', 'F', 'F', 'C', 'B', 'B', 'A'];
56 $colors = ['red', 'red', 'red', 'red', 'red', 'red', 'orange', 'orange', 'orange', 'green'];
57 $grade = $scores[$score];
58 $color = $colors[$score];
59 if ($grade != 'F') {
60 if ($decimal <= 2) $grade .= '-';
61 else if ($decimal >= 7) $grade .= '+';
62 }
63 return ['grade' => $grade,'color' => $color];
64 }
65
66
67 function convertTimeToReadable($date)
68 {
69 $lang = get_locale();
70 //enable russian language
71 if ($lang === "ru_RU") {
72 $lang .= ".UTF-8";
73 setlocale(LC_ALL, $lang);
74 }
75 if(strpos($date, ".") !== false){
76 $date = substr($date, 0, strpos($date, "."));
77 }
78 return strftime("%B %e, %Y / %R", strtotime($date." UTC"));
79 }
80
81
82 function convertToCurrentTime($date)
83 {
84 $lang = get_locale();
85 //enable russian language
86 if ($lang === "ru_RU") {
87 $lang .= ".UTF-8";
88 setlocale(LC_ALL, $lang);
89 }
90 if(strpos($date, ".") !== false){
91 $date = substr($date, 0, strpos($date, "."));
92 }
93 $date .= " UTC";
94 $current_time = strtotime($date);
95 return ['date' => date("Y-m-d", $current_time),'time' => date("H:i:s",$current_time)];
96 }
97
98 function wtsec_index_page()
99 {
100 $host = WTSEC_LIBRARY_WT::getOwnSite();
101 $services = [];
102 if (!empty($host)) {
103 $services = [
104 "settings" => [
105 "token" => WTSEC_LIBRARY_App::getToken(),
106 "site_id" => $host['id'],
107 ],
108 "score" => [
109 "total_score" => 0,
110 "tested_on" => "",
111 "server_ip" => "",
112 "location" => "",
113 "description" => wtsec_locale("score.description"),
114 "information" => "",
115 "grade" => "",
116 ],
117 ];
118
119 $score = json_decode(WTSEC_LIBRARY_WT::getScore(), true);
120 if (!empty($score)) {
121 $total_score = round($score['totalScore']);
122 $my_grading = myGrading($total_score);
123 $services["score"] = [
124 "total_score" => $total_score."%",
125 "tested_on" => convertTimeToReadable($score['date']),
126 "server_ip" => $score['ip'],
127 "location" => $score['country'],
128 "description" => wtsec_locale("score.description"),
129 "information" => wtsec_locale("score.higher_than_percent", ['percent' => $score['ishigherthan']]),
130 "grade" => $my_grading['grade'],
131 "color" => $my_grading['color'],
132 ];
133 }
134
135 $checks = WTSEC_LIBRARY_WT::getAllChecks($host['id']);
136 foreach ($checks as $service => $site) {
137 if (empty($site) || !is_array($site)) {
138 continue;
139 }
140 switch ($service) {
141 case "availability":
142 $services["wa"] = [
143 // "pause" => wtsec_getStatusStartPauseIcon($site['config']['isActive'], $site['config']['id'], $host['id']),
144 "pause" => "",
145 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
146 "response_time" => ceil($site['responseTime'] / 1000000) . ' ' . WTSEC_LIBRARY_Localization::lmsg('ms'),
147 "availability" => $site['percent'] . '%',
148 "availability_percent" => $site['percent'],
149 "last_test" => convertTimeToReadable($site['lastTest']['time']),
150 "downtime" => ceil($site['downTime'] / 1000000) . ' ' . WTSEC_LIBRARY_Localization::lmsg('ms'),
151 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.availability')
152 ];
153 break;
154 case "ssl":
155 if ((int)$site['expiryDate'] === 0) {
156 $days_left = 0;
157 } else {
158 $earlier = new DateTime();
159 $later = new DateTime($site['expiryDate']);
160 $days_left = $later->diff($earlier)->format("%a");
161 }
162 $services["ssl"] = [
163 "pause" => "",
164 "information" => wtsec_getInformation($service, $site['status']),
165 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
166 "days_left" => $days_left,
167 "issue_date" => $site['issueDate'],
168 "expiry_date" => $site['expiryDate'],
169 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.ssl'),
170 "solve_it" => in_array($site['status'],['clean','pending']) ? '' : wtsec_locale('solve_it'),
171 ];
172 break;
173 case "domain":
174 if ((int)$site['expiredDate'] === 0) {
175 $days_left = 0;
176 } else {
177 $earlier = new DateTime();
178 $later = new DateTime($site['expiredDate']);
179 $days_left = $later->diff($earlier)->format("%a");
180 }
181
182 $services["dec"] = [
183 "pause" => "",
184 "registrar" => $site['registrar'],
185 "owner" => $site['owner'],
186 "information" => wtsec_getInformation($service, $site['status']),
187 "email" => $site['email'],
188 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
189 "days_left" => $days_left,
190 "created" => $site['createdDate'],
191 "expiry_date" => $site['expiredDate'],
192 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.domain')
193 ];
194 break;
195 case "reputation":
196 $count = 0;
197 if ($site['status'] != "clean") {
198 foreach ($site['virusList'] as &$list) {
199 if (!empty($list['viruses'])) {
200 $count++;
201 }
202 }
203 }
204 $services["av"] = [
205 "pause" => "",
206 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
207 "time_of_the_last_test" => convertTimeToReadable($site['lastTest']['time']),
208 "blacklists_entries" => $count,
209 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.reputation'),
210 "reputation" => $site['status'] === "infected" ? wtsec_locale('bad_reputation') : wtsec_locale('good_reputation'),
211 ];
212 break;
213 case "maliciousScript":
214 $services["cms"] = [
215 "pause" => "",
216 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
217 "time_of_the_last_test" => $site['lastTest']['time'],
218 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.malicious')
219 ];
220 break;
221 case "deface":
222 $services["dc"] = [
223 "pause" => "",
224 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
225 "time_of_the_last_test" => convertTimeToReadable($site['lastTest']['time']),
226 "number" => $site['count'],
227 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.deface')
228 ];
229 break;
230 case "ports":
231 $services["ps"] = [
232 "pause" => "",
233 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
234 "ip" => $site['ip'],
235 "last_test" => convertTimeToReadable($site['lastTest']['time']),
236 "number" => count($site['tcp']),
237 "tcp" => !empty($site['tcp']) ? implode(",", $site['tcp']) : '',
238 "udp" => "",
239 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.port')
240 ];
241 break;
242 case "firewall":
243 $service = "WAF";
244 $_service = strtolower($service);
245 $domain = $host['hostname'];
246 $uid = $host['id'];
247
248 $chart = generateChart($site['chart']);
249 // $status = wtsec_checkStatus($uid, $service);
250
251 $data = WTSEC_LIBRARY_WT::getFirewall($host['id']);
252 $data = $data['data']['auth']['viewer']['sites']['one']['firewall'];
253
254 $countryAttacks = getCountryAttacks($data['map'], $chart['count_attacks']);
255 $edges = $data['logs']['edges'];
256
257 $services["waf"] = [
258 "pause" => "",
259 "site_address" => $domain,
260 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
261 "_status" => $site['status'],
262 "installed_status" => in_array($site['status'], ["not_installed", "error", "down", "not_supported", "not_registered"]) ? false : true,
263 "time_of_the_last_check" => convertTimeToReadable($site['lastTest']['time']),
264 "attacks" => $chart['count_attacks'],
265 "blocking" => $chart['count_blocks'],
266 "non-blocking" => $chart['count_attacks'] - $chart['count_blocks'],
267 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.firewall'),
268 "actions" => wtsec_generateButtons($uid, $_service, $service, $site['status'], WTSEC_SITE_URL),
269 "chart" => json_encode($chart['chart'], true),
270 "edges" => $edges,
271 "countryAttacks" => $countryAttacks,
272 ];
273 break;
274 case "antivirus":
275 $service = "AV";
276 $_service = strtolower($service);
277 $domain = $host['hostname'];
278 $uid = $host['id'];
279 // $status = wtsec_checkStatus($uid, $service);
280 $services["vc"] = [
281 "pause" => "",
282 "site_address" => $domain,
283 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
284 "installed_status" => in_array($site['status'], ["not_installed", "error", "down", "not_supported", "not_registered"]) ? false : true,
285 "_status" => $site['status'],
286 "signatures" => (int)$site['stats']['infected'],
287 "changes" => (int)$site['stats']['changed'],
288 "scanned" => (int)$site['stats']['scaned'],
289 "deleted" => (int)$site['stats']['deleted'],
290 "list" => $site['stats']["infected"],
291 "actions" => wtsec_generateButtons($uid, $_service, $service, $site['status'], WTSEC_SITE_URL),
292 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.antivirus')
293 ];
294 break;
295 }
296 }
297
298
299 //check AM, if not installed , run install
300 $process = "installing";
301 $check_am_file = wtsec_checkInstalledFile("AM");
302 $am_installed = $check_am_file["status"];
303 $am_installed_status = wtsec_app()->get('am_installed');
304 if (!$am_installed && !$am_installed_status) {
305 $am_is_installed = wtsec_cmd("am_install", "AM", "am", $host['id'], [], WTSEC_SITE_URL);
306 if (!$am_is_installed) {
307 $process = "failed";
308 wtsec_app()->set('am_installed', false);
309 } else {
310 wtsec_app()->set('am_installed', true);
311 }
312 } elseif ($services["vc"]["_status"] === "not_installed" || $services["waf"]["_status"] === "not_installed") {
313 $process = "installing";
314 } else {
315 $process = "installed";
316 }
317
318 $services["am"] = [
319 "status" => WTSEC_LIBRARY_WT::getStatusIcon($am_installed ? "working" : "not_installed"),
320 "actions" => wtsec_generateButtons($host['id'], "am", "AM", ["active" => $check_am_file], WTSEC_SITE_URL),
321 "process_status" => $process,
322 "installed" => $am_installed,
323 ];
324 }
325
326 wtsec_layout("dashboard", $services);
327 }
328
329 function getCountryAttacks($map, $countAttacks){
330
331 if($map){
332 $attackKey = array_search(max(array_column($map, 'attacks')), array_column($map, 'attacks'));
333 $map[$attackKey]['percent'] = round($map[$attackKey]['attacks'] / $countAttacks * 100);
334 $map[$attackKey]['country'] = wtsec_locale("countries.".$map[$attackKey]['country']);
335 return $map[$attackKey];
336 }
337
338 return ['percent' => 0, 'country' => false];
339
340 }
341
342 function generateChart($charts)
343 {
344 $count_attacks = 0;
345 $count_blocks = 0;
346 $d = date("d");
347 $m = date("m");
348 $y = date("Y");
349 $c = [];
350 $first_day = $d - 6;
351 if ($first_day < 1) {
352 $lastmonth = (int)date('d', strtotime('last day of previous month'));
353 $lastmonth_day = $lastmonth;
354 $lastmonth_month = (int)date('m', strtotime('last day of previous month'));
355 $lastmonth_year = (int)date('Y', strtotime('last day of previous month'));
356 $lastmonth = $lastmonth - ($first_day * -1);
357 for ($i = $lastmonth; $i <= $lastmonth_day; $i++) {
358 $c[$i] = [
359 'date' => $lastmonth_year.'-'.$lastmonth_month.'-'.$lastmonth_day,
360 'count' => 0,
361 'attacks' => 0,
362 'blocked' => 0,
363 ];
364 }
365 $first_day = 1;
366 }
367 for ($i = $first_day; $i <= $d; $i++) {
368 $c[$i] = [
369 'date' => $y.'-'.$m.'-'.$i,
370 'count' => 0,
371 'attacks' => 0,
372 'blocked' => 0,
373 ];
374 }
375 foreach ($charts as $chart) {
376 $d = (int)date("d", strtotime($chart['time']));
377 $c[$d]['count'] = $chart['blocked'];
378 $c[$d]['attacks'] = $chart['attacks'];
379 $c[$d]['blocked'] = $chart['blocked'];
380 $count_attacks += $chart['attacks'];
381 $count_blocks += $chart['blocked'];
382 }
383
384 //unset keys, because the js parser sorting by key in integer
385 $result = [];
386 foreach ($c as $d) {
387 $result[] = $d;
388 }
389 return ['chart' => $result, 'count_attacks' => $count_attacks, 'count_blocks' => $count_blocks];
390 }
391
392 function wtsec_getInformation($service, $status)
393 {
394 $information = [
395 "ssl" => [
396 WTSEC_LIBRARY_Localization::lmsg("statuses.ok"),
397 WTSEC_LIBRARY_Localization::lmsg("statuses.invalid"),
398 WTSEC_LIBRARY_Localization::lmsg("statuses.expired"),
399 WTSEC_LIBRARY_Localization::lmsg("statuses.expires"),
400 "unknown_status" => WTSEC_LIBRARY_Localization::lmsg("statuses.missing"),
401 ],
402 "domain" => [
403 WTSEC_LIBRARY_Localization::lmsg("statuses.ok"),
404 WTSEC_LIBRARY_Localization::lmsg("statuses.expires"),
405 "unknown_status" => WTSEC_LIBRARY_Localization::lmsg("statuses.error"),
406 ]
407 ];
408 return isset($information[$service][$status]) ? $information[$service][$status] : $information[$service]["unknown_status"];
409 }
410
411 function wtsec_getStatusStartPauseIcon($status, $config_id, $host_id)
412 {
413 $icon = '';
414 switch ($status) {
415 case "1":
416 $icon = '<div class="v-pause ww-icon ww-icon--pause" style="border:none" data-config_id="' . $config_id . '" data-host_id="' . $host_id . '"></div>';
417 break;
418 case "0":
419 $icon = '<div class="v-pause ww-icon ww-icon--play" style="border:none" data-config_id="' . $config_id . '" data-host_id="' . $host_id . '"></div>';
420 break;
421 }
422 return $icon;
423 }
424
425 function wtsec_options_page()
426 {
427 $host = WTSEC_LIBRARY_WT::getOwnSite();
428 $result = WTSEC_LIBRARY_WT::getOptions($host['id']);
429 $options = [];
430 if (isset($result['data']['userHost']['services'])) {
431 foreach ($result['data']['userHost']['services'] as $service) {
432 $configs = $service['configs'][0];
433 $options[$service['name']] = ['config_id' => $configs['id'], 'is_active' => $configs['isActive']];
434 }
435 }
436 $options['host_id'] = $host['id'];
437 wtsec_layout("options", $options);
438 }
439
440 function wtsec_services_page()
441 {
442 wtsec_layout("services");
443 }
444
445 function wtsec_antivirus_page()
446 {
447 $host = WTSEC_LIBRARY_WT::getOwnSite();
448 $services = [];
449 if (!empty($host)) {
450 $site = WTSEC_LIBRARY_WT::getAntivirus($host['id']);
451 if (isset($site['data']['auth']['viewer']['sites']['one']['antivirus']['log'])) {
452 $site = $site['data']['auth']['viewer']['sites']['one']['antivirus'];
453 $service = "AV";
454 $_service = strtolower($service);
455 $domain = $host['hostname'];
456 $uid = $host['id'];
457 $status = wtsec_checkStatus($uid, $service);
458 $services["vc"] = [
459 "pause" => "",
460 "site_address" => $domain,
461 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
462 "signatures" => (int)$site['stats']['infected'],
463 "changes" => (int)$site['stats']['changed'],
464 "scanned" => (int)$site['stats']['scaned'],
465 "deleted" => (int)$site['stats']['deleted'],
466 "list" => $site["log"]['edges'],
467 "actions" => $buttons = wtsec_generateButtons($uid, $_service, $service, $status, WTSEC_SITE_URL),
468 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.antivirus')
469 ];
470 }
471 }
472 wtsec_layout("antivirus", $services);
473 }
474
475
476 function wtsec_firewall_page()
477 {
478 $host = WTSEC_LIBRARY_WT::getOwnSite();
479 $services = [];
480 if (!empty($host)) {
481 $site = WTSEC_LIBRARY_WT::getFirewall($host['id']);
482 $chart = WTSEC_LIBRARY_WT::getFirewallChart($host['id']);
483 if (isset($site['data']['auth']['viewer']['sites']['one']['firewall']['logs'])) {
484 $site = $site['data']['auth']['viewer']['sites']['one']['firewall'];
485 $chart = $chart['data']['auth']['viewer']['sites']['one']['firewall']['chart'];
486 $chart = generateChart($chart);
487 $edges = $site['logs']['edges'];
488 $domain = $host['hostname'];
489
490 $countryAttacks = getCountryAttacks($site['map'], $chart['count_attacks']);
491
492 $services["waf"] = [
493 "pause" => "",
494 "site_address" => $domain,
495 "status" => WTSEC_LIBRARY_WT::getStatusIcon($site['status']),
496 "_status" => $site['status'],
497 "installed_status" => in_array($site['status'], ["not_installed", "error", "down", "not_supported", "not_registered"]) ? false : true,
498 "time_of_the_last_check" => convertTimeToReadable($site['lastTest']['time']),
499 "attacks" => $chart['count_attacks'],
500 "blocking" => $chart['count_blocks'],
501 "non-blocking" => $chart['count_attacks'] - $chart['count_blocks'],
502 "description" => WTSEC_LIBRARY_Localization::lmsg('descriptions.firewall'),
503 "chart" => json_encode($chart['chart'], true),
504 "edges" => $edges,
505 "countryAttacks" => $countryAttacks,
506 ];
507 }
508 }
509 wtsec_layout("firewall", $services);
510 }
511
512 function wtsec_login_form()
513 {
514 if (wtsec_request()->method === "POST") {
515 $result = WTSEC_LIBRARY_WT::auth(wtsec_request()->key);
516 if (isset($result['data']['guest']['apiKeys']['auth']['token']['value'])) {
517 WTSEC_LIBRARY_Session::setNotification("success", WTSEC_LIBRARY_Localization::lmsg('successfully_activated'));
518 $token = $result['data']['guest']['apiKeys']['auth']['token']['value'];
519 WTSEC_LIBRARY_App::login($token);
520 wtsec_app()->set("api_key", wtsec_request()->key);
521 wp_safe_redirect(wtsec_getUrl('dashboard'));
522 exit;
523 } else {
524 WTSEC_LIBRARY_Session::setNotification("error", WTSEC_LIBRARY_Localization::lmsg("form.incorrect"));
525 }
526 }
527 wp_safe_redirect(wtsec_getUrl('login'));
528 }
529
530 function wtsec_cmd_ajax()
531 {
532 $service = strtoupper(wtsec_request()->service);
533 $_service = strtolower(wtsec_request()->service);
534 $uid = wtsec_request()->uid;
535 $cmd = wtsec_request()->cmd;
536 $status = wtsec_checkStatus($uid, $service);
537 if (stripos($cmd, "install") === false) {
538 wtsec_cmd($cmd, $service, $_service, $uid, $status, WTSEC_SITE_URL);
539 wp_safe_redirect(wp_get_referer());
540 } else {
541 $redirect = wtsec_getUrl("dashboard");
542 $form_url = wp_nonce_url(admin_url('admin-post.php?cmd=' . $cmd . '&action=ajax_cmd&service=' . $service . '&uid=' . $uid), "ajax_cmd");
543 if (wtsec_filesystem_init($form_url, '', false, false)) {
544 wtsec_cmd($cmd, $service, $_service, $uid, $status, WTSEC_SITE_URL);
545 wp_safe_redirect($redirect);
546 }
547 }
548 }
549
550 function wtsec_login()
551 {
552 require_once WTSEC_PLUGIN_PATH . "includes/login.php";
553 }
554
555 function wtsec_logout()
556 {
557 WTSEC_LIBRARY_App::logout();
558 }
559
560
561 function wtsec_layout($template, $arguments = [], $faq = "faq")
562 {
563 $body = WTSEC_PLUGIN_PATH . "includes/" . $template . ".php";
564 $faq = WTSEC_PLUGIN_PATH . "includes/" . $faq . ".php";
565 require_once WTSEC_PLUGIN_PATH . "includes/layout.php";
566 }
567
568
569 function wtsec_ajax_changeStatus()
570 {
571 if (wtsec_request()->method === "POST") {
572 $host_id = wtsec_request()->host_id;
573 $config_id = wtsec_request()->config_id;
574 $result = WTSEC_LIBRARY_WT::changeStatus($config_id, $host_id);
575 echo json_encode($result);
576 }
577 wp_die();
578 }
579
580 function wtsec_changeStatus()
581 {
582 if (wtsec_request()->method === "POST") {
583 $host_id = wtsec_request()->host_id;
584 $config_id = wtsec_request()->config_id;
585 WTSEC_LIBRARY_WT::changeStatus($config_id, $host_id);
586 }
587 wp_safe_redirect(wp_get_referer());
588 }
589
590 function wtsec_page($page)
591 {
592 return wtsec_pages()[$page];
593 }
594
595 function wtsec_getUrl($page)
596 {
597 return admin_url('admin.php?page=' . WTSEC_PAGE_PREFIX . $page);
598 }
599
600 function wtsec_getRoute($page)
601 {
602 return WTSEC_PAGE_PREFIX . $page;
603 }
604
605 function wtsec_pages()
606 {
607 return [
608 // "options" => [
609 // "page_title" => WTSEC_LIBRARY_Localization::lmsg('options'),
610 // "menu_title" => WTSEC_LIBRARY_Localization::lmsg('options'),
611 // "function" => "wtsec_options_page",
612 // ],
613 "services" => [
614 "page_title" => WTSEC_LIBRARY_Localization::lmsg('services'),
615 "menu_title" => WTSEC_LIBRARY_Localization::lmsg('services'),
616 "function" => "wtsec_services_page",
617 ],
618 "vc" => [
619 "page_title" => WTSEC_LIBRARY_Localization::lmsg('remote_antivirus'),
620 "menu_title" => WTSEC_LIBRARY_Localization::lmsg('remote_antivirus'),
621 "function" => "wtsec_antivirus_page",
622 "vc_action" => "vc-action",
623 "vc_function" => "wtsec_vc_function"
624 ],
625 "waf" => [
626 "page_title" => WTSEC_LIBRARY_Localization::lmsg('firewall'),
627 "menu_title" => WTSEC_LIBRARY_Localization::lmsg('firewall'),
628 "function" => "wtsec_firewall_page",
629 "vc_action" => "firewall-action",
630 "vc_function" => "wtsec_firewall_function"
631 ],
632 ];
633 }