diff --git a/fhem/CHANGED b/fhem/CHANGED
index f915852e2..86d44b86b 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII
- SVN
+ - change: weblink fileplot/dbplot converted to SVG device (+FHEMWEB cleanup)
- change: VIERA: Added support for get dropdown
- change: EnOcean: Manufacturer Specific Applications (EEP A5-3F-7F), Shutter:
readings position and anglePos are updated automatically, if command
diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm
index 266ff0880..f18f81992 100755
--- a/fhem/FHEM/01_FHEMWEB.pm
+++ b/fhem/FHEM/01_FHEMWEB.pm
@@ -13,7 +13,6 @@ sub FW_IconURL($);
sub FW_iconName($);
sub FW_iconPath($);
sub FW_answerCall($);
-sub FW_calcWeblink($$);
sub FW_dev2image($;$);
sub FW_devState($$@);
sub FW_digestCgi($);
@@ -36,26 +35,20 @@ sub FW_returnFileAsStream($$$$$);
sub FW_roomOverview($);
sub FW_select($$$$$@);
sub FW_serveSpecial($$$$);
-sub FW_showLog($);
sub FW_showRoom();
sub FW_style($$);
sub FW_submit($$@);
-sub FW_substcfg($$$$$$);
sub FW_textfield($$$);
sub FW_textfieldv($$$$);
sub FW_updateHashes();
-sub FW_zoomLink($$$);
-use vars qw($FW_dir); # base directory for web server: the first available
- # from $modpath/www, $modpath/FHEM
-use vars qw($FW_icondir); # icon base directory for web server: the first
- # available from $FW_dir/icons, $FW_dir
-use vars qw($FW_cssdir); # css directory for web server: the first available
- # from $FW_dir/css, $FW_dir
-use vars qw($FW_gplotdir);# gplot directory for web server: the first
- # available from $FW_dir/gplot,$FW_dir
+use vars qw($FW_dir); # base directory for web server
+use vars qw($FW_icondir); # icon base directory
+use vars qw($FW_cssdir); # css directory
+use vars qw($FW_gplotdir);# gplot directory
use vars qw($MW_dir); # moddir (./FHEM), needed by edit Files in new
# structure
+
use vars qw($FW_ME); # webname (default is fhem), used by 97_GROUP/weblink
use vars qw($FW_ss); # is smallscreen, needed by 97_GROUP/95_VIEW
use vars qw($FW_tp); # is touchpad (iPad / etc)
@@ -64,6 +57,7 @@ use vars qw($FW_sp); # stylesheetPrefix
# global variables, also used by 97_GROUP/95_VIEW/95_FLOORPLAN
use vars qw(%FW_types); # device types,
use vars qw($FW_RET); # Returned data (html)
+use vars qw($FW_RETTYPE); # image/png or the like
use vars qw($FW_wname); # Web instance
use vars qw($FW_subdir); # Sub-path in URL, used by FLOORPLAN/weblink
use vars qw(%FW_pos); # scroll position
@@ -73,6 +67,9 @@ use vars qw($FW_plotmode);# Global plot mode (WEB attribute), used by weblink
use vars qw($FW_plotsize);# Global plot size (WEB attribute), used by weblink
use vars qw(%FW_webArgs); # all arguments specified in the GET
use vars qw(@FW_fhemwebjs);# List of fhemweb*js scripts to load
+use vars qw($FW_detail); # currently selected device for detail view
+use vars qw($FW_cmdret); # Returned data by the fhem call
+use vars qw($FW_room); # currently selected room
my $FW_zlib_checked;
my $FW_use_zlib = 1;
@@ -84,14 +81,10 @@ my $FW_formmethod = "post";
# Note: for delivering SVG plots we fork
my @FW_httpheader; # HTTP header, line by line
my @FW_enc; # Accepted encodings (browser header)
-my $FW_cmdret; # Returned data by the fhem call
my $FW_data; # Filecontent from browser when editing a file
-my $FW_detail; # currently selected device for detail view
-my %FW_devs; # hash of from/to entries per device
my %FW_icons; # List of icons
my @FW_iconDirs; # Directory search order for icons
my $FW_RETTYPE; # image/png or the like
-my $FW_room; # currently selected room
my %FW_rooms; # hash of all rooms
my %FW_types; # device types, for sorting
my %FW_hiddengroup;# hash of hidden groups
@@ -214,7 +207,6 @@ FW_Read($)
$FW_cname = $name;
$FW_subdir = "";
- my $ll = GetLogLevel($FW_wname,4);
my $c = $hash->{CD};
if(!$FW_zlib_checked) {
$FW_zlib_checked = 1;
@@ -223,18 +215,15 @@ FW_Read($)
eval { require Compress::Zlib; };
if($@) {
$FW_use_zlib = 0;
- Log 1, $@;
- Log 1, "$FW_wname: Can't load Compress::Zlib, deactivating compression";
+ Log3 $FW_wname, 1, $@;
+ Log3 $FW_wname, 1,
+ "$FW_wname: Can't load Compress::Zlib, deactivating compression";
$attr{$FW_wname}{fwcompress} = 0;
}
}
}
- # This is a hack... Dont want to do it each time after a fork.
- if(!$modules{SVG}{LOADED} && -f "$attr{global}{modpath}/FHEM/98_SVG.pm") {
- my $ret = CommandReload(undef, "98_SVG");
- Log 1, $ret if($ret);
- }
+
# Data from HTTP Client
my $buf;
@@ -242,7 +231,7 @@ FW_Read($)
if(!defined($ret) || $ret <= 0) {
CommandDelete(undef, $name);
- Log($ll, "Connection closed for $name");
+ Log3 $FW_wname, 4, "Connection closed for $name";
return;
}
@@ -282,12 +271,12 @@ FW_Read($)
if($secret && $basicAuth =~ m/^{.*}$/ || $headerOptions[0]) {
eval "use MIME::Base64";
if($@) {
- Log 1, $@;
+ Log3 $FW_wname, 1, $@;
} else {
my ($user, $password) = split(":", decode_base64($secret));
$pwok = eval $basicAuth;
- Log 1, "basicAuth expression: $@" if($@);
+ Log3 $FW_wname, 1, "basicAuth expression: $@" if($@);
}
}
if($headerOptions[0]) {
@@ -321,7 +310,7 @@ FW_Read($)
$hash->{LASTACCESS} = $now;
$arg = "" if(!defined($arg));
- Log $ll, "HTTP $name GET $arg";
+ Log3 $FW_wname, 4, "HTTP $name GET $arg";
my $pid;
if(AttrVal($FW_wname, "plotfork", undef)) {
# Process SVG rendering as a parallel process
@@ -344,7 +333,7 @@ FW_Read($)
my $length = length($FW_RET);
my $expires = ($cacheable?
("Expires: ".localtime($now+900)." GMT\r\n") : "");
- Log $ll, "$arg / RL: $length / $FW_RETTYPE / $compressed / $expires";
+ Log3 $FW_wname, 4, "$arg / RL:$length / $FW_RETTYPE / $compressed / $expires";
print $c "HTTP/1.1 200 OK\r\n",
"Content-Length: $length\r\n",
$expires, $compressed, $FW_headercors,
@@ -423,7 +412,7 @@ FW_answerCall($)
} else {
my $c = $me->{CD};
- Log 4, "$FW_wname: redirecting $arg to $FW_ME";
+ Log3 $FW_wname, 4, "$FW_wname: redirecting $arg to $FW_ME";
print $c "HTTP/1.1 302 Found\r\n",
"Content-Length: 0\r\n", $FW_headercors,
"Location: $FW_ME\r\n\r\n";
@@ -453,8 +442,6 @@ FW_answerCall($)
my $docmd = 0;
$docmd = 1 if($cmd &&
$cmd !~ /^showlog/ &&
- $cmd !~ /^logwrapper/ &&
- $cmd !~ /^toweblink/ &&
$cmd !~ /^style / &&
$cmd !~ /^edit/);
@@ -474,28 +461,31 @@ FW_answerCall($)
}
##############################
- # Axels FHEMWEB modules...
+ # FHEMWEB extensions (FLOORPLOAN, SVG_WriteGplot, etc)
+ my $FW_contentFunc;
if(defined($data{FWEXT})) {
foreach my $k (sort keys %{$data{FWEXT}}) {
my $h = $data{FWEXT}{$k};
- next if($arg !~ m/^$k/ || $h !~ m/HASH/ || !$h->{FUNC});
+ next if($arg !~ m/^$k/);
+ $FW_contentFunc = $h->{CONTENTFUNC};
+ next if($h !~ m/HASH/ || !$h->{FUNC});
+ #Returns undef as FW_RETTYPE if it already sent a HTTP header
no strict "refs";
- #Returns undef if it already sent a HTTP header
- my $localType;
- ($localType, $FW_RET) = &{$h->{FUNC}}($arg);
+ ($FW_RETTYPE, $FW_RET) = &{$h->{FUNC}}($arg);
use strict "refs";
- if($FW_RET && $FW_RET eq "continue") { # Continue displaying the data
- $FW_RET="";
- last;
- }
- $FW_RETTYPE = $localType;
return defined($FW_RETTYPE) ? 0 : -1;
}
}
#Now execute the command
- $FW_cmdret = $docmd ? FW_fC($cmd, $cmddev) : "";
+ $FW_cmdret = "";
+ if($docmd) {
+ $FW_cmdret = FW_fC($cmd, $cmddev);
+ if($cmd =~ m/^define +([^ ]+) /) { # "redirect" after define to details
+ $FW_detail = $1;
+ }
+ }
# Redirect after a command, to clean the browser URL window
if($docmd && !$FW_cmdret && AttrVal($FW_wname, "redirectCmds", 1)) {
@@ -511,25 +501,6 @@ FW_answerCall($)
}
FW_updateHashes();
- if($cmd =~ m/^showlog /) {
- FW_showLog($cmd);
- return 0;
- }
-
- if($cmd =~ m/^toweblink (.*)$/) {
- my @aa = split(":", $1);
- my $max = 0;
- for my $d (keys %defs) {
- $max = ($1+1) if($d =~ m/^wl_(\d+)$/ && $1 >= $max);
- }
- $defs{$aa[0]}{currentlogfile} =~ m,([^/]*)$,;
- $aa[2] = "CURRENT" if($1 eq $aa[2]);
- $FW_cmdret = FW_fC("define wl_$max weblink fileplot $aa[0]:$aa[1]:$aa[2]");
- if(!$FW_cmdret) {
- $FW_detail = "wl_$max";
- FW_updateHashes();
- }
- }
my $t = AttrVal("global", "title", "Home, Sweet Home");
@@ -605,11 +576,19 @@ FW_answerCall($)
}
FW_roomOverview($cmd);
+ if($FW_contentFunc) {
+ no strict "refs";
+ my $ret = &{$FW_contentFunc}($arg);
+ use strict "refs";
+ return $ret if($ret);
+ }
+
if($cmd =~ m/^style /) { FW_style($cmd,undef); }
- elsif($cmd =~ /^logwrapper/) { return FW_logWrapper($cmd); }
elsif($FW_detail) { FW_doDetail($FW_detail); }
elsif($FW_room) { FW_showRoom(); }
- elsif(!$FW_cmdret && AttrVal("global", "motd", "none") ne "none") {
+ elsif(!$FW_cmdret &&
+ !$FW_contentFunc &&
+ AttrVal("global", "motd", "none") ne "none") {
my $motd = AttrVal("global","motd",undef);
$motd =~ s/\n/
/g;
FW_pO "
"; - my $suffix = "".($FW_ss ? "