diff --git a/lib/http_server.pl b/lib/http_server.pl
index ce64ee87e..6a6f35875 100644
--- a/lib/http_server.pl
+++ b/lib/http_server.pl
@@ -684,6 +684,11 @@ sub http_process_request {
# print "Error, no SET argument: $header\n" unless $get_arg;
+ #allow setby to be passed in URL. Objects can then take a setby argument if there is an alternative action.
+ #used for RGB. Downside is that the true setby (web) would be lost.
+ my $get_arg_setby = "";
+ ($get_arg_setby) = $get_arg =~ /select_setby=(\S+)/;
+ $get_arg =~ s/select_setby=(\S+)// if ($get_arg_setby);
# Change select_item=$item&select_state=abc to $item=abc
$get_arg =~ s/select_item=(\S+)\&&select_state=/$1=/;
@@ -758,10 +763,10 @@ sub http_process_request {
# Can be a scalar or a object
$state =~ tr/\"/\'/; # So we can use "" to quote it
-
+ $get_arg_setby = "web [$client_ip_address]" unless $get_arg_setby;
# my $eval_cmd = qq[($item and ref($item) and UNIVERSAL::isa($item, 'Generic_Item')) ?
my $eval_cmd = qq[($item and ref($item) ne '' and ref($item) ne 'SCALAR' and $item->can('set')) ?
- ($item->set("$state", "web [$client_ip_address]")) : ($item = "$state")];
+ ($item->set("$state", "$get_arg_setby")) : ($item = "$state")];
print "SET eval: $eval_cmd\n" if $main::Debug{http};
eval $eval_cmd;
print "SET eval error. cmd=$eval_cmd error=$@\n" if $@;
diff --git a/lib/json_server.pl b/lib/json_server.pl
index fa3e1c1e5..79b747630 100755
--- a/lib/json_server.pl
+++ b/lib/json_server.pl
@@ -883,34 +883,52 @@ sub json_get {
}
if ( $path[0] eq 'security' ) {
- #check if $Authorized
if (defined $path[1] and $path[1] eq 'authorize') {
- print "IN AUTHORIZE\n";
+ # Passwords are stored as MD5 hashes in the user data file
+ # Take that MD5, then take the current date (in YYYYDDMM format) and then calculate
+ # an authorization MD5 value. Adding in the current date means that the lifespan of a compromised
+ # password token is at most 1 day.
my $status = "";
if ($args{user} && $args{user}[0] eq "") {
- $status = "Empty Username";
+ $status = "fail";
+ &main::print_log("json_server.pl: ERROR, authorize attempt with no username");
} elsif ($args{password} && $args{password}[0] eq "") {
- $status = "Empty Password";
+ $status = "fail";
+ &main::print_log("json_server.pl: ERROR, authorize attempt with no password");
+
} else {
my $password = &Groups('getpw','',$args{user}[0]);
my $time_seed = &main::time_date_stamp('18',$Time);
- my $time_seedY = &main::time_date_stamp('18',$Time - 86400);
- my $time_seedT = &main::time_date_stamp('18',$Time + 86400);
-
+ #to account for clock drift, check today and tomorrow values around midnight
#if time is between 11:55 and midnight then also check tomorrow
#if time is between midnight and 00:05 then also check yesterday
- print "PW=$password, time_seed=$time_seed, $time_seedY, $time_seedT\n";
+ if (time_greater_than("11:55 PM")) {
+ my $time_seedT = &main::time_date_stamp('18',$Time + 86400);
+ my $pwdcheck1 = md5_hex($password . $time_seedT);
+ $status = "success" if (lc $args{password}[0] eq lc $pwdcheck1);
+ }
+ if (time_less_than("00:05 AM")) {
+ my $time_seedY = &main::time_date_stamp('18',$Time - 86400);
+ my $pwdcheck2 = md5_hex($password . $time_seedY);
+ $status = "success" if (lc $args{password}[0] eq lc $pwdcheck2);
+ }
+ #print "PW=$password, time_seed=$time_seed";
my $pwdcheck = md5_hex($password . $time_seed);
- print "PWC=$pwdcheck\n";
+ #print "PWC=$pwdcheck\n";
- if (lc $args{password}[0] eq lc $pwdcheck) {
+ if ($status eq "" and (lc $args{password}[0] eq lc $pwdcheck)) {
$status = "success";
+ &main::print_log("json_server.pl: INFO, user $args{user}[0] successfully authenticated");
+
} else {
$status = "fail";
+ &main::print_log("json_server.pl: WARNING, user $args{user}[0] authentication attempt failed");
+
}
}
$json_data{security}->{authorize} = $status;
} else {
+ #check if $Authorized
my $ref;
my $users;
my $found = 0;
@@ -1508,7 +1526,7 @@ sub json_object_detail {
my %json_complete_object;
my @f = qw( category filename measurement rf_id set_by members
state states state_log type label sort_order groups hidden parents schedule logger_status
- idle_time text html seconds_remaining fp_location fp_icons fp_icon_set img link level);
+ idle_time text html seconds_remaining fp_location fp_icons fp_icon_set img link level rgb);
# Build list of fields based on those requested.
foreach my $f ( sort @f ) {
@@ -1551,6 +1569,14 @@ sub json_object_detail {
$value = $a if ( defined $a and $a ne "" ); #don't return a null value
}
+ elsif ( $f eq 'rgb' ) {
+ my ($a,$b,$c) = $object->$method;
+
+ $value = "$a,$b,$c" if (( defined $a and $a ne "" ) #don't return a null value
+ and ( defined $b and $b ne "" )
+ and ( defined $c and $c ne "" ));
+ }
+
#if ( $f eq 'hidden' ) {
# my $a = $object->$method;
# if ($a == 1 or $a eq "1") {
diff --git a/web/ia7/house/modes.shtml b/web/ia7/house/modes.shtml
index 376b763e6..b250f4e31 100644
--- a/web/ia7/house/modes.shtml
+++ b/web/ia7/house/modes.shtml
@@ -4,7 +4,7 @@