@@ -7,49 +7,49 @@ discard block |
||
7 | 7 | error_log(serialize($_POST)); |
8 | 8 | error_log(SERVER_SECRET); |
9 | 9 | if ( isset($_POST['enc']) ) { |
10 | - error_log("enc: ".$_POST['enc']); |
|
11 | - $decrypted = openssl_decrypt(base64_decode($_POST['enc']), "CHACHA20", SERVER_SECRET, 0, SERVER_IV); |
|
12 | - if ($decrypted === false) { |
|
13 | - echo "FAILURE"; |
|
14 | - exit; |
|
15 | - } else { |
|
16 | - error_log("data=$decrypted"); |
|
17 | - parse_str($decrypted, $darr); |
|
18 | - error_log(serialize($darr)); |
|
19 | - if (!isset($darr['token']) || $darr['token'] != SERVER_TOKEN) { |
|
20 | - echo "FAILURE"; |
|
21 | - exit; |
|
22 | - } |
|
23 | - error_log("GREAT!"); |
|
24 | - } |
|
10 | + error_log("enc: ".$_POST['enc']); |
|
11 | + $decrypted = openssl_decrypt(base64_decode($_POST['enc']), "CHACHA20", SERVER_SECRET, 0, SERVER_IV); |
|
12 | + if ($decrypted === false) { |
|
13 | + echo "FAILURE"; |
|
14 | + exit; |
|
15 | + } else { |
|
16 | + error_log("data=$decrypted"); |
|
17 | + parse_str($decrypted, $darr); |
|
18 | + error_log(serialize($darr)); |
|
19 | + if (!isset($darr['token']) || $darr['token'] != SERVER_TOKEN) { |
|
20 | + echo "FAILURE"; |
|
21 | + exit; |
|
22 | + } |
|
23 | + error_log("GREAT!"); |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | # when a request contains logid and backlog ";s:11:"DEBUG-11-52";s:7:"backlog";s:1:"7";} |
27 | 27 | if ( isset($darr['logid']) && isset($darr['backlog']) && isset($darr['iv']) ) { |
28 | - if (substr($darr['logid'], 0, 5) == 'DEBUG') { |
|
29 | - $logid = substr($darr['logid'], 6); |
|
28 | + if (substr($darr['logid'], 0, 5) == 'DEBUG') { |
|
29 | + $logid = substr($darr['logid'], 6); |
|
30 | 30 | } |
31 | - $iv = $darr['iv']; |
|
32 | - $res = cat_socket(implode(':', array($logid, $darr['backlog']))); |
|
33 | - $cnt = 0; |
|
34 | - error_log('GOT '.$res); |
|
35 | - if (substr($res, 0, strlen(ZIPDIR)) == ZIPDIR) { |
|
31 | + $iv = $darr['iv']; |
|
32 | + $res = cat_socket(implode(':', array($logid, $darr['backlog']))); |
|
33 | + $cnt = 0; |
|
34 | + error_log('GOT '.$res); |
|
35 | + if (substr($res, 0, strlen(ZIPDIR)) == ZIPDIR) { |
|
36 | 36 | error_log('GOT filename '.$res); |
37 | 37 | $za = new ZipArchive(); |
38 | 38 | $za->open($res); |
39 | - $cnt = $za->numFiles; |
|
40 | - $content = file_get_contents($res); |
|
39 | + $cnt = $za->numFiles; |
|
40 | + $content = file_get_contents($res); |
|
41 | 41 | $encrypted = openssl_encrypt(SERVER_TOKEN . $content, "CHACHA20", SERVER_SECRET, 0, $iv); |
42 | - header('Content-Type: application/octet-stream'); |
|
42 | + header('Content-Type: application/octet-stream'); |
|
43 | 43 | header("Content-Disposition: attachment; filename=\"detail_".$logid.".enc\""); |
44 | 44 | header("Content-Transfer-Encoding: binary"); |
45 | - echo "ZIPDATA:$encrypted"; |
|
46 | - error_log('Sent data in response'); |
|
47 | - } |
|
45 | + echo "ZIPDATA:$encrypted"; |
|
46 | + error_log('Sent data in response'); |
|
47 | + } |
|
48 | 48 | error_log('with '. $cnt . ' files'); |
49 | - if (file_exists($res)) { |
|
50 | - unlink($res); |
|
51 | - } |
|
52 | - exit; |
|
49 | + if (file_exists($res)) { |
|
50 | + unlink($res); |
|
51 | + } |
|
52 | + exit; |
|
53 | 53 | } |
54 | 54 | # MUST provide: deployment_id, inst_id |
55 | 55 | # and port, secret, pskkey, country or torevoke |
@@ -58,33 +58,33 @@ discard block |
||
58 | 58 | isset($darr['instid']) && isset($darr['deploymentid']) && |
59 | 59 | (isset($darr['port']) && isset($darr['secret']) && isset($darr['pskkey']) && isset($darr['country']) || |
60 | 60 | isset($darr['torevoke']))) { |
61 | - if (isset($darr['remove'])) { |
|
61 | + if (isset($darr['remove'])) { |
|
62 | 62 | $remove = 1; |
63 | - } else { |
|
63 | + } else { |
|
64 | 64 | if (isset($darr['operatorname'])) { |
65 | - $opn = trim($darr['operatorname']); |
|
65 | + $opn = trim($darr['operatorname']); |
|
66 | 66 | } |
67 | 67 | if (isset($darr['vlan']) && isset($darr['realmforvlan']) && |
68 | 68 | is_array($darr['realmforvlan'])) { |
69 | - $vlans = $darr['vlan'] . '#' . implode('#', $darr['realmforvlan']); |
|
69 | + $vlans = $darr['vlan'] . '#' . implode('#', $darr['realmforvlan']); |
|
70 | 70 | } |
71 | 71 | if (isset($darr['guest_vlan'])) { |
72 | - $guest_vlan = $darr['guest_vlan']; |
|
72 | + $guest_vlan = $darr['guest_vlan']; |
|
73 | + } |
|
74 | + } |
|
75 | + if (isset($darr['torevoke'])) { |
|
76 | + $el = explode('#', $darr['torevoke']); |
|
77 | + $res = cat_socket(implode(':', array($darr['instid'], $darr['deploymentid'], $el[0], $el[1]))); |
|
78 | + } else { |
|
79 | + # arguments 5-7 are Base64 encoded |
|
80 | + $res = cat_socket(implode(':', array($darr['country'], |
|
81 | + $darr['instid'], $darr['deploymentid'], |
|
82 | + $darr['port'], |
|
83 | + base64_encode($darr['secret']), |
|
84 | + base64_encode($opn), |
|
85 | + base64_encode($vlans), base64_encode($darr['pskkey']), $guest_vlan, $remove))); |
|
73 | 86 | } |
74 | - } |
|
75 | - if (isset($darr['torevoke'])) { |
|
76 | - $el = explode('#', $darr['torevoke']); |
|
77 | - $res = cat_socket(implode(':', array($darr['instid'], $darr['deploymentid'], $el[0], $el[1]))); |
|
78 | - } else { |
|
79 | - # arguments 5-7 are Base64 encoded |
|
80 | - $res = cat_socket(implode(':', array($darr['country'], |
|
81 | - $darr['instid'], $darr['deploymentid'], |
|
82 | - $darr['port'], |
|
83 | - base64_encode($darr['secret']), |
|
84 | - base64_encode($opn), |
|
85 | - base64_encode($vlans), base64_encode($darr['pskkey']), $guest_vlan, $remove))); |
|
86 | - } |
|
87 | - echo $res; |
|
87 | + echo $res; |
|
88 | 88 | } else { |
89 | - echo "FAILURE"; |
|
89 | + echo "FAILURE"; |
|
90 | 90 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | $guest_vlan = 0; |
7 | 7 | error_log(serialize($_POST)); |
8 | 8 | error_log(SERVER_SECRET); |
9 | -if ( isset($_POST['enc']) ) { |
|
9 | +if (isset($_POST['enc'])) { |
|
10 | 10 | error_log("enc: ".$_POST['enc']); |
11 | 11 | $decrypted = openssl_decrypt(base64_decode($_POST['enc']), "CHACHA20", SERVER_SECRET, 0, SERVER_IV); |
12 | 12 | if ($decrypted === false) { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | } |
26 | 26 | # when a request contains logid and backlog ";s:11:"DEBUG-11-52";s:7:"backlog";s:1:"7";} |
27 | -if ( isset($darr['logid']) && isset($darr['backlog']) && isset($darr['iv']) ) { |
|
27 | +if (isset($darr['logid']) && isset($darr['backlog']) && isset($darr['iv'])) { |
|
28 | 28 | if (substr($darr['logid'], 0, 5) == 'DEBUG') { |
29 | 29 | $logid = substr($darr['logid'], 6); |
30 | 30 | } |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | $za->open($res); |
39 | 39 | $cnt = $za->numFiles; |
40 | 40 | $content = file_get_contents($res); |
41 | - $encrypted = openssl_encrypt(SERVER_TOKEN . $content, "CHACHA20", SERVER_SECRET, 0, $iv); |
|
41 | + $encrypted = openssl_encrypt(SERVER_TOKEN.$content, "CHACHA20", SERVER_SECRET, 0, $iv); |
|
42 | 42 | header('Content-Type: application/octet-stream'); |
43 | 43 | header("Content-Disposition: attachment; filename=\"detail_".$logid.".enc\""); |
44 | 44 | header("Content-Transfer-Encoding: binary"); |
45 | 45 | echo "ZIPDATA:$encrypted"; |
46 | 46 | error_log('Sent data in response'); |
47 | 47 | } |
48 | - error_log('with '. $cnt . ' files'); |
|
48 | + error_log('with '.$cnt.' files'); |
|
49 | 49 | if (file_exists($res)) { |
50 | 50 | unlink($res); |
51 | 51 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | if (isset($darr['vlan']) && isset($darr['realmforvlan']) && |
68 | 68 | is_array($darr['realmforvlan'])) { |
69 | - $vlans = $darr['vlan'] . '#' . implode('#', $darr['realmforvlan']); |
|
69 | + $vlans = $darr['vlan'].'#'.implode('#', $darr['realmforvlan']); |
|
70 | 70 | } |
71 | 71 | if (isset($darr['guest_vlan'])) { |
72 | 72 | $guest_vlan = $darr['guest_vlan']; |