<?php 
// cldate.php
// SVG Network Clock
// Called by svg_clock.php
// Thanks to The PHP Anthology Volume II: Applications
$emflag="";
$midbit="";
if (isset($_GET['emflag'])) {
  $emflag=" " . urldecode($_GET['emflag']);
}
if (isset($_GET['timezone'])) {
  if (str_replace("+"," ",urldecode($_GET['timezone'])) == "") {
    date_default_timezone_set("UTC");
  } else {
    //$midbit="<a xlink:href=\"http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" . urlencode(str_replace("+","_",urldecode($_GET['timezone']))) . "\" target=\"_blank\">" . "http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" . urlencode(str_replace("+","_",urldecode($_GET['timezone']))) . "</a>";
    $midbit="http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" . urlencode(str_replace("+","_",urldecode($_GET['timezone'])));
    date_default_timezone_set(str_replace("+"," ",urldecode($_GET['timezone'])));
  }
} else {
  date_default_timezone_set("UTC");
}
$thedate=date('l H:i:s d M Y e I~') . $emflag;
if (strpos($thedate, " 1~") !== false) {
  $thedate=str_replace(" 1~", " ", $thedate);
} else if (strpos($thedate, " 0~") !== false) {
  $midbit="";
  $thedate=str_replace(" 0~", " ", $thedate);
}
if (isset($_GET['both'])) {
echo $thedate . $midbit . '</text>' . $midbit . '<circle id="cclock" cx="200" cy="200" r="150" fill="navy"/><text>';
} else if (isset($_GET['analogue'])) {
echo $thedate . $midbit . '</text>' . $midbit . '<circle id="cclock" cx="200" cy="200" r="150" fill="navy"/><text>';
} else {
echo $thedate . $midbit;
}
?>
