1 | 1 | simandl | <?php |
2 | | | // Sample Pluggable datasource for PHP Weathermap 0.9 |
3 | | | // - read a pair of values from a database, and return it |
4 | | | |
5 | | | // TARGET dbplug:databasename:username:pass:hostkey |
6 | | | |
7 | | | class WeatherMapDataSource_dbsample extends WeatherMapDataSource { |
8 | | | |
9 | | | function Recognise($targetstring) |
10 | | | { |
11 | | | if(preg_match("/^dbplug:([^:]+):([^:]+):([^:]+):([^:]+)$/",$targetstring,$matches)) |
12 | | | { |
13 | | | return TRUE; |
14 | | | } |
15 | | | else |
16 | | | { |
17 | | | return FALSE; |
18 | | | } |
19 | | | } |
20 | | | |
21 | | | function ReadData($targetstring, &$map, &$item) |
22 | | | { |
23 | | | if(preg_match("/^dbplug:([^:]+):([^:]+):([^:]+):([^:]+)$/",$targetstring,$matches)) |
24 | | | { |
25 | | | $database = $matches[0]; |
26 | | | $db_user = $matches[1]; |
27 | | | $db_pass = $matches[2]; |
28 | | | $key = mysql_real_escape_string($matches[3]); |
29 | | | |
30 | | | $SQL = "select in,out from table where host=$key"; |
31 | | | } |
32 | | | else |
33 | | | { |
34 | | | return ( array(-1,-1) ); |
35 | | | } |
36 | | | } |
37 | | | } |
38 | | | |
39 | | | // vim:ts=4:sw=4: |
40 | | | ?> |