jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [lib/] [datasources/] [WeatherMapDataSource_static.php] - Blame information for rev 95

 

Line No. Rev Author Line
11simandl<?php
2// Pluggable datasource for PHP Weathermap 0.9
3// - return a static value
4 
5// TARGET static:10M
6// TARGET static:2M:256K
7 
8class WeatherMapDataSource_static extends WeatherMapDataSource {
9 
10 function Recognise($targetstring)
11 {
1285simandl if( preg_match("/^static:(\-?\d+\.?\d*[KMGT]?):(\-?\d+\.?\d*[KMGT]?)$/",$targetstring,$matches) ||
13 preg_match("/^static:(\-?\d+\.?\d*[KMGT]?)$/",$targetstring,$matches) )
141simandl {
15 return TRUE;
16 }
17 else
18 {
19 return FALSE;
20 }
21 }
22 
23 function ReadData($targetstring, &$map, &$item)
24 {
2585simandl $inbw = NULL;
26 $outbw = NULL;
271simandl $data_time=0;
28 
2985simandl if(preg_match("/^static:(\-?\d+\.?\d*[KMGT]*):(\-?\d+\.?\d*[KMGT]*)$/",$targetstring,$matches))
301simandl {
31 $inbw = unformat_number($matches[1]);
32 $outbw = unformat_number($matches[2]);
33 $data_time = time();
34 }
35 
3685simandl if(preg_match("/^static:(\-?\d+\.?\d*[KMGT]*)$/",$targetstring,$matches))
371simandl {
38 $inbw = unformat_number($matches[1]);
39 $outbw = unformat_number($matches[1]);
40 $data_time = time();
41 }
42 debug ("Static ReadData: Returning ($inbw,$outbw,$data_time)\n");
43 
44 return ( array($inbw,$outbw,$data_time) );
45 }
46}
47 
48// vim:ts=4:sw=4:
49?>

Powered by WebSVN 2.2.1