htdocs/changetz.php
author Dan
Sat, 10 Jan 2009 14:08:11 -0500
changeset 49 4c4d69b2cd4d
parent 44 73f74d395f95
permissions -rw-r--r--
Rehash: added support for channel changing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     1
<?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     2
require('../timezone.php');
44
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
     3
require('../stats-fe.php');
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     4
$set_zone = false;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     5
if ( isset($_POST['tz']) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     6
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     7
  if ( in_array($_POST['tz'], $zones) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
    setcookie(COOKIE_NAME, $_POST['tz'], time() + ( 365 * 24 * 60 * 60 ));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    10
    $tz = $_POST['tz'];
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
    date_default_timezone_set($_POST['tz']);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    12
    $set_zone = str_replace('_', ' ', str_replace('/', ': ', $tz));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    13
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    14
}
44
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    15
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    16
$title = "$nick - set time zone";
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    17
require("./themes/$webtheme/header.php");
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    18
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    19
echo '<br />';
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    20
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
    if ( $set_zone )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
    {
10
a97bd37e43e9 Fixed SCRIPT_PATH detection in changetz
Dan
parents: 8
diff changeset
    23
      $target = rtrim(dirname($_SERVER['REQUEST_URI']), '/') . '/';
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
      echo '<div class="success">' . "Successfully set time zone to <b>{$set_zone}</b>. <a href=\"$target\">Return to the stats page</a>." . '</div>';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    26
    ?>
10
a97bd37e43e9 Fixed SCRIPT_PATH detection in changetz
Dan
parents: 8
diff changeset
    27
    <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    28
    Select time zone:
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    29
    <select name="tz">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    30
      <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    31
      $zones = get_timezone_list();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    32
      foreach ( $zones as $region => $areas )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    33
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
        if ( is_string($areas) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    35
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    36
          echo '<option value="' . $areas . '" class="other">' . $areas . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    37
          continue;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    38
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    39
        echo '<option disabled="disabled" class="region">' . $region . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    40
        foreach ( $areas as $aid => $area )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    41
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    42
          if ( is_array($area) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    43
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    44
            echo '  <option disabled="disabled" class="country">' . str_replace('_', ' ', $aid) . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    45
            foreach ( $area as $city )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    46
            {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    47
              $zoneid = "$region/$aid/$city";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    48
              $sel = ( $zoneid == $tz ) ? ' selected="selected"' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    49
              echo '    <option value="' . $zoneid . '" class="city"' . $sel . '>' . str_replace('_', ' ', $city) . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    50
            }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    51
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    52
          else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    53
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    54
            $zoneid = "$region/$area";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    55
            $sel = ( $zoneid == $tz ) ? ' selected="selected"' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    56
            echo '  <option value="' . $zoneid . '" class="area"' . $sel . '>' . str_replace('_', ' ', $area) . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    57
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    58
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    59
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    60
      ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    61
    </select>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    62
    <input type="submit" value="Save" /><br />
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    63
    <small>Make sure you have cookies enabled.</small>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    64
    </form>
44
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    65
  
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    66
<?php
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    67
require("./themes/$webtheme/footer.php");
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 10
diff changeset
    68
?>