PluginProbe
WebTotem Security / 2.3.24
WebTotem Security v2.3.24
3.0.2 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 All 110 releases
← All changes | services.php +90 -15 2.2.12.3.24 View file →
@@ -42,14 +42,16 @@
42 42 $target_file = trailingslashit($target_dir) . $file['name'];
43 43 if (!$wp_filesystem->put_contents($target_file, $file['file'])) {
44 44 WTSEC_LIBRARY_Session::setNotification("warning", WTSEC_LIBRARY_Localization::lmsg('could_not_install_file', ['service' => $service, 'directory' => $target_dir]));
45 45 } else {
46 - if ($service === "AM") { wtsec_addCheckFile(); }
47 46 wtsec_app()->set($_service . '_installed_file', $file['name']);
47 + if ($service === "AM") {
48 + wtsec_addCheckFile($file['name']);
49 + }
48 50 }
49 51 }
50 52 if ($service !== "AM") {
51 - wtsec_serviceConnect($uid, $service, $domain . '/' . $file['name']);
53 + //wtsec_serviceConnect($uid, $service, $domain . '/' . $file['name']);
52 54 }
53 55 } catch (Exception $e) {
54 56 WTSEC_LIBRARY_Session::setNotification("error", $e->getMessage());
55 57 return false;
@@ -65,9 +67,9 @@
65 67 break;
66 68 case $_service . "_connect":
67 69 $file = wtsec_getInstalledFile($_service);
68 70 if ($file) {
69 - wtsec_serviceConnect($uid, $service, $domain . '/' . $file);
71 + //wtsec_serviceConnect($uid, $service, $domain . '/' . $file);
70 72 } else {
71 73 WTSEC_LIBRARY_Session::setNotification("warning", WTSEC_LIBRARY_Localization::lmsg('file_not_found', ['service' => $service]));
72 74 }
73 75 break;
@@ -96,9 +98,9 @@
96 98 return true;
97 99 }
98 100
99 101 // Add check file if plugin is activated
100 -function wtsec_addCheckFile(){
102 +function wtsec_addCheckFile($name){
101 103 global $wp_filesystem;
102 104
103 105 if (empty($wp_filesystem)) {
104 106 require_once(ABSPATH . '/wp-admin/includes/file.php');
@@ -112,15 +114,12 @@
112 114 }
113 115
114 116 $target_dir = $wp_filesystem->find_folder(WTSEC_PLUGIN_PATH);
115 117 $target_file = trailingslashit($target_dir) . 'generate.php';
116 - $content = '<?php echo rand()?>';
117 118
118 - if ($wp_filesystem->put_contents($target_file, $content, FS_CHMOD_FILE)) {
119 + if ($wp_filesystem->put_contents($target_file, '<?php exit(); ?>'.$name, FS_CHMOD_FILE)) {
119 120 return true;
120 121 }
121 -
122 - WTSEC_LIBRARY_Session::setNotification("error", "generate fail");
123 122 return false;
124 123 }
125 124
126 125 function wtsec_checkStatus($id, $service)
@@ -136,11 +135,9 @@
136 135 $config_id = $cfg['id'];
137 136 }
138 137 }
139 138
140 - if ($is_active === false) {
141 - wtsec_app()->set($service . '_connected_' . $id, true);
142 - }
139 +
143 140 return ['active' => $is_active, 'config_id' => $config_id];
144 141 }
145 142
146 143 function wtsec_generateFile($id, $service)
@@ -149,12 +146,21 @@
149 146 $result = WTSEC_LIBRARY_WT::generateAmFile($id);
150 147 if (!isset($result['data']['auth']['am']['install'])) {
151 148 $file = ['filename' => null, "body" => null];
152 149 } else {
153 - $url = $result['data']['auth']['am']['install'];
154 - $file = WTSEC_LIBRARY_WT::getFileByUrl($url);
150 + $result = $result['data']['auth']['am']['install'];
151 +
152 + $url = $result['downloadLink'];
153 + $amFilename = $result['amFilename'];
154 + $wafFilename = $result['wafFilename'];
155 +
156 + if($wafFilename){
157 + wtsec_app()->set('waf_installed_file', $wafFilename);
158 + }
159 +
160 + $file = WTSEC_LIBRARY_WT::getFileByUrl($url, $amFilename);
155 161 if (empty($file)) {
156 - $file = WTSEC_LIBRARY_WT::getFileByUrl($url);
162 + $file = WTSEC_LIBRARY_WT::getFileByUrl($url, $amFilename);
157 163 }
158 164 }
159 165
160 166 $name = $file["filename"];
@@ -202,8 +208,68 @@
202 208 return false;
203 209 }
204 210 }
205 211
212 +
213 +function wtsec_AVLogsData($logs){
214 + foreach ($logs as $key => $log){
215 + $log = $log['node'];
216 + $log['filePath'] = urldecode($log['filePath']);
217 + $log['text'] = (strlen($log['filePath']) > 40) ? substr($log['filePath'],0,40).'...' : $log['filePath'];
218 + $log['time'] = convertToCurrentTime($log['time']);
219 + $log['class_path'] = '';
220 + $log['class_info'] = '';
221 +
222 + if ($log['event'] === 'modified') {
223 + $log['info'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.info.normal");
224 + $log['class_path'] = "wtotem_file-table__td_changed";
225 + $log['class_info'] = "wtotem_file-table__td_normal";
226 + $log['description'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.changed");
227 + } elseif ($log['event'] === 'quarantine') {
228 + $log['info'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.info.backdoor_virus");
229 + $log['class_path'] = "wtotem_file-table__td_changed";
230 + $log['class_info'] = "wtotem_file-table__td_normal";
231 + $log['description'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.quarantine");
232 + } elseif ($log['event'] === 'infected') {
233 + $log['info'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.info.backdoor_virus");
234 + $log['class_path'] = "wtotem_file-table__td_critical";
235 + $log['class_info'] = "wtotem_file-table__td_critical";
236 + $log['description'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.infected");
237 + } elseif ($log['event'] === 'deleted') {
238 + $log['info'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.info.deleted");
239 + $log['description'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.deleted");
240 + }elseif ($log['event'] === 'new'){
241 + $log['info'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.info.normal");
242 + $log['description'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.new");
243 + }elseif ($log['event'] === 'scanned'){
244 + $log['info'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.info.normal");
245 + $log['description'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.scanned");
246 + }else{
247 + $log['info'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.error");
248 + $log['description'] = WTSEC_LIBRARY_Localization::lmsg("antivirus.status.error");
249 + }
250 +
251 + $logs[$key]['node'] = $log;
252 + }
253 + return $logs;
254 +}
255 +
256 +function wtsec_getConfigs($host_id)
257 +{
258 + $config = WTSEC_LIBRARY_WT::getConfigs($host_id);
259 + return wtsec_arrayIndex($config['data']['auth']['viewer']['sites']['one']['configs'], 'service');
260 +}
261 +
262 +function wtsec_arrayIndex($array, $key){
263 + $newArray = [];
264 + foreach ($array as $item){
265 + if(array_key_exists($key,$item)){
266 + $newArray[$item[$key]] = $item;
267 + }
268 + }
269 + return $newArray;
270 +}
271 +
206 272 function wtsec_button($label = '', $class = '')
207 273 {
208 274 return '<button class="ww-button ' . $class . '">' . $label . '</button>';
209 275 }
@@ -274,5 +340,14 @@
274 340
275 341 function wtsec_getInstalledFile($service)
276 342 {
277 343 return wtsec_app()->get($service . "_installed_file");
278 -}
344 +}
345 +
346 +function wtsec_DeleteAm(){
347 + $host = WTSEC_LIBRARY_WT::getOwnSite();
348 + if(!empty($host)) {
349 + WTSEC_LIBRARY_WT::deleteAm($host['id']);
350 + return true;
351 + }
352 + return false;
353 +}