Information for Webmasters

Contents

» Introduction
» Flag Status
» Lighting Times
» Websites on the SRCF (incl. code examples.)
» Drupal

Introduction

The following information is aimed at College club webmasters who want to incorporate CUCBC data into their site. This page defines how CUCBC make this data available and includes a limited set of examples (using PHP) showing how to deploy this information to other sites. In general CUCBC cannot help individual webmasters/clubs with setting up such systems unless there is a technical problem with data provided by CUCBC.

Flag Status

You can access the current flag status from one of two files:

» http://www.cucbc.org/flag.txt
» http://www.cucbc.org/flag.xml

These files give the current flag status as a three letter code:

CodeStatusNotes
nopNot OperationalUsed during vacations.
grnGreen
yelYellow
rylRed/Yellow
redRed
bluCambridge Blue
gdbGDBO

Lighting Times

Lighting times for today and tomorrow can be accessed from one of two files:

» http://www.cucbc.org/darkness.txt
» http://www.cucbc.org/darkness.xml

The text file is formatted as follows:
LineDataFormat
1DateYYYY-MM-DD
2Lighting Down TodayHH:MM (24 hr)
3Lighting Up TodayHH:MM (24 hr)
4Lighting Down TomorrowHH:MM (24 hr)
5Lighting Up TomorrowHH:MM (24 hr)

The scheme for the XML file is self explanatory from element/attribute names.

Long term lightings data is available in XML and CSV format:

» XML Data for 2008
» CSV Data for 2008

The data is formatted as follows:

ColumnNameFormat
1DateYYYYMMDD
2Lighting Down (Timestamp)UNIX Timestamp
3Lighting Up (Timestamp)UNIX Timestamp
4Lighting Down (Friendly)HH:MM
5Lighting Up (Friendly)HH:MM

The PHP date() function can be used to format the timestamp values in whatever date/time format is required. The "friendly" values give 24-hour clock times for lighting down and up.

NB: The date_sunrise() and date_sunset() functions available in PHP 5 will only generate approximations to CUCBC Lighting Times.

Websites on the SRCF

The SRCF does not allow PHP to access external files so we have made the four files listed above available locally on the SRCF machine.

The SRCF copies of these files are updated automatically every 4 minutes.

The absolute paths to these files are as follows:

\societies\rowing\river_status\flag.txt \societies\rowing\river_status\flag.xml \societies\rowing\river_status\darkness.txt \societies\rowing\river_status\darkness.xml

Code Example

This snippet exemplifies how SRCF hosted websites can retrieve the flag status-code using PHP:

<?php
$filename 
'/societies/rowing/river_status/flag.txt';
// Only works on the SRCF.
// Gets data that is, at most, 4 minutes old.
$fp fopen($filename'r');
$flag fread($fpfilesize());
fclose();
// $flag now contains the three-letter flag status code.
?>

A suitable set of if...else blocks or a switch can now be used to produce relevant HTML based on the flag status.

The example below uses a switch block:

<?php
switch ($flag) {

  case 
'grn':
    
// Print HTML code to display green flag image/message.
    
break;

  case 
'yel':
    
// Print HTML code to display yellow flag image/message.
    
break;
  ...
  default:
    
// Print HTML code to display 'flag status unavailable' message.

}
?>

Disclaimer: CUCBC provides the above examples "as is" and cannot guarantee their accuracy, effectiveness, security or operation. Please see the PHP Manual for more detailed PHP documentation.

Drupal

A Drupal module is available that will provide a block displaying the current flag status along with today and tomorrow's lighting times. The data are obtained from the text files on the CUCBC web server (see above).

» CUCBC River Status Drupal Module

To install, extract the archive to your Drupal install's modules directory then move the [modules]/riverstatus/flag directory to /img/flag in your document root. The module will work with Drupal 5.x and 6.x.

© 2001 - 2024 Cambridge University Combined Boat Clubs. All rights reserved.