htdocs/changetz.php
author Dan
Sat, 11 Oct 2008 20:31:22 -0400
changeset 16 01c6a003d762
parent 10 a97bd37e43e9
child 44 73f74d395f95
permissions -rw-r--r--
Fixed reference to missing key "counts" in stats-fe
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');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     3
$set_zone = false;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     4
if ( isset($_POST['tz']) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     5
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     6
  if ( in_array($_POST['tz'], $zones) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     7
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
    setcookie(COOKIE_NAME, $_POST['tz'], time() + ( 365 * 24 * 60 * 60 ));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
    $tz = $_POST['tz'];
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    10
    date_default_timezone_set($_POST['tz']);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
    $set_zone = str_replace('_', ' ', str_replace('/', ': ', $tz));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    12
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    13
}
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    14
?><html>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    15
  <head>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    16
    <title>Change time zone</title>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    17
    <style type="text/css">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    18
    select, option {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    19
      background-color: white;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    20
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
    option.other {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
      color: black;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    23
      font-weight: normal;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
    option.region {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    26
      color: black;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    27
      font-weight: bold;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    28
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    29
    option.area {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    30
      color: black;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    31
      font-weight: normal;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    32
      padding-left: 1em;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    33
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
    option.country {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    35
      color: black;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    36
      font-weight: bold;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    37
      padding-left: 1em;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    38
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    39
    option.city {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    40
      color: black;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    41
      font-weight: normal;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    42
      padding-left: 2em;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    43
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    44
    div.success {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    45
      border: 1px solid #006300;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    46
      background-color: #d3ffd3;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    47
      padding: 10px;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    48
      margin: 10px 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    49
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    50
    </style>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    51
  </head>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    52
  <body>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    53
    <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    54
    if ( $set_zone )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    55
    {
10
a97bd37e43e9 Fixed SCRIPT_PATH detection in changetz
Dan
parents: 8
diff changeset
    56
      $target = rtrim(dirname($_SERVER['REQUEST_URI']), '/') . '/';
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    57
      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
    58
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    59
    ?>
10
a97bd37e43e9 Fixed SCRIPT_PATH detection in changetz
Dan
parents: 8
diff changeset
    60
    <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    61
    Select time zone:
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    62
    <select name="tz">
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    63
      <?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    64
      $zones = get_timezone_list();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    65
      foreach ( $zones as $region => $areas )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    66
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    67
        if ( is_string($areas) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    68
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    69
          echo '<option value="' . $areas . '" class="other">' . $areas . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    70
          continue;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    71
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    72
        echo '<option disabled="disabled" class="region">' . $region . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    73
        foreach ( $areas as $aid => $area )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    74
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    75
          if ( is_array($area) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    76
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    77
            echo '  <option disabled="disabled" class="country">' . str_replace('_', ' ', $aid) . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    78
            foreach ( $area as $city )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    79
            {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    80
              $zoneid = "$region/$aid/$city";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    81
              $sel = ( $zoneid == $tz ) ? ' selected="selected"' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    82
              echo '    <option value="' . $zoneid . '" class="city"' . $sel . '>' . str_replace('_', ' ', $city) . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    83
            }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    84
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    85
          else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    86
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    87
            $zoneid = "$region/$area";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    88
            $sel = ( $zoneid == $tz ) ? ' selected="selected"' : '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    89
            echo '  <option value="' . $zoneid . '" class="area"' . $sel . '>' . str_replace('_', ' ', $area) . '</option>' . "\n      ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    90
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    91
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    92
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    93
      ?>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    94
    </select>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    95
    <input type="submit" value="Save" /><br />
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    96
    <small>Make sure you have cookies enabled.</small>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    97
    </form>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    98
  </body>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    99
</html>