4 * SquirrelMail time zone library - time zone validation script.
6 * @copyright © 2005-2006 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 * @package squirrelmail
10 * @subpackage timezones
14 define('SM_PATH','../../');
16 /** Send http header */
17 header('Content-Type: text/plain');
19 /** Information about script */
20 echo "--------------------------------------------\n"
21 ." SquirrelMail time zone library test script\n"
22 ."--------------------------------------------\n";
25 unset($time_zone_type);
26 if (file_exists(SM_PATH
.'config/config.php')) {
27 include(SM_PATH
.'config/config.php');
29 echo "SquirrelMail configuration file is missing.\n";
34 * Script does not test, if standard time zone libraries are missing.
35 * If they are missing or corrupted - php can fail, scream and show
36 * finger or other parts of interpreter.
39 /** load original reference */
40 include(SM_PATH
.'include/timezones/standard_orig.php');
42 /** move timezones to different array */
43 $aTimeZonesOrig = $aTimeZones;
46 if (! isset($time_zone_type) ||
$time_zone_type == 0 ||
$time_zone_type == 1) {
47 /** load new time zone library */
48 include(SM_PATH
.'include/timezones/standard.php');
49 } elseif ($time_zone_type == 2 ||
$time_zone_type == 3) {
50 /** load custom time zone library */
52 if (file_exists(SM_PATH
. 'config/timezones.php')) {
53 include(SM_PATH
.'config/timezones.php');
55 echo "ERROR: config/timezones.php is missing.\n";
59 echo "ERROR: invalid value in time_zone_type configuration.\n";
63 if (! isset($aTimeZones) ||
! is_array($aTimeZones) ||
empty($aTimeZones)) {
64 echo "ERROR: timezones array is missing or empty.\n";
70 /** test backward compatibility */
71 echo "Testing backward compatibility:\n"
72 ." Failed time zones:\n";
73 foreach ($aTimeZonesOrig as $TzKey => $TzData) {
74 if (! isset($aTimeZones[$TzKey])) {
80 echo " none. Looking good.\n";
82 // error is not fatal, but test should fail only with limited custom time zone sets
87 /** test forward compatibility */
89 echo "Testing forward compatibility:\n"
90 ." New time zones:\n";
91 foreach ($aTimeZones as $TzKey => $TzData) {
92 if (! isset($aTimeZonesOrig[$TzKey])) {
98 echo " no new time zones.\n";
100 // error is not fatal. test should show new time zones, that are not
101 // present in timezones.cfg
108 echo "Testing time zone links:\n"
109 ." Failed time zone links:\n";
110 foreach ($aTimeZones as $TzKey => $TzData) {
111 if (isset($TzData['LINK']) && ! isset($aTimeZones[$TzData['LINK']]['TZ'])) {
112 echo ' '.$TzKey.' = '.$TzData['LINK']."\n";
117 echo " none. Looking good.\n";
119 // error is fatal. 'LINK' should always reffer to existing 'TZ' entries
124 /** Test TZ subkeys */
126 echo "Testing time zone TZ subkeys:\n"
127 ." Failed time zone TZ subkeys:\n";
128 foreach ($aTimeZones as $TzKey => $TzData) {
129 if (! isset($TzData['LINK']) && ! isset($TzData['TZ'])) {
130 echo ' '.$TzKey."\n";
135 echo " none. Looking good.\n";
137 // LINK or TZ are required for strict time zones. Interface won't break, but
138 // any error means inconsistency in time zone array.
143 /** Test NAME subkeys */
145 echo "Testing time zone NAME subkeys:\n"
146 ." Time zones without NAME subkeys:\n";
147 foreach ($aTimeZones as $TzKey => $TzData) {
148 if (isset($TzData['TZ']) && ! isset($TzData['NAME'])) {
149 echo ' '.$TzKey."\n";
156 // error is not fatal. It would be nice if all geographic locations
157 // use some human readable name
162 /** Test NAME subkeys */
164 echo " Time zones with empty NAME subkeys:\n";
165 foreach ($aTimeZones as $TzKey => $TzData) {
166 if (isset($TzData['NAME']) && empty($TzData['NAME'])) {
167 echo ' '.$TzKey."\n";
172 echo " none. Looking good\n";
174 // error is fatal. NAME should not be empty string.
179 /** Test TZ subkeys with UCT/UTC/GMT offsets */
181 echo "Testing TZ subkeys with UCT/UTC/GMT offsets:\n"
182 ." Time zones UCT/UTC/GMT offsets:\n";
183 foreach ($aTimeZones as $TzKey => $TzData) {
184 if (isset($TzData['TZ']) && preg_match("/^(UCT)|(UTC)|(GMT).+/i",$TzData['TZ'])) {
185 echo ' '.$TzKey.' = '.$TzData['TZ']."\n";
192 // I think error is fatal for UCT with offsets. date('T',time()) is corrupted.
197 /** Test TZ subkeys with custom TZ values and no offsets */
199 echo "Testing TZ subkeys with custom TZ values and no offsets:\n"
200 ." Time zones with custom TZ values and no offsets:\n";
201 foreach ($aTimeZones as $TzKey => $TzData) {
202 if (isset($TzData['TZ']) &&
203 ! preg_match("/^((UCT)|(UTC)|(GMT).+)|(GMT)$/i",$TzData['TZ']) &&
204 preg_match("/^[a-z]+$/i",$TzData['TZ'])) {
205 echo ' '.$TzKey.' = '.$TzData['TZ']."\n";
212 // I think error is fatal. Time zone formating requires time zone name and offset from GMT.