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