PluginProbe
WebTotem Security / 2.3.7
WebTotem Security v2.3.7
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 +99 -5 2.1.72.3.7 View file →
@@ -43,12 +43,15 @@
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 46 wtsec_app()->set($_service . '_installed_file', $file['name']);
47 + if ($service === "AM") {
48 + wtsec_addCheckFile($file['name']);
49 + }
47 50 }
48 51 }
49 52 if ($service !== "AM") {
50 - wtsec_serviceConnect($uid, $service, $domain . '/' . $file['name']);
53 + //wtsec_serviceConnect($uid, $service, $domain . '/' . $file['name']);
51 54 }
52 55 } catch (Exception $e) {
53 56 WTSEC_LIBRARY_Session::setNotification("error", $e->getMessage());
54 57 return false;
@@ -64,9 +67,9 @@
64 67 break;
65 68 case $_service . "_connect":
66 69 $file = wtsec_getInstalledFile($_service);
67 70 if ($file) {
68 - wtsec_serviceConnect($uid, $service, $domain . '/' . $file);
71 + //wtsec_serviceConnect($uid, $service, $domain . '/' . $file);
69 72 } else {
70 73 WTSEC_LIBRARY_Session::setNotification("warning", WTSEC_LIBRARY_Localization::lmsg('file_not_found', ['service' => $service]));
71 74 }
72 75 break;
@@ -94,8 +97,32 @@
94 97 }
95 98 return true;
96 99 }
97 100
101 +// Add check file if plugin is activated
102 +function wtsec_addCheckFile($name){
103 + global $wp_filesystem;
104 +
105 + if (empty($wp_filesystem)) {
106 + require_once(ABSPATH . '/wp-admin/includes/file.php');
107 + WP_Filesystem();
108 + }
109 +
110 + //retry checking
111 + if (empty($wp_filesystem)) {
112 + WTSEC_LIBRARY_Session::setNotification("error", "WP FileSystem path error");
113 + return false;
114 + }
115 +
116 + $target_dir = $wp_filesystem->find_folder(WTSEC_PLUGIN_PATH);
117 + $target_file = trailingslashit($target_dir) . 'generate.php';
118 +
119 + if ($wp_filesystem->put_contents($target_file, '<?php exit(); ?>'.$name, FS_CHMOD_FILE)) {
120 + return true;
121 + }
122 + return false;
123 +}
124 +
98 125 function wtsec_checkStatus($id, $service)
99 126 {
100 127 $service = ucfirst(strtolower($service));
101 128 $is_active = null;
@@ -121,12 +148,21 @@
121 148 $result = WTSEC_LIBRARY_WT::generateAmFile($id);
122 149 if (!isset($result['data']['auth']['am']['install'])) {
123 150 $file = ['filename' => null, "body" => null];
124 151 } else {
125 - $url = $result['data']['auth']['am']['install'];
126 - $file = WTSEC_LIBRARY_WT::getFileByUrl($url);
152 + $result = $result['data']['auth']['am']['install'];
153 +
154 + $url = $result['downloadLink'];
155 + $amFilename = $result['amFilename'];
156 + $wafFilename = $result['wafFilename'];
157 +
158 + if($wafFilename){
159 + wtsec_app()->set('waf_installed_file', $wafFilename);
160 + }
161 +
162 + $file = WTSEC_LIBRARY_WT::getFileByUrl($url, $amFilename);
127 163 if (empty($file)) {
128 - $file = WTSEC_LIBRARY_WT::getFileByUrl($url);
164 + $file = WTSEC_LIBRARY_WT::getFileByUrl($url, $amFilename);
129 165 }
130 166 }
131 167
132 168 $name = $file["filename"];
@@ -172,8 +208,66 @@
172 208 } else {
173 209 WTSEC_LIBRARY_Session::setNotification("warning", WTSEC_LIBRARY_Localization::lmsg('unable_to_connect_to_service', ['service' => $service, 'site' => $domain]));
174 210 return false;
175 211 }
212 +}
213 +
214 +
215 +function wtsec_AVLogsData($logs){
216 + foreach ($logs as $key => $log){
217 + $log = $log['node'];
218 + $log['filePath'] = urldecode($log['filePath']);
219 + $log['text'] = (strlen($log['filePath']) > 40) ? substr($log['filePath'],0,40).'...' : $log['filePath'];
220 + $log['time'] = convertToCurrentTime($log['time']);
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;
176 270 }
177 271
178 272 function wtsec_button($label = '', $class = '')
179 273 {