| @@ -1,5 +1,5 @@ | ||
| 1 | -<?php defined('ABSPATH') or die("Protected By Webtotem Wordpress Security!"); | |
| 1 | +<?php defined('ABSPATH') or die("Protected By WT!"); | |
| 2 | 2 | |
| 3 | 3 | function wtsec_cmd($wp_filesystem,$cmd, $service, $_service, $uid, $status,$domain = ''){ |
| 4 | 4 | |
| 5 | 5 | switch ($cmd) { |
| @@ -75,17 +75,24 @@ | ||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | function wtsec_checkStatus($id, $service) |
| 78 | 78 | { |
| 79 | + $service = ucfirst(strtolower($service)); | |
| 80 | + $is_active = null; | |
| 81 | + $config_id = null; | |
| 79 | 82 | $result = WTSEC_LIBRARY_WT::checkStatus($id,$service); |
| 80 | - $data = $result['data'][strtolower($service) . 'ServiceChecks'][0]; | |
| 81 | - $is_active = (boolean)$data['config']['isActive']; | |
| 82 | - $config_id = $data['config']['id']; | |
| 83 | - $status = $data['status']; | |
| 84 | - if ($status == -300 && $is_active) { | |
| 85 | - wtsec_app()->set($service . '_connected_' . $id, false); | |
| 83 | + $data = $result['data']['auth']['viewer']['sites']['one']['configs']; | |
| 84 | + foreach ($data as &$cfg){ | |
| 85 | + if(!empty($cfg)){ | |
| 86 | + $is_active = $cfg['isActive']; | |
| 87 | + $config_id = $cfg['id']; | |
| 88 | + } | |
| 86 | 89 | } |
| 87 | - return ['active' => $is_active, 'status' => $status, 'config_id' => $config_id]; | |
| 90 | + | |
| 91 | + if ($is_active === false) { | |
| 92 | + wtsec_app()->set($service . '_connected_' . $id, true); | |
| 93 | + } | |
| 94 | + return ['active' => $is_active, 'config_id' => $config_id]; | |
| 88 | 95 | } |
| 89 | 96 | |
| 90 | 97 | |
| 91 | 98 | |
| @@ -91,9 +98,9 @@ | ||
| 91 | 98 | |
| 92 | 99 | function wtsec_generateFile($id, $service) |
| 93 | 100 | { |
| 94 | 101 | $result = WTSEC_LIBRARY_WT::generateFile($id,$service); |
| 95 | - $name = $result['data']['generateAgent']['agentName'] . '.' . strtolower($service) . '.php'; | |
| 102 | + $name = $result['data']['auth']['agents']['generate']['agentName']; | |
| 96 | 103 | $file = WTSEC_LIBRARY_WT::requestURL(WTSEC_FILE_URL . '/' . $name); |
| 97 | 104 | if(empty($file)){ |
| 98 | 105 | $file = WTSEC_LIBRARY_WT::requestURL(WTSEC_FILE_URL . '/' . $name); |
| 99 | 106 | } |
| @@ -102,9 +109,9 @@ | ||
| 102 | 109 | |
| 103 | 110 | function wtsec_serviceConnect($id, $service,$domain = '') |
| 104 | 111 | { |
| 105 | 112 | $result = WTSEC_LIBRARY_WT::serviceConnect($id,$service); |
| 106 | - $status = (isset($result['errors']) || isset($result['data']['checkAgent']['lockFor']) || (isset($result['data']['checkAgent']['installed']) && $result['data']['checkAgent']['installed'] === false)) ? false : true; | |
| 113 | + $status = isset($result['errors']) && !isset($result['data']['auth']['agents']['check']) ? false : true; | |
| 107 | 114 | if (!$status) { |
| 108 | 115 | WTSEC_LIBRARY_Session::setNotification("warning",WTSEC_LIBRARY_Localization::lmsg('unable_to_connect_to_service', ['service' => $service,'site' => $domain])); |
| 109 | 116 | } |
| 110 | 117 | return $status; |