"
+
+ set filename "/www/addons/xmlapi/VERSION"
+ set fd [open $filename r]
+ set version ""
+ if { $fd >=0 } {
+ gets $fd version
+ close $fd
+ }
+
+ puts [subst {
+ | XML-API $version |
+ | checkuptodate.cgi | ???? |
+ | devicelist.cgi | Lists all devices with channels. Contain names, serial number, device type and ids.
+ sid=string - security access token id
+ show_internal=0/1 - adds internal channels also (default=0)
+ |
+ | devicetypelist.cgi | Lists all possible device types with their possible meta data.
+ sid=string - security access token id
+ |
+ | exec.cgi | Allows to execute arbitrary ReGaHss script commands (as POST data).
+ sid=string - security access token id
+ |
+ | favoritelist.cgi | Lists all favorites and users.
+ sid=string - security access token id
+ show_datapoint=0/1 - outputs datapoint_id and datapoint_type also (default=0)
+ show_internal=0/1 - adds internal channels also (default=0)
+ |
+ | functionlist.cgi | Lists all functions including channels.
+ sid=string - security access token id
+ |
+ | mastervalue.cgi | Outputs a single or several '1234,5678' devices with their names and master values.
+ sid=string - security access token id
+ device_id=list - returns master values of specified devices (e.g. "1234,5678")
+ requested_names=list - returns only master values of selected types (e.g. "TEMPERATURE_COMFORT,TEMPERATURE_LOWERING")
+ |
+ | mastervaluechange.cgi | Sets one or more master values for a list of devices.
+ sid=string - security access token id
+ device_id=list - sets master values of specified devices (e.g. "1234,5678")
+ name=list - sets only master values of selected types (e.g. "TEMPERATURE_LOWERING,TEMPERATURE_COMFORT")
+ value=list - sets master values to specified values (e.g. "17.0,22.5")
+ |
+ | programactions.cgi | Allows to change active and visible program options.
+ sid=string - security access token id
+ program_id=int - id of program to modify (e.g. "1234")
+ active=true/false - sets active status of program to true/false
+ visible=true/false - sets visible status of program to true/false
+ |
+ | programlist.cgi | Lists all programs.
+ sid=string - security access token id
+ |
+ | protocol.cgi | Outputs the system protocol.
+ sid=string - security access token id
+ start=int - start of the protocol
+ show=int - number of entries to output
+ clear=0/1 - allows to clear the system protocol
+ |
+ | roomlist.cgi | Lists all configured rooms including channels.
+ sid=string - security access token id
+ |
+ | rssilist.cgi | Lists RSSI values of all RF devices.
+ sid=string - security access token id
+ |
+ | runprogram.cgi | Starts a program with the specified id.
+ sid=string - security access token id
+ program_id=int - id of program to modify (e.g. "1234")
+ |
+ | scripterrors.cgi | Searches for the last 10 lines in /var/log/messages containing script runtime errors and outputs them.
+ sid=string - security access token id
+ |
+ | state.cgi | Outputs one or more devices with their channels and current values.
+ sid=string - security access token id
+ device_id=list - returns values of specified devices (e.g. "1234,5678")
+ channel_id=list - returns values of specified channels (e.g. "1234,5678")
+ datapoint_id=list - returns Value() for datapoint with id (e.g. "1234,5678")
+ |
+ | statechange.cgi | Allows to change the state of one or more devices.
+ sid=string - security access token id
+ ise_id=list - selects the devices with the specified ids (e.g. "1234,5678")
+ new_value=list - new values for device states (e.g. "0.20,1.45")
+ |
+ | statelist.cgi | Outputs all devices with channels and their current values.
+ sid=string - security access token id
+ ise_id=int - output only channels and values of device with specified id (e.g. "1234")
+ show_internal=0/1 - adds internal channels also (default=0)
+ |
+ | systemNotification.cgi | Outputs the currently existing system notifications.
+ sid=string - security access token id
+ |
+ | systemNotificationClear.cgi | Clears the current active system notifications (if not sticky).
+ sid=string - security access token id
+ |
+ | sysvar.cgi | Outputs a single system variable with its corresponding values.
+ sid=string - security access token id
+ ise_id=int - the id of the system variable to output (e.g. "1234")
+ text=true/false - outputs or suppressed the text for string variables (default=true)
+ |
+ | sysvarlist.cgi | Outputs all system variables with their corresponding values.
+ sid=string - security access token id
+ text=true/false - outputs or suppressed the text for string variables (default=false)
+ |
+ | tokenlist.cgi | Lists all registered security access tokens
+ sid=string - security access token id
+ |
+ | tokenregister.cgi | Registers a new security access token
+ sid=string - security access token id
+ desc=string - description for new token id
+ |
+ | tokenrevoke.cgi | Revokes an existing security access token
+ sid=string - security access token id
+ |
+ | update.cgi | ???
+ sid=string - security access token id
+ checkupdate=list - ???
+ maxdurchlaeufe=int - ??? (default=7)
+ |
+ | version.cgi | Outputs version of XML-API.
+ |
+ }]
+} else {
+ puts "not authenticated"
+}
+puts ""
+puts ""
diff --git a/xmlapi/index.html b/xmlapi/index.html
deleted file mode 100755
index 0c98ade..0000000
--- a/xmlapi/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-XML-API
-
-
-
-
-XML-API
-
-
diff --git a/xmlapi/info.html b/xmlapi/info.html
deleted file mode 100755
index 740bc48..0000000
--- a/xmlapi/info.html
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-XML-API
-
-
-
-
-
-
- | XML-API |
-
- | version.cgi | Version der XML-API |
- | devicelist.cgi | Liste aller Geräte mit Kanälen. Enthält u.a. die Namen, Seriennummern, Gerätetypen und ID's
- Parameter: show_internal=1 (gibt zusätzlich die internen Kanäle aus) |
- | functionlist.cgi | Liste aller Gewerke mit Kanälen |
- | favoritelist.cgi | Liste aller Favoriten und Usern
- Paramter: favoritelist.cgi&show_datapoint gibt zusätzlich die Attribute datapoint_id und datapoint_type aus.
- |
- | mastervalue.cgi | Gibt ein einzelnes oder mehrere (1234,5678) Geräte mit den Namen und Werten der MasterValues zurück
- Parameter: mastervalue.cgi?device_id=1234 (gibt alle MasterValues des Gerätes zurück) | mastervalue.cgi?device_id=1234&requested_names=TEMPERATURE_COMFORT,TEMPERATURE_LOWERING
- (gibt nur die MasterValues TEMPERATURE_COMFORT und TEMPERATURE_LOWERING zurück) |
- | mastervaluechange.cgi | Setzt ein oder mehrere (TEMPERATURE_LOWERING,TEMPERATURE_COMFORT) MasterValues für ein oder mehrere (1234,5678) Geräte
- Parameter: mastervaluechange.cgi?device_id=1234,5678&name=TEMPERATURE_LOWERING,TEMPERATURE_COMFORT&value=17.0,22.5 (Setzt Absenktemperatur für Gerät 1234 auf 17 Grad und Komforttemperatur für Gerät 5678 auf 22.5 Grad |
- | scripterrors.cgi | Sucht in den letzten 10 Zeilen von /var/log/messages nach Homematic-Script Fehlermeldungen |
- | sysvarlist.cgi | Liste alle Systemvariablen mit Werten
- Parameter: sysvarlist.cgi?text=true - gibt den Text des aktuellen Werts in den Attributen value_text aus.
- |
- | sysvar.cgi | Eine einzelne Systemvariablen mit Werten. Parameter: ise_id |
- | state.cgi | Gibt ein einzelnes oder mehrere ("123,456,...") Geräte mit Kanälen und aktuellen Werten zurueck Parameter: z.Bsp. state.cgi?device_id=12796 | state.cgi?channel_id=12796 | state.cgi?datapoint_id=12839 (gibt nur Value() zurueck) |
-
- |
- statelist.cgi
- |
- Liste alle Geräte mit Kanälen und aktuellen Werten
- Parameter: ise_id, show_internal=1 (gibt zusätzlich das Attribut state aus)
-
HMW-RCV-50 BidCoS-Wir!
- Damit die virtuellen Wired Kanäle der CCU angezeigt werden, muss der Name "HMW-RCV-50 BidCoS-Wir" der Komponente auf der CCU in einen X Beliebigen umbenannt werden.
- |
-
-
- | statechange.cgi | ändern eines oder mehrere Kanäle-Zustände mit der angegebenen ID Parameter: z.B. statechange.cgi?ise_id=1234&new_value=0.20 oder statechange.cgi?ise_id=1234,1235&new_value=0.20,1.45 |
- | systemNotification.cgi | Gibt die System Meldungen aus |
- | systemNotificationClear.cgi | Löscht die vorhandenen System Meldungen |
- | programlist.cgi | Liste aller Programme |
- | programactions.cgi | ändern der Programmaktionen activ und sichtbar Parameter: programactions.cgi?program_id=1234&active=true&visible=true |
- | protocol.cgi | Gibt das Systemprotokoll aus Parameter: protocol.cgi?clear=1 löscht das Systemprotokoll |
- | runprogram.cgi | Startet ein Programm mit der angegebenen ID Parameter: z.B. runprogram.cgi?program_id=1234 |
- | roomlist.cgi | Liste aller Räume mit Kanälen |
- | rssilist.cgi | Liste aller Geräte mit Signalstärke |
-
-
-
diff --git a/xmlapi/mastervalue.cgi b/xmlapi/mastervalue.cgi
index 711caeb..23b350d 100755
--- a/xmlapi/mastervalue.cgi
+++ b/xmlapi/mastervalue.cgi
@@ -1,76 +1,92 @@
#!/bin/tclsh
-load tclrega.so
load tclrpc.so
+source session.tcl
source common.tcl
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+puts "Content-Type: text/xml; charset=iso-8559-1"
+puts ""
+puts -nonewline ""
-}
+if {[info exists sid] && [check_session $sid]} {
-set device_id ""
-set channel_id ""
-set datapoint_id ""
-set requested_names ""
-set allMasterValues ""
+ set device_id ""
+ set requested_names ""
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
+ set device_id $val
+ continue
+ }
+ if {0 != [regexp "^requested_names=(.*)$" $pair dummy val]} {
+ set requested_names $val
+ continue
+ }
+ }
+ }
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
- }
-}
+ read_interfaces
-read_interfaces
+ set devids [split $device_id ,]
+ if { $requested_names == "" } {
+ set allMasterValues "*"
+ } else {
+ set allMasterValues ""
+ set requestedNames [split $requested_names ,]
+ }
-set devids [split $device_id ,]
-if { $requested_names == "" } {
- set allMasterValues "*"
-} else {
- set requestedNames [split $requested_names ,]
-}
+ foreach devid $devids {
+ array set values [rega_script {
+ integer iseId = "} $devid {";
+ var oDevice = dom.GetObject(iseId);
+ var address = oDevice.Address();
+ var deviceType = oDevice.HssType();
+ Write("");
+ }]
+ set deviceAddress $values(address)
+ set deviceType $values(deviceType)
-foreach devid $devids {
- array set values [rega_script {
- integer iseId = "} $devid {";
- var oDevice = dom.GetObject(iseId);
- var address = oDevice.Address();
- var deviceType = oDevice.HssType();
- Write("");
- }]
- set deviceAddress $values(address)
- set deviceType $values(deviceType)
+ puts -nonewline $values(STDOUT)
- puts -nonewline $values(STDOUT)
+ # simple check against unknown device id
+ if { $deviceType == "null" } {
+ puts -nonewline {DEVICE NOT FOUND}
+ } else {
+ # initialize variable, could fail in catch block below
+ set ausgabe ""
+ if {[string compare -nocase -length 9 "HM-CC-VG-" $deviceType] == 0} {
+ catch {set ausgabe [xmlrpc $interfaces(VirtualDevices) getParamset [list string $deviceAddress] [list string "MASTER"] ] }
+ } elseif {[string compare -nocase -length 5 "HMIP-" $deviceType] == 0} {
+ catch {set ausgabe [xmlrpc $interfaces(HmIP-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ] }
+ } else {
+ catch {set ausgabe [xmlrpc $interfaces(BidCos-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ] }
+ }
- if {[string compare -nocase -length 9 "HM-CC-VG-" $deviceType] == 0} {
- set ausgabe [xmlrpc $interfaces(VirtualDevices) getParamset [list string $deviceAddress] [list string "MASTER"] ]
- } elseif {[string compare -nocase -length 5 "HMIP-" $deviceType] == 0} {
- set ausgabe [xmlrpc $interfaces(HmIP-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ]
- } else {
- set ausgabe [xmlrpc $interfaces(BidCos-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ]
- }
+ foreach { bezeichnung wert } $ausgabe {
+ if { ($allMasterValues == "*" || [lsearch $requestedNames $bezeichnung] >= 0) } {
+ puts -nonewline {}
+ }
+ }
- foreach { bezeichnung wert } $ausgabe {
- if { ($allMasterValues == "*" || [lsearch $requestedNames $bezeichnung] >= 0) } {
- puts -nonewline {}
- }
- }
- puts -nonewline {}
-}
-puts -nonewline {}
+ puts -nonewline {}
+ }
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
\ No newline at end of file
diff --git a/xmlapi/mastervaluechange.cgi b/xmlapi/mastervaluechange.cgi
index 59c60b1..3418a94 100755
--- a/xmlapi/mastervaluechange.cgi
+++ b/xmlapi/mastervaluechange.cgi
@@ -1,34 +1,43 @@
#!/bin/tclsh
-load tclrega.so
load tclrpc.so
+source session.tcl
source common.tcl
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+puts "Content-Type: text/xml; charset=iso-8559-1"
+puts ""
+puts -nonewline ""
-}
+if {[info exists sid] && [check_session $sid]} {
-set device_id ""
-set name ""
-set value ""
-
-catch {
+ set device_id ""
+ set name ""
+ set value ""
+ catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
+ if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
+ set device_id $val
+ continue
+ }
+ if {0 != [regexp "^name=(.*)$" $pair dummy val]} {
+ set name $val
+ continue
+ }
+ if {0 != [regexp "^value=(.*)$" $pair dummy val]} {
+ set value $val
+ continue
+ }
}
-}
+ }
-read_interfaces
+ read_interfaces
-set rec_devids [split $device_id "\,"]
-set rec_mvaluename [split $name "\,"]
-set rec_mvaluevalue [split $value "\,"]
+ set rec_devids [split $device_id "\,"]
+ set rec_mvaluename [split $name "\,"]
+ set rec_mvaluevalue [split $value "\,"]
-for {set counter 0} {$counter<[llength $rec_devids]} {incr counter} {
+ for {set counter 0} {$counter<[llength $rec_devids]} {incr counter} {
set devid [lindex $rec_devids $counter]
set item [lindex $rec_mvaluename $counter]
@@ -36,37 +45,40 @@ for {set counter 0} {$counter<[llength $rec_devids]} {incr counter} {
set cmd "{$item {string $val}}"
array set values [rega_script {
- integer iseId = "} $devid {";
- var oDevice = dom.GetObject(iseId);
- var address = oDevice.Address();
- var deviceType = oDevice.HssType();
- Write("");
- }]
- set deviceAddress $values(address)
- set deviceType $values(deviceType)
-
- puts -nonewline $values(STDOUT)
+ integer iseId = "} $devid {";
+ var oDevice = dom.GetObject(iseId);
+ var address = oDevice.Address();
+ var deviceType = oDevice.HssType();
+ Write("");
+ }]
+ set deviceAddress $values(address)
+ set deviceType $values(deviceType)
+
+ puts -nonewline $values(STDOUT)
if {[string compare -nocase -length 9 "HM-CC-VG-" $deviceType] == 0} {
- set ausgabe [xmlrpc $interfaces(VirtualDevices) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
+ set ausgabe [xmlrpc $interfaces(VirtualDevices) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
} elseif {[string compare -nocase -length 5 "HMIP-" $deviceType] == 0} {
- set ausgabe [xmlrpc $interfaces(HmIP-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
+ set ausgabe [xmlrpc $interfaces(HmIP-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
} else {
- set ausgabe [xmlrpc $interfaces(BidCos-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
- }
- puts -nonewline {}
- puts -nonewline {}
-}
-puts -nonewline {}
+ set ausgabe [xmlrpc $interfaces(BidCos-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
+ }
+ puts -nonewline {}
+ puts -nonewline {}
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/once.tcl b/xmlapi/once.tcl
old mode 100755
new mode 100644
index f98f224..6b4eeb5
--- a/xmlapi/once.tcl
+++ b/xmlapi/once.tcl
@@ -7,65 +7,65 @@
#- http://wiki.tcl.tk/1113
#modifiziert: 15.11.2006 - Badberg - Abfrage: $tcl_version < 8.4
# Bei http://wiki.tcl.tk/1113 wird file normalize benutzt. Das Statement
-# liefert einen immer eindeutigen Namen. Bei unserer heutigen Version
+# liefert einen immer eindeutigen Namen. Bei unserer heutigen Version
# von tcl (8.2) ist diese Funktion noch nicht enthalten. Das Statement
-# file nativename liefert nur den Dateinamen, und verhindert deshalb nur
-# das doppelte sourcen einer Datei im gleichen Verzeichnis. F�r die meisten
+# file nativename liefert nur den Dateinamen, und verhindert deshalb nur
+# das doppelte sourcen einer Datei im gleichen Verzeichnis. F�r die meisten
# F�lle reicht dies aber aus.
proc sourceOnce { file } {
- upvar "1" sources sources
-
- if { $::tcl_version < 8.4 } then {
-
- if { ! [info exists sources([file nativename $file])] } then {
-
- # don't catch errors, since that may indicate
- # we failed to load it...?
- uplevel "1" [list source $file]
-
- # mark it as loaded since it was source'd with no error...
- set sources([file nativename $file]) "1"
- }
- } else {
-
- if { ! [info exists sources([file normalize $file])] } then {
-
- # don't catch errors, since that may indicate
- # we failed to load it...?
- uplevel "1" [list source $file]
-
- # mark it as loaded since it was source'd with no error...
- set sources([file normalize $file]) "1"
- }
- }
+ upvar "1" sources sources
+
+ if { $::tcl_version < 8.4 } then {
+
+ if { ! [info exists sources([file nativename $file])] } then {
+
+ # don't catch errors, since that may indicate
+ # we failed to load it...?
+ uplevel "1" [list source $file]
+
+ # mark it as loaded since it was source'd with no error...
+ set sources([file nativename $file]) "1"
+ }
+ } else {
+
+ if { ! [info exists sources([file normalize $file])] } then {
+
+ # don't catch errors, since that may indicate
+ # we failed to load it...?
+ uplevel "1" [list source $file]
+
+ # mark it as loaded since it was source'd with no error...
+ set sources([file normalize $file]) "1"
+ }
+ }
}
proc loadOnce { file } {
- upvar "1" loaded loaded
-
- if { $::tcl_version < 8.4 } then {
-
- if { ! [info exists loaded([file nativename $file])] } then {
-
- # don't catch errors, since that may indicate
- # we failed to load it...?
- uplevel "1" [list load $file]
-
- # mark it as loaded since it was source'd with no error...
- set loaded([file nativename $file]) "1"
- }
- } else {
-
- if { ! [info exists loaded([file normalize $file])] } then {
-
- # don't catch errors, since that may indicate
- # we failed to load it...?
- uplevel "1" [list load $file]
-
- # mark it as loaded since it was source'd with no error...
- set loaded([file normalize $file]) "1"
- }
- }
+ upvar "1" loaded loaded
+
+ if { $::tcl_version < 8.4 } then {
+
+ if { ! [info exists loaded([file nativename $file])] } then {
+
+ # don't catch errors, since that may indicate
+ # we failed to load it...?
+ uplevel "1" [list load $file]
+
+ # mark it as loaded since it was source'd with no error...
+ set loaded([file nativename $file]) "1"
+ }
+ } else {
+
+ if { ! [info exists loaded([file normalize $file])] } then {
+
+ # don't catch errors, since that may indicate
+ # we failed to load it...?
+ uplevel "1" [list load $file]
+
+ # mark it as loaded since it was source'd with no error...
+ set loaded([file normalize $file]) "1"
+ }
+ }
}
diff --git a/xmlapi/programactions.cgi b/xmlapi/programactions.cgi
index e6225f2..078f0d9 100755
--- a/xmlapi/programactions.cgi
+++ b/xmlapi/programactions.cgi
@@ -1,43 +1,53 @@
#!/bin/tclsh
-
-load tclrega.so
-
-set program_id "-1"
-set active ""
-set visible ""
-
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
- }
-}
-
-
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-array set res [rega_script "
- if ($program_id > 0) { object obj = dom.GetObject($program_id);
- if (obj && obj.IsTypeOf(OT_PROGRAM)) {
- if ($active == false | $active == true){
- obj.Active($active);
- }
- if ($visible == false | $visible == true){
- obj.Visible($visible);
- }
- Write(obj);
- }
- }"]
-
-if { $res(STDOUT) != "" } {
- puts -nonewline ""
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set program_id "-1"
+ set active ""
+ set visible ""
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^program_id=(.*)$" $pair dummy val]} {
+ set programn_id $val
+ continue
+ }
+ if {0 != [regexp "^active_id=(.*)$" $pair dummy val]} {
+ set active $val
+ continue
+ }
+ if {0 != [regexp "^visible=(.*)$" $pair dummy val]} {
+ set visible $val
+ continue
+ }
+ }
+ }
+
+ array set res [rega_script "
+ if ($program_id > 0) { object obj = dom.GetObject($program_id);
+ if (obj && obj.IsTypeOf(OT_PROGRAM)) {
+ if (($active == false) || ($active == true)){
+ obj.Active($active);
+ }
+ if (($visible == false) || ($visible == true)){
+ obj.Visible($visible);
+ }
+ Write(obj);
+ }
+ }"]
+
+ if { $res(STDOUT) != "" } {
+ puts -nonewline ""
+ } else {
+ puts -nonewline {}
+ }
} else {
- puts -nonewline {}
+ puts -nonewline {}
}
-puts -nonewline {}
+puts ""
diff --git a/xmlapi/programlist.cgi b/xmlapi/programlist.cgi
index 88105e3..764f5e9 100755
--- a/xmlapi/programlist.cgi
+++ b/xmlapi/programlist.cgi
@@ -1,43 +1,48 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-puts -nonewline {}
-
-array set res [rega_script {
-
-string sProgramId;
-object oProgram;
-foreach (sProgramId, dom.GetObject(ID_PROGRAMS).EnumUsedIDs())
-{
- oProgram = dom.GetObject(sProgramId);
- if(oProgram != null)
- {
- Write(""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ array set res [rega_script {
+
+ string sProgramId;
+ object oProgram;
+ foreach (sProgramId, dom.GetObject(ID_PROGRAMS).EnumUsedIDs())
+ {
+ oProgram = dom.GetObject(sProgramId);
+ if(oProgram != null)
+ {
+ Write("");
- }
-}
-}]
+ object o_sysVar = dom.GetObject(sProgramId);
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
+ if( o_sysVar.UserAccessRights(iulOtherThanAdmin) == iarFullAccess ) {
+ Write("true");
+ } else {
+ Write("false");
+ }
+
+ Write("'/>");
+ }
+ }
+
+ }]
+
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/protocol.cgi b/xmlapi/protocol.cgi
index 58f86eb..9e801cb 100755
--- a/xmlapi/protocol.cgi
+++ b/xmlapi/protocol.cgi
@@ -1,128 +1,143 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-set start "0"
-set show "0"
-set clear "0"
-
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
- }
-}
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-puts -nonewline {}
-
-append hm_script {
- string drop = "";
- integer iLastGroupIndex = 1;
- string sCollectedNames = "";
- string sCollectedValues = "";
- string sCollectedDateTimes = "";
- string sCollectedTimestamp = "";
- string s;
- integer iStart = }
-append hm_script $start
-append hm_script {;
- integer iCount = }
-append hm_script $show
-append hm_script {;
- integer eCount = dom.GetHistoryDataCount();
- integer clear = }
-append hm_script $clear
-append hm_script {;
- integer rCount;
- if (iCount == "0") {
- iCount = eCount;
+if {[info exists sid] && [check_session $sid]} {
+
+ set start "0"
+ set show "0"
+ set clear "0"
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^start=(.*)$" $pair dummy val]} {
+ set start $val
+ continue
+ }
+ if {0 != [regexp "^show=(.*)$" $pair dummy val]} {
+ set show $val
+ continue
+ }
+ if {0 != [regexp "^clear=(.*)$" $pair dummy val]} {
+ set clear $val
+ continue
+ }
}
- Write("");
-}
+ }
+
+ set hm_script {
+ string drop = "";
+ integer iLastGroupIndex = 1;
+ string sCollectedNames = "";
+ string sCollectedValues = "";
+ string sCollectedDateTimes = "";
+ string sCollectedTimestamp = "";
+ string s;
+ integer iStart = }
+
+ append hm_script $start
+
+ append hm_script {;
+ integer iCount = }
-append hm_script {
-
- if (clear == "1") {
- var clearHistory = dom.ClearHistoryData();
- WriteLine("");
- } else {
-
- foreach( s, dom.GetHistoryData( iStart, iCount, &rCount ) )
- {
- integer iGroupIndex = s.StrValueByIndex(";",0).ToInteger();
- string sDatapointId = s.StrValueByIndex(";",1);
- string sRecordedValue = s.StrValueByIndex(";",2);
- string sDateTime = s.StrValueByIndex(";",3);
- string sTimestamp = s.StrValueByIndex(";",3).ToTime().ToInteger();
-
- string sDatapointName = "";
- object oHistDP = dom.GetObject( sDatapointId );
- if( oHistDP )
+ append hm_script $show
+
+ append hm_script {;
+ integer eCount = dom.GetHistoryDataCount();
+ integer clear = }
+
+ append hm_script $clear
+
+ append hm_script {;
+ integer rCount;
+ if (iCount == "0") {
+ iCount = eCount;
+ }
+ Write("");
+ }
+
+ append hm_script {
+
+ if (clear == "1") {
+ var clearHistory = dom.ClearHistoryData();
+ WriteLine("");
+ } else {
+
+ foreach( s, dom.GetHistoryData( iStart, iCount, &rCount ) )
{
- object oDP = dom.GetObject( oHistDP.ArchiveDP() );
- if( oDP )
+ integer iGroupIndex = s.StrValueByIndex(";",0).ToInteger();
+ string sDatapointId = s.StrValueByIndex(";",1);
+ string sRecordedValue = s.StrValueByIndex(";",2);
+ string sDateTime = s.StrValueByIndex(";",3);
+ string sTimestamp = s.StrValueByIndex(";",3).ToTime().ToInteger();
+ string sDatapointName = "";
+ object oHistDP = dom.GetObject( sDatapointId );
+ if( oHistDP )
{
- sDatapointName = oDP.Name();
- boolean bSysVar = (oDP.IsTypeOf(OT_VARDP) || oDP.IsTypeOf(OT_ALARMDP));
- if( !bSysVar )
+ object oDP = dom.GetObject( oHistDP.ArchiveDP() );
+ if( oDP )
{
- object oCH = dom.GetObject( oDP.Channel() );
- if( oCH )
+ sDatapointName = oDP.Name();
+ boolean bSysVar = (oDP.IsTypeOf(OT_VARDP) || oDP.IsTypeOf(OT_ALARMDP));
+ if( !bSysVar )
{
- sDatapointName = oCH.Name();
- }
- }
-
- if( iLastGroupIndex != iGroupIndex )
- {
- drop = drop # "
\n";
- sCollectedNames = "";
- sCollectedValues = "";
- iLastGroupIndex = iGroupIndex;
- }
-
- string id = oDP.ID();
- string sRet = "";
- string sValue = sRecordedValue;
- Call("/esp/functions.fn::WriteDPText()");
- sRecordedValue = system.GetVar("sRet");
-
- sCollectedNames = sDatapointName;
- sCollectedDateTimes = sDateTime;
- sCollectedTimestamp = sTimestamp;
-
- if( !sCollectedValues.Length() )
- {
- sCollectedValues = sRecordedValue;
- }
- else
- {
- sCollectedValues = sCollectedValues#", "#sRecordedValue;
+ object oCH = dom.GetObject( oDP.Channel() );
+ if( oCH )
+ {
+ sDatapointName = oCH.Name();
+ }
+ }
+
+ if( iLastGroupIndex != iGroupIndex )
+ {
+ drop = drop # "
\n";
+ sCollectedNames = "";
+ sCollectedValues = "";
+ iLastGroupIndex = iGroupIndex;
+ }
+
+ string id = oDP.ID();
+ string sRet = "";
+ string sValue = sRecordedValue;
+ Call("/esp/functions.fn::WriteDPText()");
+ sRecordedValue = system.GetVar("sRet");
+
+ sCollectedNames = sDatapointName;
+ sCollectedDateTimes = sDateTime;
+ sCollectedTimestamp = sTimestamp;
+
+ if( !sCollectedValues.Length() )
+ {
+ sCollectedValues = sRecordedValue;
+ }
+ else
+ {
+ sCollectedValues = sCollectedValues#", "#sRecordedValue;
+ }
+
}
-
}
- }
-
- }
- if( sCollectedValues.Length() )
- {
- drop = drop # "
";
- }
+ }
+ if( sCollectedValues.Length() )
+ {
+ drop = drop # "
";
+ }
- Write(drop);
+ Write(drop);
}
-}
-
-array set res [rega_script $hm_script]
-
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
+ }
+ array set res [rega_script $hm_script]
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/roomlist.cgi b/xmlapi/roomlist.cgi
index 193d583..8c88e5f 100755
--- a/xmlapi/roomlist.cgi
+++ b/xmlapi/roomlist.cgi
@@ -1,33 +1,39 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+source session.tcl
-}
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-array set res [rega_script {
+if {[info exists sid] && [check_session $sid]} {
+ array set res [rega_script {
- object oRoom;
- string sRoomId;
- string sRoomName;
- string sChannelId;
+ object oRoom;
+ string sRoomId;
+ string sRoomName;
+ string sChannelId;
- foreach (sRoomId, dom.GetObject(ID_ROOMS).EnumUsedIDs())
- {
- oRoom = dom.GetObject(sRoomId);
-
- Write("");
-
- foreach(sChannelId, oRoom.EnumUsedIDs())
+ foreach (sRoomId, dom.GetObject(ID_ROOMS).EnumUsedIDs())
{
- Write("");
- }
+ oRoom = dom.GetObject(sRoomId);
+
+ Write("");
- Write("");
- }
+ foreach(sChannelId, oRoom.EnumUsedIDs())
+ {
+ Write("");
+ }
+
+ Write("");
+ }
-}]
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
+ }]
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/rssilist.cgi b/xmlapi/rssilist.cgi
index 2c861cd..0b47259 100755
--- a/xmlapi/rssilist.cgi
+++ b/xmlapi/rssilist.cgi
@@ -1,43 +1,43 @@
#!/bin/tclsh
-
# !*****************************************************************************
# !* rssilist.cgi
# !* Signalqualitaet aller funk komponenten
-# !*
-# !* Autor : Dirk Szymanski
-# !* Erstellt am: gleich, kleinen moment noch
-# !*
-# !* Modifiziert 11'2012 hobbyquaker: cgi.tcl rausgeschmissen, allow-origin
-# !* Header hinzugef�gt
-# !*
+# !* Autor: Dirk Szymanski
# !*****************************************************************************
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+if {[info exists sid] && [check_session $sid]} {
-}
+ load tclrpc.so
+ source common.tcl
-load tclrpc.so
-source common.tcl
+ set RSSI_BAD -120.0
+ set RSSI_MEDIUM -100.0
+ set RSSI_GOOD -20.0
-set RSSI_BAD -120.0
-set RSSI_MEDIUM -100.0
-set RSSI_GOOD -20.0
+ read_interfaces
-read_interfaces
-set url $interfaces(BidCos-RF)
+ set url $interfaces(BidCos-RF)
-if { [ catch {
+ if { [ catch {
#check if the interface supports rssi
#failure of this call will throw us out of here
xmlrpc $url system.methodHelp rssiInfo
-} ] } { continue }
+ } ] } { continue }
-array_clear rssi_map
-set rssi_list [xmlrpc $url rssiInfo ]
-array set rssi_map $rssi_list
+ array_clear rssi_map
+ set rssi_list [xmlrpc $url rssiInfo ]
+ array set rssi_map $rssi_list
-foreach dev [lsort [array names rssi_map]] {
+ foreach dev [lsort [array names rssi_map]] {
puts -nonewline ""
+ }
+
+} else {
+ puts -nonewline {}
}
-puts -nonewline {}
+puts ""
diff --git a/xmlapi/runprogram.cgi b/xmlapi/runprogram.cgi
index 12da895..118673f 100755
--- a/xmlapi/runprogram.cgi
+++ b/xmlapi/runprogram.cgi
@@ -1,33 +1,32 @@
#!/bin/tclsh
-
-load tclrega.so
-
-set program_id "-1"
-
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set program_id "-1"
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^program_id=(.*)$" $pair dummy val]} {
+ set program_id $val
+ continue
+ }
+ }
}
- }
-}
-
-
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-}
+ array set res [rega_script "if ($program_id > 0) { object obj = dom.GetObject($program_id); if (obj && obj.IsTypeOf(OT_PROGRAM)) { obj.ProgramExecute(); Write(obj); }}"]
-array set res [rega_script "if ($program_id > 0) { object obj = dom.GetObject($program_id); if (obj && obj.IsTypeOf(OT_PROGRAM)) { obj.ProgramExecute(); Write(obj); }}"]
-
-if { $res(STDOUT) != "" } {
- puts -nonewline ""
+ if { $res(STDOUT) != "" } {
+ puts -nonewline ""
+ } else {
+ puts -nonewline {}
+ }
} else {
- puts -nonewline {}
+ puts -nonewline {}
}
-
-puts -nonewline {}
-
-
+puts ""
diff --git a/xmlapi/scripterrors.cgi b/xmlapi/scripterrors.cgi
index a29f569..960ec76 100755
--- a/xmlapi/scripterrors.cgi
+++ b/xmlapi/scripterrors.cgi
@@ -1,26 +1,27 @@
#!/bin/tclsh
-
# Sucht in den letzten 10 Zeilen von /var/log/messages nach Homematic-Script Fehlermeldungen
# 11'2012 - hobbyquaker https://github.com/hobbyquaker
-#
+source session.tcl
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-}
+if {[info exists sid] && [check_session $sid]} {
-set Datei [open "|/usr/bin/tail -n 10 /var/log/messages" r]
-while {[gets $Datei Zeile] >= 0} {
- if [regexp Error.*near $Zeile] {
- regexp {([a-zA-Z]+ [0-9\: ]+) \(none\) local0.err ReGaHss: Error: IseESP\:\:([a-zA-Z]+)\= Error ([0-9]+) at row ([0-9]+) col ([0-9]+)} $Zeile line time msg code row col
- puts -nonewline ""
+ set Datei [open "|/usr/bin/tail -n 10 /var/log/messages" r]
+ while {[gets $Datei Zeile] >= 0} {
+ if [regexp Error.*near $Zeile] {
+ regexp {([a-zA-Z]+ [0-9]+ [0-9\:]+) .+ local0.err ReGaHss: ERROR: SyntaxError\: Error ([0-9]+) at row ([0-9]+) col ([0-9]+)} $Zeile line time code row col
+ puts -nonewline ""
+ }
}
+} else {
+ puts -nonewline {}
}
-puts {}
\ No newline at end of file
+puts ""
diff --git a/xmlapi/session.tcl b/xmlapi/session.tcl
new file mode 100644
index 0000000..aa8d826
--- /dev/null
+++ b/xmlapi/session.tcl
@@ -0,0 +1,90 @@
+#!/bin/tclsh
+load tclrega.so
+
+catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ set sid ""
+ foreach pair $pairs {
+ if {0 != [regexp "^sid=(.*)$" $pair dummy val]} {
+ set sid $val
+ break
+ }
+ }
+}
+
+proc get_tokens {} {
+ set filename "/etc/config/addons/xmlapi/token.list"
+
+ set tokens ""
+ if {! [catch {set fd [open $filename r] } errmsg]} {
+ set tokens [read $fd]
+ close $fd
+ }
+
+ return $tokens
+}
+
+proc register_token desc {
+ set filename "/etc/config/addons/xmlapi/token.list"
+
+ set tokens ""
+ if {! [catch {set fd [open $filename r] } errmsg]} {
+ set tokens [read $fd]
+ close $fd
+ }
+
+ # function to generate a random string of 16 characters
+ # cf. https://wiki.tcl-lang.org/page/Generating+random+strings
+ set newToken [subst [string repeat {[format %c [expr {int(rand() * 26) + (rand() > .5 ? 97 : 65)}]]} 16]]
+
+ # add token to dict
+ dict append tokens $newToken $desc
+
+ if {! [catch {set fd [open $filename w] } errmsg]} {
+ puts $fd $tokens
+ }
+
+ return $newToken
+}
+
+proc revoke_token token {
+ set filename "/etc/config/addons/xmlapi/token.list"
+
+ set tokens ""
+ if {! [catch {set fd [open $filename r] } errmsg]} {
+ set tokens [read $fd]
+ close $fd
+ }
+
+ if {[dict exists $tokens $token]} {
+ # remove token from dict
+ dict unset tokens $token
+
+ if {! [catch {set fd [open $filename w] } errmsg]} {
+ puts $fd $tokens
+ return 1
+ }
+ }
+
+ return 0
+}
+
+proc check_session sid {
+ # check for api tokens first and then check
+ # for webui session ids as well as a fallback
+ if {[regexp {^([0-9a-zA-Z]{16})$} $sid all sidnr]} {
+ set tokens [get_tokens]
+
+ # check if sid exists in token dict
+ if {[dict exists $tokens $sid]} {
+ return 1
+ }
+ } elseif {[regexp {^@([0-9a-zA-Z]{10})@$} $sid all sidnr]} {
+ set res [lindex [rega_script "Write(system.GetSessionVarStr('$sidnr'));"] 1]
+ if {$res != ""} {
+ return 1
+ }
+ }
+ return 0
+}
diff --git a/xmlapi/state.cgi b/xmlapi/state.cgi
index f209e15..c0c17ea 100755
--- a/xmlapi/state.cgi
+++ b/xmlapi/state.cgi
@@ -1,121 +1,137 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-set device_id ""
-set channel_id ""
-set datapoint_id ""
-
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
- }
-}
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set device_id ""
+ set channel_id ""
+ set datapoint_id ""
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
+ set device_id $val
+ continue
+ }
+ if {0 != [regexp "^channel_id=(.*)$" $pair dummy val]} {
+ set channel_id $val
+ continue
+ }
+ if {0 != [regexp "^datapoint_id=(.*)$" $pair dummy val]} {
+ set datapoint_id $val
+ continue
+ }
+ }
+ }
+
+ array set res [rega_script {
+
+ string sDevIds = "} $device_id {";
+ string sChannelIds = "} $channel_id {";
+ string sDatapointIds = "} $datapoint_id {";
+ string sChnId;
+ string sDPId;
+
+ if (sDatapointIds.Length() > 0 ) {
+
+ string sDatapointId;
+ foreach(sDatapointId, sDatapointIds.Split(",")) {
+
+ object oDatapoint = dom.GetObject(sDatapointId);
+ if (oDatapoint.IsTypeOf(OT_DP)) {
+ Write("");
+ }
+ }
+
+ } else {
+
+ if (sChannelIds.Length() > 0 ) {
+
+ string sChannelId;
+ foreach(sChannelId, sChannelIds.Split(",")) {
+ object oChannel2 = dom.GetObject(sChannelId);
-array set res [rega_script {
-
- string sDevIds = "} $device_id {";
- string sChannelIds = "} $channel_id {";
- string sDatapointIds = "} $datapoint_id {";
- string sChnId;
- string sDPId;
-
- if (sDatapointIds.Length() > 0 ) {
-
- string sDatapointId;
- foreach(sDatapointId, sDatapointIds.Split(",")) {
-
- object oDatapoint = dom.GetObject(sDatapointId);
- if (oDatapoint.IsTypeOf(OT_DP)){
- Write("");
- }
-
- }
-
- } else {
-
- if (sChannelIds.Length() > 0 ) {
-
- string sChannelId;
- foreach(sChannelId, sChannelIds.Split(",")) {
- object oChannel2 = dom.GetObject(sChannelId);
-
- if (sDevIds.Length() > 0 ) {
- sDevIds = sDevIds # "," # oChannel2.Device().ToString();
- } else {
- sDevIds = oChannel2.Device().ToString();
- }
- }
- }
-
- string sDevId;
- foreach(sDevId, sDevIds.Split(",")) {
-
- object oDevice = dom.GetObject(sDevId);
-
- if(oDevice.ReadyConfig() && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") && oDevice.IsTypeOf(OT_DEVICE)) {
- Write(""); ! device tag schliessen
-
- foreach(sChnId, oDevice.Channels()) {
- object oChannel = dom.GetObject(sChnId);
- if ((!oChannel.Internal()) || oChannel.Internal()) {
-
- Write("");
-
- foreach(sDPId, oChannel.DPs().EnumUsedIDs()) {
- object oDP = dom.GetObject(sDPId);
- if(oDP) {
- string dp = oDP.Name().StrValueByIndex(".", 2);
-
- if( (dp != "ON_TIME") && (dp != "INHIBIT") && (dp != "CMD_RETS") && (dp != "CMD_RETL") && (dp != "CMD_SETS") && (dp != "CMD_SETL") ) {
- Write("");
- }
- }
- }
- Write("");
- }
- }
- Write("");
- }
- }
- }
-}]
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
+ if (sDevIds.Length() > 0 ) {
+ sDevIds = sDevIds # "," # oChannel2.Device().ToString();
+ } else {
+ sDevIds = oChannel2.Device().ToString();
+ }
+ }
+ }
+
+ string sDevId;
+ foreach(sDevId, sDevIds.Split(",")) {
+
+ object oDevice = dom.GetObject(sDevId);
+
+ if(oDevice.ReadyConfig() && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") && oDevice.IsTypeOf(OT_DEVICE)) {
+ Write(""); ! device tag schliessen
+
+ foreach(sChnId, oDevice.Channels()) {
+ object oChannel = dom.GetObject(sChnId);
+ if ((!oChannel.Internal()) || oChannel.Internal()) {
+
+ Write("");
+
+ foreach(sDPId, oChannel.DPs().EnumUsedIDs()) {
+ object oDP = dom.GetObject(sDPId);
+ if(oDP) {
+ string dp = oDP.Name().StrValueByIndex(".", 2);
+
+ if( (dp != "ON_TIME") && (dp != "INHIBIT") && (dp != "CMD_RETS") && (dp != "CMD_RETL") && (dp != "CMD_SETS") && (dp != "CMD_SETL") ) {
+ Write("");
+ }
+ }
+ }
+ Write("");
+ }
+ }
+ Write("");
+ }
+ }
+ }
+ }]
+
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
\ No newline at end of file
diff --git a/xmlapi/statechange.cgi b/xmlapi/statechange.cgi
index baa8564..05ee2a1 100755
--- a/xmlapi/statechange.cgi
+++ b/xmlapi/statechange.cgi
@@ -1,59 +1,68 @@
#!/bin/tclsh
+source session.tcl
-load tclrega.so
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-set ise_id ""
-set new_value ""
+if {[info exists sid] && [check_session $sid]} {
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
+ set ise_id ""
+ set new_value ""
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^ise_id=(.*)$" $pair dummy val]} {
+ set ise_id $val
+ continue
+ }
+ if {0 != [regexp "^new_value=(.*)$" $pair dummy val]} {
+ set new_value $val
+ continue
+ }
+ }
}
-}
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-regsub -all {%20} $new_value { } new_value
-regsub -all {%21} $new_value {!} new_value
-regsub -all {%23} $new_value {#} new_value
-regsub -all {%25} $new_value {%} new_value
-regsub -all {%2A} $new_value {*} new_value
-regsub -all {%2F} $new_value {/} new_value
-regsub -all {%3C} $new_value {<} new_value
-regsub -all {%3E} $new_value {>} new_value
-regsub -all {%3F} $new_value {?} new_value
-
-if { [string match "rgb*" $new_value ]} {
- array set res [rega_script "Write(dom.GetObject($ise_id).State('$new_value'));"]
-
- if {$res(STDOUT) != "null"} {
- puts -nonewline "";
- } else {
- puts -nonewline "";
- }
-
-} else {
- set rec_new_value [split $new_value "\,"]
- set rec_ise_id [split $ise_id "\,"]
+ regsub -all {%20} $new_value { } new_value
+ regsub -all {%21} $new_value {!} new_value
+ regsub -all {%23} $new_value {#} new_value
+ regsub -all {%25} $new_value {%} new_value
+ regsub -all {%2A} $new_value {*} new_value
+ regsub -all {%2F} $new_value {/} new_value
+ regsub -all {%3C} $new_value {<} new_value
+ regsub -all {%3E} $new_value {>} new_value
+ regsub -all {%3F} $new_value {?} new_value
+ regsub -all {%5E} $new_value {^} new_value
+ regsub -all {%3D} $new_value {=} new_value
+ regsub -all {%2C} $new_value {,} new_value
- for {set x 0} {$x<[llength $rec_ise_id]} {incr x} {
+ if { [string match "rgb*" $new_value ] || [string match "*=*" $new_value ] } {
+ array set res [rega_script "Write(dom.GetObject($ise_id).State('$new_value'));"]
- array set res [rega_script "Write(dom.GetObject([lindex $rec_ise_id $x]).State('[lindex $rec_new_value $x]'));"]
+ if {$res(STDOUT) != "null"} {
+ puts -nonewline "";
+ } else {
+ puts -nonewline "";
+ }
- if {$res(STDOUT) != "null"} {
- puts -nonewline "";
- } else {
- puts -nonewline "";
- }
- }
-}
+ } else {
+
+ set rec_new_value [split $new_value "\,"]
+ set rec_ise_id [split $ise_id "\,"]
-puts -nonewline {}
+ for {set x 0} {$x<[llength $rec_ise_id]} {incr x} {
+ array set res [rega_script "Write(dom.GetObject([lindex $rec_ise_id $x]).State('[lindex $rec_new_value $x]'));"]
+
+ if {$res(STDOUT) != "null"} {
+ puts -nonewline "";
+ } else {
+ puts -nonewline "";
+ }
+ }
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/statelist.cgi b/xmlapi/statelist.cgi
index 0ce41b0..bce192e 100755
--- a/xmlapi/statelist.cgi
+++ b/xmlapi/statelist.cgi
@@ -1,157 +1,158 @@
#!/bin/tclsh
-
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-set ise_id 0
-set show_internal 0
-
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set ise_id 0
+ set show_internal 0
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^ise_id=(.*)$" $pair dummy val]} {
+ set ise_id $val
+ continue
+ }
+ if {0 != [regexp "^show_internal=(.*)$" $pair dummy val]} {
+ set show_internal $val
+ continue
+ }
+ }
}
-}
-set comm "var ise_id=$ise_id;\n"
-set comm "var show_internal=$show_internal;\n"
-
-
-if { $ise_id != 0 } then {
-
- append comm {
- object obj = dom.GetObject(ise_id);
- if(obj.TypeName() == "HSSDP")
+ set comm "var ise_id=$ise_id;\n"
+ append comm "var show_internal=$show_internal;\n"
+
+ if { $ise_id != 0 } then {
+
+ append comm {
+ object obj = dom.GetObject(ise_id);
+ if(obj.TypeName() == "HSSDP")
+ {
+ object oDP = obj;
+ string dp = oDP.Name().StrValueByIndex(".", 2);
+
+ Write("");
+ }
+ }
+
+ } else {
+
+ append comm {
+
+ string sDevId;
+ string sChnId;
+ string sDPId;
+
+ foreach (sDevId, root.Devices().EnumUsedIDs())
+ {
+ object oDevice = dom.GetObject(sDevId);
+
+ if( oDevice.ReadyConfig() && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") )
{
- object oDP = obj;
- string dp = oDP.Name().StrValueByIndex(".", 2);
-
- Write(""); ! device tag schliessen
+
+ foreach(sChnId, oDevice.Channels())
+ {
+ object oChannel = dom.GetObject(sChnId);
+ if ( (! oChannel.Internal()) || oChannel.Internal() )
+ {
+ Write("");
+
+ foreach(sDPId, oChannel.DPs().EnumUsedIDs())
+ {
+ object oDP = dom.GetObject(sDPId);
+ if(oDP)
+ {
+ string dp = oDP.Name().StrValueByIndex(".", 2);
+
+ if( (dp != "ON_TIME") && (dp != "INHIBIT") && (dp != "CMD_RETS") && (dp != "CMD_RETL") && (dp != "CMD_SETS") && (dp != "CMD_SETL") )
+ {
+ Write("");
+ }
+ }
+ }
+ Write("");
}
- ! value nimmt den von der ccu gecachten wert, moeglicherweise nicht korrekt. Ggf. bei einigen geraeten immer abfragen
- Write(" value='");WriteXML(oDP.Value());Write("'");
- Write(" valuetype='");WriteXML(oDP.ValueType());Write("'");
- Write(" timestamp='");WriteXML(oDP.Timestamp().ToInteger());Write("'");
- Write(" />");
+ }
+ Write("");
}
+ }
}
-} else {
-
-
-
-
-
-append comm {
-
-string sDevId;
-string sChnId;
-string sDPId;
-
- foreach (sDevId, root.Devices().EnumUsedIDs())
- {
- object oDevice = dom.GetObject(sDevId);
-
- if( oDevice.ReadyConfig() && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") )
- {
- Write(""); ! device tag schliessen
-
- foreach(sChnId, oDevice.Channels())
- {
- object oChannel = dom.GetObject(sChnId);
- if ( (! oChannel.Internal()) || oChannel.Internal() )
- {
-
- Write("");
-
- foreach(sDPId, oChannel.DPs().EnumUsedIDs())
- {
- object oDP = dom.GetObject(sDPId);
- if(oDP)
- {
- string dp = oDP.Name().StrValueByIndex(".", 2);
-
- if( (dp != "ON_TIME") && (dp != "INHIBIT") && (dp != "CMD_RETS") && (dp != "CMD_RETL") && (dp != "CMD_SETS") && (dp != "CMD_SETL") )
- {
- Write("");
- }
- }
- }
- Write("");
- }
- }
- Write("");
- }
- }
+ array set res [rega_script $comm]
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
}
-
- array set res [rega_script $comm]
-
- puts -nonewline $res(STDOUT)
+} else {
+ puts -nonewline {}
}
-puts -nonewline {}
-
-
+puts ""
diff --git a/xmlapi/systemNotification.cgi b/xmlapi/systemNotification.cgi
index 98cf2b9..7a9a6d6 100755
--- a/xmlapi/systemNotification.cgi
+++ b/xmlapi/systemNotification.cgi
@@ -1,53 +1,50 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
- }
-}
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set hm_script {
+ object oTmpArray = dom.GetObject(ID_SERVICES);
+
+ if( oTmpArray ) {
+ string sTmp;
-append hm_script {;
- object oTmpArray = dom.GetObject(ID_SERVICES);
-
- if( oTmpArray ) {
- string sTmp;
-
- foreach(sTmp, oTmpArray.EnumIDs()){
-
- object oTmp = dom.GetObject( sTmp );
-
- if( oTmp ){
- if( oTmp.IsTypeOf( OT_ALARMDP ) && ( oTmp.AlState() == asOncoming ) ){
-
- var trigDP = dom.GetObject(oTmp.AlTriggerDP());
- if( trigDP ) {
- Write("");
- }
- }
+ foreach(sTmp, oTmpArray.EnumIDs()){
+
+ object oTmp = dom.GetObject( sTmp );
+
+ if( oTmp ){
+ if( oTmp.IsTypeOf( OT_ALARMDP ) && ( oTmp.AlState() == asOncoming ) ){
+
+ var trigDP = dom.GetObject(oTmp.AlTriggerDP());
+ if( trigDP ) {
+ Write("");
+ }
+ }
+ }
}
- }
- }
-}
+ }
+ }
-array set res [rega_script $hm_script]
+ array set res [rega_script $hm_script]
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/systemNotificationClear.cgi b/xmlapi/systemNotificationClear.cgi
index a7cb26f..1c8f86f 100755
--- a/xmlapi/systemNotificationClear.cgi
+++ b/xmlapi/systemNotificationClear.cgi
@@ -1,13 +1,14 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+source session.tcl
-}
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-append hm_script {;
+if {[info exists sid] && [check_session $sid]} {
- string itemID;
+ set hm_script {
+ string itemID;
string address;
object aldp_obj;
@@ -20,10 +21,14 @@ append hm_script {;
}
}
}
-
-}
+ }
-array set res [rega_script $hm_script]
+ array set res [rega_script $hm_script]
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
\ No newline at end of file
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/sysvar.cgi b/xmlapi/sysvar.cgi
index 711b0f5..5b84d5a 100755
--- a/xmlapi/sysvar.cgi
+++ b/xmlapi/sysvar.cgi
@@ -1,81 +1,95 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+source session.tcl
-}
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-set text "true"
-set ise_id "-1"
+if {[info exists sid] && [check_session $sid]} {
-catch {
+ set text "true"
+ set ise_id "-1"
+ catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
- }
+ if {0 != [regexp "^text=(.*)$" $pair dummy val]} {
+ set text $val
+ continue
+ }
+ if {0 != [regexp "^ise_id=(.*)$" $pair dummy val]} {
+ set ise_id $val
+ continue
+ }
}
-}
+ }
-append hm_script {
+ set hm_script {
+ object oSysVar;
+ string sSysVarId;
+ string sShowText=
+ }
- object oSysVar;
- string sSysVarId;
- string sShowText=
-}
-append hm_script $text
-append hm_script {;
- string iSysVarId=}
-append hm_script $ise_id
-append hm_script {;
-
- foreach (sSysVarId, dom.GetObject(ID_SYSTEM_VARIABLES).EnumUsedIDs()){
-
- oSysVar = dom.GetObject(sSysVarId);
-
- if (oSysVar.ID() == iSysVarId) {
-
- Write("");
- }
- }
-}
+ append hm_script $text
+
+ append hm_script {;
+ string iSysVarId=}
+
+ append hm_script $ise_id
+
+ append hm_script {;
+
+ foreach (sSysVarId, dom.GetObject(ID_SYSTEM_VARIABLES).EnumUsedIDs()){
+
+ oSysVar = dom.GetObject(sSysVarId);
-array set res [rega_script $hm_script]
+ if (oSysVar.ID() == iSysVarId) {
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
+ Write("");
+ }
+ }
+ }
+
+ array set res [rega_script $hm_script]
+
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/sysvarlist.cgi b/xmlapi/sysvarlist.cgi
index b64ed8b..58432b1 100755
--- a/xmlapi/sysvarlist.cgi
+++ b/xmlapi/sysvarlist.cgi
@@ -1,76 +1,86 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
+source session.tcl
-}
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-set text "false"
+if {[info exists sid] && [check_session $sid]} {
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
+ set text "false"
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^text=(.*)$" $pair dummy val]} {
+ set text $val
+ continue
+ }
+ }
}
- }
-}
-
-append hm_script {
+ set hm_script {
+ object oSysVar;
+ string sSysVarId;
+ string sShowText=
+ }
- object oSysVar;
- string sSysVarId;
- string sShowText=
-}
+ append hm_script $text
-append hm_script $text
+ append hm_script {;
-append hm_script {;
+ foreach (sSysVarId, dom.GetObject(ID_SYSTEM_VARIABLES).EnumUsedIDs()) {
+ oSysVar = dom.GetObject(sSysVarId);
+ Write("");
+ }
+ }
- foreach (sSysVarId, dom.GetObject(ID_SYSTEM_VARIABLES).EnumUsedIDs()) {
- oSysVar = dom.GetObject(sSysVarId);
- Write("");
- }
+ array set res [rega_script $hm_script]
+ if { $res(STDOUT) != "" } {
+ puts -nonewline $res(STDOUT)
+ }
+} else {
+ puts -nonewline {}
}
-
-array set res [rega_script $hm_script]
-
-puts -nonewline $res(STDOUT)
-puts -nonewline {}
+puts ""
diff --git a/xmlapi/tokenlist.cgi b/xmlapi/tokenlist.cgi
new file mode 100755
index 0000000..6940d45
--- /dev/null
+++ b/xmlapi/tokenlist.cgi
@@ -0,0 +1,26 @@
+#!/bin/tclsh
+#
+# script to list all currently registred API tokens
+#
+# parameters: none
+# return: list of currently active API tokens
+#
+
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set tokens [get_tokens]
+
+ dict for {token desc} $tokens {
+ puts "$token"
+ }
+
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/tokenregister.cgi b/xmlapi/tokenregister.cgi
new file mode 100755
index 0000000..36b00a3
--- /dev/null
+++ b/xmlapi/tokenregister.cgi
@@ -0,0 +1,33 @@
+#!/bin/tclsh
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set desc ""
+ set ise_id "-1"
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^desc=(.*)$" $pair dummy val]} {
+ set desc $val
+ break
+ }
+ }
+ }
+
+ set newToken [register_token $desc]
+ if { $newToken != "" } {
+ puts "$newToken"
+ } else {
+ puts ""
+ }
+
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/tokenrevoke.cgi b/xmlapi/tokenrevoke.cgi
new file mode 100755
index 0000000..09b40cf
--- /dev/null
+++ b/xmlapi/tokenrevoke.cgi
@@ -0,0 +1,20 @@
+#!/bin/tclsh
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set result [revoke_token $sid]
+ if { $result == 1 } {
+ puts ""
+ } else {
+ puts ""
+ }
+
+} else {
+ puts -nonewline {}
+}
+puts ""
diff --git a/xmlapi/update-check.cgi b/xmlapi/update-check.cgi
index 2b10feb..490cddd 100755
--- a/xmlapi/update-check.cgi
+++ b/xmlapi/update-check.cgi
@@ -1,14 +1,15 @@
#!/bin/tclsh
-set checkURL "https://raw.githubusercontent.com/hobbyquaker/XML-API/master/VERSION"
-set downloadURL "https://github.com/hobbyquaker/XML-API/releases/latest"
+set checkURL "https://raw.githubusercontent.com/homematic-community/XML-API/master/VERSION"
+set downloadURL "https://github.com/homematic-community/XML-API/releases"
catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
+ if {$pair == "cmd=download"} {
+ set cmd "download"
+ break
}
}
}
diff --git a/xmlapi/update.cgi b/xmlapi/update.cgi
index 719f457..2cbb2c6 100755
--- a/xmlapi/update.cgi
+++ b/xmlapi/update.cgi
@@ -1,53 +1,63 @@
#!/bin/tclsh
-load tclrega.so
-puts -nonewline {Content-Type: text/xml
-Access-Control-Allow-Origin: *
-
-}
-
-set checkupdate ""
-set maxdurchlaeufe 7
-
-catch {
- set input $env(QUERY_STRING)
- set pairs [split $input &]
- foreach pair $pairs {
- if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
- set $varname $val
+source session.tcl
+
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
+
+if {[info exists sid] && [check_session $sid]} {
+
+ set checkupdate ""
+ set maxdurchlaeufe 7
+ catch {
+ set input $env(QUERY_STRING)
+ set pairs [split $input &]
+ foreach pair $pairs {
+ if {0 != [regexp "^checkupdate=(.*)$" $pair dummy val]} {
+ set checkupdate $val
+ continue
+ }
+ if {0 != [regexp "^maxdurchlaeufe=(.*)$" $pair dummy val]} {
+ set maxdurchlaeufe $val
+ continue
+ }
+ }
}
- }
-}
-catch {
+ catch {
set idlist [split [string trim $checkupdate] ";"]
set resultids ""
set zaehler 0
while { ([llength $resultids] < 1) && ($zaehler < $maxdurchlaeufe) } {
- foreach pair $idlist {
- if {$pair != {} } then {
- set vp [split $pair "="]
-
- set id [lindex $vp 0]
- set timestamp [lindex $vp 1]
-
- set res [rega "dom.GetObject($id).Timestamp().ToInteger();"]
-
- if { $res == $timestamp } {
- continue
- }
- # unterschiedlich, also id merken
- array set res_arr [rega_script "object o=dom.GetObject($id);\nvar value=o.Value();\nvar lastupdate=o.Timestamp().ToInteger();\nvar type=o.TypeName();"]
- # puts -nonewline $res_arr(STDOUT)
- puts -nonewline ""
- lappend resultids $id
- }
- }
- if { [llength $resultids] < 1 } {
- after 500
- incr zaehler
+ foreach pair $idlist {
+ if {$pair != {} } then {
+ set vp [split $pair "="]
+
+ set id [lindex $vp 0]
+ set timestamp [lindex $vp 1]
+
+ set res [rega "dom.GetObject($id).Timestamp().ToInteger();"]
+
+ if { $res == $timestamp } {
+ continue
+ }
+
+ # unterschiedlich, also id merken
+ array set res_arr [rega_script "object o=dom.GetObject($id);\nvar value=o.Value();\nvar lastupdate=o.Timestamp().ToInteger();\nvar type=o.TypeName();"]
+ # puts -nonewline $res_arr(STDOUT)
+ puts -nonewline ""
+ lappend resultids $id
}
+ }
+ if { [llength $resultids] < 1 } {
+ after 500
+ incr zaehler
+ }
}
+ }
+} else {
+ puts -nonewline {}
}
-puts -nonewline {}
+puts ""
diff --git a/xmlapi/version.cgi b/xmlapi/version.cgi
index 7016812..636336d 100755
--- a/xmlapi/version.cgi
+++ b/xmlapi/version.cgi
@@ -7,9 +7,10 @@ if { $fd >=0 } {
close $fd
}
-set output "Content-Type: text/xml
-Access-Control-Allow-Origin: *
+puts "Content-Type: text/xml; charset=iso-8859-1"
+puts ""
+puts -nonewline ""
-$version"
+puts -nonewline $version
-puts -nonewline $output
+puts ""
diff --git a/xmlapi/xml.tcl b/xmlapi/xml.tcl
old mode 100755
new mode 100644
index ec22b3d..476fb8d
--- a/xmlapi/xml.tcl
+++ b/xmlapi/xml.tcl
@@ -21,7 +21,7 @@
#*******************************************************************************
proc xml_escape { value } {
set xml_map ""
-
+
lappend xml_map "<" "<"
lappend xml_map ">" ">"
lappend xml_map "&" "&"