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 :

The DXrobot

The DXrobot

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 :

function CheckAurora()
  // aurora
  $size = ReturnSize('http://www.xs4all.nl/~amunters/aurorastatus.gif');
    case '214':
      return '<div class="AuroraClosed">Band Closed</div>';

    case '235':
      return '<div class="MidLatAurora">Mid Lat Aurora</div>';

    case '243':
      return '<div class="HighLatAurora">High Lat Aurora</div>';

    case '0':
      return '<div class="NoData">No Data</div>';

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 :

function ReturnSize($url)
  $filesize = 0;
  $filehandle = @fopen($url, 'rb');

  if ($filehandle)
    $filebuffer = "";
      $filebuffer .= fread($filehandle,1024);
    $filesize = strlen($filebuffer);
    return $filesize;
    return $filesize;

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 :

/* 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 */
 color: #000000;
 background-color: #FF0000;

 color: #FFCC00;
 background-color: #000000;

 color: #00FF00;
 background-color: #000000;
/* End Aurora */

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 :

<table border="0" cellspacing="0" cellpadding="0">
   <tr><td>VHF Aurora : <td><td><?php echo CheckAurora() ?></td></tr>
 <tr><td>VHF Es EU : <td><td><?php echo CheckEskipEU() ?></td></tr>
 <tr><td>VHF Es NA : <td><td><?php echo CheckEskipNA() ?></td></tr>
 <span class="RobotLink"><a href="<a href="http://www.gooddx.net">http://www.gooddx.net</a>" target="_blank">The DXrobot Widget</a></span> by <a href="<a href="http://on3jt.byze.be">http://on3jt.byze.be</a>" target="_blank">ON3JT</a>

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 :

<?php include("scripts/dxrobot.php") ?>
    <link rel='stylesheet' href='http://www.site.com/scripts/dxrobot.css' type='text/css' media='screen' />
    <?php echo CheckAurora() ?>

If you do so I would appreciate it if you place a link to my site.