| @@ -10,9 +10,8 @@ | ||
| 10 | 10 | add_action('wp_ajax_ajax_antivirus', 'wtsec_ajax_antivirus'); |
| 11 | 11 | add_action('wp_ajax_chart_filter', 'wtsec_chart_filter'); |
| 12 | 12 | add_action('wp_ajax_map_filter', 'wtsec_map_filter'); |
| 13 | 13 | add_action('wp_ajax_color_scheme_toggle', 'wtsec_color_scheme'); |
| 14 | -add_action('wp_ajax_configs_toggle', 'wtsec_configs_toggle'); | |
| 15 | 14 | |
| 16 | 15 | |
| 17 | 16 | function wtsec_add_menu_link() |
| 18 | 17 | { |
| @@ -71,12 +70,8 @@ | ||
| 71 | 70 | |
| 72 | 71 | |
| 73 | 72 | function convertTimeToReadable($date) |
| 74 | 73 | { |
| 75 | - if(!$date){ | |
| 76 | - return WTSEC_LIBRARY_Localization::lmsg('unknown'); | |
| 77 | - } | |
| 78 | - | |
| 79 | 74 | $lang = get_locale(); |
| 80 | 75 | //enable russian language |
| 81 | 76 | if ($lang === "ru_RU") { |
| 82 | 77 | $lang .= ".UTF-8"; |
| @@ -363,8 +358,10 @@ | ||
| 363 | 358 | function generateChart($charts, $days = 7) |
| 364 | 359 | { |
| 365 | 360 | |
| 366 | 361 | if(is_array($days)) { |
| 362 | + $beginDate = new DateTime( $days['begin'] ); | |
| 363 | + $endDate = new DateTime( $days['end'] ); | |
| 367 | 364 | $dateDiff = strtotime($days['end'] - strtotime($days['begin'])); |
| 368 | 365 | $days = floor($dateDiff / (60 * 60 * 24)); |
| 369 | 366 | } |
| 370 | 367 | |
| @@ -409,11 +406,9 @@ | ||
| 409 | 406 | |
| 410 | 407 | //unset keys, because the js parser sorting by key in integer |
| 411 | 408 | $result = []; |
| 412 | 409 | foreach ($c as $d) { |
| 413 | - if(isset($d['date'])){ | |
| 414 | - $result[] = $d; | |
| 415 | - } | |
| 410 | + $result[] = $d; | |
| 416 | 411 | } |
| 417 | 412 | |
| 418 | 413 | return ['chart' => $result, 'count_attacks' => $count_attacks, 'count_blocks' => $count_blocks]; |
| 419 | 414 | } |
| @@ -453,9 +448,17 @@ | ||
| 453 | 448 | |
| 454 | 449 | function wtsec_options_page() |
| 455 | 450 | { |
| 456 | 451 | $host = WTSEC_LIBRARY_WT::getOwnSite(); |
| 457 | - $options = wtsec_getConfigs($host['id']); | |
| 452 | + $result = WTSEC_LIBRARY_WT::getOptions($host['id']); | |
| 453 | + $options = []; | |
| 454 | + if (isset($result['data']['userHost']['services'])) { | |
| 455 | + foreach ($result['data']['userHost']['services'] as $service) { | |
| 456 | + $configs = $service['configs'][0]; | |
| 457 | + $options[$service['name']] = ['config_id' => $configs['id'], 'is_active' => $configs['isActive']]; | |
| 458 | + } | |
| 459 | + } | |
| 460 | + $options['host_id'] = $host['id']; | |
| 458 | 461 | wtsec_layout("options", $options); |
| 459 | 462 | } |
| 460 | 463 | |
| 461 | 464 | function wtsec_services_page() |
| @@ -668,19 +671,8 @@ | ||
| 668 | 671 | |
| 669 | 672 | wp_die(); |
| 670 | 673 | } |
| 671 | 674 | |
| 672 | -function wtsec_configs_toggle() | |
| 673 | -{ | |
| 674 | - $post = ($_POST) ? wtsec_clean($_POST):[]; | |
| 675 | - $service_id = $post['service']; | |
| 676 | - $config = WTSEC_LIBRARY_WT::toggleConfigs($service_id); | |
| 677 | - echo json_encode($config['data']['auth']['configs']['toggle']); | |
| 678 | - | |
| 679 | - wp_die(); | |
| 680 | -} | |
| 681 | - | |
| 682 | - | |
| 683 | 675 | function wtsec_login_form() |
| 684 | 676 | { |
| 685 | 677 | if (wtsec_request()->method === "POST") { |
| 686 | 678 | $result = WTSEC_LIBRARY_WT::auth(wtsec_request()->key); |
| @@ -806,13 +798,13 @@ | ||
| 806 | 798 | |
| 807 | 799 | function wtsec_pages() |
| 808 | 800 | { |
| 809 | 801 | return [ |
| 810 | - "options" => [ | |
| 811 | - "page_title" => WTSEC_LIBRARY_Localization::lmsg('options'), | |
| 812 | - "menu_title" => WTSEC_LIBRARY_Localization::lmsg('options'), | |
| 813 | - "function" => "wtsec_options_page", | |
| 814 | - ], | |
| 802 | +// "options" => [ | |
| 803 | +// "page_title" => WTSEC_LIBRARY_Localization::lmsg('options'), | |
| 804 | +// "menu_title" => WTSEC_LIBRARY_Localization::lmsg('options'), | |
| 805 | +// "function" => "wtsec_options_page", | |
| 806 | +// ], | |
| 815 | 807 | "services" => [ |
| 816 | 808 | "page_title" => WTSEC_LIBRARY_Localization::lmsg('services'), |
| 817 | 809 | "menu_title" => WTSEC_LIBRARY_Localization::lmsg('services'), |
| 818 | 810 | "function" => "wtsec_services_page", |