-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathassisted-toggle.php
More file actions
31 lines (26 loc) · 967 Bytes
/
Copy pathassisted-toggle.php
File metadata and controls
31 lines (26 loc) · 967 Bytes
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
<?php
require('config.php');
require('includes/functions.php');
header('Content-Type: text/json');
// Bust cache. Mainly for IE
header('Cache-Control: no-cache, no-store');
header('Expires: '.date(DATE_RFC822));
$status = array(
'assisted' => null,
'changed' => false
);
try {
$assistedStatus = simplexml_load_file("http://".$ipAddress.":".$restPort."/opt?auth=".$restPassword."&command=StatusAssisted");
$status['assisted'] = $assistedStatus == "True";
if($status['assisted'] === false) {
$status['changed'] = file_get_contents("http://".$ipAddress.":".$restPort."/opt?auth=".$restPassword."&command=EnableAssisted&arg=1");
$status['assisted'] = true;
} else {
$status['changed'] = file_get_contents("http://".$ipAddress.":".$restPort."/opt?auth=".$restPassword."&command=EnableAssisted&arg=0");
$status['assisted'] = false;
}
} catch (Exception $e) {
http_response_code(500);
$status['error'] = $e->getMessage();
}
exit(json_encode($status));