mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
statistics2.cgi: fix for invalid rev id
git-svn-id: https://svn.fhem.de/fhem/trunk@14754 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
129e5e3274
commit
fa32aeb9de
@ -86,21 +86,21 @@ sub insertDB() {
|
||||
my $json = $data{json};
|
||||
my $geo = getLocation();
|
||||
|
||||
$dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) ||
|
||||
die "Cannot connect: $DBI::errstr";
|
||||
|
||||
my $decoded = decode_json($json);
|
||||
if (defined($decoded->{'system'}{'revision'})) {
|
||||
# replace revision number with revision date
|
||||
my $rev = $decoded->{'system'}{'revision'} + 1;
|
||||
if($rev =~ /^\d+$/) {
|
||||
my $d = (split(/ /,qx(sudo -u rko /usr/bin/svn info -r $rev $fhemPathSvn|grep Date:)))[3];
|
||||
return undef unless (defined($d));
|
||||
my ($year,$mon,$mday) = split(/-/,$d);
|
||||
$decoded->{'system'}{'revdate'} = mktime(0,0,7,$mday,($mon-1),($year-1900),0,0,0);
|
||||
$json = encode_json $decoded;
|
||||
}
|
||||
}
|
||||
|
||||
$dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) ||
|
||||
die "Cannot connect: $DBI::errstr";
|
||||
$sth = $dbh->prepare(q{INSERT OR REPLACE INTO jsonNodes(uniqueID,geo,json) VALUES(?,?,?)});
|
||||
my $result = $sth->execute($uniqueID,$geo,$json);
|
||||
add2total() if $result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user