3 * SquirrelMail time zone library - time zone validation script.
5 * Copyright (c) 2005 The SquirrelMail Project Team
6 * This file is part of SquirrelMail webmail interface.
8 * SquirrelMail is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * SquirrelMail is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with SquirrelMail; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * @package squirrelmail
24 * @subpackage timezones
28 define('SM_PATH','../../');
30 /** Send http header */
31 header('Content-Type: text/plain');
33 /** Information about script */
34 echo "--------------------------------------------\n"
35 ." SquirrelMail time zone library test script\n"
36 ."--------------------------------------------\n";
39 unset($time_zone_type);
40 if (file_exists(SM_PATH
.'config/config.php')) {
41 include(SM_PATH
.'config/config.php');
43 echo "SquirrelMail configuration file is missing.\n";
48 * Script does not test, if standard time zone libraries are missing.
49 * If they are missing or corrupted - php can fail, scream and show
50 * finger or other parts of interpreter.
53 /** load original reference */
54 include(SM_PATH
.'include/timezones/standard_orig.php');
56 /** move timezones to different array */
57 $aTimeZonesOrig = $aTimeZones;
60 if (! isset($time_zone_type) ||
$time_zone_type == 0 ||
$time_zone_type == 1) {
61 /** load new time zone library */
62 include(SM_PATH
.'include/timezones/standard.php');
63 } elseif ($time_zone_type == 2 ||
$time_zone_type == 3) {
64 /** load custom time zone library */
66 if (file_exists(SM_PATH
. 'config/timezones.php')) {
67 include(SM_PATH
.'config/timezones.php');
69 echo "ERROR: config/timezones.php is missing.\n";
73 echo "ERROR: invalid value in time_zone_type configuration.\n";
77 if (! isset($aTimeZones) ||
! is_array($aTimeZones) ||
empty($aTimeZones)) {
78 echo "ERROR: timezones array is missing or empty.\n";
84 /** test backward compatibility */
85 echo "Testing backward compatibility:\n"
86 ." Failed time zones:\n";
87 foreach ($aTimeZonesOrig as $TzKey => $TzData) {
88 if (! isset($aTimeZones[$TzKey])) {
94 echo " none. Looking good.\n";
96 // error is not fatal, but test should fail only with limited custom time zone sets
101 /** test forward compatibility */
103 echo "Testing forward compatibility:\n"
104 ." New time zones:\n";
105 foreach ($aTimeZones as $TzKey => $TzData) {
106 if (! isset($aTimeZonesOrig[$TzKey])) {
107 echo ' '.$TzKey."\n";
112 echo " no new time zones.\n";
114 // error is not fatal. test should show new time zones, that are not
115 // present in timezones.cfg
122 echo "Testing time zone links:\n"
123 ." Failed time zone links:\n";
124 foreach ($aTimeZones as $TzKey => $TzData) {
125 if (isset($TzData['LINK']) && ! isset($aTimeZones[$TzData['LINK']]['TZ'])) {
126 echo ' '.$TzKey.' = '.$TzData['LINK']."\n";
131 echo " none. Looking good.\n";
133 // error is fatal. 'LINK' should always reffer to existing 'TZ' entries
138 /** Test TZ subkeys */
140 echo "Testing time zone TZ subkeys:\n"
141 ." Failed time zone TZ subkeys:\n";
142 foreach ($aTimeZones as $TzKey => $TzData) {
143 if (! isset($TzData['LINK']) && ! isset($TzData['TZ'])) {
144 echo ' '.$TzKey."\n";
149 echo " none. Looking good.\n";
151 // LINK or TZ are required for strict time zones. Interface won't break, but
152 // any error means inconsistency in time zone array.
157 /** Test NAME subkeys */
159 echo "Testing time zone NAME subkeys:\n"
160 ." Time zones without NAME subkeys:\n";
161 foreach ($aTimeZones as $TzKey => $TzData) {
162 if (isset($TzData['TZ']) && ! isset($TzData['NAME'])) {
163 echo ' '.$TzKey."\n";
170 // error is not fatal. It would be nice if all geographic locations
171 // use some human readable name
176 /** Test TZ subkeys with UCT/UTC/GMT offsets */
178 echo "Testing TZ subkeys with UCT/UTC/GMT offsets:\n"
179 ." Time zones UCT/UTC/GMT offsets:\n";
180 foreach ($aTimeZones as $TzKey => $TzData) {
181 if (isset($TzData['TZ']) && preg_match("/^(UCT)|(UTC)|(GMT).+/i",$TzData['TZ'])) {
182 echo ' '.$TzKey.' = '.$TzData['TZ']."\n";
189 // I think error is fatal for UCT with offsets. date('T',time()) is corrupted.
194 /** Test TZ subkeys with custom TZ values and no offsets */
196 echo "Testing TZ subkeys with custom TZ values and no offsets:\n"
197 ." Time zones with custom TZ values and no offsets:\n";
198 foreach ($aTimeZones as $TzKey => $TzData) {
199 if (isset($TzData['TZ']) &&
200 ! preg_match("/^((UCT)|(UTC)|(GMT).+)|(GMT)$/i",$TzData['TZ']) &&
201 preg_match("/^[a-z]+$/i",$TzData['TZ'])) {
202 echo ' '.$TzKey.' = '.$TzData['TZ']."\n";
209 // I think error is fatal. Time zone formating requires time zone name and offset from GMT.