diff --git a/createDevice.php b/createDevice.php new file mode 100644 index 0000000..66c1887 --- /dev/null +++ b/createDevice.php @@ -0,0 +1,201 @@ +'.$sel[$d].''; + } + + $CMD = "cmd=DeviceVirtualCreate&data=1".TOKEN."".$colourID."".( $name != "" ? $name : "NEW Virtual Device" )."".$devices. ( $remoteControl != "" ? "".$remoteControl."" : "" ).""; + $result = getCurlReturn($CMD); + $array = xmlToArray($result); + + $newDevice = $array['did']; + + if( $newDevice != ""){ + header("Location: info.php?did=".$newDevice); + } + } + + /* + if (this.image != null && this.image.length() > 0) { + dataString.append(String.format("%s", new Object[]{xmlEscape(this.image)})); + } + if (this.producttype != null) { + dataString.append(String.format("%s", new Object[]{xmlEscape(this.producttype)})); + } + */ + + + exit; +} + + +pageHeader("TCP Lighting Controller - Create Device"); +?> +
Lighting Controls | Lighting Scheduler | API Test Zone | Scenes/Smart Control
+'; +?> + +

Create Virtual Device

+ +

Add two or more devices to the selected list

+
+
+ + 1".TOKEN.""; + $result = getCurlReturn($CMD); + $array = xmlToArray($result); + $ROOM_COLOURS = array(); + //pa($array); + foreach( $array['room'] as $room ){ + $ROOM_COLOURS[ $room["colorid"] ]["name"] = $room["name"]; + $ROOM_COLOURS[ $room["colorid"] ]["hex"] = $room["color"]; + $ROOM_COLOURS[ $room["colorid"] ]["colorid"] = $room["colorid"]; + $ROOM_COLOURS[ $room["colorid"] ]["image"] = $room["img"]; + $ROOM_COLOURS[ $room["colorid"] ]["room"] = $room["rid"]; + } + ?> +
+ +
+ +
+ + + + + + + + + + +
Available Selected
+ + + +
+
+ +
+ + + +
+ +
+ + + + + + +'; +pageFooter(); +?> diff --git a/images/remote.png b/images/remote.png new file mode 100644 index 0000000..00d163b Binary files /dev/null and b/images/remote.png differ diff --git a/index.php b/index.php index 196bac5..7e8dc83 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ pageHeader("TCP Lighting Controller"); ?> -
Lighting Scheduler | API Test Zone | Scenes/Smart Control
+
Lighting Scheduler | API Test Zone | Scenes/Smart Control | Create Virtual Device
0 && this.full.equalsIgnoreCase("1")) { + fullDelete = "1"; + } + dataString = String.format("1%s%s%s", new Object[]{xmlEscape(this.token), xmlEscape(this.did), fullDelete}); + this.postData.add(new BasicNameValuePair("cmd", "DeviceDelete")); + this.postData.add(new BasicNameValuePair("data", dataString)); + */ + + $did = $_REQUEST['delete']; + $fullDelete = $_REQUEST['fullDelete']; + + $CMD = "cmd=DeviceDelete&data=1".TOKEN."".$did."".($fullDelete == 1 ? '1' : '').""; + $result = getCurlReturn($CMD); + $array = xmlToArray($result); + + + + echo json_encode( array("delete" => $did, "fullDelete" => $fullDelete, "Result" => $array) ); + + } +} if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST'){ @@ -28,6 +53,7 @@ $did = $_POST['did']; $name = $_POST['name']; $color = $_POST['color']; + $remote = $_POST['remote']; $imdata = ""; if( isset($_FILES["image"]) && $_FILES["image"]["tmp_name"] != "" ){ @@ -53,7 +79,7 @@ - $CMD = "cmd=DeviceSetInfo&data=1".TOKEN."".$did."".$name."".$color."".($imdata != "" ? "".$imdata."" : "").""; + $CMD = "cmd=DeviceSetInfo&data=1".TOKEN."".$did."".$name."".$color."".($imdata != "" ? "".$imdata."" : "").( $remote != "" ? "".$remote."" : "" ).""; //echo htmlentities($CMD); $result = getCurlReturn($CMD); @@ -68,9 +94,42 @@ } if(isset($_POST['rid']) && $_POST['rid'] != "" ){ + + + + /* + StringBuilder dataString = new StringBuilder(String.format("1%s", new Object[]{xmlEscape(this.token)})); + if (this.bycolor == null && this.rid != null) { + dataString.append(String.format("%s", new Object[]{xmlEscape(this.rid)})); + } + if (!(this.bycolor == null || this.colorid == null)) { + dataString.append(String.format("%s", new Object[]{xmlEscape(this.colorid)})); + } + if (this.name != null) { + dataString.append(String.format("%s", new Object[]{xmlEscape(this.name)})); + } + if (this.type != null) { + dataString.append(String.format("%s", new Object[]{xmlEscape(this.type)})); + } + dataString.append(""); + if (this.preprocessForBatch) { + this.gcmdDictionary = new HashMap(); + this.gcmdDictionary.put("gdata", dataString.toString()); + this.gcmdDictionary.put("gcmd", "RoomSetInfo"); + this.gcmdDictionary.put("cmdOwner", this); + } + this.postData.add(new BasicNameValuePair("cmd", "RoomSetInfo")); + this.postData.add(new BasicNameValuePair("data", dataString.toString())); + */ + + $_REQUEST['rid'] = $_POST['rid']; } + + + + } @@ -83,15 +142,31 @@ echo '
'; //echo '

Device Info

'; //echo '

Device ID:'.$did.'

'; - - $CMD = "cmd=DeviceGetInfo&data=1".TOKEN."".$did."name,power,product,class,image,control,realtype,other,status"; $result = getCurlReturn($CMD); $array = xmlToArray($result); - + ?> +
Update Device @@ -126,6 +201,24 @@ +
+

@@ -146,6 +239,10 @@ echo '
'; echo '
'; echo ''; + + ?> + + '; ?>