On several sites you’ll find some html code showing the Aurora status, European and North American Eskip status. These images are created by the DX robot, maintained and ran by Allard Munters PE1NWL. You know what I mean if you can see it :
Allard has spent a lot of time to create this tool but from my point of view there was something missing. I wanted a tool to customize the layout so it fits more in the design of a website. I mailed with Allard a few times asking if he could produce some kind of tool that only gives the needed data. He understood my problem, he had a tool but in only shows the Eskip status. No problem.
I started to think about my own tool using PHP and a custom stylesheet. The images with the text like Band Closed, High Muf, 144Mhz Es Now !!! are one and the same gif called – for example – eskipstatus.gif, eskipstatusNA.gif and aurorastatus.gif. In the link that Allard provides the gifs are rotated on his server to the correct status. This means that http://www.xs4all.nl/~amunters/aurorastatus.gif can show these words : Band Closed, Mid Lat Aurora or High Lat Aurora. So why not ask the size of the image and use this to show the status ?
Start of the code
What I did was open a connection to the GIF file and read it to obtain the size in bytes :
[sourcecode language=’php’]
function CheckAurora()
{
// aurora
$size = ReturnSize(‘http://www.xs4all.nl/~amunters/aurorastatus.gif’);
switch($size)
{
case ‘214’:
return ‘
‘;
break;
case ‘235’:
return ‘
‘;
break;
case ‘243’:
return ‘
‘;
break;
case ‘0’:
return ‘
‘;
break;
}
}
[/sourcecode]
The variable $size holds the size of the gif file in bytes. It is filled from the function ReturnSize(url) (see below). Then we compare the size of the gif using the switch($size) function. You can see that there are 3 different states. Case ‘0’ is hit when the ReturnSize function fails to open the gif file. You’ll notice that the return values have a div with a class embedded and some text. The div class reffers to the CSS styling I used.
The ReturnSize function :
[sourcecode language=’php’]
function ReturnSize($url)
{
$filesize = 0;
$filehandle = @fopen($url, ‘rb’);
if ($filehandle)
{
$filebuffer = “”;
while(!feof($filehandle))
{
$filebuffer .= fread($filehandle,1024);
}
fclose($filehandle);
$filesize = strlen($filebuffer);
return $filesize;
}
else
{
return $filesize;
}
}
[/sourcecode]
I immediately set the filesize to 0. On the next line I open the url with Read Binairy rights. Then calculate the size and return it. By writing this I see that some code could be written better. I wrote this code 3 years or so ago….But you get the idea of the works.
Your Style
With the Cascading Style Sheet you can set the layout to your own needs. This is a part of the one that I use :
[sourcecode language=’css’]
/* Common Styles used in all styles */
.HighLatAurora, .MidLatAurora, .AuroraClosed, .EskipClosed, .EskipMUF, .EskipNow, .NoData
{
font-weight: bold;
padding: 3px;
margin-top: 3px;
margin-bottom: 3px;
margin-left : 5px;
}
/* Aurora styles */
.HighLatAurora
{
color: #000000;
background-color: #FF0000;
}
.MidLatAurora
{
color: #FFCC00;
background-color: #000000;
}
.AuroraClosed
{
color: #00FF00;
background-color: #000000;
}
/* End Aurora */
[/sourcecode]
The class defined on line 2 is a group of all the common attributes used in the next classes. This class has to be defined first to create some kind of inheritance.
How to show the status ?
In your page you insert the php code like this : <?php echo CheckAurora() ?>
A typical page with the status could be :
[sourcecode language=’html’]
VHF Aurora : | ||
VHF Es EU : | ||
VHF Es NA : |
http://www.gooddx.net” target=”_blank”>The DXrobot Widget by https://on3jt.byze.be” target=”_blank”>ON3JT
[/sourcecode]
And there you have it, a way to costumize the DXrobot on your site. Read on to download the code.
WordPress widget
I used this project on my previous site but from march 2008 I switched to WordPress for my site. WordPress is a blogging tool and makes it easy to put data on your site. No more messing around…
To show the DXrobot in a WordPress environment I decided to pick up the old code and convert it to a widget. Widgets are the things on the sidebars in a WordPress site. On my site this is the most right column with some menu’s and other widgets. Writing a widget was not that easy as I expected, but with the detailed help found on some sites it could be done.
You can download the widget here : DXrobot Widget
Unzip it and upload the widget to your plugin directory of your WordPress : for example www.site.com/wp-content/plugins/DXrobot
Now you can activitate it in WordPress and drag and drop it on your sidebar. You may change the title on the widget. Customize the CSS to your site before uploading.
The download contains two files : the widget itself in dxrobot.php and the stylesheet dxrobot.css. You can strip dxrobot.php to use it on your site if you don’t use WordPress. But this requires a bit of scripting.
This means to include the dxrobot.php and the dxrobot.css in your page like this :
[sourcecode language=’html’]
[/sourcecode]
If you do so I would appreciate it if you place a link to my site.