jablonka.czprosek.czf

weathermap

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

 

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 {
12 if( preg_match("/^static:(\d+\.?\d*[KMGT]*):(\d+\.?\d*[KMGT]*)$/",$targetstring,$matches) ||
13 preg_match("/^static:(\d+\.?\d*[KMGT]*)$/",$targetstring,$matches) )
14 {
15 return TRUE;
16 }
17 else
18 {
19 return FALSE;
20 }
21 }
22 
23 function ReadData($targetstring, &$map, &$item)
24 {
25 $inbw=-1;
26 $outbw=-1;
27 $data_time=0;
28 
29 if(preg_match("/^static:(\d+\.?\d*[KMGT]*):(\d+\.?\d*[KMGT]*)$/",$targetstring,$matches))
30 {
31 $inbw = unformat_number($matches[1]);
32 $outbw = unformat_number($matches[2]);
33 $data_time = time();
34 }
35 
36 if(preg_match("/^static:(\d+\.?\d*[KMGT]*)$/",$targetstring,$matches))
37 {
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