getStatus.php
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
//GPL license
include sanitize_file_name('gplLicense.php');
/*to get status of an ongoing test*/
function Beagle_WP_getStatusOf_CurrentTestData()
{
global $wpdb;
global $apiServerBaseUrl;
$Beagle_WP_scan_table = $wpdb->prefix . "beagleScanData";
$getTableData = $wpdb->get_results($wpdb->prepare("SELECT * FROM $Beagle_WP_scan_table"));
foreach ($getTableData as $entryOne) {
$Beagle_WP_access_token = $entryOne->access_token;
$Beagle_WP_application_token = $entryOne->application_token;
$BWP_result_token = $entryOne->result_token;
}
try {
if ($Beagle_WP_access_token != null && $Beagle_WP_application_token != null && $BWP_result_token != null) {
$beaglrURL = $apiServerBaseUrl . 'test/status';
$getStatusDataTest = array("access_token" => $Beagle_WP_access_token, "application_token" => $Beagle_WP_application_token, "result_token" => $BWP_result_token);
$request = wp_remote_post($beaglrURL, array(
'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
'body' => json_encode($getStatusDataTest),
'method' => 'POST',
'data_format' => 'body',
));
$statusResponse = json_decode(wp_remote_retrieve_body($request));
try {
if ($statusResponse) {
$updateData = $wpdb->query($wpdb->prepare("UPDATE $Beagle_WP_scan_table SET status = %s WHERE application_token = %s", $statusResponse->status, $Beagle_WP_application_token));
}
echo json_encode($statusResponse);
exit;
} catch (Exception $e) {
}
}
} catch (Exception $e) {
}
}