# 2012-12-22 # # Description: http://fkurz.net/ham/stuff.html?rbnbandmap # # This code is in the public domain. # DB config $mysql_host = "localhost"; $mysql_user = ""; $mysql_pass = ""; $mysql_dbname = ""; mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die ("

Sorry: Could not connect to database.

"); mysql_select_db($mysql_dbname); if (array_key_exists('req', $_GET) == '1') { data_request(); } else { show_bandmap(); } function data_request () { $allconts = array('EU', 'NA', 'AS', 'SA', 'AF', 'OC'); $queryconts = array(); foreach ($allconts as $c) { if ($_GET[$c] == 'true') { array_push($queryconts, "'".$c."'"); } } $queryconts_string = implode(',', $queryconts); $json_a = array(); mysql_query("set timezone = '+00:00'"); mysql_query("delete from spots where time < (UTC_TIMESTAMP() - INTERVAL 20 MINUTE);"); $q = mysql_query("select freq, dxcall, `call`, timestampdiff(minute, time, UTC_TIMESTAMP()) as age, substring(`comment`, 9,2) as snr from spots where fromcont in ($queryconts_string) order by freq, dxcall;"); # create JSON, aggregate all rows with same freq and dxcall # into one entry. $dxc = ""; # DX call of current entry $freq = ""; # freq $age = 20; # age of youngest spot $spotters = array();# Hash keys = spotter calls, values = snrs $spotters_old = ""; while ($r = mysql_fetch_object($q)) { # Append to new entry if ($r->dxcall != $dxc or abs($r->freq - $freq) > 0.5) { # Output previous entry if it exists if ($dxc != "") { array_push($json_a, build_json($dxc, $freq, $age, $spotters, $spotters_old)); } $dxc = $r->dxcall; $freq = sprintf("%.1f", $r->freq); $age = $r->age; $spotters = array(); $spotters[$r->call] = $r->snr; $spotters_old = '"'.$r->call.'"'; } else { # Append new spotter to existing entry if ($r->age < $age) { $age = $r->age; } if (!array_key_exists($r->call, $spotters) or $spotters[$r->call] < $r->snr) { $spotters[$r->call] = $r->snr; } $spotters_old .= ' "'.$r->call.'"'; } } # get rid of last entry array_push($json_a, build_json($dxc, $freq, $age, $spotters, $spotters_old)); echo "[".implode(",", $json_a)."]"; mysql_close(); } function build_json ($dxc, $freq, $age, $spotters, $spotters_old) { $ret = ""; $ret .= "{\n\"freq\":\"$freq\",\n"; $ret .= "\"dxcall\":\"$dxc\",\n"; $ret .= "\"age\":\"$age\",\n"; # Entries like this are created from spotters array # { "call":"DR1A", "snr":"12" } $tmp = array(); arsort($spotters); foreach ($spotters as $c => $s) { array_push($tmp, "{ \"call\":\"$c\", \"snr\":\"$s\" }"); } $ret1 = implode(",", $tmp); $ret .= "\"snr_spotters\": [ $ret1 ]\n}"; return $ret; } function show_bandmap () { ?> RBN bandmap

Bandmap with 30 seconds update interval

Spots should appear here. If they don't, maybe you have Javascript disabled in your browser.\n"; ?>

New spots (less than 2 minutes old) appear with a red background, old spots (over 10 minutes old) with gray background.

The font color of the receiving skimmer's callsign depends on the SNR: SNR > 40 dB, SNR > 30 dB, SNR > 20 dB, SNR > 10 dB, SNR > 0 dB. Hover your mouse over a spotter call to see the exact value.

Filter by continents: Only Skimmers from EU NA AS SA AF OC

PHP / JavaScript code by Fabian, DJ1YFK