#!/usr/bin/perl

use DBI;

open DATA, "wget -qO- http://192.168.1.98/pagedata|";
@ant1=<DATA>;
close DATA;
#print @ant1;

@ant1[0]=~s/(Влажность  )([+-]?\d+\.?\d*)//gis;$vlag=$2;
@ant1[0]=~s/(ºF\|Температура )([+-]?\d+\.?\d*)//gis;$temp=$2;
@ant1[0]=~s/(Hg\|Температура )([+-]?\d+\.?\d*)//gis;$temp2=$2;
@ant1[0]=~s/(\|Температура )([+-]?\d+\.?\d*)<br>//gis;$temp3=$2;
@ant1[0]=~s/(Давление )([+-]?\d+\.?\d*)//gis;$davl=$2;


#print "\n$temp $temp2 $temp3 $vlag % $davl\n";
#exit;

my $dbh= DBI->connect("DBI:mysql:termo","sersql","sersql");
($sec,$min,$hour,$mday,$monn,$yearn,$wday,$yday,$isdst) = localtime(time());
$zamer=int($hour*20+$min/3);

my $sth= $dbh->prepare("insert into sensor1 values (0,NOW(),\"$temp\",\"$zamer\")");$sth->execute();
if (($davl > 700)&&($davl < 800)){$sth= $dbh->prepare("insert into sensor2 values (0,NOW(),\"$davl\",\"$zamer\")");$sth->execute();}
$sth= $dbh->prepare("insert into sensor3 values (0,NOW(),\"$vlag\",\"$zamer\")");$sth->execute();
$sth= $dbh->prepare("insert into sensor4 values (0,NOW(),\"$temp\",\"$zamer\")");$sth->execute();




