weathermap |
Subversion Repositories: |
Rev 1 | Rev 85 | |
---|---|---|
Line 19... | Line 19... | |
} |
} | |
|
| |
// function ReadData($targetstring, $configline, $itemtype, $itemname, $map) |
// function ReadData($targetstring, $configline, $itemtype, $itemname, $map) | |
function ReadData($targetstring, &$map, &$item) |
function ReadData($targetstring, &$map, &$item) | |
{ |
{ | |
$inbw=-1; |
$data[IN] = NULL; | |
$outbw=-1; |
$data[OUT] = NULL; | |
$data_time=0; |
$data_time=0; | |
$itemname = $item->name; |
$itemname = $item->name; | |
|
| |
$matches=0; |
$matches=0; | |
|
| |
Line 38... | Line 38... | |
# strip out any Windows line-endings that have gotten in here |
# strip out any Windows line-endings that have gotten in here | |
$buffer=str_replace("\r", "", $buffer); |
$buffer=str_replace("\r", "", $buffer); | |
|
| |
if (preg_match("/^$itemname\t(\d+\.?\d*[KMGT]*)\t(\d+\.?\d*[KMGT]*)/", $buffer, $matches)) |
if (preg_match("/^$itemname\t(\d+\.?\d*[KMGT]*)\t(\d+\.?\d*[KMGT]*)/", $buffer, $matches)) | |
{ |
{ | |
$inbw=unformat_number($matches[1]); |
$data[IN]=unformat_number($matches[1]); | |
$outbw=unformat_number($matches[2]); |
$data[OUT]=unformat_number($matches[2]); | |
} |
} | |
} |
} | |
$stats = stat($targetstring); |
$stats = stat($targetstring); | |
$data_time = $stats['mtime']; |
$data_time = $stats['mtime']; | |
} |
} | |
else { |
else { | |
// some error code to go in here |
// some error code to go in here | |
debug ("TabText ReadData: Couldn't open ($targetstring). \n"); } |
debug ("TabText ReadData: Couldn't open ($targetstring). \n"); } | |
|
| |
debug ("TabText ReadData: Returning ($inbw,$outbw,$data_time)\n"); |
debug ("TabText ReadData: Returning (".($data[IN]===NULL?'NULL':$data[IN]).",".($data[OUT]===NULL?'NULL':$data[OUT]).",$data_time)\n"); | |
|
| |
return ( array($inbw,$outbw,$data_time) ); |
return( array($data[IN], $data[OUT], $data_time) ); | |
} |
} | |
} |
} | |
|
| |
// vim:ts=4:sw=4: |
// vim:ts=4:sw=4: | |
?> |
?> |